diff --git a/components/style/properties/computed_value_flags.rs b/components/style/properties/computed_value_flags.rs index 25adc3327ca..3ed1f6f2787 100644 --- a/components/style/properties/computed_value_flags.rs +++ b/components/style/properties/computed_value_flags.rs @@ -42,6 +42,9 @@ bitflags! { /// A flag used to mark styles which are a pseudo-element or under one. const IS_IN_PSEUDO_ELEMENT_SUBTREE = 1 << 4; + /// A flag used to mark styles which have contain:style or under one. + const SELF_OR_ANCESTOR_HAS_CONTAIN_STYLE = 1 << 5; + /// Whether this style's `display` property depends on our parent style. /// /// This is important because it may affect our optimizations to avoid @@ -109,7 +112,9 @@ impl ComputedValueFlags { Self::CAN_BE_FRAGMENTED | Self::IS_IN_PSEUDO_ELEMENT_SUBTREE | Self::HAS_TEXT_DECORATION_LINES | - Self::IS_IN_OPACITY_ZERO_SUBTREE + Self::IS_IN_OPACITY_ZERO_SUBTREE | + Self::SELF_OR_ANCESTOR_HAS_CONTAIN_STYLE + } /// Flags that may be propagated to descendants. diff --git a/components/style/style_adjuster.rs b/components/style/style_adjuster.rs index 9ad47db0ab4..9ec0f576785 100644 --- a/components/style/style_adjuster.rs +++ b/components/style/style_adjuster.rs @@ -7,11 +7,13 @@ use crate::computed_value_flags::ComputedValueFlags; use crate::dom::TElement; +use crate::properties::longhands::contain::SpecifiedValue; use crate::properties::longhands::display::computed_value::T as Display; use crate::properties::longhands::float::computed_value::T as Float; use crate::properties::longhands::position::computed_value::T as Position; use crate::properties::{self, ComputedValues, StyleBuilder}; + /// A struct that implements all the adjustment methods. /// /// NOTE(emilio): If new adjustments are introduced that depend on reset @@ -245,6 +247,15 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { .add_flags(ComputedValueFlags::IS_ROOT_ELEMENT_STYLE); } + if self.style + .get_box() + .clone_contain() + .contains(SpecifiedValue::STYLE) + { + self.style + .add_flags(ComputedValueFlags::SELF_OR_ANCESTOR_HAS_CONTAIN_STYLE); + } + if self.style.get_parent_column().is_multicol() { self.style.add_flags(ComputedValueFlags::CAN_BE_FRAGMENTED); } diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index 0fbb030143e..25f8ae12769 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -1402,7 +1402,7 @@ impl TouchAction { bitflags! { #[derive(MallocSizeOf, Parse, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] - #[css(bitflags(single = "none,strict,content", mixed="size,layout,paint,inline-size", overlapping_bits))] + #[css(bitflags(single = "none,strict,content", mixed="size,layout,style,paint,inline-size", overlapping_bits))] #[repr(C)] /// Constants for contain: https://drafts.csswg.org/css-contain/#contain-property pub struct Contain: u8 { @@ -1414,14 +1414,16 @@ bitflags! { const BLOCK_SIZE = 1 << 1; /// `layout` variant, turns on layout containment const LAYOUT = 1 << 2; + /// `style` variant, turns on style containment + const STYLE = 1 << 3; /// `paint` variant, turns on paint containment - const PAINT = 1 << 3; + const PAINT = 1 << 4; /// 'size' variant, turns on size containment - const SIZE = 1 << 4 | Contain::INLINE_SIZE.bits | Contain::BLOCK_SIZE.bits; + const SIZE = 1 << 5 | Contain::INLINE_SIZE.bits | Contain::BLOCK_SIZE.bits; /// `content` variant, turns on layout and paint containment - const CONTENT = 1 << 5 | Contain::LAYOUT.bits | Contain::PAINT.bits; + const CONTENT = 1 << 6 | Contain::LAYOUT.bits | Contain::STYLE.bits | Contain::PAINT.bits; /// `strict` variant, turns on all types of containment - const STRICT = 1 << 6 | Contain::LAYOUT.bits | Contain::PAINT.bits | Contain::SIZE.bits; + const STRICT = 1 << 7 | Contain::LAYOUT.bits | Contain::STYLE.bits | Contain::PAINT.bits | Contain::SIZE.bits; } }