aboutsummaryrefslogtreecommitdiffstats
path: root/components/msg/compositor_msg.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/msg/compositor_msg.rs')
-rw-r--r--components/msg/compositor_msg.rs59
1 files changed, 43 insertions, 16 deletions
diff --git a/components/msg/compositor_msg.rs b/components/msg/compositor_msg.rs
index fc3e46d0945..d71291eae7c 100644
--- a/components/msg/compositor_msg.rs
+++ b/components/msg/compositor_msg.rs
@@ -36,35 +36,62 @@ impl FrameTreeId {
}
#[derive(Clone, PartialEq, Eq, Copy, Hash, Deserialize, Serialize, HeapSizeOf)]
-pub struct LayerId(
- /// A base layer ID, currently derived from DOM element pointer address.
- pub usize,
-
- /// FIXME(#2010, pcwalton): A marker for overflow scroll layers.
- pub u32,
+pub enum LayerType {
+ /// A layer for the fragment body itself.
+ FragmentBody,
+ /// An extra layer created for a DOM fragments with overflow:scroll.
+ OverflowScroll,
+ /// A layer created to contain ::before pseudo-element content.
+ BeforePseudoContent,
+ /// A layer created to contain ::after pseudo-element content.
+ AfterPseudoContent,
+}
- /// A sub ID, which is used for synthesizing new layers for content that
- /// belongs on top of this layer. This prevents accidentally making colliding
- /// layer ids.
- pub u32
+#[derive(Clone, PartialEq, Eq, Copy, Hash, Deserialize, Serialize, HeapSizeOf)]
+pub struct LayerId(
+ /// The type of the layer. This serves to differentiate layers that share fragments.
+ LayerType,
+ /// The identifier for this layer's fragment, derived from the fragment memory address.
+ usize,
+ /// Whether or not this layer is a companion layer, synthesized to ensure that
+ /// content on top of this layer's fragment has the proper rendering order.
+ bool
);
impl Debug for LayerId {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- let LayerId(a, b, c) = *self;
- write!(f, "Layer({}, {}, {})", a, b, c)
+ let LayerId(layer_type, id, companion) = *self;
+ let type_string = match layer_type {
+ LayerType::FragmentBody => "-FragmentBody",
+ LayerType::OverflowScroll => "-OverflowScroll",
+ LayerType::BeforePseudoContent => "-BeforePseudoContent",
+ LayerType::AfterPseudoContent => "-AfterPseudoContent",
+ };
+
+ let companion_string = if companion {
+ "-companion"
+ } else {
+ ""
+ };
+
+ write!(f, "{}{}{}", id, type_string, companion_string)
}
}
impl LayerId {
/// FIXME(#2011, pcwalton): This is unfortunate. Maybe remove this in the future.
pub fn null() -> LayerId {
- LayerId(0, 0, 0)
+ LayerId(LayerType::FragmentBody, 0, false)
+ }
+
+ pub fn new_of_type(layer_type: LayerType, fragment_id: usize) -> LayerId {
+ LayerId(layer_type, fragment_id, false)
}
- pub fn next_layer_id(&self) -> LayerId {
- let LayerId(a, b, sub_id) = *self;
- LayerId(a, b, sub_id + 1)
+ pub fn companion_layer_id(&self) -> LayerId {
+ let LayerId(layer_type, id, companion) = *self;
+ assert!(!companion);
+ LayerId(layer_type, id, true)
}
}