mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +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.
|
/// Whether the style depends on viewport units.
|
||||||
const USES_VIEWPORT_UNITS = 1 << 20;
|
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::IS_IN_PSEUDO_ELEMENT_SUBTREE |
|
||||||
Self::HAS_TEXT_DECORATION_LINES |
|
Self::HAS_TEXT_DECORATION_LINES |
|
||||||
Self::IS_IN_OPACITY_ZERO_SUBTREE |
|
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.
|
/// 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.
|
/// Compute a few common flags for both text and element's style.
|
||||||
fn set_bits(&mut self) {
|
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 !display.is_contents() {
|
||||||
if !self
|
if !self
|
||||||
|
@ -280,9 +281,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
if self
|
if box_style
|
||||||
.style
|
|
||||||
.get_box()
|
|
||||||
.clone_contain()
|
.clone_contain()
|
||||||
.contains(SpecifiedValue::STYLE)
|
.contains(SpecifiedValue::STYLE)
|
||||||
{
|
{
|
||||||
|
@ -290,6 +289,14 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
.add_flags(ComputedValueFlags::SELF_OR_ANCESTOR_HAS_CONTAIN_STYLE);
|
.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() {
|
if self.style.get_parent_column().is_multicol() {
|
||||||
self.style.add_flags(ComputedValueFlags::CAN_BE_FRAGMENTED);
|
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
|
/// https://drafts.csswg.org/css-contain-3/#container-name
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue