pub struct StackingContext {
scroll_tree_node_id: ScrollTreeNodeId,
clip_id: Option<ClipId>,
initializing_fragment: Option<ArcRefCell<BoxFragment>>,
context_type: StackingContextType,
pub(super) contents: Vec<StackingContextContent>,
pub(super) real_stacking_contexts_and_positioned_stacking_containers: Vec<StackingContext>,
pub(super) float_stacking_containers: Vec<StackingContext>,
pub(super) atomic_inline_stacking_containers: Vec<StackingContext>,
debug_print_items: Option<RefCell<Vec<DebugPrintItem>>>,
}
Expand description
Either a stacking context or a stacking container, per the definitions in https://drafts.csswg.org/css-position-4/#painting-order.
We use the term “real stacking context” in situations that call for a stacking context but not a stacking container.
Fields§
§scroll_tree_node_id: ScrollTreeNodeId
The spatial id of this fragment. This is used to properly handle things like preserve-3d.
clip_id: Option<ClipId>
The clip chain id of this stacking context if it has one. Used for filter clipping.
initializing_fragment: Option<ArcRefCell<BoxFragment>>
The BoxFragment
that established this stacking context. We store the fragment here
rather than just the style, so that incremental layout can automatically update the style.
context_type: StackingContextType
The type of this stacking context. Used for collecting and sorting.
contents: Vec<StackingContextContent>
The contents that need to be painted in fragment order.
real_stacking_contexts_and_positioned_stacking_containers: Vec<StackingContext>
Stacking contexts that need to be stolen by the parent stacking context if this is a stacking container, that is, real stacking contexts and positioned stacking containers (where ‘z-index’ is auto). https://drafts.csswg.org/css-position-4/#paint-a-stacking-container
To paint a stacking container, given a box root and a canvas canvas:
- 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).
float_stacking_containers: Vec<StackingContext>
Float stacking containers. Separate from real_stacking_contexts_or_positioned_stacking_containers because they should never be stolen by the parent stacking context. https://drafts.csswg.org/css-position-4/#paint-a-stacking-container
atomic_inline_stacking_containers: Vec<StackingContext>
Atomic inline stacking containers. Separate from real_stacking_contexts_or_positioned_stacking_containers because they should never be stolen by the parent stacking context, and separate from float_stacking_containers so that StackingContextContent can index into this vec to paint them in fragment order. https://drafts.csswg.org/css-position-4/#paint-a-stacking-container https://drafts.csswg.org/css-position-4/#paint-a-box-in-a-line-box
debug_print_items: Option<RefCell<Vec<DebugPrintItem>>>
Information gathered about the painting order, for Self::debug_print.
Implementations§
Source§impl StackingContext
impl StackingContext
Sourcefn hit_test(&self, hit_test: &mut HitTest<'_>) -> bool
fn hit_test(&self, hit_test: &mut HitTest<'_>) -> bool
Perform a hit test against a StackingContext
. Note that this is the reverse
of the stacking context walk algorithm in stacking_context.rs
. Any changes made
here should be reflected in the forward version in that file.
pub(crate) fn hit_test_content( &self, content: &StackingContextContent, hit_test: &mut HitTest<'_>, ) -> bool
Source§impl StackingContext
impl StackingContext
fn create_descendant( &self, spatial_id: ScrollTreeNodeId, clip_id: ClipId, initializing_fragment: ArcRefCell<BoxFragment>, context_type: StackingContextType, ) -> Self
fn create_root( root_scroll_node_id: ScrollTreeNodeId, debug: &DebugOptions, ) -> Self
Sourcefn add_stacking_context(&mut self, stacking_context: StackingContext)
fn add_stacking_context(&mut self, stacking_context: StackingContext)
Add a child stacking context to this stacking context.
pub(crate) fn z_index(&self) -> i32
pub(crate) fn sort(&mut self)
fn push_webrender_stacking_context_if_necessary( &self, builder: &mut DisplayListBuilder<'_>, ) -> bool
Sourcepub(crate) fn build_canvas_background_display_list(
&self,
builder: &mut DisplayListBuilder<'_>,
fragment_tree: &FragmentTree,
)
pub(crate) fn build_canvas_background_display_list( &self, builder: &mut DisplayListBuilder<'_>, fragment_tree: &FragmentTree, )
https://drafts.csswg.org/css-backgrounds/#special-backgrounds
This is only called for the root StackingContext
Sourcepub(crate) fn build_display_list(&self, builder: &mut DisplayListBuilder<'_>)
pub(crate) fn build_display_list(&self, builder: &mut DisplayListBuilder<'_>)
Build a display list from a a StackingContext
. Note that this is the forward
version of the reversed stacking context walk algorithm in hit_test.rs
. Any
changes made here should be reflected in the reverse version in that file.
Sourcefn debug_push_print_item(&self, field: DebugPrintField, index: usize)
fn debug_push_print_item(&self, field: DebugPrintField, index: usize)
Store the fact that something was painted, if Self::debug_print_items is not None.
This is used to help reconstruct the original painting order in Self::debug_print without duplicating our painting order logic, since that could fall out of sync with the real logic.
Sourcepub fn debug_print(&self)
pub fn debug_print(&self)
Print the stacking context tree.
Sourcefn debug_print_with_tree(&self, tree: &mut PrintTree)
fn debug_print_with_tree(&self, tree: &mut PrintTree)
Print a subtree with the given PrintTree, or panic if Self::debug_print_items is None.
Trait Implementations§
Source§impl MallocSizeOf for StackingContext
impl MallocSizeOf for StackingContext
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Auto Trait Implementations§
impl !Freeze for StackingContext
impl !RefUnwindSafe for StackingContext
impl Send for StackingContext
impl !Sync for StackingContext
impl Unpin for StackingContext
impl !UnwindSafe for StackingContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more