aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/display_list_builder.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout/display_list_builder.rs')
-rw-r--r--components/layout/display_list_builder.rs127
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,
}