Skip to content

Improve code quality for push_new_empty_item. #3341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions webrender_api/src/display_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,13 +1002,13 @@ impl DisplayListBuilder {
)
}

fn push_new_empty_item(&mut self, item: SpecificDisplayItem) {
fn push_new_empty_item(&mut self, item: SpecificDisplayItem, clip_and_scroll: &ClipAndScrollInfo) {
let info = LayoutPrimitiveInfo::new(LayoutRect::zero());
serialize_fast(
&mut self.data,
&DisplayItem {
item,
clip_and_scroll: *self.clip_stack.last().unwrap(),
clip_and_scroll: *clip_and_scroll,
info,
}
)
Expand Down Expand Up @@ -1279,7 +1279,8 @@ impl DisplayListBuilder {
}

pub fn pop_reference_frame(&mut self) {
self.push_new_empty_item(SpecificDisplayItem::PopReferenceFrame);
let clip_and_scroll = *self.clip_stack.last().unwrap();
self.push_new_empty_item(SpecificDisplayItem::PopReferenceFrame, &clip_and_scroll);
}

pub fn push_stacking_context(
Expand All @@ -1305,14 +1306,16 @@ impl DisplayListBuilder {
}

pub fn pop_stacking_context(&mut self) {
self.push_new_empty_item(SpecificDisplayItem::PopStackingContext);
let clip_and_scroll = *self.clip_stack.last().unwrap();
self.push_new_empty_item(SpecificDisplayItem::PopStackingContext, &clip_and_scroll);
}

pub fn push_stops(&mut self, stops: &[GradientStop]) {
if stops.is_empty() {
return;
}
self.push_new_empty_item(SpecificDisplayItem::SetGradientStops);
let clip_and_scroll = *self.clip_stack.last().unwrap();
self.push_new_empty_item(SpecificDisplayItem::SetGradientStops, &clip_and_scroll);
self.push_iter(stops);
}

Expand Down Expand Up @@ -1399,7 +1402,8 @@ impl DisplayListBuilder {
I::IntoIter: ExactSizeIterator + Clone,
{
let id = self.generate_clip_chain_id();
self.push_new_empty_item(SpecificDisplayItem::ClipChain(ClipChainItem { id, parent }));
let clip_and_scroll = *self.clip_stack.last().unwrap();
self.push_new_empty_item(SpecificDisplayItem::ClipChain(ClipChainItem { id, parent }), &clip_and_scroll);
self.push_iter(clips);
id
}
Expand Down Expand Up @@ -1524,7 +1528,8 @@ impl DisplayListBuilder {
}

pub fn pop_all_shadows(&mut self) {
self.push_new_empty_item(SpecificDisplayItem::PopAllShadows);
let clip_and_scroll = *self.clip_stack.last().unwrap();
self.push_new_empty_item(SpecificDisplayItem::PopAllShadows, &clip_and_scroll);
}

pub fn finalize(self) -> (PipelineId, LayoutSize, BuiltDisplayList) {
Expand Down