mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #13682 - mrobinson:push_pop, r=pcwalton
Integrate stacking contexts into the display list <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Integrate stacking contexts into the display list by adding two new entry types, PushStackingContext and PopStackingContext. This allows us to eliminate the ugly offsets map that DisplayList used to contain and seems to speed up display list construction. With this approach we are able to also completely prune pseudo-stacking contexts from the final display list and remove their (minimal) overhead from display list traversal Traversing the display list is also a bit simpler now. Additionally, this will allow easier editing of the DisplayList to properly support scrolling roots. The push/pop entries can be duplicated to clone complex StackingContext trees between layers. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13682) <!-- Reviewable:end -->
This commit is contained in:
commit
6e0d7326ab
4 changed files with 438 additions and 482 deletions
|
@ -1780,7 +1780,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
|||
ScrollPolicy::Scrollable,
|
||||
creation_mode);
|
||||
self.base.collect_stacking_contexts_for_children(&mut new_context);
|
||||
let new_children: Vec<Box<StackingContext>> = new_context.children.drain(..).collect();
|
||||
let new_children: Vec<StackingContext> = new_context.children.drain(..).collect();
|
||||
|
||||
let mut non_floating_children = Vec::new();
|
||||
for child in new_children {
|
||||
|
@ -1808,6 +1808,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
|||
&self.base,
|
||||
scroll_policy,
|
||||
StackingContextCreationMode::InnerScrollWrapper);
|
||||
|
||||
self.base.collect_stacking_contexts_for_children(&mut inner_stacking_context);
|
||||
|
||||
let mut outer_stacking_context = self.fragment.create_stacking_context(
|
||||
|
|
|
@ -260,40 +260,32 @@ impl WebRenderStackingContextConverter for StackingContext {
|
|||
builder: &mut webrender_traits::DisplayListBuilder,
|
||||
frame_builder: &mut WebRenderFrameBuilder,
|
||||
_force_positioned_stacking_level: bool) {
|
||||
for child in self.children() {
|
||||
while let Some(item) = traversal.advance(self) {
|
||||
item.convert_to_webrender(builder, frame_builder);
|
||||
}
|
||||
while let Some(item) = traversal.next() {
|
||||
match item {
|
||||
&DisplayItem::PushStackingContextClass(ref stacking_context_item) => {
|
||||
let stacking_context = &stacking_context_item.stacking_context;
|
||||
debug_assert!(stacking_context.context_type == StackingContextType::Real);
|
||||
|
||||
if child.context_type == StackingContextType::Real {
|
||||
let scroll_layer_id_for_children = if self.scrolls_overflow_area {
|
||||
scroll_layer_id
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let stacking_context_id = child.convert_to_webrender(traversal,
|
||||
api,
|
||||
pipeline_id,
|
||||
epoch,
|
||||
scroll_layer_id_for_children,
|
||||
scroll_policy,
|
||||
frame_builder);
|
||||
builder.push_stacking_context(stacking_context_id);
|
||||
} else {
|
||||
child.convert_children_to_webrender(traversal,
|
||||
api,
|
||||
pipeline_id,
|
||||
epoch,
|
||||
scroll_layer_id,
|
||||
scroll_policy,
|
||||
builder,
|
||||
frame_builder,
|
||||
true);
|
||||
}
|
||||
}
|
||||
let scroll_layer_id_for_children = if self.scrolls_overflow_area {
|
||||
scroll_layer_id
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
while let Some(item) = traversal.advance(self) {
|
||||
item.convert_to_webrender(builder, frame_builder);
|
||||
let stacking_context_id =
|
||||
stacking_context.convert_to_webrender(traversal,
|
||||
api,
|
||||
pipeline_id,
|
||||
epoch,
|
||||
scroll_layer_id_for_children,
|
||||
scroll_policy,
|
||||
frame_builder);
|
||||
builder.push_stacking_context(stacking_context_id);
|
||||
|
||||
}
|
||||
&DisplayItem::PopStackingContextClass(_) => return,
|
||||
_ => item.convert_to_webrender(builder, frame_builder),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,19 +351,22 @@ impl WebRenderDisplayListConverter for DisplayList {
|
|||
scroll_layer_id: Option<webrender_traits::ScrollLayerId>,
|
||||
frame_builder: &mut WebRenderFrameBuilder)
|
||||
-> webrender_traits::StackingContextId {
|
||||
let mut traversal = DisplayListTraversal {
|
||||
display_list: self,
|
||||
current_item_index: 0,
|
||||
last_item_index: self.list.len() - 1,
|
||||
};
|
||||
let mut traversal = DisplayListTraversal::new(self);
|
||||
let item = traversal.next();
|
||||
match item {
|
||||
Some(&DisplayItem::PushStackingContextClass(ref stacking_context_item)) => {
|
||||
let stacking_context = &stacking_context_item.stacking_context;
|
||||
stacking_context.convert_to_webrender(&mut traversal,
|
||||
api,
|
||||
pipeline_id,
|
||||
epoch,
|
||||
scroll_layer_id,
|
||||
ScrollPolicy::Scrollable,
|
||||
frame_builder)
|
||||
}
|
||||
_ => unreachable!("DisplayList did not start with StackingContext."),
|
||||
|
||||
self.root_stacking_context.convert_to_webrender(&mut traversal,
|
||||
api,
|
||||
pipeline_id,
|
||||
epoch,
|
||||
scroll_layer_id,
|
||||
ScrollPolicy::Scrollable,
|
||||
frame_builder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -513,6 +508,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
|||
item.base.clip.to_clip_region(frame_builder),
|
||||
pipeline_id);
|
||||
}
|
||||
DisplayItem::PushStackingContextClass(_) | DisplayItem::PopStackingContextClass(_) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue