mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
style: Flag computed styles of elements with container-type: *size
set & propagate them to their descendants
Low-hanging fruit optimization that enables short-circuit exit of container query lookups. Differential Revision: https://phabricator.services.mozilla.com/D158056
This commit is contained in:
parent
3acb103324
commit
5cbb81a0df
3 changed files with 24 additions and 5 deletions
|
@ -101,6 +101,10 @@ bitflags! {
|
|||
|
||||
/// Whether the style depends on viewport units.
|
||||
const USES_VIEWPORT_UNITS = 1 << 20;
|
||||
|
||||
/// A flag used to mark styles which have `container-type` of `size` or
|
||||
/// `inline-size`, or under one.
|
||||
const SELF_OR_ANCESTOR_HAS_SIZE_CONTAINER_TYPE = 1 << 21;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +117,8 @@ impl ComputedValueFlags {
|
|||
Self::IS_IN_PSEUDO_ELEMENT_SUBTREE |
|
||||
Self::HAS_TEXT_DECORATION_LINES |
|
||||
Self::IS_IN_OPACITY_ZERO_SUBTREE |
|
||||
Self::SELF_OR_ANCESTOR_HAS_CONTAIN_STYLE
|
||||
Self::SELF_OR_ANCESTOR_HAS_CONTAIN_STYLE |
|
||||
Self::SELF_OR_ANCESTOR_HAS_SIZE_CONTAINER_TYPE
|
||||
}
|
||||
|
||||
/// Flags that may be propagated to descendants.
|
||||
|
|
|
@ -250,7 +250,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
|
||||
/// Compute a few common flags for both text and element's style.
|
||||
fn set_bits(&mut self) {
|
||||
let display = self.style.get_box().clone_display();
|
||||
let box_style = self.style.get_box();
|
||||
let display = box_style.clone_display();
|
||||
|
||||
if !display.is_contents() {
|
||||
if !self
|
||||
|
@ -280,9 +281,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
if self
|
||||
.style
|
||||
.get_box()
|
||||
if box_style
|
||||
.clone_contain()
|
||||
.contains(SpecifiedValue::STYLE)
|
||||
{
|
||||
|
@ -290,6 +289,14 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
.add_flags(ComputedValueFlags::SELF_OR_ANCESTOR_HAS_CONTAIN_STYLE);
|
||||
}
|
||||
|
||||
if box_style
|
||||
.clone_container_type()
|
||||
.is_size_container_type()
|
||||
{
|
||||
self.style
|
||||
.add_flags(ComputedValueFlags::SELF_OR_ANCESTOR_HAS_SIZE_CONTAINER_TYPE);
|
||||
}
|
||||
|
||||
if self.style.get_parent_column().is_multicol() {
|
||||
self.style.add_flags(ComputedValueFlags::CAN_BE_FRAGMENTED);
|
||||
}
|
||||
|
|
|
@ -1509,6 +1509,13 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
impl ContainerType {
|
||||
/// Is this type containing size in any way?
|
||||
pub fn is_size_container_type(&self) -> bool {
|
||||
self.intersects(ContainerType::SIZE | ContainerType::INLINE_SIZE)
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-contain-3/#container-name
|
||||
#[repr(transparent)]
|
||||
#[derive(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue