mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #29880 - mrobinson:fix-float-stacking-context-order, r=Loirooriol
Don't pass float stacking containers up to parent stacking contexts 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). --- <!-- 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] There are tests for these changes <!-- 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. -->
This commit is contained in:
commit
0b310e6e6a
21 changed files with 35 additions and 38 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue