Truly independent web browser
LibWeb: Read an element's inline style from its declaration block
Andreas Klingd22b6193ccfc
diff --git a/Libraries/LibWeb/Rust/src/css/declaration_block.rs b/Libraries/LibWeb/Rust/src/css/declaration_block.rsindex 2d246975422..d683ab35716 100644--- a/Libraries/LibWeb/Rust/src/css/declaration_block.rs+++ b/Libraries/LibWeb/Rust/src/css/declaration_block.rs@@ -21,7 +21,7 @@ use std::cell::RefCell;use std::ffi::c_void;use std::ptr::NonNull;use std::rc::Rc;-use std::sync::atomic::{AtomicPtr, AtomicU64, AtomicUsize, Ordering, fence};+use std::sync::atomic::{AtomicPtr, AtomicU32, AtomicU64, Ordering, fence};#[derive(Clone)]pub(crate) struct DeclaredProperty {@@ -253,7 +253,11 @@ impl<'a> CustomProperties<'a> {/// need no padding: 16 + 10 bytes per property and 18 per custom property. C++ holds a block by a/// pointer at this header, as an opaque type.pub struct DeclarationBlockHeader {- references: AtomicUsize,+ references: AtomicU32,+ /// Whether any declaration of the block can define a transition.+ declares_transitions: bool,+ /// Whether any value of the block reads an attribute.+ reads_attributes: bool,property_count: u32,custom_property_count: u32,/// What the style engine derives from the block, made by the first engine that publishes it,@@ -358,6 +362,15 @@ impl DeclarationBlockHeader {}}+ /// Ask the processor to fetch the block's arrays, reading its header.+ pub(crate) fn prefetch_arrays(&self) {+ let layout = self.layout();+ let base = std::ptr::from_ref(self).cast::<u8>();+ prefetch(base.wrapping_add(layout.values));+ prefetch(base.wrapping_add(layout.entries));+ prefetch(self.cascade.load(Ordering::Relaxed).cast_const());+ }+/// The bytes of the block's allocation and of the names of its custom properties.pub(crate) fn heap_bytes(&self) -> usize {let mut size = self.layout().layout.size();@@ -404,7 +417,19 @@ const _: () = {};/// The most references a block may have, beyond which counting aborts.-const MAXIMUM_BLOCK_REFERENCES: usize = isize::MAX as usize;+const MAXIMUM_BLOCK_REFERENCES: u32 = i32::MAX as u32;++/// Ask the processor to fetch the cache line at `address` without waiting for it.+#[inline]+pub(crate) fn prefetch<T>(address: *const T) {+ #[cfg(target_arch = "x86_64")]+ // SAFETY: A prefetch reads nothing and cannot fault, whatever the address.+ unsafe {+ std::arch::x86_64::_mm_prefetch::<{ std::arch::x86_64::_MM_HINT_T0 }>(address.cast());+ }+ #[cfg(not(target_arch = "x86_64"))]+ let _ = address;+}impl SharedDeclarationBlock {pub(crate) fn as_ptr(&self) -> *const DeclarationBlockHeader {@@ -464,7 +489,17 @@ impl SharedDeclarationBlock {#[cfg(test)]pub(crate) fn reference_count(&self) -> usize {- self.references.load(Ordering::Relaxed)+ self.references.load(Ordering::Relaxed) as usize+ }++ /// Whether any declaration of the block can define a transition.+ pub(crate) fn declares_transitions(&self) -> bool {+ self.declares_transitions+ }++ /// Whether any value of the block reads an attribute.+ pub(crate) fn reads_attributes(&self) -> bool {+ self.reads_attributes}}@@ -557,8 +592,24 @@ impl DeclarationBlockBuilder {if base.is_null() {handle_alloc_error(layout.layout);}+ let declares_transitions = self+ .properties+ .iter()+ .any(|property| crate::css::property_metadata::property_defines_a_css_transition(property.property_id));+ let reads_attributes = self+ .properties+ .iter()+ .map(|property| &property.value)+ .chain(+ self.custom_properties+ .iter()+ .map(|property| &property.declaration.value),+ )+ .any(|value| crate::css::style::value_reads_attributes(value));base.cast::<DeclarationBlockHeader>().write(DeclarationBlockHeader {- references: AtomicUsize::new(1),+ references: AtomicU32::new(1),+ declares_transitions,+ reads_attributes,property_count,custom_property_count,cascade: AtomicPtr::new(std::ptr::null_mut()),diff --git a/Libraries/LibWeb/Rust/src/css/style/bridge.rs b/Libraries/LibWeb/Rust/src/css/style/bridge.rsindex 655cef1ee77..8e8bd947bca 100644--- a/Libraries/LibWeb/Rust/src/css/style/bridge.rs+++ b/Libraries/LibWeb/Rust/src/css/style/bridge.rs@@ -1434,15 +1434,22 @@ pub(super) fn register_element_declared_properties<'a>(node: StyleNodeID,kind: FfiElementDeclarationKind,declarations: impl ExactSizeIterator<Item = crate::css::declaration_block::DeclarationRef<'a>>,- custom_properties: crate::css::declaration_block::CustomProperties<'_>,) {let declarations = super::specified_value::element_declared_properties(declarations);- let custom_declarations = collect_native_custom_declarations(engine, custom_properties);- let declaration_kind = decode_element_declaration_kind(kind);- engine.set_element_declared_properties(node, declaration_kind, declarations, custom_declarations);+ engine.set_element_declared_properties(node, decode_element_declaration_kind(kind), declarations);// The engine holds the declarations as they were published.}+/// Records the custom properties an element's inline declaration block declares.+pub(super) fn register_element_custom_properties(+ engine: &mut StyleEngine,+ node: StyleNodeID,+ custom_properties: crate::css::declaration_block::CustomProperties<'_>,+) {+ let custom_declarations = collect_native_custom_declarations(engine, custom_properties);+ engine.element_declarations.set_custom(node, custom_declarations);+}+/// Whether `declarations` can define transitions.pub(crate) fn declares_transitions<'a>(declarations: impl IntoIterator<Item = crate::css::declaration_block::DeclarationRef<'a>>,@@ -1465,11 +1472,25 @@ pub extern "C" fn style_engine_set_element_inline_style_properties(let Some(node) = StyleNodeID::from_raw(node) else {return false;};- let data = block.map(DeclarationBlock::data);- let has_transitions = data- .as_ref()- .is_some_and(|data| declares_transitions(data.properties()));- super::engine_calls::queue(host, super::engine_calls::EngineWrite::InlineStyle { node, data });+ let data = block.map(DeclarationBlock::data).filter(|data| !data.is_empty());+ let has_transitions = data.as_ref().is_some_and(|data| data.declares_transitions());+ if let Some(data) = &data+ && data.reads_attributes()+ {+ super::host_atoms::note_attr_names_read_by_block(host, data);+ }+ let declares_custom = data.as_ref().is_some_and(|data| !data.custom_properties().is_empty());+ let previous = host+ .engine_memo()+ .projection+ .borrow_mut()+ .write_inline_declarations(node, data.clone());+ if declares_custom || previous.is_some_and(|previous| !previous.custom_properties().is_empty()) {+ super::engine_calls::queue(+ host,+ super::engine_calls::EngineWrite::InlineCustomProperties { node, data },+ );+ }has_transitions}diff --git a/Libraries/LibWeb/Rust/src/css/style/element_declarations.rs b/Libraries/LibWeb/Rust/src/css/style/element_declarations.rsindex 0f7e69b8d58..47f38a8378c 100644--- a/Libraries/LibWeb/Rust/src/css/style/element_declarations.rs+++ b/Libraries/LibWeb/Rust/src/css/style/element_declarations.rs@@ -12,8 +12,8 @@ use super::index::StyleAtomID;use super::input_types::ElementDeclarationKind;use super::pipeline::rule_store::CustomDeclaration;use super::tree::StyleNodeID;-use crate::cow_column::CowVec;-use crate::css::declaration_block::DeclarationEntry;+use crate::cow_column::{ColumnSnapshot, CowColumn, CowVec};+use crate::css::declaration_block::{DeclarationEntry, SharedDeclarationBlock, prefetch};use crate::css::style_value::RetainedStyleValueData;type Checks = super::pipeline::compute::WrittenValueChecks;@@ -177,10 +177,9 @@ unsafe impl Send for ElementDeclarationRow {}// SAFETY: As above; nothing mutates a row through a shared reference.unsafe impl Sync for ElementDeclarationRow {}-/// An element's inline declaration, taken out of its row while a private demand computes the+/// The custom properties of an element's inline declaration, taken out of its row while a private demand computes the/// element as though it had none.pub(super) struct HiddenInlineDeclarations {- declarations: Vec<(DeclarationEntry, RetainedStyleValueData, Checks)>,custom: Vec<CustomDeclarationWritten>,}@@ -409,14 +408,6 @@ impl ElementDeclarationRow {Self::build(entries, ends, custom)}- /// The declarations of `kind`, copied out.- fn copy_of(&self, kind: ElementDeclarationKind) -> Vec<(DeclarationEntry, RetainedStyleValueData, Checks)> {- let own = self.declarations(kind);- (0..own.declared.len())- .map(|index| (own.declared[index], own.written[index].clone(), own.checks[index]))- .collect()- }-fn storage_bytes(&self) -> usize {row_layout(self.count(), self.custom_count()).size()}@@ -513,12 +504,80 @@ impl ElementDeclarationRow {}}+/// The block of an element's inline declarations, as the column of them holds it. Two are the same only as the same+/// block: a block's content is the host's to compare.+#[derive(Clone, Default)]+pub(in crate::css::style) struct InlineDeclarations(Option<SharedDeclarationBlock>);++impl PartialEq for InlineDeclarations {+ fn eq(&self, other: &Self) -> bool {+ match (&self.0, &other.0) {+ (Some(block), Some(other)) => std::ptr::eq(block.as_ptr(), other.as_ptr()),+ (None, None) => true,+ _ => false,+ }+ }+}++impl InlineDeclarations {+ pub(in crate::css::style) fn new(block: Option<SharedDeclarationBlock>) -> Self {+ Self(block)+ }++ pub(in crate::css::style) fn is_some(&self) -> bool {+ self.0.is_some()+ }++ pub(in crate::css::style) fn into_block(self) -> Option<SharedDeclarationBlock> {+ self.0+ }++ /// The bytes of what the engine derived from the block and of the values it holds that `sizer` reaches for the first+ /// time. The block itself is its element's.+ pub(in crate::css::style) fn heap_size(&self, sizer: &mut crate::heap_size::HeapSizer) -> usize {+ use crate::heap_size::HeapSize;+ let Some(block) = &self.0 else {+ return 0;+ };+ if !sizer.first_sight(block.as_ptr()) {+ return 0;+ }+ block.cascade_data().map_or(0, |data| data.heap_bytes())+ + RetainedStyleValueData::slice_from_shared(block.properties().values()).heap_size(sizer)+ + RetainedStyleValueData::slice_from_shared(block.custom_properties().values()).heap_size(sizer)+ }+}++/// How many elements a chunk of the column of inline declarations holds.+const INLINE_DECLARATIONS_PER_CHUNK: usize = 64;++/// The inline declarations of a document's elements by slot, which its host writes as it writes their rows, made only as+/// far as the last element that held any.+pub(in crate::css::style) type InlineDeclarationColumn = CowColumn<InlineDeclarations, INLINE_DECLARATIONS_PER_CHUNK>;++/// The inline declarations of a document's elements as its host last published them.+pub(in crate::css::style) type InlineDeclarationSnapshot =+ ColumnSnapshot<InlineDeclarations, INLINE_DECLARATIONS_PER_CHUNK>;++const _: () = {+ const fn assert_shared_between_threads<T: Send + Sync>() {}+ assert_shared_between_threads::<InlineDeclarationSnapshot>();+};+/// Element-declaration rows addressed directly by dense element identity.///-/// Each directory slot costs one pointer. A populated slot holds one allocation with the-/// declarations of every kind.+/// An element's inline declarations are read from the block the host published in its column. Each directory slot of the+/// rows costs one pointer, and a populated slot holds one allocation with the presentation attributes' declarations and+/// the custom properties of the inline declarations.#[derive(Clone, Default)]pub(super) struct ElementDeclarationStore {+ /// Each element's inline declarations as the host published them.+ inline: InlineDeclarationSnapshot,+ /// The element whose inline declarations read as none while a private demand computes it.+ hidden_inline: Option<StyleNodeID>,+ /// What a test wrote of the column in place of a host.+ #[cfg(test)]+ inline_written_for_test: InlineDeclarationColumn,/// Each element's row, by element index, copied on write in chunks so that a fork shares them.rows: CowVec<Option<ElementDeclarationRow>, ELEMENT_DECLARATION_ROWS_PER_CHUNK>,/// How many rows hold custom declarations: none means no inline style declares one.@@ -560,7 +619,8 @@ impl ElementDeclarationStore {/// written with counted aside.pub(super) fn heap_size(&self, sizer: &mut crate::heap_size::HeapSizer) -> usize {use crate::heap_size::HeapSize;- let mut bytes = self.rows.heap_size(sizer, |_, _| 0);+ let mut bytes =+ self.rows.heap_size(sizer, |_, _| 0) + self.inline.heap_size(sizer, InlineDeclarations::heap_size);for row in self.rows.iter().flatten() {if !sizer.first_sight(row.0.as_ptr()) {continue;@@ -574,21 +634,81 @@ impl ElementDeclarationStore {bytes}+ /// Have the inline declarations of the elements read as the host published them.+ pub(super) fn adopt_inline(&mut self, inline: InlineDeclarationSnapshot) {+ self.inline = inline;+ }++ /// Have the inline declarations of `node` be `declarations`, as a host would publish them.+ #[cfg(test)]+ pub(super) fn set_inline_for_test(+ &mut self,+ node: StyleNodeID,+ declarations: Vec<(DeclarationEntry, RetainedStyleValueData)>,+ ) {+ let mut builder = crate::css::declaration_block::DeclarationBlockBuilder::default();+ builder.properties = declarations+ .into_iter()+ .map(|(declared, written)| crate::css::declaration_block::DeclaredProperty {+ property_id: declared.property(),+ important: declared.important(),+ value: written.into_arc(),+ })+ .collect();+ let block = builder.finish();+ let slot = node.element_slot();+ self.inline_written_for_test.grow_to(slot + 1);+ self.inline_written_for_test.set(slot, InlineDeclarations(Some(block)));+ self.inline = self.inline_written_for_test.publish();+ }++ fn inline_block(&self, node: StyleNodeID) -> Option<&SharedDeclarationBlock> {+ node.element_index()?;+ if self.hidden_inline == Some(node) {+ return None;+ }+ self.inline.get(node.element_slot())?.0.as_ref()+ }++ fn inline_declarations(&self, node: StyleNodeID) -> Option<ElementDeclarations<'_>> {+ let block = self.inline_block(node)?;+ let properties = block.properties();+ // NB: The element's block is immutable, and what is derived from it is made by the first thread to read it, as+ // an element nothing styles costs nothing here.+ block.make_cascade_data(super::pipeline::rule_store::BlockCascadeData::new);+ Some(ElementDeclarations {+ declared: properties.entries(),+ written: RetainedStyleValueData::slice_from_shared(properties.values()),+ checks: block+ .cascade_data()+ .expect("the block's cascade data was just made")+ .checks(),+ })+ }+fn row(&self, node: StyleNodeID) -> Option<&ElementDeclarationRow> {let index = node.element_index()? as usize;self.rows.get(index)?.as_ref()}- /// Ask the processor to fetch a node's row, which reading the row's address alone does not.+ /// Ask the processor to fetch a node's row and inline declarations, which reading their addresses alone does not.fn prefetch_row(&self, node: StyleNodeID) {+ if let Some(block) = self.inline_block(node) {+ prefetch(block.as_ptr());+ }if let Some(row) = self.row(node) {prefetch(row.0.as_ptr());}}/// Ask the processor to fetch the values a node's declarations were written with, reading the- /// row and its declarations.+ /// row, the block and their declarations.fn prefetch_written_values(&self, node: StyleNodeID) {+ if let Some(inline) = self.inline_declarations(node) {+ for written in inline.written {+ prefetch(written.pointer());+ }+ }let Some(row) = self.row(node) else {return;};@@ -597,8 +717,11 @@ impl ElementDeclarationStore {}}- /// Ask the processor to fetch the declarations a node's row holds, reading the row.+ /// Ask the processor to fetch the declarations a node's row and block hold, reading those.fn prefetch_declarations(&self, node: StyleNodeID) {+ if let Some(block) = self.inline_block(node) {+ block.prefetch_arrays();+ }let Some(row) = self.row(node) else {return;};@@ -612,18 +735,22 @@ impl ElementDeclarationStore {/// The longhand properties one kind of the node's own declarations covers.#[must_use]pub(super) fn declared_properties(&self, node: StyleNodeID, kind: ElementDeclarationKind) -> &[DeclarationEntry] {- self.row(node).map_or(&[], |row| row.declarations(kind).declared)+ self.declarations(node, kind)+ .map_or(&[], |declarations| declarations.declared)}/// One kind of the node's element declarations, with the values they were written with;- /// `None` when it has none of any kind.+ /// `None` when it has none of that kind or of any other its row holds.#[must_use]pub(super) fn declarations(&self,node: StyleNodeID,kind: ElementDeclarationKind,) -> Option<ElementDeclarations<'_>> {- self.row(node).map(|row| row.declarations(kind))+ match kind {+ ElementDeclarationKind::InlineStyle => self.inline_declarations(node),+ _ => self.row(node).map(|row| row.declarations(kind)),+ }}/// Put `row` in the slot at `index`, or empty the slot where `row` holds nothing.@@ -648,30 +775,29 @@ impl ElementDeclarationStore {declarations: Vec<(DeclarationEntry, RetainedStyleValueData)>,) {let index = node.element_index().expect("only elements carry element declarations") as usize;+ debug_assert!(kind != ElementDeclarationKind::InlineStyle);let declarations = declarations.into_iter().map(|(declared, written)| {let checks = Checks::prepare(declared.property(), &written);(declared, written, checks)});- self.replace_kind(index, kind, declarations, None);+ self.replace_kind(index, kind, declarations);}- /// Replace the declarations of `kind` in the row at `index`, and its custom declarations where- /// `custom` names them.+ /// Replace the declarations of `kind` in the row at `index`.fn replace_kind(&mut self,index: usize,kind: ElementDeclarationKind,declarations: impl ExactSizeIterator<Item = (DeclarationEntry, RetainedStyleValueData, Checks)>,- custom: Option<Vec<CustomDeclarationWritten>>,) {let (row, had_custom) = match self.rows.get_mut(index).and_then(Option::as_mut) {Some(row) => {let had_custom = row.custom().is_some();- let custom = custom.unwrap_or_else(|| row.copy_custom());+ let custom = row.copy_custom();(row.with(kind, declarations, custom), had_custom)}None => {- if declarations.len() == 0 && custom.as_ref().is_none_or(Vec::is_empty) {+ if declarations.len() == 0 {return;}let mut ends = [0; ElementDeclarationKind::COUNT];@@ -681,10 +807,7 @@ impl ElementDeclarationStore {ends[other.index()] = count;}}- (- ElementDeclarationRow::build(declarations, ends, custom.unwrap_or_default()),- false,- )+ (ElementDeclarationRow::build(declarations, ends, Vec::new()), false)}};self.put(index, Some(row), had_custom);@@ -746,36 +869,23 @@ impl ElementDeclarationStore {}}- /// Take the node's inline declaration out of its row while a private demand computes the node- /// as though it had none. The demand puts it back before it returns.+ /// Have the node's inline declaration read as none while a private demand computes the node as though it had none.+ /// The demand puts it back before it returns.pub(super) fn hide_inline_for_demand(&mut self, node: StyleNodeID) -> Option<HiddenInlineDeclarations> {- let index = node.element_index()? as usize;- let row = self.rows.get_mut(index)?.as_mut()?;- let kind = ElementDeclarationKind::InlineStyle;- let hidden = HiddenInlineDeclarations {- declarations: row.copy_of(kind),- custom: row.copy_custom(),- };- // NB: The row stays, even where it is empty, for the demand to put the declaration back in.- *row = row.with(kind, std::iter::empty(), Vec::new());- if !hidden.custom.is_empty() {- self.rows_with_custom_declarations -= 1;+ node.element_index()?;+ let custom = self.row(node).map_or_else(Vec::new, ElementDeclarationRow::copy_custom);+ if !custom.is_empty() {+ self.set_custom(node, Vec::new());}- Some(hidden)+ self.hidden_inline = Some(node);+ Some(HiddenInlineDeclarations { custom })}pub(super) fn restore_inline_after_demand(&mut self, node: StyleNodeID, hidden: HiddenInlineDeclarations) {- let index = node.element_index().expect("only an element has an inline declaration") as usize;- assert!(- self.rows.get(index).is_some_and(Option::is_some),- "a private demand keeps the element's declaration row"- );- self.replace_kind(- index,- ElementDeclarationKind::InlineStyle,- hidden.declarations.into_iter(),- Some(hidden.custom),- );+ self.hidden_inline = None;+ if !hidden.custom.is_empty() {+ self.set_custom(node, hidden.custom);+ }}/// Ask the processor to fetch the own declarations of the next elements a traversal styles,@@ -809,18 +919,6 @@ impl ElementDeclarationStore {}}-/// Ask the processor to fetch the cache line at `address` without waiting for it.-#[inline]-fn prefetch<T>(address: *const T) {- #[cfg(target_arch = "x86_64")]- // SAFETY: A prefetch reads nothing and cannot fault, whatever the address.- unsafe {- std::arch::x86_64::_mm_prefetch::<{ std::arch::x86_64::_MM_HINT_T0 }>(address.cast());- }- #[cfg(not(target_arch = "x86_64"))]- let _ = address;-}-#[cfg(test)]mod tests {use super::*;@@ -886,14 +984,14 @@ mod tests {store.set(node, hints, unwritten_declarations(&[declared(3)]));store.set_custom(node, written(&[custom(7), custom(8)]));- store.set(node, inline, unwritten_declarations(&[declared(1), declared(2)]));+ store.set_inline_for_test(node, unwritten_declarations(&[declared(1), declared(2)]));assert!(store.any_declares_custom_properties());assert_eq!(store.custom_declarations(node), &[custom(7), custom(8)][..]);assert_eq!(store.custom(node).map(|custom| custom.written_values().len()), Some(2));assert_eq!(store.declared_properties(node, inline), &[declared(1), declared(2)][..]);assert_eq!(store.declared_properties(node, hints), &[declared(3)][..]);let row = store.row(node).expect("the element declares");- assert_eq!(row.storage_bytes(), 16 + 8 + 2 * 16 + 3 * 14);+ assert_eq!(row.storage_bytes(), 16 + 8 + 2 * 16 + 14);// A private demand takes the inline declarations, custom ones too, out and puts them back.let hidden = store.hide_inline_for_demand(node).expect("the element declares");@@ -922,14 +1020,9 @@ mod tests {DeclarationEntry::new(property, important, super::super::cascade::CascadeOperator::Declared)};- store.set(- first,- inline,- unwritten_declarations(&[declared(1, false), declared(2, true)]),- );+ store.set_inline_for_test(first, unwritten_declarations(&[declared(1, false), declared(2, true)]));store.set(first, hints, unwritten_declarations(&[declared(3, false)]));store.set(later, svg, unwritten_declarations(&[declared(4, false)]));- store.set(later, inline, Vec::new());assert_eq!(store.declared_properties(first, inline),&[declared(1, false), declared(2, true)][..]@@ -938,8 +1031,6 @@ mod tests {assert_eq!(store.declared_properties(later, svg), &[declared(4, false)][..]);assert!(store.declared_properties(later, inline).is_empty());assert_eq!(store.rows.len(), 65);- store.set(first, inline, Vec::new());- assert!(store.declared_properties(first, inline).is_empty());assert_eq!(store.declared_properties(first, hints), &[declared(3, false)][..]);// Retirement has to clear a row before the dense identity is reused.diff --git a/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs b/Libraries/LibWeb/Rust/src/css/style/engine_calls.rsindex f325e1634eb..e992b99bfee 100644--- a/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs+++ b/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs@@ -88,8 +88,9 @@ pub(crate) enum EngineWrite {kind: super::bridge::FfiElementDeclarationKind,properties: Box<[crate::css::declaration_block::DeclaredProperty]>,},- /// An element's inline declaration block, or none.- InlineStyle {+ /// The custom properties an element's inline declaration block declares, which the engine names in atoms of its own.+ /// The rest of the block reaches it with the host's rows.+ InlineCustomProperties {node: StyleNodeID,data: Option<crate::css::declaration_block::SharedDeclarationBlock>,},@@ -254,7 +255,6 @@ impl EngineWrite {properties.iter().map(crate::css::declaration_block::DeclaredProperty::borrowed),- Default::default(),);}Self::AnimationKeyframes { tree_scope, row } => engine.animation_keyframes.set(tree_scope, row),@@ -269,14 +269,10 @@ impl EngineWrite {.keep_timing(node, 0, identity, timing);}}- Self::InlineStyle { node, data } => {- super::bridge::register_element_declared_properties(+ Self::InlineCustomProperties { node, data } => {+ super::bridge::register_element_custom_properties(engine,node,- super::bridge::FfiElementDeclarationKind::InlineStyle,- data.as_ref()- .map_or_else(Default::default, |data| data.properties())- .iter(),data.as_ref().map_or(Default::default(), |data| data.custom_properties()),);diff --git a/Libraries/LibWeb/Rust/src/css/style/host_atoms.rs b/Libraries/LibWeb/Rust/src/css/style/host_atoms.rsindex d1097ac1201..1486ba5a1b0 100644--- a/Libraries/LibWeb/Rust/src/css/style/host_atoms.rs+++ b/Libraries/LibWeb/Rust/src/css/style/host_atoms.rs@@ -435,7 +435,6 @@ pub(crate) fn note_attr_names_read_by_change(host: &DocumentHost, change: &Arena| Rule::LayerOrder { .. } => {}},ArenaChange::Engine(write) => match write {- Engine::InlineStyle { data: Some(data), .. } => note_attr_names_read_by_block(host, data),Engine::PresentationalHints { properties, .. } => {note_attr_names_read_by(host, properties.iter().map(|property| &*property.value));}@@ -449,7 +448,7 @@ pub(crate) fn note_attr_names_read_by_change(host: &DocumentHost, change: &Arenanote_attr_names_read_by_block(host, rule.declarations());}}- Engine::InlineStyle { data: None, .. }+ Engine::InlineCustomProperties { .. }| Engine::PublishFontFaces { .. }| Engine::ElementCustomPropertyData { .. }| Engine::PseudoElementCustomPropertyData { .. }diff --git a/Libraries/LibWeb/Rust/src/css/style/inputs.rs b/Libraries/LibWeb/Rust/src/css/style/inputs.rsindex 787df231acc..aa71073d4ff 100644--- a/Libraries/LibWeb/Rust/src/css/style/inputs.rs+++ b/Libraries/LibWeb/Rust/src/css/style/inputs.rs@@ -1503,7 +1503,8 @@ impl RetainedState {////// Said as the rule is compiled rather than as an input: which layer a rule is in is part of what/// the rule is, and a rule that moves between layers is recompiled.- /// Record which longhand properties one of an element's own declarations covers.+ /// Record which longhand properties an element's presentation attributes cover, each with the value it was written+ /// with.////// An element-attached declaration is a cascade component above layers: a style attribute beats/// every layered and unlayered rule in its context, whatever layer they are in.@@ -1512,54 +1513,15 @@ impl RetainedState {node: StyleNodeID,kind: ElementDeclarationKind,declarations: Vec<(DeclarationEntry, RetainedStyleValueData)>,- custom_declarations: Vec<(CustomDeclaration, RetainedStyleValueData)>,) {- debug_assert!(custom_declarations.is_empty() || kind == ElementDeclarationKind::InlineStyle);let current = self.element_declarations.declarations(node, kind).unwrap_or_default();- let current_custom = match kind {- ElementDeclarationKind::InlineStyle => self.element_declarations.custom(node),- _ => None,- };- let current_custom_declarations = current_custom.map_or(&[][..], |custom| custom.declared());- let current_custom_values = current_custom.map_or(&[][..], |custom| custom.written_values());if current.iter().eq(declarations.iter().map(|(declared, written)| (declared, written)))- && current_custom_declarations- .iter()- .zip(current_custom_values)- .eq(custom_declarations- .iter()- .map(|(declared, written)| (declared, written))){return;}- // An element's declarations are its own allocations, but every value equal to one also has- // a canonical one, which elements declaring the same text then share, and the caches over- // computed values see as the same value. A value taking part in a substitution keeps its- // own: the longhands a shorthand awaiting substitution expands to name it by identity.- let declarations = declarations- .into_iter()- .map(|(declared, written)| {- use crate::css::style_value::StyleValueData;- let takes_part_in_substitution = matches!(- written.optional_data(),- Some(- StyleValueData::Unresolved { .. }- | StyleValueData::PendingSubstitution { .. }- | StyleValueData::Shorthand { .. }- )- );- if takes_part_in_substitution || written.optional_data().is_none() {- return (declared, written);- }- (declared, self.canonical_value(&written.into_arc()))- })- .collect();self.element_declarations.set(node, kind, declarations);- if kind == ElementDeclarationKind::InlineStyle {- self.element_declarations.set_custom(node, custom_declarations);- }}}@@ -1604,7 +1566,6 @@ impl StyleEngine {),),font_resolution: None,- canonical_values: crate::fork::ForkShared::new(CanonicalValues::default()),computed_group_sets: Default::default(),style_record_view_epoch_depth: 0,custom_property_environments: Default::default(),@@ -1934,6 +1895,9 @@ impl StyleEngine {declarations: &[super::bridge::FfiElementDeclarationDelta],) {let moves_links = projection.moves_links();+ self.retained+ .element_declarations+ .adopt_inline(projection.inline_declarations.clone());for (counter, count) in self.retained.projection.adopt(projection) {self.retained.counters.add(counter, count);}@@ -2492,7 +2456,6 @@ impl RetainedState {custom_property_registry: _,font_resolution: _,monospace_font_family: _,- canonical_values: _,computed_group_sets,style_record_view_epoch_depth: _,custom_property_environments: _,diff --git a/Libraries/LibWeb/Rust/src/css/style/instrumentation.rs b/Libraries/LibWeb/Rust/src/css/style/instrumentation.rsindex a243eb60708..56735292ec7 100644--- a/Libraries/LibWeb/Rust/src/css/style/instrumentation.rs+++ b/Libraries/LibWeb/Rust/src/css/style/instrumentation.rs@@ -74,7 +74,6 @@ define_counters! {StyleRulesCompiled => "styleRulesCompiled",// Computation and publication.- SpecifiedValuesReused => "specifiedValuesReused",// The user agent declaration blocks the document's rules declare: those the process interned// for this document, which no document of the process interned before, and those it shared.// The declaration blocks of the document's own sheets its rules declare, which the processdiff --git a/Libraries/LibWeb/Rust/src/css/style/intern_table.rs b/Libraries/LibWeb/Rust/src/css/style/intern_table.rsdeleted file mode 100644index af1d82886ff..00000000000--- a/Libraries/LibWeb/Rust/src/css/style/intern_table.rs+++ /dev/null@@ -1,226 +0,0 @@-/*- * Copyright (c) 2026-present, the Ladybird developers.- *- * SPDX-License-Identifier: BSD-2-Clause- */--//! Shared hash index and dense payload storage for style-engine interners.--use hashbrown::HashTable;-use std::ops::Index;-use std::ops::IndexMut;--pub(super) trait InternIdentity: Copy {- fn index(self) -> usize;- fn from_index(index: usize) -> Self;-}--/// An entry's identity and 32 bits of its hash, which with a 32-bit identity fit in 8 bytes.-#[derive(Clone, Copy)]-struct HashedIdentity<Identity> {- hash: u32,- identity: Identity,-}--/// The 32 bits of `hash` an entry keeps.-fn short_hash(hash: u64) -> u32 {- (hash ^ (hash >> 32)) as u32-}--/// The hash the table places an entry by, spread from the 32 bits it keeps over all 64, as the-/// table reads its top bits.-fn table_hash(short_hash: u32) -> u64 {- u64::from(short_hash).wrapping_mul(0x9e37_79b9_7f4a_7c15)-}--pub(super) struct InternTable<Identity, Payload> {- entries: Vec<Payload>,- identities: HashTable<HashedIdentity<Identity>>,-}--impl<Identity, Payload> Default for InternTable<Identity, Payload> {- fn default() -> Self {- Self {- entries: Vec::new(),- identities: HashTable::new(),- }- }-}--impl<Identity: InternIdentity, Payload> InternTable<Identity, Payload> {- /// The bytes of the payload column and the hash index, with what `payload_heap` says each- /// payload holds.- pub(super) fn heap_size(- &self,- sizer: &mut crate::heap_size::HeapSizer,- mut payload_heap: impl FnMut(&Payload, &mut crate::heap_size::HeapSizer) -> usize,- ) -> usize {- crate::heap_size::vec_bytes(&self.entries)- + self.identities.allocation_size()- + self- .entries- .iter()- .map(|payload| payload_heap(payload, sizer))- .sum::<usize>()- }-- pub(super) fn find(&self, hash: u64, mut matches: impl FnMut(Identity, &Payload) -> bool) -> Option<Identity> {- let hash = short_hash(hash);- self.identities- .find(table_hash(hash), |candidate| {- candidate.hash == hash && matches(candidate.identity, &self.entries[candidate.identity.index()])- })- .map(|candidate| candidate.identity)- }-- pub(super) fn insert(&mut self, hash: u64, identity: Identity, payload: Payload) {- if identity.index() == self.entries.len() {- self.entries.push(payload);- } else {- self.entries[identity.index()] = payload;- }- self.identities.insert_unique(- table_hash(short_hash(hash)),- HashedIdentity {- hash: short_hash(hash),- identity,- },- |candidate| table_hash(candidate.hash),- );- }-- pub(super) fn get(&self, identity: Identity) -> &Payload {- &self.entries[identity.index()]- }-- pub(super) fn get_mut(&mut self, identity: Identity) -> &mut Payload {- &mut self.entries[identity.index()]- }-- pub(super) fn len(&self) -> usize {- self.entries.len()- }-- /// Keep only the payloads `keep` says to, packing the ones kept in their order: each keeps- /// its hash, and the identity of its new index.- pub(super) fn retain(&mut self, mut keep: impl FnMut(&Payload) -> bool) {- let mut new_index = Vec::with_capacity(self.entries.len());- let mut kept = 0_usize;- let entries = std::mem::take(&mut self.entries);- for payload in entries {- if keep(&payload) {- new_index.push(Some(kept));- self.entries.push(payload);- kept += 1;- } else {- new_index.push(None);- }- }- self.entries.shrink_to_fit();- self.identities- .retain(|candidate| match new_index[candidate.identity.index()] {- Some(index) => {- candidate.identity = Identity::from_index(index);- true- }- None => false,- });- self.identities.shrink_to_fit(|candidate| table_hash(candidate.hash));- }-}--impl<Identity: InternIdentity, Payload: Clone> Clone for InternTable<Identity, Payload> {- fn clone(&self) -> Self {- let entries = self.entries.clone();- let mut identities = HashTable::with_capacity(self.identities.len());- for candidate in &self.identities {- identities.insert_unique(table_hash(candidate.hash), *candidate, |candidate| {- table_hash(candidate.hash)- });- }- Self { entries, identities }- }-}--impl<Identity: InternIdentity, Payload> Index<Identity> for InternTable<Identity, Payload> {- type Output = Payload;-- fn index(&self, identity: Identity) -> &Self::Output {- self.get(identity)- }-}--impl<Identity: InternIdentity, Payload> IndexMut<Identity> for InternTable<Identity, Payload> {- fn index_mut(&mut self, identity: Identity) -> &mut Self::Output {- self.get_mut(identity)- }-}--impl<Identity: InternIdentity, Payload> Index<usize> for InternTable<Identity, Payload> {- type Output = Payload;-- fn index(&self, index: usize) -> &Self::Output {- &self.entries[index]- }-}--impl<Identity: InternIdentity, Payload> IndexMut<usize> for InternTable<Identity, Payload> {- fn index_mut(&mut self, index: usize) -> &mut Self::Output {- &mut self.entries[index]- }-}--impl<'a, Identity: InternIdentity, Payload> IntoIterator for &'a InternTable<Identity, Payload> {- type Item = &'a Payload;- type IntoIter = std::slice::Iter<'a, Payload>;-- fn into_iter(self) -> Self::IntoIter {- self.entries.iter()- }-}--#[cfg(test)]-mod tests {- use super::*;-- #[derive(Clone, Copy, Debug, PartialEq, Eq)]- struct TestIdentity(u32);-- impl InternIdentity for TestIdentity {- fn index(self) -> usize {- self.0 as usize- }-- fn from_index(index: usize) -> Self {- Self(u32::try_from(index).unwrap())- }- }-- #[test]- fn content_collisions_compare_dense_payloads() {- let mut table = InternTable::default();- table.insert(7, TestIdentity(0), "first");- table.insert(7, TestIdentity(1), "second");-- assert_eq!(- table.find(7, |_identity, payload| *payload == "second"),- Some(TestIdentity(1))- );- assert_eq!(table.find(8, |_identity, _payload| true), None);- }-- #[test]- fn retained_payloads_are_found_under_their_new_identities() {- let mut table = InternTable::default();- table.insert(1, TestIdentity(0), "dropped");- table.insert(2, TestIdentity(1), "kept");- table.retain(|payload| *payload == "kept");-- assert_eq!(table.len(), 1);- assert_eq!(- table.find(2, |_identity, payload| *payload == "kept"),- Some(TestIdentity(0))- );- assert_eq!(table.find(1, |_identity, _payload| true), None);- }-}diff --git a/Libraries/LibWeb/Rust/src/css/style/memory_report.rs b/Libraries/LibWeb/Rust/src/css/style/memory_report.rsindex 543522b6e6f..6bd0579cc48 100644--- a/Libraries/LibWeb/Rust/src/css/style/memory_report.rs+++ b/Libraries/LibWeb/Rust/src/css/style/memory_report.rs@@ -46,7 +46,6 @@ memory_owners! {SheetSegments => "sheetSegments",SharedDeclarations => "sharedDeclarations",Invalidation => "invalidation",- SpecifiedValues => "specifiedValues",Records => "records",Payloads => "payloads",GroupValueFacts => "groupValueFacts",@@ -147,8 +146,6 @@ impl super::StyleEngine {live.report_memory(&mut report);}state.computed_group_sets.report_memory(&mut report);- let bytes = state.canonical_values.heap_size(&mut report.sizer);- report.add(MemoryOwner::SpecifiedValues, bytes);let bytes = state.custom_property_environments.heap_size(&mut report.sizer);report.add(MemoryOwner::CustomProperties, bytes);report.add(diff --git a/Libraries/LibWeb/Rust/src/css/style/mod.rs b/Libraries/LibWeb/Rust/src/css/style/mod.rsindex 3674e172fc5..bfd83dec855 100644--- a/Libraries/LibWeb/Rust/src/css/style/mod.rs+++ b/Libraries/LibWeb/Rust/src/css/style/mod.rs@@ -46,25 +46,6 @@ macro_rules! define_id {#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, PartialOrd, Ord)]$visibility struct $name($field_visibility u32);};- // An identity an `InternTable` hands out, which indexes the table directly.- ($(#[$attribute:meta])* interned $($rest:tt)*) => {- define_id! { $(#[$attribute])* $($rest)* }- define_id!(@interned $($rest)*);- };- (@interned default $($rest:tt)*) => {- define_id!(@interned $($rest)*);- };- (@interned $visibility:vis struct $name:ident($($field:tt)*);) => {- impl $crate::css::style::intern_table::InternIdentity for $name {- fn index(self) -> usize {- self.0 as usize- }-- fn from_index(index: usize) -> Self {- Self(u32::try_from(index).expect("interned identity exceeds u32"))- }- }- };}pub(crate) mod animations;@@ -105,7 +86,6 @@ mod inputs;mod installed_records;pub(crate) use inputs::next_declaration_block_version;pub mod instrumentation;-mod intern_table;pub(crate) mod layout_style;pub(crate) mod memory_report;pub mod order;@@ -138,6 +118,12 @@ pub mod selector_evaluation;mod shareable;mod size_container_invalidation;mod specified_value;++/// Whether the host has to note what `value` reads of its element's attributes.+pub(crate) fn value_reads_attributes(value: &crate::css::style_value::StyleValueData) -> bool {+ custom_property_cascade::unresolved_reading_attributes(value).is_some()+}+mod transaction_view;pub mod tree;mod weak_pool;@@ -217,7 +203,6 @@ use pipeline::rule_store::StyleScopeID;use selector::Incomplete;use selector::MatchScratch;use selector::Specificity;-use specified_value::CanonicalValues;use transaction_view::TransactionFactSide;use tree::HostTree;use tree::SegmentedNodeColumn;@@ -265,8 +250,6 @@ pub struct RetainedState {/// ancestor's font-relative lengths against.monospace_font_family: RetainedStyleValueData,- /// The values elements' own declarations share, one per content.- canonical_values: crate::fork::ForkShared<CanonicalValues>,/// The shared computed-group payload tuple last published for each live element. This is the/// computed half of the eventual base style record; custom properties and metadata remain/// separate inputs until that record is complete.diff --git a/Libraries/LibWeb/Rust/src/css/style/ordering.rs b/Libraries/LibWeb/Rust/src/css/style/ordering.rsindex c82564c5723..c8fc4c2f014 100644--- a/Libraries/LibWeb/Rust/src/css/style/ordering.rs+++ b/Libraries/LibWeb/Rust/src/css/style/ordering.rs@@ -273,16 +273,5 @@ impl StyleEngine {pub(super) fn release_transaction_and_sweep_atoms(&mut self, transaction: StyleUpdate) {self.release_transaction(transaction);self.sweep_style_atoms();- self.sweep_specified_values();- }-- /// Drop the canonical values no element declares any more, once the set doubled since the- /// last sweep: a script rewriting an inline style enters a value for each write, which nothing- /// else would let go of.- pub(super) fn sweep_specified_values(&mut self) {- if !self.retained.canonical_values.should_sweep() || self.host.defers_atom_sweep {- return;- }- self.retained.canonical_values.sweep();}}diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/fork_tests.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/fork_tests.rsindex e878497a9a3..e8ce80f46dc 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/fork_tests.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/fork_tests.rs@@ -118,7 +118,7 @@ fn fork_bytes(engine: &StyleEngine) -> i64 {/// What a fork of the smaller document allocates, and how much more per element a fork of one/// twice as large does, at most.-const FORK_BYTES: i64 = 5_000;+const FORK_BYTES: i64 = 5_100;const FORK_BYTES_PER_ELEMENT: f64 = 1.5;#[test]diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/matched_declarations.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/matched_declarations.rsindex e85f99b48b0..ede376d7fed 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/matched_declarations.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/matched_declarations.rs@@ -917,9 +917,8 @@ mod tests {let plain = nodes[RECORDS + 2];// NB: A value no other test holds, as tests run side by side and small numbers are shared.let written = RetainedStyleValueData::from_owned(StyleValueData::Number { value: 8675309.25 });- engine.element_declarations.set(+ engine.element_declarations.set_inline_for_test(declaring,- ElementDeclarationKind::InlineStyle,vec![(DeclarationEntry::new(crate::css::property_metadata::property_id::MARGIN_LEFT,diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/projection.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/projection.rsindex bbcd6804ca1..8d59cc16610 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/projection.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/projection.rs@@ -1292,6 +1292,7 @@ impl Projection {let ProjectionPublication {rows,shadows,+ inline_declarations: _,slot_count,catalogs,host_fact_sets,diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/projection/writer.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/projection/writer.rsindex 1c1a6def35a..b8afc0be8d5 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/projection/writer.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/projection/writer.rs@@ -24,6 +24,9 @@ use super::super::super::instrumentation::Counter;use super::super::super::instrumentation::Counters;use super::super::super::tree::StyleNodeID;+use super::super::super::element_declarations::{+ InlineDeclarationColumn, InlineDeclarationSnapshot, InlineDeclarations,+};use super::super::super::element_host_facts::HostFactSet;use super::super::super::element_host_facts::HostFactSets;use super::ArrivalFacts;@@ -44,6 +47,7 @@ use super::list_bloom_of;use super::relations_of;use crate::cow_column::ColumnSnapshot;use crate::cow_column::CowColumn;+use crate::css::declaration_block::SharedDeclarationBlock;use crate::css::retained_fly_string::RetainedUtf16FlyString;use smallvec::SmallVec;use std::sync::Arc;@@ -66,6 +70,11 @@ pub(in crate::css::style) struct ProjectionWriter {rows: CowColumn<Row, ROWS_PER_CHUNK>,/// The elements' shadow relations, made only as far as the last element that held any.shadows: ShadowColumn,+ /// The elements' inline declarations.+ inline_declarations: InlineDeclarationColumn,+ /// Whether the inline declarations of an element were written since the last publication, which the rows written do+ /// not list: what a transaction takes of them the host says beside its rows.+ inline_declarations_written: bool,/// The rows as the host last published them.published: ColumnSnapshot<Row, ROWS_PER_CHUNK>,/// One past the greatest element slot written.@@ -100,6 +109,7 @@ pub(in crate::css::style) struct ProjectionWriter {pub(in crate::css::style) struct ProjectionPublication {pub(super) rows: ColumnSnapshot<Row, ROWS_PER_CHUNK>,pub(super) shadows: ShadowSnapshot,+ pub(in crate::css::style) inline_declarations: InlineDeclarationSnapshot,pub(super) slot_count: usize,pub(super) catalogs: Catalogs,pub(super) host_fact_sets: Arc<HostFactSets>,@@ -138,6 +148,7 @@ impl ProjectionWriter {+ self.shadows.heap_size(sizer, |shadow, sizer| {super::shadow_links_heap_size(shadow.as_ref(), sizer)})+ + self.inline_declarations.heap_size(sizer, InlineDeclarations::heap_size)+ self.published.heap_size(sizer, Row::heap_size);if sizer.arc_shallow(&self.host_fact_sets) != 0 {bytes += crate::heap_size::ARC_HEADER_BYTES + size_of::<HostFactSets>() + self.host_fact_sets.heap_size();@@ -170,7 +181,10 @@ impl ProjectionWriter {/// Whether anything was written since the last publication.#[must_use]pub(in crate::css::style) fn has_unpublished_writes(&self) -> bool {- !self.written.nodes.is_empty() || self.catalogs_written || self.host_facts_written+ !self.written.nodes.is_empty()+ || self.catalogs_written+ || self.host_facts_written+ || self.inline_declarations_written}/// Publish the rows as written: the barrier the render owner takes them at. The elements that left the tree are@@ -192,6 +206,7 @@ impl ProjectionWriter {let rows = self.rows.publish();self.catalogs_written = false;self.host_facts_written = false;+ self.inline_declarations_written = false;let counts = WRITE_COUNTERS.into_iter().filter_map(|counter| {@@ -203,6 +218,7 @@ impl ProjectionWriter {let publication = ProjectionPublication {rows: rows.clone(),shadows: self.shadows.publish(),+ inline_declarations: self.inline_declarations.publish(),slot_count: self.slot_count,catalogs: self.catalogs.clone(),host_fact_sets: Arc::clone(&self.host_fact_sets),@@ -397,9 +413,33 @@ impl ProjectionWriter {});}+ /// Have the inline declarations of `node` be `block`, answering those it held. The render owner reads them from the+ /// next publication on.+ pub(in crate::css::style) fn write_inline_declarations(+ &mut self,+ node: StyleNodeID,+ block: Option<SharedDeclarationBlock>,+ ) -> Option<SharedDeclarationBlock> {+ let slot = node.element_slot();+ if block.is_none()+ && !self+ .inline_declarations+ .get(slot)+ .is_some_and(InlineDeclarations::is_some)+ {+ return None;+ }+ self.inline_declarations.grow_to(slot + 1);+ self.inline_declarations_written = true;+ self.inline_declarations+ .replace(slot, InlineDeclarations::new(block))+ .and_then(InlineDeclarations::into_block)+ }+/// Retire the element identity `node`, dropping its links and every shadow relation that names/// it. Its facts stay until [`Self::forget`].pub(in crate::css::style) fn retire(&mut self, node: StyleNodeID) {+ self.write_inline_declarations(node, None);let slot = self.edit(node, |row| {assert!(row.live(), "retiring an identity that is not live");row.links = Links::default();diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/rule_store.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/rule_store.rsindex b420f3a741c..1f952ef4a9a 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/rule_store.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/rule_store.rs@@ -293,7 +293,7 @@ impl BlockCascadeData {}/// The checks of each longhand's written value.- fn checks(&self) -> &[WrittenValueChecks] {+ pub(in crate::css::style) fn checks(&self) -> &[WrittenValueChecks] {// SAFETY: The allocation holds `length` checks after the header.unsafe {ak::slice_from_raw_parts(@@ -306,7 +306,7 @@ impl BlockCascadeData {}}- fn heap_bytes(&self) -> usize {+ pub(in crate::css::style) fn heap_bytes(&self) -> usize {Self::layout(self.length as usize).size()}diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/winner_store.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/winner_store.rsindex f5509063d31..4c647030512 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/winner_store.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/winner_store.rs@@ -463,9 +463,8 @@ mod tests {owned.seed_retained_property(property, value.clone_retained(), true, false);}let observer = written[0].clone_retained().into_arc();- engine.element_declarations.set(+ engine.element_declarations.set_inline_for_test(node,- kind,properties.iter().map(|&property| DeclarationEntry::new(property, true, CascadeOperator::Declared))diff --git a/Libraries/LibWeb/Rust/src/css/style/specified_value.rs b/Libraries/LibWeb/Rust/src/css/style/specified_value.rsindex 121fca2e8fc..b94d48738a5 100644--- a/Libraries/LibWeb/Rust/src/css/style/specified_value.rs+++ b/Libraries/LibWeb/Rust/src/css/style/specified_value.rs@@ -4,92 +4,12 @@* SPDX-License-Identifier: BSD-2-Clause*/-//! The canonical values of elements' own declarations, and the entries those declarations take.+//! The entries elements' own declarations take.use crate::css::declaration_block;use crate::css::declaration_block::DeclarationEntry;use crate::css::style_value::RetainedStyleValueData;use crate::css::style_value::StyleValueData;-use crate::css::style_value_arc::StyleValueArc;--use super::RetainedState;-use super::instrumentation::Counter;--define_id! { struct CanonicalValueIndex(); }--impl super::intern_table::InternIdentity for CanonicalValueIndex {- fn index(self) -> usize {- self.0 as usize- }-- fn from_index(index: usize) -> Self {- Self(u32::try_from(index).expect("canonical value set exceeds u32 indexing"))- }-}--/// How many values the set holds before its first sweep.-const MINIMUM_SWEEP_THRESHOLD: usize = 1024;--/// The values elements' own declarations were written with, one per content, so that elements-/// declaring equal values share one, which the caches over computed values key by. A value the set-/// alone holds is no element's any more, and a sweep drops it.-#[derive(Clone)]-pub(super) struct CanonicalValues {- entries: super::intern_table::InternTable<CanonicalValueIndex, RetainedStyleValueData>,- /// How many values the set holds before it sweeps the ones only it holds: twice as many as the- /// last sweep kept, so sweeping costs a constant per value entered.- sweep_threshold: usize,-}--impl Default for CanonicalValues {- fn default() -> Self {- Self {- entries: super::intern_table::InternTable::default(),- sweep_threshold: MINIMUM_SWEEP_THRESHOLD,- }- }-}--impl CanonicalValues {- /// The bytes of the set and its index, with the values it holds counted aside.- pub(super) fn heap_size(&self, sizer: &mut crate::heap_size::HeapSizer) -> usize {- use crate::heap_size::HeapSize;- self.entries.heap_size(sizer, |value, sizer| value.heap_size(sizer))- }-- /// Whether the set grew enough since its last sweep to sweep it again.- pub(super) fn should_sweep(&self) -> bool {- self.entries.len() >= self.sweep_threshold- }-- /// Drop the values only the set holds, which no element declares any more.- ///- /// NB: A fork's copy of the set holds a second reference to each of its values, so a sweep- /// while a fork lives keeps them all.- pub(super) fn sweep(&mut self) {- self.entries.retain(|value| !value.is_unique());- self.sweep_threshold = (self.entries.len() * 2).max(MINIMUM_SWEEP_THRESHOLD);- }-- /// The value equal to `value` elements share, entering `value` as that one where none is, and- /// whether one was. A value whose content cannot name it, as an image's resource context is- /// not part of its content, is its own.- fn canonical(&mut self, value: &StyleValueArc) -> (RetainedStyleValueData, bool) {- if crate::css::style_compute::value_may_need_style_sheet_resource_context(value) {- return (RetainedStyleValueData::from_arc(value.clone()), false);- }- let content_hash = value.content_hash();- let data: &StyleValueData = value;- if let Some(index) = self.entries.find(content_hash, |_index, entry| entry.data() == data) {- return (self.entries.get(index).clone(), true);- }- let index =- CanonicalValueIndex(u32::try_from(self.entries.len()).expect("canonical value set exceeds u32 indexing"));- let canonical = RetainedStyleValueData::from_arc(value.clone());- self.entries.insert(content_hash, index, canonical.clone());- (canonical, false)- }-}/// The entries of the longhands `declarations` declare, each with the value an element declaring/// it is written with, a shorthand's longhands taking its value.@@ -129,53 +49,31 @@ pub(crate) fn element_declared_properties<'a>(entries}-impl RetainedState {- /// The value equal to `value` the elements of the document share.- pub(super) fn canonical_value(&mut self, value: &StyleValueArc) -> RetainedStyleValueData {- let (canonical, reused) = self.canonical_values.canonical(value);- if reused {- self.counters.bump(Counter::SpecifiedValuesReused);- }- canonical- }-}-#[cfg(test)]-#[allow(clippy::arc_with_non_send_sync)]mod tests {use super::*;+ use crate::css::declaration_block::DeclarationBlockBuilder;+ use crate::css::declaration_block::DeclaredProperty;+ use crate::css::property_metadata::property_id;+ use crate::css::style_value::shared_style_value;#[test]- fn equal_content_shares_one_value() {- let mut values = CanonicalValues::default();- let originals: Vec<_> = (0..64)- .map(|i| StyleValueArc::new(StyleValueData::Number { value: f64::from(i) }))- .collect();- let canonical: Vec<_> = originals.iter().map(|value| values.canonical(value).0).collect();- let respellings: Vec<_> = (0..64)- .map(|i| StyleValueArc::new(StyleValueData::Number { value: f64::from(i) }))- .collect();- for (respelling, canonical) in respellings.iter().zip(&canonical) {- let (shared, reused) = values.canonical(respelling);- assert!(reused);- assert_eq!(shared.pointer(), canonical.pointer());- }- }-- #[test]- fn a_sweep_drops_the_values_only_the_set_holds() {- let mut values = CanonicalValues::default();- let kept = values- .canonical(&StyleValueArc::new(StyleValueData::Number { value: 1.0 }))- .0;- drop(values.canonical(&StyleValueArc::new(StyleValueData::Number { value: 2.0 })));- values.sweep();- assert_eq!(values.entries.len(), 1);+ fn a_shorthand_hint_declares_each_longhand_with_one_value() {+ let mut hints = DeclarationBlockBuilder::default();+ hints.append_in_specified_order(DeclaredProperty {+ property_id: property_id::BORDER,+ important: false,+ value: shared_style_value(StyleValueData::Keyword {+ keyword: crate::css::style_compute::keyword::INHERIT,+ }),+ });+ let declared = element_declared_properties(hints.properties.iter().map(DeclaredProperty::borrowed));+ // The longhands comprise four widths, four styles, four colors, and five border-image properties.+ assert_eq!(declared.len(), 17);assert!(- values- .canonical(&StyleValueArc::new(StyleValueData::Number { value: 1.0 }))- .1+ declared+ .iter()+ .all(|(_, written)| written.pointer() == declared[0].1.pointer()));- drop(kept);}}diff --git a/Libraries/LibWeb/Rust/src/css/style_compute.rs b/Libraries/LibWeb/Rust/src/css/style_compute.rsindex 3837747d75e..363418e1ade 100644--- a/Libraries/LibWeb/Rust/src/css/style_compute.rs+++ b/Libraries/LibWeb/Rust/src/css/style_compute.rs@@ -2033,10 +2033,6 @@ pub(crate) fn collect_external_value_dependencies(value: &StyleValueData) -> Extdependencies}-pub(crate) fn value_may_need_style_sheet_resource_context(value: &StyleValueData) -> bool {- collect_external_value_dependencies(value).may_need_style_sheet_resource_context-}-/// The external dependencies of a value, or `None` for one whose computational independence is/// not known, which only a value that never reaches computation has.pub(crate) fn try_external_value_dependencies(value: &StyleValueData) -> Option<ExternalValueDependencies> {diff --git a/Libraries/LibWeb/Rust/src/css/style_value.rs b/Libraries/LibWeb/Rust/src/css/style_value.rsindex 394f79450ac..cd86911808e 100644--- a/Libraries/LibWeb/Rust/src/css/style_value.rs+++ b/Libraries/LibWeb/Rust/src/css/style_value.rs@@ -577,16 +577,6 @@ impl RetainedStyleValueData {unsafe { ak::slice_from_raw_parts(values.as_ptr().cast(), values.len()) }}- /// Whether this is the only reference to the value, which a handle without one is not.- pub(crate) fn is_unique(&self) -> bool {- if self.optional_data().is_none() {- return false;- }- // SAFETY: The handle holds a reference to the value, which the borrowed one never drops.- let value = std::mem::ManuallyDrop::new(unsafe { StyleValueArc::from_raw(self.pointer()) });- StyleValueArc::is_unique(&value)- }-/// Converts the retained reference into an Arc, transferring the strong reference.pub(crate) fn into_arc(self) -> StyleValueArc {let pointer = self.pointer();diff --git a/Tests/LibWeb/TestCSSSyntaxParser.cpp b/Tests/LibWeb/TestCSSSyntaxParser.cppindex f50d33595bb..582062c390c 100644--- a/Tests/LibWeb/TestCSSSyntaxParser.cpp+++ b/Tests/LibWeb/TestCSSSyntaxParser.cpp@@ -392,19 +392,6 @@ TEST_CASE(style_engine_expands_presentation_hint_shorthands_in_rust)Vector<StyleProperty> hints { StyleProperty { Important::No, PropertyID::Border, inherited.properties()[0].value } };engine.set_element_presentational_hint_properties(node, StyleEngineFFI::FfiElementDeclarationKind::PresentationalHint, hints);EXPECT(!engine.css_transitions_may_observe_style_changes());- // Border expands through intermediate shorthands such as border-width. Each resulting- // longhand after the first must reuse the same immutable keyword value. The 17 longhands- // comprise four widths, four styles, four colors, and five border-image properties.- Layout::ForcedReadScope read { engine.render_document() };- for (size_t index = 0;; ++index) {- StringView name;- u64 value = 0;- VERIFY(engine.counter(read, index, name, value));- if (name == "specifiedValuesReused"sv) {- EXPECT_EQ(value, 16ull);- break;- }- }auto transitions = parse_native_declaration_block(u"transition-duration: 1s"sv);engine.set_element_presentational_hint_properties(node, StyleEngineFFI::FfiElementDeclarationKind::PresentationalHint, transitions.properties());EXPECT(engine.css_transitions_may_observe_style_changes());diff --git a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-animated-element.txt b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-animated-element.txtindex e54fad7fad2..1156412d002 100644--- a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-animated-element.txt+++ b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-animated-element.txt@@ -6,7 +6,6 @@ animation: 500 elementssheetSegments: within 0sharedDeclarations: within 0invalidation: within 0- specifiedValues: within 0records: within 456payloads: within 656groupValueFacts: within 0@@ -35,7 +34,6 @@ transition: 500 elementssheetSegments: within 0sharedDeclarations: within 0invalidation: within 0- specifiedValues: within 0records: within 456payloads: within 352groupValueFacts: within 0diff --git a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-document-by-owner.txt b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-document-by-owner.txtindex 855d2a453b6..ebebb6550aa 100644--- a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-document-by-owner.txt+++ b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-document-by-owner.txt@@ -5,7 +5,6 @@ userAgentIndex: within 149568sheetSegments: within 0sharedDeclarations: within 14592invalidation: within 904-specifiedValues: within 0records: within 1552payloads: within 7120groupValueFacts: within 672@@ -15,7 +14,7 @@ recordCells: within 112installed: within 1320projection: within 5408hostTree: within 4672-elementDeclarations: within 16+elementDeclarations: within 32heldRecordMaps: within 1168layoutStyleColumns: within 104otherMaps: within 88diff --git a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-element-by-owner.txt b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-element-by-owner.txtindex 6e417f462e1..7af848430b5 100644--- a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-element-by-owner.txt+++ b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-element-by-owner.txt@@ -6,7 +6,6 @@ shared: 500 elements, 500 styledsheetSegments: within 0sharedDeclarations: within 0invalidation: within 0- specifiedValues: within 0records: within 4payloads: within 4groupValueFacts: within 4@@ -35,7 +34,6 @@ custom: 500 elements, 500 styledsheetSegments: within 0sharedDeclarations: within 0invalidation: within 0- specifiedValues: within 0records: within 312payloads: within 164groupValueFacts: within 4@@ -45,11 +43,11 @@ custom: 500 elements, 500 styledinstalled: within 48projection: within 52hostTree: within 24- elementDeclarations: within 80+ elementDeclarations: within 88heldRecordMaps: within 12layoutStyleColumns: within 0otherMaps: within 0- styleValues: within 108+ styleValues: within 144animationEffects: within 0fontResolutions: within 0cssAnimations: within 0@@ -64,7 +62,6 @@ unique: 500 elements, 500 styledsheetSegments: within 0sharedDeclarations: within 0invalidation: within 0- specifiedValues: within 32records: within 92payloads: within 164groupValueFacts: within 4@@ -93,7 +90,6 @@ uniqueFont: 500 elements, 500 styledsheetSegments: within 0sharedDeclarations: within 0invalidation: within 0- specifiedValues: within 68records: within 160payloads: within 340groupValueFacts: within 4@@ -122,7 +118,6 @@ uniqueVisual: 500 elements, 500 styledsheetSegments: within 0sharedDeclarations: within 0invalidation: within 0- specifiedValues: within 0records: within 156payloads: within 188groupValueFacts: within 4@@ -151,7 +146,6 @@ substituted: 500 elements, 500 styledsheetSegments: within 0sharedDeclarations: within 0invalidation: within 0- specifiedValues: within 0records: within 312payloads: within 164groupValueFacts: within 4@@ -161,11 +155,11 @@ substituted: 500 elements, 500 styledinstalled: within 16projection: within 44hostTree: within 24- elementDeclarations: within 80+ elementDeclarations: within 84heldRecordMaps: within 12layoutStyleColumns: within 0otherMaps: within 0- styleValues: within 124+ styleValues: within 160animationEffects: within 0fontResolutions: within 0cssAnimations: within 0diff --git a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-element-with-hints.txt b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-element-with-hints.txtindex 1237747020a..c36f7807f74 100644--- a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-element-with-hints.txt+++ b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-element-with-hints.txt@@ -1,19 +1,16 @@repeated:- specifiedValues: within 4elementDeclarations: within 12styleValues: within 4records: within 4payloads: within 4cppHintProperties: within 16repeated two:- specifiedValues: within 4elementDeclarations: within 12styleValues: within 4records: within 4payloads: within 4cppHintProperties: within 32unique:- specifiedValues: within 32elementDeclarations: within 40styleValues: within 92records: within 160diff --git a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-rule-by-owner.txt b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-rule-by-owner.txtindex 2f34578ba56..78095dfbea8 100644--- a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-rule-by-owner.txt+++ b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-rule-by-owner.txt@@ -4,7 +4,6 @@ document:userAgentIndex: within 149568sheetSegments: within 0invalidation: within 880- specifiedValues: within 0styleValues: within 4224class:ruleStore: within 80@@ -12,7 +11,6 @@ class:userAgentIndex: within 0sheetSegments: within 56invalidation: within 8- specifiedValues: within 0sharedDeclarations: within 40styleValues: within 8total: within 184@@ -22,7 +20,6 @@ descendant:userAgentIndex: within 0sheetSegments: within 344invalidation: within 8- specifiedValues: within 0sharedDeclarations: within 40styleValues: within 0total: within 460@@ -32,7 +29,6 @@ selector list:userAgentIndex: within 0sheetSegments: within 112invalidation: within 8- specifiedValues: within 0sharedDeclarations: within 40styleValues: within 8total: within 224diff --git a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-selector-by-owner.txt b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-selector-by-owner.txtindex 8530ca54f0d..7e8f4924698 100644--- a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-selector-by-owner.txt+++ b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-selector-by-owner.txt@@ -4,7 +4,6 @@ class:userAgentIndex: within 0sheetSegments: within 248invalidation: within 8- specifiedValues: within 0sharedDeclarations: within 8styleValues: within 0total: within 392@@ -14,7 +13,6 @@ descendant:userAgentIndex: within 0sheetSegments: within 424invalidation: within 8- specifiedValues: within 0sharedDeclarations: within 8styleValues: within 0total: within 568@@ -24,7 +22,6 @@ is:userAgentIndex: within 0sheetSegments: within 408invalidation: within 8- specifiedValues: within 0sharedDeclarations: within 8styleValues: within 0total: within 544@@ -34,7 +31,6 @@ selector list:userAgentIndex: within 0sheetSegments: within 488invalidation: within 8- specifiedValues: within 0sharedDeclarations: within 8styleValues: within 0total: within 664@@ -44,7 +40,6 @@ descendant, media print:userAgentIndex: within 0sheetSegments: within 0invalidation: within 0- specifiedValues: within 0sharedDeclarations: within 8styleValues: within 0total: within 80diff --git a/Tests/LibWeb/Text/expected/css/style-memory/inline-style-rewrites-keep-specified-values-bounded.txt b/Tests/LibWeb/Text/expected/css/style-memory/inline-style-rewrites-keep-specified-values-bounded.txtdeleted file mode 100644index e1f05d8473f..00000000000--- a/Tests/LibWeb/Text/expected/css/style-memory/inline-style-rewrites-keep-specified-values-bounded.txt+++ /dev/null@@ -1 +0,0 @@-bounded: truediff --git a/Tests/LibWeb/Text/input/css/style-memory/bytes-per-document-by-owner.html b/Tests/LibWeb/Text/input/css/style-memory/bytes-per-document-by-owner.htmlindex 1efd51b7ce5..dd1733870b3 100644--- a/Tests/LibWeb/Text/input/css/style-memory/bytes-per-document-by-owner.html+++ b/Tests/LibWeb/Text/input/css/style-memory/bytes-per-document-by-owner.html@@ -32,7 +32,7 @@installed: 1320,projection: 5408,hostTree: 4672,- elementDeclarations: 16,+ elementDeclarations: 32,heldRecordMaps: 1168,layoutStyleColumns: 104,otherMaps: 88,diff --git a/Tests/LibWeb/Text/input/css/style-memory/bytes-per-element-by-owner.html b/Tests/LibWeb/Text/input/css/style-memory/bytes-per-element-by-owner.htmlindex 09654008ac0..4fb6229a91d 100644--- a/Tests/LibWeb/Text/input/css/style-memory/bytes-per-element-by-owner.html+++ b/Tests/LibWeb/Text/input/css/style-memory/bytes-per-element-by-owner.html@@ -41,7 +41,7 @@// - records, payloads, groupValueFacts: the computed style and its group data.// - retainedSlots, recordCells, installed, heldRecordMaps: which style an element holds.// - layoutStyleColumns: the layout object's style pointer.- // - styleValues, specifiedValues, elementDeclarations: the inline style property set.+ // - styleValues, elementDeclarations: the inline style property set.// - customProperties: the inherited variables map.// - projection: a row per element: tag, flags, host facts, states, interned fact lists pointer, dispatch bloom and// element links.@@ -71,9 +71,9 @@installed: 48,projection: 52,hostTree: 24,- elementDeclarations: 80,+ elementDeclarations: 88,heldRecordMaps: 12,- styleValues: 108,+ styleValues: 144,hostMemo: 36,cppInstalledStyles: 8,};@@ -86,14 +86,13 @@installed: 16,projection: 44,hostTree: 24,- elementDeclarations: 80,+ elementDeclarations: 84,heldRecordMaps: 12,- styleValues: 124,+ styleValues: 160,hostMemo: 72,cppInstalledStyles: 8,};const uniqueBudgets = {- specifiedValues: 32,records: 92,payloads: 164,groupValueFacts: 4,@@ -107,7 +106,6 @@};const uniqueFontBudgets = {- specifiedValues: 68,records: 160,payloads: 340,groupValueFacts: 4,@@ -150,9 +148,20 @@// document keep each element's text of it, which bytes-per-element-reading-style-text covers. Where one ran, what// that text adds to these owners is not this page's to bound.- // NB: Elements styled on different threads can each make a value or record of the same style.const slack = 1;+ // NB: A style thread makes its own copy of a group or record its caches don't hold yet, so which threads took part+ // between two reports decides how many copies the slope finds, down to none where one thread styles a page. These+ // are the bytes of one copy by owner, for at most the eight style threads a machine gets and the calling thread.+ const copyingThreads = 9;+ const bytesPerThreadCopy = {+ records: 312,+ payloads: 680,+ groupValueFacts: 208,+ retainedSlots: 60,+ styleValues: 88,+ };+function check(name, result, budgets) {println(`${name}: ${result.elements} elements, ${result.styledElements} styled`);for (const owner in result.slopes) {@@ -161,7 +170,8 @@continue;const slope = result.slopes[owner];const budget = budgets[owner] ?? 0;- println(` ${owner}: ${slope.toFixed(1) <= budget + slack ? "within" : `OVER (${slope.toFixed(1)})`} ${budget}`);+ const copies = copyingThreads * (bytesPerThreadCopy[owner] ?? 0) / result.elements;+ println(` ${owner}: ${slope.toFixed(1) <= budget + slack + copies ? "within" : `OVER (${slope.toFixed(1)})`} ${budget}`);}}diff --git a/Tests/LibWeb/Text/input/css/style-memory/bytes-per-element-with-hints.html b/Tests/LibWeb/Text/input/css/style-memory/bytes-per-element-with-hints.htmlindex f3cf708ab55..dc469ef63b1 100644--- a/Tests/LibWeb/Text/input/css/style-memory/bytes-per-element-with-hints.html+++ b/Tests/LibWeb/Text/input/css/style-memory/bytes-per-element-with-hints.html@@ -28,7 +28,6 @@// Bytes per element each owner may add, which a change that grows an owner past has to raise. Only the owners a// hint can move are listed: bytes-per-element-by-owner bounds the rest.const hintOwners = [- "specifiedValues","elementDeclarations","styleValues","records",@@ -38,7 +37,6 @@// NB: The engine holds elements with equal hints on one row. What each holds of its own is the C++ list of the hints// it published, which only tells a republication that nothing moved.const repeatedBudgets = {- specifiedValues: 4,elementDeclarations: 12,styleValues: 4,records: 4,@@ -50,7 +48,6 @@cppHintProperties: 32,};const uniqueBudgets = {- specifiedValues: 32,elementDeclarations: 40,styleValues: 92,records: 160,diff --git a/Tests/LibWeb/Text/input/css/style-memory/bytes-per-rule-by-owner.html b/Tests/LibWeb/Text/input/css/style-memory/bytes-per-rule-by-owner.htmlindex 550d0420dbf..5092a001a94 100644--- a/Tests/LibWeb/Text/input/css/style-memory/bytes-per-rule-by-owner.html+++ b/Tests/LibWeb/Text/input/css/style-memory/bytes-per-rule-by-owner.html@@ -13,7 +13,6 @@"userAgentIndex","sheetSegments","invalidation",- "specifiedValues","sharedDeclarations","styleValues",];diff --git a/Tests/LibWeb/Text/input/css/style-memory/bytes-per-selector-by-owner.html b/Tests/LibWeb/Text/input/css/style-memory/bytes-per-selector-by-owner.htmlindex a7e3359366f..a5c045ed788 100644--- a/Tests/LibWeb/Text/input/css/style-memory/bytes-per-selector-by-owner.html+++ b/Tests/LibWeb/Text/input/css/style-memory/bytes-per-selector-by-owner.html@@ -13,7 +13,6 @@"userAgentIndex","sheetSegments","invalidation",- "specifiedValues","sharedDeclarations","styleValues",];diff --git a/Tests/LibWeb/Text/input/css/style-memory/inline-style-rewrites-keep-specified-values-bounded.html b/Tests/LibWeb/Text/input/css/style-memory/inline-style-rewrites-keep-specified-values-bounded.htmldeleted file mode 100644index c1e743777a7..00000000000--- a/Tests/LibWeb/Text/input/css/style-memory/inline-style-rewrites-keep-specified-values-bounded.html+++ /dev/null@@ -1,26 +0,0 @@-<!doctype html>-<body>-<div id="target"></div>-<script src="../../include.js"></script>-<script>- // Every write of an inline style interns its value. Once no declaration names a value, the table lets go of it,- // so a script rewriting one inline style holds the table to what the document declares: the most it holds while- // the script writes its last values is no more than the most it held while it wrote its first.- test(() => {- let written = 0;- const peakWhileRewriting = count => {- let peak = 0;- for (let i = 0; i < count; ++i) {- target.style.width = `${++written}px`;- target.offsetWidth;- if (i % 250 === 0)- peak = Math.max(peak, internals.styleMemoryReport().owners.specifiedValues);- }- return peak;- };- const first = peakWhileRewriting(3000);- peakWhileRewriting(3000);- const last = peakWhileRewriting(3000);- println(`bounded: ${last <= first * 1.25}`);- });-</script>