Don't pass up float stacking containers to parent stacking contexts

Instead of passing up stacking containers created by floated content,
keep them in their original parent stacking containers. This is in in
line with specification text for stacking containers:

> To paint a stacking container, given a box root and a canvas canvas:
>
>   1.  Paint a stacking context given root and canvas, treating root as
>       if it created a new stacking context, but omitting any positioned
>       descendants or descendants that actually create a stacking context
>       (letting the parent stacking context paint them, instead).
This commit is contained in:
Martin Robinson 2023-06-15 16:18:27 +02:00
parent fa266abd29
commit ae3c22aa88
No known key found for this signature in database
GPG key ID: D56AA4FA55EFE6F8
21 changed files with 35 additions and 38 deletions

View file

@ -200,6 +200,11 @@ pub(crate) enum StackingContextType {
PseudoAtomicInline,
}
/// A [StackingContext] represents either a stacking context or a stacking
/// container according to the definitions outlined in
/// <https://drafts.csswg.org/css-position-4/#painting-order>
/// Stacking containers are sometimes called "pseudo-stacking contexts"
/// in the Servo source.
pub struct StackingContext {
/// The spatial id of this fragment. This is used to properly handle
/// things like preserve-3d.
@ -218,7 +223,19 @@ pub struct StackingContext {
/// of this stacking context.
stacking_contexts: Vec<StackingContext>,
/// All float pseudo stacking context children of this stacking context.
/// All float stacking container children of this stacking context.
/// These are stored separately because they should not be passed up to
/// their real stacking context ancestors. From the definition of stacking
/// containers from <https://drafts.csswg.org/css-position-4#painting-order>:
///
/// > To paint a stacking container, given a box root and a canvas canvas:
/// > 1. Paint a stacking context given root and canvas, treating root as
/// > if it created a new stacking context, but omitting any positioned
/// > descendants or descendants that actually create a stacking context
/// > (letting the parent stacking context paint them, instead).
///
/// Note that all stacking containers / pseudo stacking contexts are passed up
/// to parent stacking contexts, except in the case of floats.
float_stacking_contexts: Vec<StackingContext>,
}
@ -249,6 +266,15 @@ impl StackingContext {
}
}
/// Add a child stacking context to this stacking context.
fn add_stacking_context(&mut self, stacking_context: StackingContext) {
if stacking_context.context_type == StackingContextType::PseudoFloat {
self.float_stacking_contexts.push(stacking_context);
} else {
self.stacking_contexts.push(stacking_context);
}
}
fn z_index(&self) -> i32 {
self.initializing_fragment_style
.as_ref()
@ -754,9 +780,7 @@ impl BoxFragment {
}
child_stacking_context.sort();
parent_stacking_context
.stacking_contexts
.push(child_stacking_context);
parent_stacking_context.add_stacking_context(child_stacking_context);
parent_stacking_context
.stacking_contexts
.append(&mut stolen_children);

View file

@ -0,0 +1,2 @@
[c414-flt-wrap-001.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[clear-clearance-calculation-003.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[floats-placement-001.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[floats-placement-002.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[floats-placement-003.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[floats-placement-008.html]
expected: FAIL

View file

@ -0,0 +1,3 @@
[hit-test-floats-001.html]
[hit-test-floats-001]
expected: FAIL

View file

@ -1,2 +0,0 @@
[stack-floats-001.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[stack-floats-002.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[stack-floats-004.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[flex-align-content-center.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[flex-align-content-end.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[flex-align-content-space-around.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[flex-align-content-space-between.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[flex-align-content-start.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[flexbox_flex-formatting-interop.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[position-absolute-dynamic-static-position-floats-004.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[inline-level-absolute-in-block-level-context-004.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[inline-level-absolute-in-block-level-context-009.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[inline-level-absolute-in-block-level-context-010.html]
expected: FAIL