aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <infra@servo.org>2023-04-23 20:25:01 +0200
committerGitHub <noreply@github.com>2023-04-23 20:25:01 +0200
commit0b888c86442f0e2efaf440842517f0912c9f10ef (patch)
tree4c0ba1ca5b6c327e0be0659c4a4c56415dbf1286
parentbf29f59adf5c7f3cd1081baa29f4c07e782374fa (diff)
parentdb194e74adbd24c9de5545ddf791b8b8f8f53c43 (diff)
downloadservo-0b888c86442f0e2efaf440842517f0912c9f10ef.tar.gz
servo-0b888c86442f0e2efaf440842517f0912c9f10ef.zip
Auto merge of #29644 - mrobinson:rename-establishes-containing-block, r=delan
Rename `ComputedValuesExt::establishes_containing_block` This renames the helper method to be a bit more accurate. For elements with static, relative, and sticky positioning, their containing block is always formed by their nearest block container ancestor. This method is really dealing with style that means an element will establish a containing block for absolutely positioned descendants. <!-- 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 - [x] These changes do not require tests because they do not change behavior. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
-rw-r--r--components/layout_2020/display_list/stacking_context.rs5
-rw-r--r--components/layout_2020/positioned.rs2
-rw-r--r--components/layout_2020/style_ext.rs16
3 files changed, 17 insertions, 6 deletions
diff --git a/components/layout_2020/display_list/stacking_context.rs b/components/layout_2020/display_list/stacking_context.rs
index 78992d9c5bc..8cc717569f9 100644
--- a/components/layout_2020/display_list/stacking_context.rs
+++ b/components/layout_2020/display_list/stacking_context.rs
@@ -540,7 +540,10 @@ impl BoxFragment {
padding_rect: &PhysicalRect<Length>,
containing_block_info: &mut ContainingBlockInfo,
) {
- if !self.style.establishes_containing_block() {
+ if !self
+ .style
+ .establishes_containing_block_for_absolute_descendants()
+ {
return;
}
diff --git a/components/layout_2020/positioned.rs b/components/layout_2020/positioned.rs
index 2580d4af9bc..883f783dfd8 100644
--- a/components/layout_2020/positioned.rs
+++ b/components/layout_2020/positioned.rs
@@ -196,7 +196,7 @@ impl PositioningContext {
pub(crate) fn new_for_style(style: &ComputedValues) -> Option<Self> {
if style.establishes_containing_block_for_all_descendants() {
Some(Self::new_for_containing_block_for_all_descendants())
- } else if style.establishes_containing_block() {
+ } else if style.establishes_containing_block_for_absolute_descendants() {
Some(Self {
for_nearest_positioned_ancestor: Some(Vec::new()),
for_nearest_containing_block_for_all_descendants: Vec::new(),
diff --git a/components/layout_2020/style_ext.rs b/components/layout_2020/style_ext.rs
index 58551aedbe6..c1d2f47e2fa 100644
--- a/components/layout_2020/style_ext.rs
+++ b/components/layout_2020/style_ext.rs
@@ -113,7 +113,7 @@ pub(crate) trait ComputedValuesExt {
fn has_transform_or_perspective(&self) -> bool;
fn effective_z_index(&self) -> i32;
fn establishes_stacking_context(&self) -> bool;
- fn establishes_containing_block(&self) -> bool;
+ fn establishes_containing_block_for_absolute_descendants(&self) -> bool;
fn establishes_containing_block_for_all_descendants(&self) -> bool;
fn background_is_transparent(&self) -> bool;
fn get_webrender_primitive_flags(&self) -> wr::PrimitiveFlags;
@@ -395,7 +395,13 @@ impl ComputedValuesExt for ComputedValues {
!self.get_position().z_index.is_auto()
}
- fn establishes_containing_block(&self) -> bool {
+ /// Returns true if this style establishes a containing block for absolute
+ /// descendants (`position: absolute`). If this style happens to establish a
+ /// containing block for “all descendants” (ie including `position: fixed`
+ /// descendants) this method will return true, but a true return value does
+ /// not imply that the style establishes a containing block for all descendants.
+ /// Use `establishes_containing_block_for_all_descendants()` instead.
+ fn establishes_containing_block_for_absolute_descendants(&self) -> bool {
if self.establishes_containing_block_for_all_descendants() {
return true;
}
@@ -403,8 +409,10 @@ impl ComputedValuesExt for ComputedValues {
self.clone_position() != ComputedPosition::Static
}
- /// Returns true if this style establishes a containing block for all descendants
- /// including fixed and absolutely positioned ones.
+ /// Returns true if this style establishes a containing block for
+ /// all descendants, including fixed descendants (`position: fixed`).
+ /// Note that this also implies that it establishes a containing block
+ /// for absolute descendants (`position: absolute`).
fn establishes_containing_block_for_all_descendants(&self) -> bool {
if self.get_box().display.outside() != stylo::DisplayOutside::Inline &&
self.has_transform_or_perspective()