diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-10-19 12:54:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-19 12:54:40 -0500 |
commit | e667e62f0ca8cd5fd21282333808cccaed8c957c (patch) | |
tree | 6b1169f6447d8fbb074f63a60f523996cd47fd45 /components/layout/display_list_builder.rs | |
parent | 350c60b62d077cb19c4bd2cb7433c18ca08791bd (diff) | |
parent | 2219b14be97b4a4d2708b9b5e3d1df184b6601df (diff) | |
download | servo-e667e62f0ca8cd5fd21282333808cccaed8c957c.tar.gz servo-e667e62f0ca8cd5fd21282333808cccaed8c957c.zip |
Auto merge of #13820 - mrobinson:remove-nesting, r=glennw
Remove the concept of nested stacking contexts from display list builder
<!-- 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: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because they should not change behavior.
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
With the removal of the legacy rendering path, we don't need to worry
about nested stacking contexts. This change just pushes the
complication to the WebRender conversion step, but a later change will
remove the concept from WebRender as well.
This also helps to prepare for the introduction of ids for particular
scrolling regions, an integral part of multiple ScrollLayers per block.
<!-- 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/13820)
<!-- Reviewable:end -->
Diffstat (limited to 'components/layout/display_list_builder.rs')
-rw-r--r-- | components/layout/display_list_builder.rs | 127 |
1 files changed, 45 insertions, 82 deletions
diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 3dcbee9de3c..2574d345466 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -298,7 +298,8 @@ pub trait FragmentDisplayListBuilding { id: StackingContextId, base_flow: &BaseFlow, scroll_policy: ScrollPolicy, - mode: StackingContextCreationMode) + mode: StackingContextCreationMode, + scroll_id: Option<StackingContextId>) -> StackingContext; /// Returns the 4D matrix representing this fragment's transform. @@ -1354,36 +1355,26 @@ impl FragmentDisplayListBuilding for Fragment { id: StackingContextId, base_flow: &BaseFlow, scroll_policy: ScrollPolicy, - mode: StackingContextCreationMode) + mode: StackingContextCreationMode, + scroll_id: Option<StackingContextId>) -> StackingContext { - let border_box = match mode { - StackingContextCreationMode::InnerScrollWrapper => { - Rect::new(Point2D::zero(), base_flow.overflow.scroll.size) - } - _ => { - self.stacking_relative_border_box(&base_flow.stacking_relative_position, - &base_flow.early_absolute_position_info - .relative_containing_block_size, - base_flow.early_absolute_position_info - .relative_containing_block_mode, - CoordinateSystem::Parent) - } - }; - let overflow = match mode { - StackingContextCreationMode::InnerScrollWrapper => { - Rect::new(Point2D::zero(), base_flow.overflow.scroll.size) - } - StackingContextCreationMode::OuterScrollWrapper => { - Rect::new(Point2D::zero(), border_box.size) - } - _ => { - // First, compute the offset of our border box (including relative positioning) - // from our flow origin, since that is what `BaseFlow::overflow` is relative to. - let border_box_offset = - border_box.translate(&-base_flow.stacking_relative_position).origin; - // Then, using that, compute our overflow region relative to our border box. - base_flow.overflow.paint.translate(&-border_box_offset) - } + let scrolls_overflow_area = mode == StackingContextCreationMode::ScrollWrapper; + let border_box = + self.stacking_relative_border_box(&base_flow.stacking_relative_position, + &base_flow.early_absolute_position_info + .relative_containing_block_size, + base_flow.early_absolute_position_info + .relative_containing_block_mode, + CoordinateSystem::Parent); + let overflow = if scrolls_overflow_area { + Rect::new(Point2D::zero(), base_flow.overflow.scroll.size) + } else { + // First, compute the offset of our border box (including relative positioning) + // from our flow origin, since that is what `BaseFlow::overflow` is relative to. + let border_box_offset = + border_box.translate(&-base_flow.stacking_relative_position).origin; + // Then, using that, compute our overflow region relative to our border box. + base_flow.overflow.paint.translate(&-border_box_offset) }; let transform = self.transform_matrix(&border_box); @@ -1419,20 +1410,12 @@ impl FragmentDisplayListBuilding for Fragment { filters.push(Filter::Opacity(effects.opacity)) } - // There are two situations that need layers: when the fragment has the HAS_LAYER - // flag and when we are building a layer tree for overflow scrolling. - let layer_info = if mode == StackingContextCreationMode::InnerScrollWrapper { - Some(LayerInfo::new(self.layer_id_for_overflow_scroll(), - scroll_policy, - None, - color::transparent())) - } else if self.flags.contains(HAS_LAYER) { + let layer_info = if self.flags.contains(HAS_LAYER) { Some(LayerInfo::new(self.layer_id(), scroll_policy, None, color::transparent())) } else { None }; - let scrolls_overflow_area = mode == StackingContextCreationMode::OuterScrollWrapper; let transform_style = self.style().get_used_transform_style(); let establishes_3d_context = scrolls_overflow_area || transform_style == transform_style::T::flat; @@ -1453,8 +1436,8 @@ impl FragmentDisplayListBuilding for Fragment { transform, perspective, establishes_3d_context, - scrolls_overflow_area, - layer_info) + layer_info, + scroll_id) } fn adjust_clipping_region_for_children(&self, @@ -1736,22 +1719,10 @@ impl BlockFlowDisplayListBuilding for BlockFlow { } let has_scrolling_overflow = self.has_scrolling_overflow(); - let stacking_context_id = if has_scrolling_overflow { - StackingContextId::new_outer(self.fragment.fragment_type()) - } else { - StackingContextId::new_of_type(self.fragment.node.id() as usize, - self.fragment.fragment_type()) - }; + let stacking_context_id = StackingContextId::new_of_type(self.fragment.node.id() as usize, + self.fragment.fragment_type()); self.base.stacking_context_id = stacking_context_id; - let inner_stacking_context_id = if has_scrolling_overflow { - StackingContextId::new_of_type(self.fragment.node.id() as usize, - self.fragment.fragment_type()) - } else { - stacking_context_id - }; - - if block_stacking_context_type == BlockStackingContextType::PseudoStackingContext { let creation_mode = if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) || self.fragment.style.get_box().position != position::T::static_ { @@ -1764,7 +1735,8 @@ impl BlockFlowDisplayListBuilding for BlockFlow { let mut new_context = self.fragment.create_stacking_context(stacking_context_id, &self.base, ScrollPolicy::Scrollable, - creation_mode); + creation_mode, + None); self.base.collect_stacking_contexts_for_children(&mut new_context); let new_children: Vec<StackingContext> = new_context.children.drain(..).collect(); @@ -1788,32 +1760,23 @@ impl BlockFlowDisplayListBuilding for BlockFlow { ScrollPolicy::Scrollable }; - let stacking_context = if self.has_scrolling_overflow() { - let mut inner_stacking_context = self.fragment.create_stacking_context( - inner_stacking_context_id, - &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( - stacking_context_id, - &self.base, - scroll_policy, - StackingContextCreationMode::OuterScrollWrapper); - outer_stacking_context.add_child(inner_stacking_context); - outer_stacking_context + let (creation_mode, internal_id) = if has_scrolling_overflow { + (StackingContextCreationMode::ScrollWrapper, + Some(StackingContextId::new_of_type(self.fragment.node.id() as usize, + self.fragment.fragment_type()))) + } else { - let mut stacking_context = self.fragment.create_stacking_context( - stacking_context_id, - &self.base, - scroll_policy, - StackingContextCreationMode::Normal); - self.base.collect_stacking_contexts_for_children(&mut stacking_context); - stacking_context + (StackingContextCreationMode::Normal, None) }; + let mut stacking_context = self.fragment.create_stacking_context( + stacking_context_id, + &self.base, + scroll_policy, + creation_mode, + internal_id); + self.base.collect_stacking_contexts_for_children(&mut stacking_context); + parent.add_child(stacking_context); } @@ -1931,7 +1894,8 @@ impl InlineFlowDisplayListBuilding for InlineFlow { fragment.stacking_context_id, &self.base, ScrollPolicy::Scrollable, - StackingContextCreationMode::Normal)); + StackingContextCreationMode::Normal, + None)); } _ => fragment.stacking_context_id = parent.id, } @@ -2135,8 +2099,7 @@ pub enum BorderPaintingMode<'a> { #[derive(Copy, Clone, PartialEq)] pub enum StackingContextCreationMode { Normal, - OuterScrollWrapper, - InnerScrollWrapper, + ScrollWrapper, PseudoPositioned, PseudoFloat, } |