diff options
Diffstat (limited to 'components/layout/display_list/mod.rs')
-rw-r--r-- | components/layout/display_list/mod.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/components/layout/display_list/mod.rs b/components/layout/display_list/mod.rs index aa6d3d2f500..ccd7763144f 100644 --- a/components/layout/display_list/mod.rs +++ b/components/layout/display_list/mod.rs @@ -2,6 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use malloc_size_of_derive::MallocSizeOf; +use serde::{Deserialize, Serialize}; + pub use self::builder::{ BorderPaintingMode, DisplayListBuildState, IndexableText, StackingContextCollectionFlags, StackingContextCollectionState, @@ -15,3 +18,24 @@ pub(crate) mod conversions; mod gradient; pub mod items; mod webrender_helpers; + +/// A unique ID for every stacking context. +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] +pub struct StackingContextId( + /// The identifier for this StackingContext, derived from the Flow's memory address + /// and fragment type. As a space optimization, these are combined into a single word. + pub u64, +); + +impl StackingContextId { + /// Returns the stacking context ID for the outer document/layout root. + #[inline] + pub fn root() -> StackingContextId { + StackingContextId(0) + } + + pub fn next(&self) -> StackingContextId { + let StackingContextId(id) = *self; + StackingContextId(id + 1) + } +} |