Add stacking_relative_border_box_for_display_list

This commit is contained in:
Manish Goregaokar 2018-02-14 13:30:48 -08:00
parent f7ac5d712f
commit 6232846699
2 changed files with 27 additions and 47 deletions

View file

@ -60,7 +60,7 @@ use style::computed_values::overflow_x::T as StyleOverflow;
use style::computed_values::pointer_events::T as PointerEvents; use style::computed_values::pointer_events::T as PointerEvents;
use style::computed_values::position::T as StylePosition; use style::computed_values::position::T as StylePosition;
use style::computed_values::visibility::T as Visibility; use style::computed_values::visibility::T as Visibility;
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::properties::style_structs; use style::properties::style_structs;
use style::servo::restyle_damage::ServoRestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage;
@ -651,17 +651,11 @@ pub trait FragmentDisplayListBuilding {
/// * `state`: The display building state, including the display list currently /// * `state`: The display building state, including the display list currently
/// under construction and other metadata useful for constructing it. /// under construction and other metadata useful for constructing it.
/// * `dirty`: The dirty rectangle in the coordinate system of the owning flow. /// * `dirty`: The dirty rectangle in the coordinate system of the owning flow.
/// * `stacking_relative_flow_origin`: Position of the origin of the owning flow with respect
/// to its nearest ancestor stacking context.
/// * `relative_containing_block_size`: The size of the containing block that
/// `position: relative` makes use of.
/// * `clip`: The region to clip the display items to. /// * `clip`: The region to clip the display items to.
fn build_display_list( fn build_display_list(
&mut self, &mut self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
stacking_relative_flow_origin: &Vector2D<Au>, stacking_relative_border_box: Rect<Au>,
relative_containing_block_size: &LogicalSize<Au>,
relative_containing_block_mode: WritingMode,
border_painting_mode: BorderPaintingMode, border_painting_mode: BorderPaintingMode,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
clip: &Rect<Au>, clip: &Rect<Au>,
@ -1721,9 +1715,7 @@ impl FragmentDisplayListBuilding for Fragment {
fn build_display_list( fn build_display_list(
&mut self, &mut self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
stacking_relative_flow_origin: &Vector2D<Au>, stacking_relative_border_box: Rect<Au>,
relative_containing_block_size: &LogicalSize<Au>,
relative_containing_block_mode: WritingMode,
border_painting_mode: BorderPaintingMode, border_painting_mode: BorderPaintingMode,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
clip: &Rect<Au>, clip: &Rect<Au>,
@ -1733,19 +1725,9 @@ impl FragmentDisplayListBuilding for Fragment {
return; return;
} }
// Compute the fragment position relative to the parent stacking context. If the fragment
// itself establishes a stacking context, then the origin of its position will be (0, 0)
// for the purposes of this computation.
let stacking_relative_border_box = self.stacking_relative_border_box(
stacking_relative_flow_origin,
relative_containing_block_size,
relative_containing_block_mode,
CoordinateSystem::Own,
);
debug!( debug!(
"Fragment::build_display_list at rel={:?}, abs={:?}, flow origin={:?}: {:?}", "Fragment::build_display_list at rel={:?}, abs={:?}: {:?}",
self.border_box, stacking_relative_border_box, stacking_relative_flow_origin, self self.border_box, stacking_relative_border_box, self
); );
// Check the clip rect. If there's nothing to render at all, don't even construct display // Check the clip rect. If there's nothing to render at all, don't even construct display
@ -2893,17 +2875,12 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
let background_border_section = self.background_border_section(); let background_border_section = self.background_border_section();
state.processing_scrolling_overflow_element = self.has_scrolling_overflow(); state.processing_scrolling_overflow_element = self.has_scrolling_overflow();
let stacking_relative_border_box =
self.base.stacking_relative_border_box_for_display_list(&self.fragment);
// Add the box that starts the block context. // Add the box that starts the block context.
self.fragment.build_display_list( self.fragment.build_display_list(
state, state,
&self.base.stacking_relative_position, stacking_relative_border_box,
&self.base
.early_absolute_position_info
.relative_containing_block_size,
self.base
.early_absolute_position_info
.relative_containing_block_mode,
border_painting_mode, border_painting_mode,
background_border_section, background_border_section,
&self.base.clip, &self.base.clip,
@ -3006,15 +2983,11 @@ impl InlineFlowDisplayListBuilding for InlineFlow {
index: usize, index: usize,
) { ) {
let fragment = self.fragments.fragments.get_mut(index).unwrap(); let fragment = self.fragments.fragments.get_mut(index).unwrap();
let stacking_relative_border_box =
self.base.stacking_relative_border_box_for_display_list(fragment);
fragment.build_display_list( fragment.build_display_list(
state, state,
&self.base.stacking_relative_position, stacking_relative_border_box,
&self.base
.early_absolute_position_info
.relative_containing_block_size,
self.base
.early_absolute_position_info
.relative_containing_block_mode,
BorderPaintingMode::Separate, BorderPaintingMode::Separate,
DisplayListSection::Content, DisplayListSection::Content,
&self.base.clip, &self.base.clip,
@ -3066,17 +3039,11 @@ impl ListItemFlowDisplayListBuilding for ListItemFlow {
fn build_display_list_for_list_item(&mut self, state: &mut DisplayListBuildState) { fn build_display_list_for_list_item(&mut self, state: &mut DisplayListBuildState) {
// Draw the marker, if applicable. // Draw the marker, if applicable.
for marker in &mut self.marker_fragments { for marker in &mut self.marker_fragments {
let stacking_relative_border_box =
self.block_flow.base.stacking_relative_border_box_for_display_list(marker);
marker.build_display_list( marker.build_display_list(
state, state,
&self.block_flow.base.stacking_relative_position, stacking_relative_border_box,
&self.block_flow
.base
.early_absolute_position_info
.relative_containing_block_size,
self.block_flow
.base
.early_absolute_position_info
.relative_containing_block_mode,
BorderPaintingMode::Separate, BorderPaintingMode::Separate,
DisplayListSection::Content, DisplayListSection::Content,
&self.block_flow.base.clip, &self.block_flow.base.clip,

View file

@ -1155,6 +1155,19 @@ impl BaseFlow {
self.speculated_float_placement_out.left > Au(0) || self.speculated_float_placement_out.left > Au(0) ||
self.speculated_float_placement_out.right > Au(0) self.speculated_float_placement_out.right > Au(0)
} }
/// Compute the fragment position relative to the parent stacking context. If the fragment
/// itself establishes a stacking context, then the origin of its position will be (0, 0)
/// for the purposes of this computation.
pub fn stacking_relative_border_box_for_display_list(&self, fragment: &Fragment) -> Rect<Au> {
fragment.stacking_relative_border_box(
&self.stacking_relative_position,
&self.early_absolute_position_info.relative_containing_block_size,
self.early_absolute_position_info.relative_containing_block_mode,
CoordinateSystem::Own,
)
}
} }
impl<'a> ImmutableFlowUtils for &'a Flow { impl<'a> ImmutableFlowUtils for &'a Flow {