Truly independent web browser
LibWeb: Trace live style passes instead of counting them
Aliaksandr Kalenikedc6c346d2c3
diff --git a/Documentation/Style/StyleEngineTesting.md b/Documentation/Style/StyleEngineTesting.mdindex b083bc234c6..47bb21decc5 100644--- a/Documentation/Style/StyleEngineTesting.md+++ b/Documentation/Style/StyleEngineTesting.md@@ -34,7 +34,8 @@ the `RustWorkspace` ctest, from the build directory. Do not run Cargo from the r| `LIBWEB_VERIFY_STYLE_CHUNKS` | Checks the reads recorded for shared group chunks. || `LIBWEB_STYLE_THREADS` | Sets the number of threads a pass uses. |-`internals.styleColdPass()` runs a cold pass and reports on it, and `internals.styleLiveReport()` reports on the live engine.+`internals.styleSelfCheck()` compares the live engine with a cold pass and with the records the host installed, and answers each+difference as a line naming the element.## Debugging@@ -42,11 +43,12 @@ the `RustWorkspace` ctest, from the build directory. Do not run Cargo from the rmissed something: the report names the element and what differs. If the self-check passes, the bug is outside theincremental path: in what the host publishes, in computation itself (a cold pass is wrong too), or in the consumer.-**Performance.** A profile shows host and engine cost side by side. `internals.styleCounters()` says how much work an update-did, and `Meta/StyleUpdateCapture/` captures it for a page.+**Performance.** A profile shows host and engine cost side by side. The style trace says which elements an update restyled,+and `Meta/StyleUpdateCapture/` captures how long it took for a page.## Writing tests- A behavior fix lands with a test that failed before it.-- To assert invalidation reach, compare counters around the mutation rather than timing it.+- To assert invalidation reach, trace the passes the mutation causes (`styleWork()` and `styleTest()` in+ `Tests/LibWeb/Text/input/work-test.js`) and check the elements they restyled, rather than counting or timing them.- Reach a retained state, such as warm caches, through ordinary DOM and CSSOM operations in the test.diff --git a/Libraries/LibWeb/CSS/StyleEngineBridge.h b/Libraries/LibWeb/CSS/StyleEngineBridge.hindex 7791923fb22..44ee427ee02 100644--- a/Libraries/LibWeb/CSS/StyleEngineBridge.h+++ b/Libraries/LibWeb/CSS/StyleEngineBridge.h@@ -105,15 +105,13 @@ bool style_engine_pending_transaction_may_affect_layout_geometry(DocumentHost covoid style_engine_defer_pending_transaction_for_geometry_read(DocumentHost const*, BegunRead const*);bool style_engine_begin_deferred_geometry_transaction_flush(DocumentHost const*, BegunRead const*);bool style_engine_has_deferred_geometry_transaction(DocumentHost const*, BegunRead const*);-u64 style_engine_cold_pass(DocumentHost const*, BegunRead const*, StyleNodeID root, bool verify, u32 threads);-u64 style_engine_cold_pass_report(DocumentHost const*, BegunRead const*, u32 index);-u64 style_engine_live_report(DocumentHost const*, BegunRead const*, StyleNodeID root, bool verify, u32 index);u64 style_engine_style_counter(DocumentHost const*, BegunRead const*, u32 index);bool style_engine_reset_style_counters(DocumentHost const*, BegunRead const*);-bool style_engine_last_pass_is_full(DocumentHost const*, BegunRead const*);-u32 style_engine_last_pass_size(DocumentHost const*, BegunRead const*, StyleNodeID root, bool changed);-u32 style_engine_last_pass_element(DocumentHost const*, BegunRead const*, StyleNodeID root, bool changed, u32 index);u64 style_engine_animated_style_samples(DocumentHost const*, BegunRead const*, bool rebuilt_every_group, bool reset);+bool style_engine_begin_style_trace(DocumentHost const*, BegunRead const*);+bool style_engine_end_style_trace(DocumentHost const*, BegunRead const*);+u32 style_engine_style_trace_size(DocumentHost const*, BegunRead const*, StyleNodeID root);+u64 style_engine_style_trace_entry(DocumentHost const*, BegunRead const*, StyleNodeID root, u32 index);u32 style_engine_layer_index(DocumentHost const*, BegunRead const*, TreeScopeID tree_scope, u32 layer);u64 style_engine_size_query_container_scan_visits(DocumentHost const*, BegunRead const*, bool reset);u64 style_engine_ensure_random_base_value(DocumentHost const*, BegunRead const*, StyleNodeID node, ReadonlySpan<u16> name, bool element_shared);diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cppindex 9de98a5adc6..6ae6973d2f9 100644--- a/Libraries/LibWeb/Internals/Internals.cpp+++ b/Libraries/LibWeb/Internals/Internals.cpp@@ -3210,78 +3210,108 @@ void Internals::panic_render_state_for_testing()Layout::RustFFI::render_state_panic_for_testing(window().associated_document().layout_node_arena().host());}-GC::Ref<JS::Object> Internals::style_cold_pass(bool verify, u32 threads)+Vector<String> Internals::style_self_check(){// A script reads the render state, which waits for a frame in flight.Layout::ForcedReadScope read { window().associated_document() };- auto& realm = window().principal_realm();- auto object = JS::Object::create(realm, nullptr);auto& document = window().associated_document();auto* root = document.document_element();- if (!root || root->style_node_id() == 0)- return object;- auto host = document.style_computer().style_engine().host();- auto nanoseconds = CSS::StyleEngineFFI::style_engine_cold_pass(host, read, root->style_node_id(), verify, threads);- object->define_direct_property("milliseconds"_utf16_fly_string, JS::Value(static_cast<double>(nanoseconds) / 1'000'000.0), JS::default_attributes);- // NB: In the order of the report fields of the Rust style engine.- static constexpr Array field_names {- "elements"sv,- "indexedEntries"sv,- "indexNanoseconds"sv,- "styleNanoseconds"sv,- "threads"sv,- "candidates"sv,- "bloomRejections"sv,- "evaluations"sv,- "matches"sv,- "winners"sv,- "computedElements"sv,- "directlyComputedElements"sv,- "sharedElements"sv,- "reusedElements"sv,- "pseudoElements"sv,- "differences"sv,- };- for (u32 index = 0; index < field_names.size(); ++index) {- auto value = CSS::StyleEngineFFI::style_engine_cold_pass_report(host, read, index);- object->define_direct_property(Utf16FlyString::from_utf8(field_names[index]), JS::Value(static_cast<double>(value)), JS::default_attributes);- }- return object;+ Vector<String> lines;+ CSS::StyleEngineFFI::style_engine_self_check_report(document.style_computer().style_engine().host(), read, root ? root->style_node_id().value() : 0, &lines,+ [](void* context, u8 const* bytes, size_t length) {+ static_cast<Vector<String>*>(context)->append(MUST(String::from_utf8(StringView { bytes, length })));+ });+ return lines;}-GC::Ref<JS::Object> Internals::style_live_report(bool verify)+void Internals::begin_style_trace()+{+ // A script reads the render state, which waits for a frame in flight.+ Layout::ForcedReadScope read { window().associated_document() };+ (void)CSS::StyleEngineFFI::style_engine_begin_style_trace(window().associated_document().style_computer().style_engine().host(), read);+}++Utf16String Internals::take_style_trace(){// A script reads the render state, which waits for a frame in flight.Layout::ForcedReadScope read { window().associated_document() };- auto& realm = window().principal_realm();- auto object = JS::Object::create(realm, nullptr);auto& document = window().associated_document();+ auto& style_computer = document.style_computer();+ auto host = style_computer.style_engine().host();auto* root = document.document_element();- if (!root || root->style_node_id() == 0)- return object;- auto host = document.style_computer().style_engine().host();- // NB: In the order of the live report fields of the Rust style engine.- static constexpr Array field_names {- "passes"sv,- "fullPasses"sv,- "styledElements"sv,- "invalidationNanoseconds"sv,- "styleNanoseconds"sv,- "verifiedElements"sv,- "missingRecords"sv,- "differences"sv,- "hintedElements"sv,- "hintedSubtrees"sv,- "changedElements"sv,- "invalidationVisits"sv,- "invalidationTests"sv,- "coldPasses"sv,- };- for (u32 index = 0; index < field_names.size(); ++index) {- auto value = CSS::StyleEngineFFI::style_engine_live_report(host, read, root->style_node_id(), verify && index == 0, index);- object->define_direct_property(Utf16FlyString::from_utf8(field_names[index]), JS::Value(static_cast<double>(value)), JS::default_attributes);+ auto root_id = root ? root->style_node_id() : CSS::StyleNodeID {};+ Utf16StringBuilder builder;+ HashMap<Utf16String, u32> occurrences_in_pass;+ auto size = CSS::StyleEngineFFI::style_engine_style_trace_size(host, read, root_id);+ for (u32 index = 0; index < size; ++index) {+ auto entry = CSS::StyleEngineFFI::style_engine_style_trace_entry(host, read, root_id, index);+ auto kind = (entry >> 32) & 0xff;+ if (kind == 7) {+ static constexpr Array event_names {+ "rule index built"sv,+ "rule index updated"sv,+ "user agent rule index built"sv,+ "selectors compiled"sv,+ "style rules compiled"sv,+ "sheet declarations interned"sv,+ "sheet declarations shared"sv,+ };+ auto event = (entry >> 40) & 0xff;+ auto times = entry & 0xffffffff;+ builder.appendff(" {}", event_names[event - 1]);+ if (times > 1)+ builder.appendff(" x{}", times);+ builder.append_ascii('\n');+ continue;+ }+ if (kind != 4) {+ occurrences_in_pass.clear();+ static constexpr Array pass_names { "FULL"sv, "PARTIAL"sv, "COLD"sv, ""sv, "ANIMATION"sv, "PROGRAM"sv };+ builder.appendff("style {}\n", pass_names[kind - 1]);+ continue;+ }+ auto element = style_computer.element_for_style_node(CSS::StyleNodeID { static_cast<u32>(entry) });+ if (!element)+ continue;+ auto description = element->debug_description();+ auto occurrence = ++occurrences_in_pass.ensure(description, [] { return 0u; });+ builder.appendff(" {}", description);+ if (occurrence > 1)+ builder.appendff("@{}", occurrence);+ Vector<StringView, 2> notes;+ switch ((entry >> 40) & 0xff) {+ case 1:+ notes.append("computed"sv);+ break;+ case 2:+ notes.append("shared"sv);+ break;+ case 3:+ notes.append("reused"sv);+ break;+ case 4:+ notes.append("declined"sv);+ break;+ case 5:+ notes.append("kept"sv);+ break;+ case 6:+ notes.append("sampled"sv);+ break;+ case 7:+ notes.append("sampled every group"sv);+ break;+ default:+ break;+ }+ if (entry & (1ull << 48))+ notes.append("changed"sv);+ if (!notes.is_empty())+ builder.appendff(" ({})", MUST(String::join(", "sv, notes)));+ builder.append_ascii('\n');}- return object;+ (void)CSS::StyleEngineFFI::style_engine_end_style_trace(host, read);+ return builder.to_string();}GC::Ref<JS::Object> Internals::style_counters()@@ -3325,38 +3355,6 @@ void Internals::reset_style_counters()(void)CSS::StyleEngineFFI::style_engine_reset_style_counters(window().associated_document().style_computer().style_engine().host(), read);}-GC::Ref<JS::Object> Internals::style_last_pass()-{- // A script reads the render state, which waits for a frame in flight.- Layout::ForcedReadScope read { window().associated_document() };- auto& realm = window().principal_realm();- auto& document = window().associated_document();- auto& style_computer = document.style_computer();- auto host = style_computer.style_engine().host();- auto object = JS::Object::create(realm, nullptr);- auto* root = document.document_element();- auto root_id = root ? root->style_node_id() : CSS::StyleNodeID {};- object->define_direct_property("fullPass"_utf16_fly_string, JS::Value(CSS::StyleEngineFFI::style_engine_last_pass_is_full(host, read)), JS::default_attributes);- auto elements = [&](bool changed) {- auto array = MUST(JS::Array::create(realm, 0));- if (root_id == 0)- return array;- u32 index = 0;- auto size = CSS::StyleEngineFFI::style_engine_last_pass_size(host, read, root_id, changed);- for (u32 position = 0; position < size; ++position) {- auto element = style_computer.element_for_style_node(CSS::StyleNodeID { CSS::StyleEngineFFI::style_engine_last_pass_element(host, read, root_id, changed, position) });- if (!element)- continue;- auto identity = element->id().has_value() ? *element->id() : element->local_name();- MUST(array->create_data_property_or_throw(index++, JS::PrimitiveString::create(vm(), identity)));- }- return array;- };- object->define_direct_property("styled"_utf16_fly_string, elements(false), JS::default_attributes);- object->define_direct_property("changed"_utf16_fly_string, elements(true), JS::default_attributes);- return object;-}-// Names every rule identity StyleEngine was given, so a disagreement can be reported as the selector// that caused it rather than as a number.static void collect_style_engine_rule_names(Layout::BegunRead const& read, CSS::StyleComputer const& style_computer, CSS::CSSRule const& rule, HashMap<CSS::StyleEngineRuleID, Utf16String>& names, HashMap<CSS::StyleEngineRuleID, Utf16String>& places, Utf16String const& place)diff --git a/Libraries/LibWeb/Internals/Internals.h b/Libraries/LibWeb/Internals/Internals.hindex 912a65087cf..7a13fffd6be 100644--- a/Libraries/LibWeb/Internals/Internals.h+++ b/Libraries/LibWeb/Internals/Internals.h@@ -346,11 +346,11 @@ public:u64 layout_style_record_identity(DOM::Element&);u64 layout_node_identity(DOM::Node&);void panic_render_state_for_testing();- GC::Ref<JS::Object> style_cold_pass(bool verify, u32 threads);- GC::Ref<JS::Object> style_live_report(bool verify);GC::Ref<JS::Object> style_counters();void reset_style_counters();- GC::Ref<JS::Object> style_last_pass();+ Vector<String> style_self_check();+ void begin_style_trace();+ Utf16String take_style_trace();Utf16String style_engine_matched_rules();GC::Ref<JS::Object> style_group_sharing_info(DOM::Element&);void update_style();diff --git a/Libraries/LibWeb/Internals/Internals.idl b/Libraries/LibWeb/Internals/Internals.idlindex 75c8c9f2f23..e652d5627e5 100644--- a/Libraries/LibWeb/Internals/Internals.idl+++ b/Libraries/LibWeb/Internals/Internals.idl@@ -441,12 +441,6 @@ interface Internals {unsigned long long layoutNodeIdentity(Node node);// Makes the document's render state panic answering this call, which waits for it: the WebContent process crashes.undefined panicRenderStateForTesting();- // Styles the whole document from scratch in a cold pass, without installing anything, and reports what it measured- // and how its answers compared with the records installed.- object styleColdPass(optional boolean verify = true, optional unsigned long threads = 0);- // Reports what live style measured since it started, checking the records it holds against the records installed- // when asked to.- object styleLiveReport(optional boolean verify = true);// Reports what live style did since the counters were last reset, on the render state the// host writes. Keys: passes, fullPasses, styledElements, changedElements, hintedElements,// hintedSubtrees, invalidationVisits, invalidationTests, coldPasses, sharedElements,@@ -455,11 +449,16 @@ interface Internals {object styleCounters();// Zeroes the counters styleCounters() reports and forgets the last pass.undefined resetStyleCounters();- // Reports the most recent pass of live style, with the passes after it that restyled what it- // left waiting on fonts, as { fullPass, styled, changed }: whether it restyled every element,- // the elements it styled, and those whose records it changed, each as its id, or its tag name- // without one, in tree order.- object styleLastPass();+ // Each way what live style holds for the document disagrees with a cold pass over the same inputs, or with the+ // records the host installed, one per element or pseudo-element. Empty where they agree.+ sequence<DOMString> styleSelfCheck();+ // Records the passes of live style that the host keeps, until takeStyleTrace(), which answers them one per block: a+ // "style FULL", "style PARTIAL" or "style COLD" line, then a line per element the pass styled, in tree order, with+ // how it came by its record and whether the record changed. A full pass lists only the elements it changed. A+ // "style ANIMATION" block names the elements whose animations the host composed over their records, and a "style+ // PROGRAM" block what the engine did to the rules it styles from.+ undefined beginStyleTrace();+ DOMString takeStyleTrace();// Reports a snapshot of StyleEngine's matched rules for the whole document.DOMString styleEngineMatchedRules();// Returns, for each ComputedValues style value group of the given element, whether thediff --git a/Libraries/LibWeb/Rust/src/css/style/boundary.rs b/Libraries/LibWeb/Rust/src/css/style/boundary.rsindex c43323b7084..dfbf77d2dee 100644--- a/Libraries/LibWeb/Rust/src/css/style/boundary.rs+++ b/Libraries/LibWeb/Rust/src/css/style/boundary.rs@@ -507,24 +507,27 @@ style_boundary! {defer_pending_transaction_for_geometry_read() -> ();begin_deferred_geometry_transaction_flush() -> bool;has_deferred_geometry_transaction() -> bool;- cold_pass(root: Option<StyleNodeID>, verify: bool, threads: u32) -> u64 => root.map_or(0, |root| engine.run_cold_pass(root, verify, threads));- cold_pass_report(index: u32) -> u64 => engine.cold_pass_report(index);- live_report(root: Option<StyleNodeID>, verify: bool, index: u32) -> u64 =>- root.map_or(0, |root| engine.retained.live_report(root, verify, index));style_counter(index: u32) -> u64 => engine.retained.live_counters.get(index);reset_style_counters() -> bool => {engine.retained.live_counters.reset();true};- last_pass_is_full() -> bool => engine.retained.live_counters.last_pass_is_full();- last_pass_size(root: Option<StyleNodeID>, changed: bool) -> u32 => root.map_or(0, |root| {+ begin_style_trace() -> bool => {+ engine.retained.live_counters.begin_trace();+ true+ };+ end_style_trace() -> bool => {+ engine.retained.live_counters.end_trace();+ true+ };+ style_trace_size(root: Option<StyleNodeID>) -> u32 => root.map_or(0, |root| {let retained = &mut engine.retained;- retained.live_counters.last_pass_elements(&retained.projection, root, changed).len() as u32+ retained.live_counters.trace_entries(&retained.projection, root).len() as u32});- last_pass_element(root: Option<StyleNodeID>, changed: bool, index: u32) -> u32 => root.map_or(0, |root| {+ style_trace_entry(root: Option<StyleNodeID>, index: u32) -> u64 => root.map_or(0, |root| {let retained = &mut engine.retained;- let elements = retained.live_counters.last_pass_elements(&retained.projection, root, changed);- elements.get(index as usize).map_or(0, |node| node.raw())+ let entries = retained.live_counters.trace_entries(&retained.projection, root);+ entries.get(index as usize).copied().unwrap_or(0)});animated_style_samples(rebuilt_every_group: bool, reset: bool) -> u64 =>engine.retained.live_counters.animated_samples(rebuilt_every_group, reset);diff --git a/Libraries/LibWeb/Rust/src/css/style/bridge/animations.rs b/Libraries/LibWeb/Rust/src/css/style/bridge/animations.rsindex 92a77e8d68d..43cfd5b760a 100644--- a/Libraries/LibWeb/Rust/src/css/style/bridge/animations.rs+++ b/Libraries/LibWeb/Rust/src/css/style/bridge/animations.rs@@ -432,7 +432,10 @@ pub(in crate::css::style) unsafe fn publish_sampled_animation_overlay(}};crate::css::style::engine_sample::release_rebuilt_overlay_payloads(&payloads, rebuilt.groups);- engine.retained.live_counters.note_animated_sample(rebuilt.every_group);+ engine+ .retained+ .live_counters+ .note_animated_sample(node, rebuilt.every_group);Ok(FfiAnimationOverlayPublication {invalidation,publication,diff --git a/Libraries/LibWeb/Rust/src/css/style/inputs.rs b/Libraries/LibWeb/Rust/src/css/style/inputs.rsindex dc491a78bf6..ec7890059dc 100644--- a/Libraries/LibWeb/Rust/src/css/style/inputs.rs+++ b/Libraries/LibWeb/Rust/src/css/style/inputs.rs@@ -1602,10 +1602,8 @@ impl StyleEngine {html_element_namespace: StyleAtomID::NONE,sibling_positions: crate::fork::ForkReset::default(),containers_counted_by_style_queries: Default::default(),- cold_pass_report: [0; pipeline::ReportField::COUNT],live_style: None,live_style_may_start: crate::fork::ForkReset::original(),- cold_passes: std::sync::Arc::default(),live_counters: Default::default(),style_layout_pool: None,substituted_font_values: std::sync::Arc::default(),@@ -2225,6 +2223,9 @@ impl StyleEngine {version.scope = scope;self.replace_rule_version(rule, version);self.retained.counters.bump(Counter::StyleRulesCompiled);+ self.retained+ .live_counters+ .note_program_event(super::pipeline::counters::ProgramEvent::StyleRulesCompiled, 1);rule}@@ -2263,6 +2264,9 @@ impl StyleEngine {version.scope = self.scope_of_chain(scope);self.replace_rule_version(rule, version);self.retained.counters.bump(Counter::StyleRulesCompiled);+ self.retained+ .live_counters+ .note_program_event(super::pipeline::counters::ProgramEvent::StyleRulesCompiled, 1);}/// Report that a rule's declarations moved, without touching anything else about it.@@ -2506,11 +2510,9 @@ impl RetainedState {// Dropped in `forget_departed_elements` when a relation holds a departed element.// Scratch of one transaction.// Not keyed by style node.- cold_pass_report: _,// Keyed by style node, and only ever started by a test.live_style: _,live_style_may_start: _,- cold_passes: _,// The last pass's elements, which a reader leaves out where they departed.live_counters: _,style_layout_pool: _,diff --git a/Libraries/LibWeb/Rust/src/css/style/mod.rs b/Libraries/LibWeb/Rust/src/css/style/mod.rsindex c128b9bee02..6937fd7e94b 100644--- a/Libraries/LibWeb/Rust/src/css/style/mod.rs+++ b/Libraries/LibWeb/Rust/src/css/style/mod.rs@@ -327,14 +327,10 @@ pub struct RetainedState {/// The elements a style() container query asked as containers with a value counting their place among their/// siblings. A fork shares them, as too many only walk more. An element's identity used again stays here too.containers_counted_by_style_queries: Arc<Mutex<HashSet<StyleNodeID>>>,- /// What the last cold pass measured.- cold_pass_report: pipeline::Report,/// What the engine keeps of the document it owns, which a fork goes on keeping.live_style: Option<Box<pipeline::Live>>,/// Whether this is the state the host writes, on which alone the engine starts.live_style_may_start: crate::fork::ForkReset<crate::fork::IsOriginal>,- /// How many cold passes the engine started from, on this state and on every fork of it.- cold_passes: std::sync::Arc<std::sync::atomic::AtomicU64>,/// What the engine did on this state, for tests to read.live_counters: pipeline::counters::Counters,/// The threads style passes run on, which the process shares where a render state holds thediff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/cold_pass.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/cold_pass.rsdeleted file mode 100644index 9836831487f..00000000000--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/cold_pass.rs+++ /dev/null@@ -1,89 +0,0 @@-/*- * Copyright (c) 2026-present, the Ladybird developers.- *- * SPDX-License-Identifier: BSD-2-Clause- */--//! A pass styling the whole document from scratch, for a test to read what it measures and whether-//! what the engine holds differs from what it computes. Nothing it computes is installed.--use super::super::{RetainedState, StyleEngine, StyleNodeID};-use super::self_check;--/// What the last cold pass measured, by `ReportField`.-pub(in super::super) type Report = [u64; ReportField::COUNT];--#[derive(Clone, Copy)]-#[repr(u32)]-pub(in super::super) enum ReportField {- Elements,- IndexedEntries,- IndexNanoseconds,- StyleNanoseconds,- Threads,- Candidates,- BloomRejections,- Evaluations,- Matches,- Winners,- ComputedElements,- DirectlyComputedElements,- SharedElements,- ReusedElements,- PseudoElements,- Differences,-}--impl ReportField {- pub(in super::super) const COUNT: usize = Self::Differences as usize + 1;-}--impl StyleEngine {- /// Style the document tree under `root` from scratch on `threads` threads, or as many as the- /// machine has for none, count what differs from what the engine holds when asked to, and- /// report the time the styling took in nanoseconds.- pub(in super::super) fn run_cold_pass(&mut self, root: StyleNodeID, verify: bool, threads: u32) -> u64 {- let Some(pass) = self_check::reference_pass(self, root, true, threads) else {- return 0;- };- let statistics = &pass.statistics;- let outcomes = &statistics.outcomes;- let mut report = [0_u64; ReportField::COUNT];- let mut set = |field: ReportField, value: u64| report[field as usize] = value;- set(ReportField::Elements, outcomes.elements());- set(ReportField::IndexedEntries, pass.indexed_entries);- set(ReportField::IndexNanoseconds, pass.index_nanoseconds);- set(ReportField::StyleNanoseconds, pass.style_nanoseconds);- set(ReportField::Threads, pass.threads);- set(ReportField::Candidates, statistics.match_counters.candidates);- set(ReportField::BloomRejections, statistics.match_counters.bloom_rejections);- set(ReportField::Evaluations, statistics.match_counters.evaluations);- set(ReportField::Matches, statistics.match_counters.matches);- set(ReportField::Winners, statistics.cascade_counters.winners);- set(ReportField::ComputedElements, outcomes.styled());- set(ReportField::DirectlyComputedElements, outcomes.computed_directly());- set(ReportField::SharedElements, outcomes.shared());- set(ReportField::ReusedElements, outcomes.reused());- set(- ReportField::PseudoElements,- self.retained- .projection- .style_preorder(root)- .map(|node| pass.records.pseudo_element_records(node).len() as u64)- .sum(),- );- let nanoseconds = pass.index_nanoseconds + pass.style_nanoseconds;- if verify {- report[ReportField::Differences as usize] = self.self_check_failures(root, None).len() as u64;- }- self.retained.cold_pass_report = report;- nanoseconds- }-}--impl RetainedState {- /// The value of one field of the last cold pass's report, or zero past the last field.- pub(in super::super) fn cold_pass_report(&self, index: u32) -> u64 {- self.cold_pass_report.get(index as usize).copied().unwrap_or(0)- }-}diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/compute.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/compute.rsindex 1a23683c882..0a51b028e2e 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/compute.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/compute.rs@@ -1182,7 +1182,6 @@ impl RetainedState {groups: unsafe {crate::css::computed_values::ComputedGroups::new(payloads, style_bits, current_color, borrowed)},- directly: !runs_drive,element_dependent,custom_property_reads: super::custom_property_cascade::LonghandCustomPropertyReads::new(custom_property_reads,@@ -2188,8 +2187,6 @@ pub(in crate::css::style) struct ComputedElement {/// The element's groups, which its record takes, borrowing those of the sets of its parent's/// or the initial style it shares.pub(in crate::css::style) groups: crate::css::computed_values::ComputedGroups,- /// Whether every winner computed directly, without the longhand drive.- pub(in crate::css::style) directly: bool,/// Whether a winner computed against the element itself, so the style is the element's alone.pub(in crate::css::style) element_dependent: bool,/// The custom properties the winners substitute.diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/counters.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/counters.rsindex 18e585368dc..feabb0db816 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/counters.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/counters.rs@@ -5,7 +5,7 @@*///! What the engine did over the life of a document's render state, counted for tests to bound,-//! and what its last pass styled.+//! and the passes a test traces.//!//! A pass counts what it does in counts of its own, kept with the engine between the//! transactions it restyles after, which the state takes into its counters once the pass kept the@@ -76,11 +76,141 @@ impl StyleCounter {pub(in super::super) const COUNT: usize = Self::RelativeWalks as usize + 1;}-/// What a pass counts until the state takes it, and what it styled.+/// What a pass counts until the state takes it, and what it styled while a trace is open.#[derive(Clone, Default)]pub(super) struct PassCounts {counts: [u64; StyleCounter::COUNT],- last_pass: Option<LastPass>,+ traced: Vec<TracedPass>,+ /// What the engine did to its rule index since the state last took the counts, which a trace keeps.+ program_events: Vec<(ProgramEvent, u64)>,+}++/// Something the engine did to the rules it styles from, which a trace lists in a `style PROGRAM` block, with how many+/// times it happened in a row.+#[derive(Clone, Copy, PartialEq, Eq)]+#[repr(u8)]+pub(in super::super) enum ProgramEvent {+ RuleIndexBuilt = 1,+ RuleIndexUpdated = 2,+ UserAgentRuleIndexBuilt = 3,+ SelectorsCompiled = 4,+ StyleRulesCompiled = 5,+ SheetDeclarationsInterned = 6,+ SheetDeclarationsShared = 7,+}++/// How an element of a traced pass came by its record.+#[derive(Clone, Copy, PartialEq, Eq)]+#[repr(u8)]+pub(super) enum TracedOutcome {+ Computed = 1,+ Shared = 2,+ Reused = 3,+ Declined = 4,+ /// The element took the custom properties its parent hands down now without being styled.+ KeptWithMovedCustomProperties = 5,+ /// The host composed the element's animations over its record, rebuilding only the groups they write.+ Sampled = 6,+ /// The host composed the element's animations over its record, rebuilding every group of it.+ SampledEveryGroup = 7,+}++impl From<&Outcome> for TracedOutcome {+ fn from(outcome: &Outcome) -> Self {+ match outcome {+ Outcome::Computed => Self::Computed,+ Outcome::Shared => Self::Shared,+ Outcome::Reused => Self::Reused,+ Outcome::CascadeDeclined | Outcome::ComputeDeclined => Self::Declined,+ }+ }+}++#[derive(Clone, Copy, PartialEq, Eq)]+#[repr(u8)]+enum TracedPassKind {+ Full = 1,+ Partial = 2,+ Cold = 3,+ /// The animation samples the host composed over records, which no pass ran.+ Animation = 5,+ /// What the engine did to the rules it styles from.+ Program = 6,+}++/// A pass a test traces: the elements it styled, each with how it came by its record, and the elements whose records+/// it changed, or, for a program block, what the engine did to its rules.+#[derive(Clone)]+struct TracedPass {+ kind: TracedPassKind,+ elements: Vec<(StyleNodeID, Option<TracedOutcome>)>,+ changed: Vec<StyleNodeID>,+ program_events: Vec<(ProgramEvent, u64)>,+}++/// The passes the engine ran since a test began tracing, with their entries in tree order once a test reads them.+#[derive(Clone, Default)]+struct StyleTrace {+ passes: Vec<TracedPass>,+ entries: Option<Vec<u64>>,+}++/// The kind of an entry of a style trace, in bits 32 to 39, as the host decodes it.+const TRACE_ENTRY_KIND_SHIFT: u32 = 32;+/// The outcome of an element entry, in bits 40 to 47.+const TRACE_ENTRY_OUTCOME_SHIFT: u32 = 40;+/// Whether the record of the element of an entry changed.+const TRACE_ENTRY_CHANGED: u64 = 1 << 48;+const TRACE_ENTRY_KIND_ELEMENT: u64 = 4;+const TRACE_ENTRY_KIND_PROGRAM_EVENT: u64 = 7;++impl StyleTrace {+ /// The passes as entries: one per pass, followed by one per element it lists, in the order a style traversal from+ /// `root` reaches them. A full pass lists only the elements whose records it changed, as it styled every one.+ fn entries(&mut self, tree: &Projection, root: StyleNodeID) -> &[u64] {+ self.entries.get_or_insert_with(|| {+ let order: std::collections::HashMap<StyleNodeID, usize> = if tree.is_live(root) {+ tree.style_preorder(root)+ .enumerate()+ .map(|(position, node)| (node, position))+ .collect()+ } else {+ Default::default()+ };+ let mut entries = Vec::new();+ for pass in &self.passes {+ entries.push((pass.kind as u64) << TRACE_ENTRY_KIND_SHIFT);+ for &(event, times) in &pass.program_events {+ entries.push(+ times.min(u64::from(u32::MAX))+ | (TRACE_ENTRY_KIND_PROGRAM_EVENT << TRACE_ENTRY_KIND_SHIFT)+ | ((event as u64) << TRACE_ENTRY_OUTCOME_SHIFT),+ );+ }+ let changed: std::collections::HashSet<StyleNodeID> = pass.changed.iter().copied().collect();+ let mut elements: Vec<(StyleNodeID, Option<TracedOutcome>)> = pass+ .elements+ .iter()+ .copied()+ .filter(|(node, _)| order.contains_key(node))+ .filter(|(node, _)| pass.kind != TracedPassKind::Full || changed.contains(node))+ .collect();+ elements.sort_by_key(|(node, _)| order[node]);+ elements.dedup_by_key(|(node, _)| *node);+ for (node, outcome) in elements {+ let mut entry = u64::from(node.raw()) | (TRACE_ENTRY_KIND_ELEMENT << TRACE_ENTRY_KIND_SHIFT);+ if let Some(outcome) = outcome {+ entry |= (outcome as u64) << TRACE_ENTRY_OUTCOME_SHIFT;+ }+ if changed.contains(&node) {+ entry |= TRACE_ENTRY_CHANGED;+ }+ entries.push(entry);+ }+ }+ entries+ })+ }}impl PassCounts {@@ -95,7 +225,6 @@ impl PassCounts {LiveField::HintedSubtrees => StyleCounter::HintedSubtrees,LiveField::InvalidationVisits => StyleCounter::InvalidationVisits,LiveField::InvalidationTests => StyleCounter::InvalidationTests,- _ => return,};self.counts[counter as usize] += value;}@@ -105,6 +234,8 @@ impl PassCounts {self.counts[StyleCounter::IndexedEntries as usize] += arrived as u64;self.counts[StyleCounter::CompiledSelectors as usize] += index.compiled_selectors;self.counts[StyleCounter::UserAgentIndexBuilds as usize] += u64::from(index.built_user_agent_index);+ self.program_events.push((ProgramEvent::RuleIndexUpdated, 1));+ self.note_index_program(index);}/// Note that the engine built `index`.@@ -113,141 +244,94 @@ impl PassCounts {self.counts[StyleCounter::IndexedEntries as usize] += index.indexed_entries;self.counts[StyleCounter::CompiledSelectors as usize] += index.compiled_selectors;self.counts[StyleCounter::UserAgentIndexBuilds as usize] += u64::from(index.built_user_agent_index);+ self.program_events.push((ProgramEvent::RuleIndexBuilt, 1));+ self.note_index_program(index);}- /// Note that a transaction took inputs, which the passes after it restyle: one that no pass- /// follows styled nothing.- pub(super) fn note_transaction(&mut self) {- self.last_pass.get_or_insert_with(LastPass::default);+ fn note_index_program(&mut self, index: &RuleIndex) {+ if index.built_user_agent_index {+ self.program_events.push((ProgramEvent::UserAgentRuleIndexBuilt, 1));+ }+ if index.compiled_selectors > 0 {+ self.program_events+ .push((ProgramEvent::SelectorsCompiled, index.compiled_selectors));+ }}- /// Note what a pass styled, everything where `full` is, and `changed`, the elements whose- /// records, or pseudo-element records, are not the ones they held. A pass restyling what the- /// one before it left waiting on fonts goes on with what that one styled.- pub(super) fn note_pass(&mut self, full: bool, statistics: &Statistics, changed: &[StyleNodeID]) {+ /// Note a pass, which restyled everything where `full` is, and, where `traces` is, what it styled and `changed`,+ /// the elements whose records, or pseudo-element records, are not the ones they held.+ pub(super) fn note_pass(&mut self, full: bool, statistics: &Statistics, changed: &[StyleNodeID], traces: bool) {self.counts[StyleCounter::SharedElements as usize] += statistics.outcomes.shared;self.counts[StyleCounter::ReusedElements as usize] += statistics.outcomes.reused;self.counts[StyleCounter::MatchedElements as usize] += statistics.outcomes.matched;self.counts[StyleCounter::RelativeWalks as usize] += statistics.match_counters.relative_walks;- let last_pass = self.last_pass.get_or_insert_with(LastPass::default);- last_pass.full |= full;- last_pass.styled.extend_from_slice(&statistics.styled);- last_pass.changed.extend_from_slice(changed);+ if !traces {+ return;+ }+ let outcomes: std::collections::HashMap<StyleNodeID, TracedOutcome> =+ statistics.traced_outcomes.iter().copied().collect();+ let mut elements: Vec<(StyleNodeID, Option<TracedOutcome>)> = statistics+ .styled+ .iter()+ .map(|node| (*node, outcomes.get(node).copied()))+ .collect();+ elements.extend(+ statistics+ .moved_custom_properties+ .iter()+ .map(|node| (*node, Some(TracedOutcome::KeptWithMovedCustomProperties))),+ );+ self.traced.push(TracedPass {+ kind: if full {+ TracedPassKind::Full+ } else {+ TracedPassKind::Partial+ },+ elements,+ changed: changed.to_vec(),+ program_events: Vec::new(),+ });}}/// How many elements of a pass took the record of another, by how they found it.#[derive(Clone, Copy, Default)]pub(super) struct OutcomeCounts {- /// The elements a pass reached.- elements: u64,shared: u64,reused: u64,- computed: u64,- computed_directly: u64,/// The elements matched against the whole rule index.matched: u64,}impl OutcomeCounts {pub(super) fn note(&mut self, outcome: &Outcome) {- self.elements += 1;match outcome {Outcome::Shared => self.shared += 1,Outcome::Reused => self.reused += 1,- Outcome::Computed { directly } => {- self.computed += 1;- self.computed_directly += u64::from(*directly);- }- Outcome::CascadeDeclined | Outcome::ComputeDeclined => {}+ Outcome::Computed | Outcome::CascadeDeclined | Outcome::ComputeDeclined => {}}}- pub(super) fn elements(&self) -> u64 {- self.elements- }-- /// The elements the pass holds a record of.- pub(super) fn styled(&self) -> u64 {- self.shared + self.reused + self.computed- }-- pub(super) fn shared(&self) -> u64 {- self.shared- }-- pub(super) fn reused(&self) -> u64 {- self.reused- }-- pub(super) fn computed_directly(&self) -> u64 {- self.computed_directly- }-/// Note an element matched against the whole rule index.pub(super) fn note_matched(&mut self) {self.matched += 1;}pub(super) fn add(&mut self, other: &Self) {- self.elements += other.elements;- self.computed += other.computed;- self.computed_directly += other.computed_directly;self.shared += other.shared;self.reused += other.reused;self.matched += other.matched;}}-/// What the last pass of the engine styled, with the passes after it that restyled what it left-/// waiting on fonts.-#[derive(Clone, Default)]-struct LastPass {- /// Whether it restyled every element.- full: bool,- /// The elements it styled.- styled: Vec<StyleNodeID>,- /// The elements it left holding records, or pseudo-element records, other than the ones they- /// held before.- changed: Vec<StyleNodeID>,- /// Whether `styled` and `changed` are in tree order, without repeats or departed elements.- in_tree_order: bool,-}--impl LastPass {- /// Put the elements in the order a style traversal from `root` reaches them, leaving out the- /// ones it does not reach any more.- fn put_in_tree_order(&mut self, tree: &Projection, root: StyleNodeID) {- if self.in_tree_order {- return;- }- self.in_tree_order = true;- if !tree.is_live(root) {- self.styled.clear();- self.changed.clear();- return;- }- let order: std::collections::HashMap<StyleNodeID, usize> = tree- .style_preorder(root)- .enumerate()- .map(|(position, node)| (node, position))- .collect();- for nodes in [&mut self.styled, &mut self.changed] {- nodes.retain(|node| order.contains_key(node));- nodes.sort_unstable_by_key(|node| order[node]);- nodes.dedup();- }- }-}--/// What the engine did on a document's render state since the counters were last reset, what-/// its last pass styled, and how often the host composed animations over records.+/// What the engine did on a document's render state since the counters were last reset, the+/// passes it ran while a test traces them, and how often the host composed animations over+/// records.#[derive(Clone, Default)]pub(in super::super) struct Counters {counts: [u64; StyleCounter::COUNT],- /// Shared with a fork until either side writes it: a fork restyles nothing until the host- /// moves on under it.- last_pass: crate::fork::ForkShared<LastPass>,+ /// A fork starts without one: it restyles nothing until the host moves on under it.+ trace: crate::fork::ForkReset<Option<Box<StyleTrace>>>,/// The animation samples the host composed over the record an element installed, by whether/// composing them rebuilt every group of the record or only the ones they write. These are/// reset with the host's style invalidation counters, not with the others.@@ -257,17 +341,64 @@ pub(in super::super) struct Counters {impl Counters {/// Take what a pass counted, once it kept the records it computed.pub(super) fn take_pass(&mut self, pass: &mut PassCounts) {- let PassCounts { counts, last_pass } = std::mem::take(pass);+ let PassCounts {+ counts,+ traced,+ program_events,+ } = std::mem::take(pass);for (total, count) in self.counts.iter_mut().zip(counts) {*total += count;}- if let Some(last_pass) = last_pass {- self.last_pass.assign(last_pass);+ for (event, times) in program_events {+ self.note_program_event(event, times);+ }+ if let Some(trace) = &mut *self.trace {+ trace.passes.extend(traced);+ trace.entries = None;}}+ /// Note, for a trace, that the engine did `event` to its rules `times` times.+ pub(in super::super) fn note_program_event(&mut self, event: ProgramEvent, times: u64) {+ let Some(trace) = &mut *self.trace else {+ return;+ };+ trace.entries = None;+ if let Some(pass) = trace.passes.last_mut()+ && pass.kind == TracedPassKind::Program+ {+ match pass.program_events.last_mut() {+ Some((last, total)) if *last == event => *total += times,+ _ => pass.program_events.push((event, times)),+ }+ return;+ }+ trace.passes.push(TracedPass {+ kind: TracedPassKind::Program,+ elements: Vec::new(),+ changed: Vec::new(),+ program_events: vec![(event, times)],+ });+ }+/// Note that the engine started from a cold pass, with `index`, the rule index it built.pub(super) fn note_live_start(&mut self, index: &RuleIndex) {+ if let Some(trace) = &mut *self.trace {+ trace.passes.push(TracedPass {+ kind: TracedPassKind::Cold,+ elements: Vec::new(),+ changed: Vec::new(),+ program_events: Vec::new(),+ });+ trace.entries = None;+ }+ self.note_program_event(ProgramEvent::RuleIndexBuilt, 1);+ if index.built_user_agent_index {+ self.note_program_event(ProgramEvent::UserAgentRuleIndexBuilt, 1);+ }+ if index.compiled_selectors > 0 {+ self.note_program_event(ProgramEvent::SelectorsCompiled, index.compiled_selectors);+ }self.counts[StyleCounter::ColdPasses as usize] += 1;self.counts[StyleCounter::IndexBuilds as usize] += 1;self.counts[StyleCounter::IndexedEntries as usize] += index.indexed_entries;@@ -285,38 +416,80 @@ impl Counters {self.counts.get(index as usize).copied().unwrap_or(0)}- /// Zero the counters and forget the last pass.+ /// Zero the counters.pub(in super::super) fn reset(&mut self) {self.counts = [0; StyleCounter::COUNT];- self.last_pass.assign(LastPass::default());}- /// Whether the last pass restyled every element.- pub(in super::super) fn last_pass_is_full(&self) -> bool {- self.last_pass.full+ /// Start tracing the passes of the engine anew.+ pub(in super::super) fn begin_trace(&mut self) {+ *self.trace = Some(Default::default());}- /// The elements the last pass styled, or the ones whose records it changed where `changed` is,- /// in the order a style traversal from `root` reaches them.- pub(in super::super) fn last_pass_elements(- &mut self,+ /// Stop tracing the passes of the engine, forgetting the ones traced.+ pub(in super::super) fn end_trace(&mut self) {+ *self.trace = None;+ }++ pub(in super::super) fn is_tracing(&self) -> bool {+ self.trace.is_some()+ }++ /// The elements the traced passes styled, without the ones that only took moved custom properties, in the order a+ /// style traversal from `root` reaches them, or `None` where one of the passes restyled every element.+ #[cfg(test)]+ pub(in super::super) fn elements_styled_by_traced_partial_passes(+ &self,tree: &Projection,root: StyleNodeID,- changed: bool,- ) -> &[StyleNodeID] {- if !self.last_pass.in_tree_order {- self.last_pass.put_in_tree_order(tree, root);+ ) -> Option<Vec<StyleNodeID>> {+ let passes = &self.trace.as_ref()?.passes;+ if passes+ .iter()+ .any(|pass| matches!(pass.kind, TracedPassKind::Full | TracedPassKind::Cold))+ {+ return None;}- match changed {- true => &self.last_pass.changed,- false => &self.last_pass.styled,+ let styled: std::collections::HashSet<StyleNodeID> = passes+ .iter()+ .filter(|pass| pass.kind == TracedPassKind::Partial)+ .flat_map(|pass| &pass.elements)+ .filter(|(_, outcome)| *outcome != Some(TracedOutcome::KeptWithMovedCustomProperties))+ .map(|(node, _)| *node)+ .collect();+ Some(tree.style_preorder(root).filter(|node| styled.contains(node)).collect())+ }++ /// The traced passes as the host reads them: one entry per pass, its kind in bits 32 to 39, followed by one entry+ /// per element it lists, in the order a style traversal from `root` reaches them, with the element's node in bits 0+ /// to 31, the kind of an element entry, its outcome in bits 40 to 47, and bit 48 set where its record changed.+ pub(in super::super) fn trace_entries(&mut self, tree: &Projection, root: StyleNodeID) -> &[u64] {+ match &mut *self.trace {+ Some(trace) => trace.entries(tree, root),+ None => &[],}}- /// Note that the host composed an animation sample over the record an element installed,+ /// Note that the host composed an animation sample over the record `node` installed,/// rebuilding every group of it where `rebuilt_every_group` is.- pub(in super::super) fn note_animated_sample(&mut self, rebuilt_every_group: bool) {+ pub(in super::super) fn note_animated_sample(&mut self, node: StyleNodeID, rebuilt_every_group: bool) {self.animated_samples[usize::from(rebuilt_every_group)] += 1;+ if let Some(trace) = &mut *self.trace {+ let outcome = match rebuilt_every_group {+ true => TracedOutcome::SampledEveryGroup,+ false => TracedOutcome::Sampled,+ };+ match trace.passes.last_mut() {+ Some(pass) if pass.kind == TracedPassKind::Animation => pass.elements.push((node, Some(outcome))),+ _ => trace.passes.push(TracedPass {+ kind: TracedPassKind::Animation,+ elements: vec![(node, Some(outcome))],+ changed: Vec::new(),+ program_events: Vec::new(),+ }),+ }+ trace.entries = None;+ }}/// How many animation samples the host composed, of those that rebuilt every group wherediff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/custom_property_moves.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/custom_property_moves.rsindex 8ef9420348b..dab05e1a381 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/custom_property_moves.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/custom_property_moves.rs@@ -140,8 +140,8 @@ mod tests {let styled = engine.retained.live_counters- .last_pass_elements(&engine.retained.projection, nodes[0], false)- .to_vec();+ .elements_styled_by_traced_partial_passes(&engine.retained.projection, nodes[0])+ .expect("the pass styled only some elements");assert_live_matches_cold(&mut engine, nodes[0]);std::array::from_fn(|index| styled.contains(&nodes[index + 1]))}diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/differential_tests.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/differential_tests.rsindex c0b42e808d5..63d7ffb1cdf 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/differential_tests.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/differential_tests.rs@@ -901,12 +901,13 @@ fn matching_flags_the_parents_whose_children_selectors_read_siblings_positions_o);}-/// The elements the last pass styled, where it styled only some.+/// The elements the last style update styled, where it styled only some.fn styled_by_a_targeted_pass(engine: &mut StyleEngine, root: StyleNodeID) -> Vec<StyleNodeID> {- let retained = &mut engine.retained;- let counters = &mut retained.live_counters;- assert!(!counters.last_pass_is_full(), "the pass styled only some elements");- counters.last_pass_elements(&retained.projection, root, false).to_vec()+ let retained = &engine.retained;+ retained+ .live_counters+ .elements_styled_by_traced_partial_passes(&retained.projection, root)+ .expect("the pass styled only some elements")}#[test]diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rsindex 623f9dfabd3..28157fb203c 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rs@@ -53,22 +53,11 @@ pub(super) enum LiveField {Passes,FullPasses,StyledElements,- InvalidationNanoseconds,- StyleNanoseconds,- VerifiedElements,- MissingRecords,- Differences,HintedElements,HintedSubtrees,ChangedElements,InvalidationVisits,InvalidationTests,- /// How many cold passes the engine started from, on the render state and its forks.- ColdPasses,-}--impl LiveField {- pub(super) const COUNT: usize = Self::ColdPasses as usize + 1;}/// The engine of a document's render state. A fork of the render state takes it as it is, and@@ -105,7 +94,6 @@ pub(in super::super) struct Live {/// order did, whose entries the rule index ranks again.reordered_scopes: HashSet<TreeScopeID>,layered_scopes: HashSet<TreeScopeID>,- report: ForkReset<[u64; LiveField::COUNT]>,/// What passes counted since the state last took it into its counters.counts: super::counters::PassCounts,/// How many threads passes run on.@@ -543,7 +531,6 @@ impl Live {pub(in super::super) fn note_transaction(&mut self, state: &RetainedState, transaction: &StyleUpdate) {#[cfg(test)]let _section = super::allocation_count::StyleSection::enter();- let started = Instant::now();self.generation += 1;// NB: An environment change or a restart can move how any element computes.if transaction.restyles_everything {@@ -571,7 +558,6 @@ impl Live {if transaction.has_no_element_inputs() && changes.is_empty() && transaction.rule_changes.is_empty() {return;}- self.counts.note_transaction();self.kept_hidden.extend(transaction.style_inputs.iter().map(|&(node, _)| node));self.kept_hidden@@ -592,7 +578,6 @@ impl Live {self.hints.reserve(state.projection.element_slot_count());self.invalidate(state, transaction, changes);}- self.bump(LiveField::InvalidationNanoseconds, started.elapsed().as_nanos() as u64);}/// Note what no pass tells of the hints: a pass styles the elements holding a record and tells@@ -1075,7 +1060,6 @@ impl Live {}fn bump(&mut self, field: LiveField, value: u64) {- self.report[field as usize] += value;self.counts.note(field, value);}@@ -2073,7 +2057,6 @@ impl Live {resolve: &mut ResolveWaits<'_>,) -> traversal::Statistics {let state: &RetainedState = retained;- let started = Instant::now();self.generation += 1;self.note_hints_moved_kept_hidden_records();let slot_count = state.projection.element_slot_count();@@ -2177,7 +2160,6 @@ impl Live {if hinted {self.mark_dirty_ancestors(&state.projection);}- let invalidated = Instant::now();if hinted {let hinted = |bits: HintBits| {self.hints@@ -2225,7 +2207,6 @@ impl Live {self.owe_animation_plans(state, root, moved);}self.keep_deferred_hints(&state.projection, &[], &[]);- self.bump(LiveField::InvalidationNanoseconds, started.elapsed().as_nanos() as u64);return traversal::Statistics::default();}self.hints.sort_reasons();@@ -2253,6 +2234,7 @@ impl Live {kept_matched_declarations: Some(&self.scratch.matched_declarations),waits_once: round + 1 < MAX_SUSPENDING_ROUNDS,cache_audit: self.cache_audit,+ traces: state.live_counters.is_tracing(),root_font: root_font.map_or_else(Default::default, std::sync::OnceLock::from),root_font_moved: root_font_moved.map_or_else(Default::default, std::sync::OnceLock::from),..PassContext::new(state, &self.index, &self.initial, &records, held_root_font)@@ -2301,8 +2283,12 @@ impl Live {Some(&mut self.uninstalled),&mut scratch.replaced,);- self.counts- .note_pass(!hinted, &statistics, &self.uninstalled[changed_start..]);+ self.counts.note_pass(+ !hinted,+ &statistics,+ &self.uninstalled[changed_start..],+ state.live_counters.is_tracing(),+ );// NB: A record holding what the one it replaces does gives way to it where that one is// installed, which it is not for an element that arrived in the place of another.self.uninstalled.extend(@@ -2407,20 +2393,10 @@ impl Live {);self.kept_hidden_records.note_moved(statistics.moved_custom_properties.iter().copied());- let styled = Instant::now();self.bump(LiveField::Passes, 1);self.bump(LiveField::FullPasses, u64::from(!hinted));self.bump(LiveField::StyledElements, statistics.styled.len() as u64);self.bump(LiveField::ChangedElements, statistics.changed_elements);-- self.bump(- LiveField::InvalidationNanoseconds,- invalidated.duration_since(started).as_nanos() as u64,- );- self.bump(- LiveField::StyleNanoseconds,- styled.duration_since(invalidated).as_nanos() as u64,- );statistics}}@@ -4209,7 +4185,6 @@ impl StyleEngine {changed_sheets: HashSet::default(),reordered_scopes: HashSet::default(),layered_scopes: HashSet::default(),- report: Default::default(),counts: Default::default(),threads,cache_audit,@@ -4232,14 +4207,10 @@ impl StyleEngine {.collect(),kept_hidden_records: Default::default(),}));- self.retained- .cold_passes- .fetch_add(1, std::sync::atomic::Ordering::Relaxed);let started = Instant::now();self.live_pass(root, true);let nanoseconds = started.elapsed().as_nanos() as u64;if let Some(live) = self.retained.live_style.as_mut() {- *live.report = [0; LiveField::COUNT];// NB: The cold pass computes the records that are installed already, where it does.if !installs_cold_pass {live.uninstalled.clear();@@ -4613,39 +4584,6 @@ impl HeldComposition {}}-impl RetainedState {- /// Check the records the engine holds for the document under `root` against the installed- /// ones, when asked to, and answer one field of what it measured since it started.- pub(in super::super) fn live_report(&mut self, root: StyleNodeID, verify: bool, index: u32) -> u64 {- if verify && let Some(mut live) = self.live_style.take() {- let mut verified = 0;- let mut missing = 0;- for node in self.projection.style_preorder(root) {- if node.element_index().is_none() || self.computed_group_sets.assigned_style_record(node).is_none() {- continue;- }- if live.records.get(node).is_none() {- missing += 1;- continue;- }- verified += 1;- }- live.report[LiveField::VerifiedElements as usize] = verified;- live.report[LiveField::MissingRecords as usize] = missing;- live.report[LiveField::Differences as usize] =- super::self_check::installed_differences(self, root, &live.records, &|_| String::new()).len() as u64;- self.live_style = Some(live);- }- if index == LiveField::ColdPasses as u32 {- return self.cold_passes.load(std::sync::atomic::Ordering::Relaxed);- }- self.live_style- .as_ref()- .and_then(|live| live.report.get(index as usize).copied())- .unwrap_or(0)- }-}-#[cfg(test)]mod tests {use super::*;diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/mod.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/mod.rsindex 8a219018b77..e3c67ff4b6f 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/mod.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/mod.rs@@ -13,7 +13,6 @@ pub(crate) mod allocation_count;mod allocation_tests;mod bloom;mod cascade;-mod cold_pass;pub(in crate::css::style) mod compute;pub(super) mod counters;pub(in crate::css::style) mod custom_properties;@@ -65,7 +64,6 @@ pub(crate) use records::Record;pub(crate) use records::{CustomDeclarations, RareSetFacts, RareStyleFacts};pub(super) use records::{RecordFacts, Sample};-pub(super) use cold_pass::{Report, ReportField};pub(super) use rules::ProcessRuleIndexes;#[cfg(test)]pub(super) use rules::entries_of;diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/rules.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/rules.rsindex ef734e427b2..78fed05e47e 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/rules.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/rules.rs@@ -1101,6 +1101,7 @@ impl IndexEntries {}/// How many entries there are, the dead ones among them.+ #[cfg(test)]pub(super) fn count(&self) -> usize {self.user_agent_count() + self.own.len()}@@ -1158,6 +1159,7 @@ impl IndexEntries {}/// How many entries the user agent index the document shares has.+ #[cfg(test)]fn user_agent_count(&self) -> usize {self.user_agent.as_ref()diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/self_check.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/self_check.rsindex 5532a2aa138..0ae2ad958a8 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/self_check.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/self_check.rs@@ -23,7 +23,6 @@ use crate::css::custom_properties::CustomPropertyStore;use crate::css::property_metadata::{FIRST_LONGHAND_PROPERTY_ID, LAST_LONGHAND_PROPERTY_ID, property_name};use crate::css::style_value::{RetainedStyleValueData, retained_style_values_equal};use std::sync::Arc;-use std::time::Instant;/// What `LIBWEB_STYLE_SELFCHECK` asks for.#[derive(Clone, Copy, Debug, PartialEq, Eq)]@@ -494,15 +493,9 @@ pub(super) fn installed_differences(failures}-/// What a reference pass computed and measured.+/// What a reference pass computed.pub(super) struct ReferencePass {pub(super) records: RetainedRecords,- /// What its last round measured.- pub(super) statistics: traversal::Statistics,- pub(super) indexed_entries: u64,- pub(super) index_nanoseconds: u64,- pub(super) style_nanoseconds: u64,- pub(super) threads: u64,/// What its last round produced for each element.#[cfg(test)]pub(super) outputs: Vec<WriteOnce<traversal::ElementOutput>>,@@ -521,9 +514,7 @@ pub(super) fn reference_pass(let initial = engine.computed_initial(root)?;// NB: A pass on one thread leaves the engine's pool as it is.let pool = (threads > 1).then(|| engine.style_layout_pool(threads)).flatten();- let started = Instant::now();let index = RuleIndex::build(&engine.retained.rules, engine.retained.process_rule_indexes());- let index_nanoseconds = started.elapsed().as_nanos() as u64;engine.retained.live_counters.note_cold_pass_index(&index);// A drive that waits on a font declines its element; the pass styles every element again once// the resolver answered.@@ -534,7 +525,6 @@ pub(super) fn reference_pass(cells.reserve(slot_count);#[cfg(test)]let outputs: Vec<WriteOnce<traversal::ElementOutput>> = (0..slot_count).map(|_| WriteOnce::default()).collect();- let started = Instant::now();let statistics = {let records = Records::new(state, &cells, None).composing_over_equal_records(|first, second| record_differences(first, second).is_empty());@@ -547,18 +537,12 @@ pub(super) fn reference_pass(};traversal::style_document(&context, pool.as_deref(), root)};- let style_nanoseconds = started.elapsed().as_nanos() as u64;if statistics.font_requests.is_empty() && statistics.random_requests.is_empty() {let styled: Vec<_> = state.projection.style_preorder(root).collect();let mut records = RetainedRecords::default();records.absorb(&mut cells, &styled, None, &mut Default::default());return Ok(ReferencePass {records,- statistics,- indexed_entries: index.entries.count() as u64,- index_nanoseconds,- style_nanoseconds,- threads: pool.as_deref().map_or(0, rayon::ThreadPool::current_num_threads) as u64 + 1,#[cfg(test)]outputs,});@@ -620,6 +604,28 @@ impl StyleEngine {failures}+ /// What the engine holds for the document under `root` disagrees in with a reference pass over+ /// the same inputs and with the records the host installed, one line per element or+ /// pseudo-element, naming each element the engine holds no record of where the host installed one.+ pub(in super::super) fn self_check_report(&self, root: StyleNodeID) -> Vec<String> {+ let mut lines = self.self_check_failures(root, None);+ if let Some(live) = self.retained.live_style.as_deref() {+ let name_of = |atom: StyleAtomID| self.atoms.name_of(atom).unwrap_or_else(|| format!("atom{}", atom.0));+ for node in self.retained.projection.style_preorder(root) {+ if node.element_index().is_some()+ && self.retained.computed_group_sets.assigned_style_record(node).is_some()+ && live.records.get(node).is_none()+ {+ lines.push(format!(+ "{}: the host installed a record, live holds none",+ describe(&self.retained, node, &name_of)+ ));+ }+ }+ }+ lines+ }+/// Check the records the engine holds for the document under `root` against a reference/// pass, as `settings` ask.pub(in super::super) fn run_self_check(&self, root: StyleNodeID, settings: SelfCheckSettings) {diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/test_support.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/test_support.rsindex 1d45e56290e..2df54beee0e 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/test_support.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/test_support.rs@@ -351,8 +351,9 @@ pub(super) fn add_user_agent_sheet(engine: &mut StyleEngine, source: &str) -> (S/// Take a style update and every later wave of its pass, as the host does when it installs/// each wave; nothing is installed here. The engine, where it owns the document, restyles what-/// the transaction changed as it does.+/// the transaction changed as it does. The style trace holds the passes of this update only.pub(super) fn run_style_update(engine: &mut StyleEngine, root: StyleNodeID) {+ engine.retained.live_counters.begin_trace();engine.run_style_update(root, |_| {});}diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/traversal.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/traversal.rsindex ab374c83e19..c4aced838d3 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/traversal.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/traversal.rs@@ -143,9 +143,7 @@ impl InitialStyle {/// How an element's style came about.#[derive(Clone, Copy)]pub(super) enum Outcome {- Computed {- directly: bool,- },+ Computed,/// The element took the record of an element it agrees with.Shared,/// The element took the record of an element whose cascade picked the same declarations.@@ -280,6 +278,8 @@ pub(super) struct PassContext<'a> {pub(super) uses_caches: bool,/// What the audit of what the pass reuses asks for, as `LIBWEB_STYLE_AUDIT_CACHES` asks.pub(super) cache_audit: super::self_check::Mode,+ /// Whether the pass notes how each element came by its record, for a test tracing it.+ pub(super) traces: bool,/// The font inputs of the document element's record from before the pass, which elements/// resolve root-relative lengths against unless the pass styles the document element.pub(super) held_root_font: Option<RootFontInputs>,@@ -325,6 +325,7 @@ impl<'a> PassContext<'a> {waits_once: false,uses_caches: true,cache_audit: super::self_check::Mode::Off,+ traces: false,held_root_font,root_font: Default::default(),root_font_moved: Default::default(),@@ -509,6 +510,8 @@ pub(super) struct Statistics {pub(super) suspended: Vec<Suspended>,/// The elements the pass styled.pub(super) styled: Vec<StyleNodeID>,+ /// How each element the pass styled came by its record, where it traces.+ pub(super) traced_outcomes: Vec<(StyleNodeID, super::counters::TracedOutcome)>,/// The elements that took the custom properties their parents hand down now without being/// styled, keeping their style otherwise.pub(super) moved_custom_properties: Vec<StyleNodeID>,@@ -970,6 +973,11 @@ impl<'a> Scratch<'a> {.records.insert_pseudo_element_records(node, pseudo_element_records);self.statistics.outcomes.note(&Outcome::Shared);+ if context.traces {+ self.statistics+ .traced_outcomes+ .push((node, super::counters::TracedOutcome::Shared));+ }self.audit_caches(context, node, cache_audit::Reuse::SharedStyle);#[cfg(test)]context.set_output(node, || ElementOutput {@@ -1014,7 +1022,6 @@ impl<'a> Scratch<'a> {Some(record) => Ok((record,ComputedFacts {- directly: false,element_dependent: false,reused: true,},@@ -1063,9 +1070,7 @@ impl<'a> Scratch<'a> {);match computed.reused {true => Outcome::Reused,- false => Outcome::Computed {- directly: computed.directly,- },+ false => Outcome::Computed,}}Err(outcome) => {@@ -1095,6 +1100,9 @@ impl<'a> Scratch<'a> {self.statistics.waiting_with_kept_matches.push(node);}self.statistics.outcomes.note(&outcome);+ if context.traces {+ self.statistics.traced_outcomes.push((node, (&outcome).into()));+ }#[cfg(test)]context.set_output(node, || ElementOutput {matches: matched.then(|| self.matches.clone()),@@ -1808,7 +1816,6 @@ impl<'a> Scratch<'a> {return Ok((record,ComputedFacts {- directly: false,element_dependent: false,reused: true,},@@ -2062,7 +2069,6 @@ impl<'a> Scratch<'a> {Ok((record,ComputedFacts {- directly: computed.directly,element_dependent: computed.element_dependent,reused: false,},@@ -2606,7 +2612,6 @@ enum PseudoElementOutcome {/// What came of computing an element besides its record.struct ComputedFacts {- directly: bool,element_dependent: bool,/// Whether the record is one computed for an element before, reused.reused: bool,@@ -3203,6 +3208,7 @@ impl Statistics {.extend(round.waiting_with_kept_matches);statistics.waiting_pseudo_elements.extend(round.waiting_pseudo_elements);statistics.styled.extend(round.styled);+ statistics.traced_outcomes.extend(round.traced_outcomes);statistics.moved_custom_properties.extend(round.moved_custom_properties);statistics.changed_elements += round.changed_elements;statistics.children_moved.extend(round.children_moved);diff --git a/Libraries/LibWeb/Rust/src/css/style/process_style.rs b/Libraries/LibWeb/Rust/src/css/style/process_style.rsindex 7844fc3386f..cb81a593925 100644--- a/Libraries/LibWeb/Rust/src/css/style/process_style.rs+++ b/Libraries/LibWeb/Rust/src/css/style/process_style.rs@@ -358,6 +358,13 @@ impl StyleEngine {true => Counter::SheetDeclarationsInterned,false => Counter::SheetDeclarationsShared,});+ self.retained.live_counters.note_program_event(+ match made {+ true => super::pipeline::counters::ProgramEvent::SheetDeclarationsInterned,+ false => super::pipeline::counters::ProgramEvent::SheetDeclarationsShared,+ },+ 1,+ );self.stage_rule_declarations(rule, declarations);}}diff --git a/Libraries/LibWeb/Rust/src/css/style/reaction_application.rs b/Libraries/LibWeb/Rust/src/css/style/reaction_application.rsindex 01a51a579b3..7f06ee9be8a 100644--- a/Libraries/LibWeb/Rust/src/css/style/reaction_application.rs+++ b/Libraries/LibWeb/Rust/src/css/style/reaction_application.rs@@ -274,6 +274,29 @@ pub extern "C" fn style_engine_self_check(host: &DocumentHost, read: &BegunRead,}}+/// Hands `consume` each line of what the engine holds for the host's document under `root`, its document element's style+/// node or zero, disagrees in with a cold pass over the same inputs and with the records the host installed.+///+/// # Safety+///+/// `consume` must copy the bytes it is handed before it returns.+#[unsafe(no_mangle)]+pub unsafe extern "C" fn style_engine_self_check_report(+ host: &DocumentHost,+ read: &BegunRead,+ root: u32,+ context: *mut std::ffi::c_void,+ consume: unsafe extern "C" fn(*mut std::ffi::c_void, *const u8, usize),+) {+ let Some(root) = StyleNodeID::from_raw(root) else {+ return;+ };+ for line in with_engine(read, host, |engine| engine.self_check_report(root)) {+ // SAFETY: Guaranteed by the caller.+ unsafe { consume(context, line.as_ptr(), line.len()) };+ }+}+/// Applies the reactions of the style updates of one update_style() of the host's document, from the one computed/// beside the event loop/// where `drains_flown_transaction`, through `host_application`, the host's state for applying them, and answers whatdiff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/box-presence-changes-beside-the-layout-that-builds-boxes.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/box-presence-changes-beside-the-layout-that-builds-boxes.txtindex 6307c7a9033..d3b704b9d3e 100644--- a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/box-presence-changes-beside-the-layout-that-builds-boxes.txt+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/box-presence-changes-beside-the-layout-that-builds-boxes.txt@@ -16,4 +16,4 @@ empty read appended, sibling shown: 20empty unread shown, hidden and shown: 10empty unread shown, then hidden: 0empty unread appended, sibling shown: 20-differences from a cold pass: 0+self-check: []diff --git a/Tests/LibWeb/Text/expected/css/animated-non-inherited-property-descendant-invalidation.txt b/Tests/LibWeb/Text/expected/css/animated-non-inherited-property-descendant-invalidation.txtindex a8a2dd3d0cf..d2a37809868 100644--- a/Tests/LibWeb/Text/expected/css/animated-non-inherited-property-descendant-invalidation.txt+++ b/Tests/LibWeb/Text/expected/css/animated-non-inherited-property-descendant-invalidation.txt@@ -1,3 +1,3 @@-plain descendants styled <= 0: true-text-decoration-line inheritor styled: 1-transform inheritor restyled: true+plain descendants restyled: []+text-decoration-line inheritor restyled: [decorationInheritor]+transform inheritor restyled: [transformInheritor]diff --git a/Tests/LibWeb/Text/expected/css/disconnected-node-mutation-no-style-invalidation.txt b/Tests/LibWeb/Text/expected/css/disconnected-node-mutation-no-style-invalidation.txtindex 2c3291a1c75..83e631dbcc3 100644--- a/Tests/LibWeb/Text/expected/css/disconnected-node-mutation-no-style-invalidation.txt+++ b/Tests/LibWeb/Text/expected/css/disconnected-node-mutation-no-style-invalidation.txt@@ -1,5 +1,5 @@-no pass after disconnected mutations: true-nothing styled after disconnected mutations: true+style passes after disconnected mutations: (no pass)+restyled after disconnected mutations: [].highlight span background: rgb(255, 255, 0)div:has(> .flag) outline color: rgb(1, 2, 3).red child color: rgb(255, 0, 0)diff --git a/Tests/LibWeb/Text/expected/css/environment-change-restyles-environment-readers.txt b/Tests/LibWeb/Text/expected/css/environment-change-restyles-environment-readers.txtindex ec32ab94fcf..c645a415c29 100644--- a/Tests/LibWeb/Text/expected/css/environment-change-restyles-environment-readers.txt+++ b/Tests/LibWeb/Text/expected/css/environment-change-restyles-environment-readers.txt@@ -1,8 +1,8 @@color-scheme meta: lightDark=rgb(1, 1, 1) systemColor=rgb(255, 255, 255) registered=rgb(3, 3, 3) thinBorder=1px-color-scheme meta styled: lightDark systemColor declaresScheme registered+color-scheme meta restyled: [html, lightDark, systemColor, declaresScheme, registered]device pixel ratio 2: lightDark=rgb(1, 1, 1) systemColor=rgb(255, 255, 255) registered=rgb(3, 3, 3) thinBorder=0.5px-device pixel ratio 2 styled: thinBorder imageSet+device pixel ratio 2 restyled: [html, thinBorder, imageSet]device pixel ratio 1: lightDark=rgb(1, 1, 1) systemColor=rgb(255, 255, 255) registered=rgb(3, 3, 3) thinBorder=1px-device pixel ratio 1 styled: thinBorder imageSet+device pixel ratio 1 restyled: [html, thinBorder, imageSet]preferred dark: lightDark=rgb(2, 2, 2) systemColor=rgb(18, 18, 18) registered=rgb(4, 4, 4) thinBorder=1px-preferred dark styled: lightDark systemColor declaresScheme registered thinBorder imageSet plain plainChild+preferred dark restyled: [html, head, body, lightDark, systemColor, declaresScheme, registered, thinBorder, imageSet, plain, plainChild, script, script@2, script@3, out]diff --git a/Tests/LibWeb/Text/expected/css/root-font-change-restyles-root-font-readers.txt b/Tests/LibWeb/Text/expected/css/root-font-change-restyles-root-font-readers.txtindex 906df12b8e6..d06ed23a9c7 100644--- a/Tests/LibWeb/Text/expected/css/root-font-change-restyles-root-font-readers.txt+++ b/Tests/LibWeb/Text/expected/css/root-font-change-restyles-root-font-readers.txt@@ -1,11 +1,3 @@before: remWidth=32px calcWidth=26px pxWidth=20px emWidth=32px substituted=64px registered=80px fontSizeChild=16px pseudo=48pxafter: remWidth=40px calcWidth=30px pxWidth=20px emWidth=32px substituted=80px registered=100px fontSizeChild=20px pseudo=60px-remWidth styled: true-calcWidth styled: true-pseudo styled: true-substituted styled: true-registered styled: true-fontSize styled: true-fontSizeChild styled: true-pxWidth styled: false-emWidth styled: false+restyled: [html, head, body, remWidth, calcWidth, pseudo, substituted, registered, fontSize, fontSizeChild]diff --git a/Tests/LibWeb/Text/expected/css/shared-link-style-sheet-compiles-once.txt b/Tests/LibWeb/Text/expected/css/shared-link-style-sheet-compiles-once.txtindex baad4bdb884..4421f4693c1 100644--- a/Tests/LibWeb/Text/expected/css/shared-link-style-sheet-compiles-once.txt+++ b/Tests/LibWeb/Text/expected/css/shared-link-style-sheet-compiles-once.txt@@ -1,5 +1,5 @@first: rgb(0, 128, 0)others: rgb(0, 128, 0), rgb(0, 128, 0), rgb(0, 128, 0)-rules compiled for the other links: 0+rules compiled for the other links: []after the first other stops matching: rgb(0, 0, 0), rgb(0, 128, 0), rgb(0, 128, 0)after removing the second other: rgb(0, 0, 0), rgb(0, 128, 0)diff --git a/Tests/LibWeb/Text/expected/css/sheet-declarations-intern-once-per-process.txt b/Tests/LibWeb/Text/expected/css/sheet-declarations-intern-once-per-process.txtindex 11767e929ec..92063dc8766 100644--- a/Tests/LibWeb/Text/expected/css/sheet-declarations-intern-once-per-process.txt+++ b/Tests/LibWeb/Text/expected/css/sheet-declarations-intern-once-per-process.txt@@ -1,6 +1,4 @@first frame margin-top: 7px-first frame blocks interned: 50-first frame blocks shared: 0+what the first frame did to its rules: [style rules compiled x50, sheet declarations interned x50, rule index built, selectors compiled x50]second frame margin-top: 7px-second frame blocks interned: 0-second frame blocks shared: 50+what the second frame did to its rules: [style rules compiled x50, sheet declarations shared x50, rule index built, selectors compiled x50]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/cascade-topology-equal-winners.txt b/Tests/LibWeb/Text/expected/css/style-engine/cascade-topology-equal-winners.txtindex dcc5995830d..f50ea592975 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/cascade-topology-equal-winners.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/cascade-topology-equal-winners.txt@@ -1,2 +1,2 @@-reverse layers with equal ordinary winners: [sentinel]-restore layers with equal ordinary winners: [sentinel]+reverse layers with equal ordinary winners: [sentinel] + unchanged [first, last]+restore layers with equal ordinary winners: [sentinel] + unchanged [first, last]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/cascade-topology-mutations.txt b/Tests/LibWeb/Text/expected/css/style-engine/cascade-topology-mutations.txtindex d9d39f10972..d6b2122b225 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/cascade-topology-mutations.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/cascade-topology-mutations.txt@@ -9,13 +9,13 @@ make a layered declaration important: [item]make it normal again: [item]insert an empty layer block: []delete the empty layer: []-insert nested layers with overlapping rules: []-delete the nested layer: []+insert nested layers with overlapping rules: [] + unchanged [item]+delete the nested layer: [] + unchanged [item]insert a layered rule behind a matching condition: []-delete the gated layer: []+delete the gated layer: [] + unchanged [item]move a sheet out of the document: [item]-put it back at the front: []+put it back at the front: [] + unchanged [item]move a shadow sheet past the one it overlaps: [inner, inner-first]declare layers inside the shadow root: []put the shadow layers in the other order: []-append a sheet that is already last: []+append a sheet that is already last: [] + unchanged [item]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/cascade-topology-sheet-replacement.txt b/Tests/LibWeb/Text/expected/css/style-engine/cascade-topology-sheet-replacement.txtindex 24b92a9264d..b0c3adc01df 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/cascade-topology-sheet-replacement.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/cascade-topology-sheet-replacement.txt@@ -1,2 +1,2 @@-replace a sheet while reversing equal-value layers: [sentinel]-replace a sheet while restoring equal-value layers: [sentinel]+replace a sheet while reversing equal-value layers: [sentinel] + unchanged [first, last]+replace a sheet while restoring equal-value layers: [sentinel] + unchanged [first, last]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/cold-pass-shadow-scopes.txt b/Tests/LibWeb/Text/expected/css/style-engine/cold-pass-shadow-scopes.txtindex 920290ecf4a..78df60326bd 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/cold-pass-shadow-scopes.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/cold-pass-shadow-scopes.txt@@ -1,5 +1 @@-computed every styled element: true-verified shadow tree elements: true-missing records: 0-live differences: 0-differences: 0+self-check: []diff --git a/Tests/LibWeb/Text/expected/css/style-engine/cssom-program-input-precision.txt b/Tests/LibWeb/Text/expected/css/style-engine/cssom-program-input-precision.txtindex f51bdd1fd0d..9b59f20b748 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/cssom-program-input-precision.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/cssom-program-input-precision.txt@@ -1,30 +1,30 @@-repeat layers styled <= 0: true+repeat layers restyled: []repeat layers colors: rgb(0, 0, 255), rgb(0, 0, 255)-remove repeated layers styled <= 0: true+remove repeated layers restyled: []remove repeated layers colors: rgb(0, 0, 255), rgb(0, 0, 255)-reorder layers styled <= 2: true+reorder layers restyled: [target, target]reorder layers colors: rgb(255, 0, 0), rgb(255, 0, 0)-restore layers styled <= 2: true+restore layers restyled: [target, target]restore layers colors: rgb(0, 0, 255), rgb(0, 0, 255)-insert style rule styled <= 2: true+insert style rule restyled: [target, target]insert style rule colors: rgb(0, 128, 0), rgb(0, 128, 0)-edit declarations styled <= 2: true+edit declarations restyled: [target, target]edit declarations colors: rgb(128, 0, 128), rgb(128, 0, 128)-replace declarations styled <= 2: true+replace declarations restyled: [target, target]replace declarations colors: rgb(128, 128, 0), rgb(128, 128, 0)-edit custom property styled <= 2: true+edit custom property restyled: [target, target]edit custom property colors: rgb(0, 128, 0), rgb(0, 128, 0)-delete style rule styled <= 2: true+delete style rule restyled: [target, target]delete style rule colors: rgb(0, 0, 255), rgb(0, 0, 255)-insert grouped rules styled <= 2: true+insert grouped rules restyled: [target, target]insert grouped rules colors: rgb(255, 165, 0), rgb(255, 165, 0)-delete grouped rules styled <= 2: true+delete grouped rules restyled: [target, target]delete grouped rules colors: rgb(0, 0, 255), rgb(0, 0, 255)-insert nested rules styled <= 2: true+insert nested rules restyled: [target, target]insert nested rules colors: rgb(165, 42, 42), rgb(165, 42, 42)-delete nested rules styled <= 2: true+delete nested rules restyled: [target, target]delete nested rules colors: rgb(0, 0, 255), rgb(0, 0, 255)-insert font feature values styled: 0, full pass: false+insert font feature values restyled: []insert font feature values colors: rgb(0, 0, 255), rgb(0, 0, 255)-delete font feature values styled: 0, full pass: false+delete font feature values restyled: []delete font feature values colors: rgb(0, 0, 255), rgb(0, 0, 255)diff --git a/Tests/LibWeb/Text/expected/css/style-engine/custom-property-registration-is-targeted.txt b/Tests/LibWeb/Text/expected/css/style-engine/custom-property-registration-is-targeted.txtindex cb982cbe21c..a5fe2ebbcc8 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/custom-property-registration-is-targeted.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/custom-property-registration-is-targeted.txt@@ -1,4 +1,4 @@-@property styled: 2, full pass: false+@property restyled: [div.declarer, div.reference], passes: PARTIALunrelated registered initial value: 0px-CSS.registerProperty() styled: 2, full passes: 0+CSS.registerProperty() restyled: [div, div@2], passes: PARTIALunrelated API initial value: 0pxdiff --git a/Tests/LibWeb/Text/expected/css/style-engine/declaration-mutations.txt b/Tests/LibWeb/Text/expected/css/style-engine/declaration-mutations.txtindex 635d8308087..e67607ae13b 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/declaration-mutations.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/declaration-mutations.txt@@ -2,11 +2,11 @@ gain an inline style: [item]edit that inline style: [item]add a property through the CSSOM: [item]lose the inline style: [item]-gain a presentational hint: [table]-lose it: [table]+gain a presentational hint: [table] + unchanged [tbody]+lose it: [table] + unchanged [tbody]gain an SVG presentation attribute: [circle]change it: [circle]lose it: [circle]-remove one inline property through the CSSOM: []+remove one inline property through the CSSOM: [] + unchanged [item]remove the last property from a stylesheet rule: [item, sibling]rewrite the same inline style: []diff --git a/Tests/LibWeb/Text/expected/css/style-engine/deferred-selection-style-computation.txt b/Tests/LibWeb/Text/expected/css/style-engine/deferred-selection-style-computation.txtindex 007c25591dd..1f13c52029b 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/deferred-selection-style-computation.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/deferred-selection-style-computation.txt@@ -1,12 +1,12 @@unselected query: rgb(10, 20, 30)-query stays local: true-activation preserves element styles: false-activation stays local: false+query restyled: []+activation changed: [html, body, container, div]+activation restyled: [html, head, body, container, div, div@2, div@3, div@4, div@5, div@6, div@7, div@8, div@9, div@10, div@11, div@12, div@13, div@14, div@15, div@16, div@17, div@18, div@19, div@20, div@21, div@22, div@23, div@24, div@25, div@26, div@27, div@28, div@29, div@30, div@31, div@32, div@33, div@34, div@35, div@36, div@37, div@38, div@39, div@40, div@41, div@42, div@43, div@44, div@45, div@46, div@47, div@48, div@49, div@50, div@51, div@52, div@53, div@54, div@55, div@56, div@57, div@58, div@59, div@60, div@61, div@62, div@63, div@64, script, out]layout after activation: (no layout)selected query: rgb(40, 50, 60)-extension updates only intersecting subtrees: true+extension restyled: [div]deselected query: rgb(70, 80, 90)-reactivation preserves element styles: false+reactivation changed: [html, body, container, div, div@2]reactivated query: rgb(70, 80, 90)unselected query while active: rgb(70, 80, 90)activation with pending rule and class changes: rgb(90, 100, 110)diff --git a/Tests/LibWeb/Text/expected/css/style-engine/deferred-selection-style-restyle.txt b/Tests/LibWeb/Text/expected/css/style-engine/deferred-selection-style-restyle.txtindex 6328e0a8d56..773ab0736d5 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/deferred-selection-style-restyle.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/deferred-selection-style-restyle.txt@@ -1,22 +1,22 @@-attach stays selective: false+attach restyled: [html, head, body, container, div.target, div, div@2, div@3, div@4, div@5, div@6, div@7, div@8, div@9, div@10, div@11, div@12, div@13, div@14, div@15, div@16, div@17, div@18, div@19, div@20, div@21, div@22, div@23, div@24, div@25, div@26, div@27, div@28, div@29, div@30, div@31, div@32, div@33, div@34, div@35, div@36, div@37, div@38, div@39, div@40, div@41, div@42, div@43, div@44, div@45, div@46, div@47, div@48, div@49, div@50, div@51, div@52, div@53, div@54, div@55, div@56, div@57, div@58, div@59, div@60, div@61, div@62, div@63, script, out]attach color: rgb(0, 0, 128)attach selection: rgb(0, 0, 255)-reorder stays selective: false+reorder restyled: [html, head, body, container, div.target, div, div@2, div@3, div@4, div@5, div@6, div@7, div@8, div@9, div@10, div@11, div@12, div@13, div@14, div@15, div@16, div@17, div@18, div@19, div@20, div@21, div@22, div@23, div@24, div@25, div@26, div@27, div@28, div@29, div@30, div@31, div@32, div@33, div@34, div@35, div@36, div@37, div@38, div@39, div@40, div@41, div@42, div@43, div@44, div@45, div@46, div@47, div@48, div@49, div@50, div@51, div@52, div@53, div@54, div@55, div@56, div@57, div@58, div@59, div@60, div@61, div@62, div@63, script, out]reorder color: rgb(0, 128, 0)reorder selection: rgb(255, 0, 0)-declaration stays selective: false-selection-only change changes no element styles: true+declaration restyled: [html, head, body, container, div.target, div, div@2, div@3, div@4, div@5, div@6, div@7, div@8, div@9, div@10, div@11, div@12, div@13, div@14, div@15, div@16, div@17, div@18, div@19, div@20, div@21, div@22, div@23, div@24, div@25, div@26, div@27, div@28, div@29, div@30, div@31, div@32, div@33, div@34, div@35, div@36, div@37, div@38, div@39, div@40, div@41, div@42, div@43, div@44, div@45, div@46, div@47, div@48, div@49, div@50, div@51, div@52, div@53, div@54, div@55, div@56, div@57, div@58, div@59, div@60, div@61, div@62, div@63, script, out]+selection-only change changed: []declaration color: rgb(0, 128, 0)declaration selection: rgb(128, 0, 128)-mixed declaration stays selective: false+mixed declaration restyled: [html, head, body, container, div.target, div, div@2, div@3, div@4, div@5, div@6, div@7, div@8, div@9, div@10, div@11, div@12, div@13, div@14, div@15, div@16, div@17, div@18, div@19, div@20, div@21, div@22, div@23, div@24, div@25, div@26, div@27, div@28, div@29, div@30, div@31, div@32, div@33, div@34, div@35, div@36, div@37, div@38, div@39, div@40, div@41, div@42, div@43, div@44, div@45, div@46, div@47, div@48, div@49, div@50, div@51, div@52, div@53, div@54, div@55, div@56, div@57, div@58, div@59, div@60, div@61, div@62, div@63, script, out]mixed declaration color: rgb(0, 128, 0)mixed declaration selection: rgb(255, 165, 0)inline opacity: 0.5-replace stays selective: false+replace restyled: [html, head, body, container, div.target, div, div@2, div@3, div@4, div@5, div@6, div@7, div@8, div@9, div@10, div@11, div@12, div@13, div@14, div@15, div@16, div@17, div@18, div@19, div@20, div@21, div@22, div@23, div@24, div@25, div@26, div@27, div@28, div@29, div@30, div@31, div@32, div@33, div@34, div@35, div@36, div@37, div@38, div@39, div@40, div@41, div@42, div@43, div@44, div@45, div@46, div@47, div@48, div@49, div@50, div@51, div@52, div@53, div@54, div@55, div@56, div@57, div@58, div@59, div@60, div@61, div@62, div@63, script, out]replace color: rgb(0, 128, 0)replace selection: rgb(255, 192, 203)-detach stays selective: false+detach restyled: [html, head, body, container, div.target, div, div@2, div@3, div@4, div@5, div@6, div@7, div@8, div@9, div@10, div@11, div@12, div@13, div@14, div@15, div@16, div@17, div@18, div@19, div@20, div@21, div@22, div@23, div@24, div@25, div@26, div@27, div@28, div@29, div@30, div@31, div@32, div@33, div@34, div@35, div@36, div@37, div@38, div@39, div@40, div@41, div@42, div@43, div@44, div@45, div@46, div@47, div@48, div@49, div@50, div@51, div@52, div@53, div@54, div@55, div@56, div@57, div@58, div@59, div@60, div@61, div@62, div@63, script, out]detach color: rgb(0, 0, 128)detach selection: rgb(0, 0, 255)-unqueried selection activated locally: false+unqueried selection activation restyled: [html, head, body, container, div.target, div, div@2, div@3, div@4, div@5, div@6, div@7, div@8, div@9, div@10, div@11, div@12, div@13, div@14, div@15, div@16, div@17, div@18, div@19, div@20, div@21, div@22, div@23, div@24, div@25, div@26, div@27, div@28, div@29, div@30, div@31, div@32, div@33, div@34, div@35, div@36, div@37, div@38, div@39, div@40, div@41, div@42, div@43, div@44, div@45, div@46, div@47, div@48, div@49, div@50, div@51, div@52, div@53, div@54, div@55, div@56, div@57, div@58, div@59, div@60, div@61, div@62, div@63, script, out]active selection: rgb(0, 0, 255)diff --git a/Tests/LibWeb/Text/expected/css/style-engine/descendant-combinator-restyles-subjects.txt b/Tests/LibWeb/Text/expected/css/style-engine/descendant-combinator-restyles-subjects.txtindex cf6f6c9fec5..27bdc063b90 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/descendant-combinator-restyles-subjects.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/descendant-combinator-restyles-subjects.txt@@ -1,5 +1,5 @@descendants of the guard: 12-full pass: false+passes: PARTIALchanged: [guard, deep]-styled only what changed: true-unguarded focus: full pass false, changed [outer], styles the item false+restyled but unchanged: []+unguarded focus: passes PARTIAL, changed [outer], restyled [outer]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/descendant-restyle-narrows-to-matching-ancestors.txt b/Tests/LibWeb/Text/expected/css/style-engine/descendant-restyle-narrows-to-matching-ancestors.txtindex 4adea8bf7d6..7603b481f27 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/descendant-restyle-narrows-to-matching-ancestors.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/descendant-restyle-narrows-to-matching-ancestors.txt@@ -1,4 +1,4 @@spans under the guard: 3-full pass: false+passes: PARTIALchanged: [guard, qualified]-styled only what changed: true+restyled but unchanged: []diff --git a/Tests/LibWeb/Text/expected/css/style-engine/document-rule-skips-shadow-tree.txt b/Tests/LibWeb/Text/expected/css/style-engine/document-rule-skips-shadow-tree.txtindex 26359be945a..e4243044f55 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/document-rule-skips-shadow-tree.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/document-rule-skips-shadow-tree.txt@@ -1,3 +1,3 @@-full pass: false+passes: (no pass)changed: []-styled only what changed: true+restyled but unchanged: []diff --git a/Tests/LibWeb/Text/expected/css/style-engine/document-scale-restyle.txt b/Tests/LibWeb/Text/expected/css/style-engine/document-scale-restyle.txtindex 0d808f409d4..d0d99473aa9 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/document-scale-restyle.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/document-scale-restyle.txt@@ -1,13 +1,9 @@-descendant styled the same at every document size: true-descendant full passes: 0, 0, 0-descendant changed: descendant-target, descendant-target, descendant-target-sibling styled the same at every document size: true-sibling full passes: 0, 0, 0-sibling changed: sibling-target, sibling-target, sibling-target-positional styled the same at every document size: true-positional full passes: 0, 0, 0-positional changed: div positional-target, div positional-target, div positional-target-relational styled the same at every document size: true-relational full passes: 0, 0, 0-relational changed: relational-anchor span, relational-anchor span, relational-anchor span+descendant: passes PARTIAL, changed [descendant-target], restyled but unchanged []+descendant style work is the same at every document size: true+sibling: passes PARTIAL, changed [sibling-target], restyled but unchanged []+sibling style work is the same at every document size: true+positional: passes PARTIAL, changed [div, positional-target], restyled but unchanged []+positional style work is the same at every document size: true+relational: passes PARTIAL, changed [relational-anchor, span.witness], restyled but unchanged []+relational style work is the same at every document size: truelargest unrelated population: 4096diff --git a/Tests/LibWeb/Text/expected/css/style-engine/has-mutations.txt b/Tests/LibWeb/Text/expected/css/style-engine/has-mutations.txtindex b2715b600c7..5baebc69658 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/has-mutations.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/has-mutations.txt@@ -20,5 +20,5 @@ the first alternative of a listed argument: [listed-alternatives, listed-hit]the second alternative of a listed argument: [listed-alternatives-2, listed-hit-2]an argument that names no fact at all: [anything, anything-child]an argument that names a position: [positional-last]-an argument that names a constraint: [constrained, constrained-input, div, div, div]+an argument that names a constraint: [constrained, constrained-input, div, div@2, div@3]a sibling seam closing over a departure: [seam-after]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/host-selector-restyles-host.txt b/Tests/LibWeb/Text/expected/css/style-engine/host-selector-restyles-host.txtindex 08c98561d83..3a7711fdb7c 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/host-selector-restyles-host.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/host-selector-restyles-host.txt@@ -1,3 +1,3 @@-full pass: false+passes: PARTIALchanged: [host, style, child]-styled only what changed: true+restyled but unchanged: []diff --git a/Tests/LibWeb/Text/expected/css/style-engine/hover-restyle-updates-box.txt b/Tests/LibWeb/Text/expected/css/style-engine/hover-restyle-updates-box.txtindex 860b6d98cbe..98d0caecc06 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/hover-restyle-updates-box.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/hover-restyle-updates-box.txt@@ -1,5 +1,5 @@initial: width=100px background=rgb(0, 128, 0) box.width=100hovered by the render clock: box width on screen=150-cold passes since: 0+style restarted from a cold pass: falsehovered: width=150px background=rgb(255, 0, 0) box.width=150unhovered: width=100px background=rgb(0, 128, 0) box.width=100diff --git a/Tests/LibWeb/Text/expected/css/style-engine/inherited-color-mix-resolves-against-own-color.txt b/Tests/LibWeb/Text/expected/css/style-engine/inherited-color-mix-resolves-against-own-color.txtindex 1419425604b..6c19e7b689b 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/inherited-color-mix-resolves-against-own-color.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/inherited-color-mix-resolves-against-own-color.txt@@ -1,4 +1,4 @@-start: differences from a cold pass: 0-third moved: differences from a cold pass: 0-first moved: differences from a cold pass: 0-third back: differences from a cold pass: 0+start: self-check: []+third moved: self-check: []+first moved: self-check: []+third back: self-check: []diff --git a/Tests/LibWeb/Text/expected/css/style-engine/install-same-custom-property-values.txt b/Tests/LibWeb/Text/expected/css/style-engine/install-same-custom-property-values.txtindex c1235caac85..33b61bef2a7 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/install-same-custom-property-values.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/install-same-custom-property-values.txt@@ -1,4 +1,4 @@inserted: 600 children, 0 with the style of another-inserted: 0 installed differently from a cold pass+inserted: self-check: []restyled: 600 children, 0 with the style of another-restyled: 0 installed differently from a cold pass+restyled: self-check: []diff --git a/Tests/LibWeb/Text/expected/css/style-engine/large-restyle-batch.txt b/Tests/LibWeb/Text/expected/css/style-engine/large-restyle-batch.txtindex 1447daaffa6..c896ebe39bf 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/large-restyle-batch.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/large-restyle-batch.txt@@ -1,3 +1,3 @@-full pass: false-changed elements: 1100-styled <= 1100: true+passes: PARTIAL+every item changed: true+restyled besides the items: []diff --git a/Tests/LibWeb/Text/expected/css/style-engine/live-default-state-fact.txt b/Tests/LibWeb/Text/expected/css/style-engine/live-default-state-fact.txtindex 2ac80908a95..7ba52590b11 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/live-default-state-fact.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/live-default-state-fact.txt@@ -3,11 +3,11 @@ make checkbox non-default: [checkbox-subject]make option default: [option]make option non-default: [option]make checked input a radio: [typed, typed-subject]-make checked input text again: [typed, div, div, div, typed-subject]-remove first submit status: [span, first-submit-subject, second-submit-subject]-restore first submit status: [span, first-submit-subject, second-submit-subject]-move second submit first: [first-submit-subject, second-submit-subject]-move first submit first: [first-submit-subject, second-submit-subject]+make checked input text again: [typed, div, div@2, div@3, typed-subject]+remove first submit status: [span, first-submit-subject, second-submit-subject] + unchanged [first-submit]+restore first submit status: [span, first-submit-subject, second-submit-subject] + unchanged [first-submit]+move second submit first: [first-submit-subject, second-submit-subject] + unchanged [second-submit]+move first submit first: [first-submit-subject, second-submit-subject] + unchanged [first-submit, span]associate first submit to another form: [second-submit-subject]restore first submit owner: [second-submit-subject]remove first submit: [first-submit-subject, second-submit-subject]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/live-state-facts.txt b/Tests/LibWeb/Text/expected/css/style-engine/live-state-facts.txtindex 16e9f39d43c..11e31e407a7 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/live-state-facts.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/live-state-facts.txt@@ -1,11 +1,11 @@make checkbox indeterminate: [indeterminate-subject]make checkbox determinate: [indeterminate-subject]-make progress determinate: [div, progress-subject]-make progress indeterminate: [div, progress-subject]+make progress determinate: [div@2, progress-subject] + unchanged [progress, div]+make progress indeterminate: [div@2, progress-subject] + unchanged [progress, div]make text input read-only: [read-only-subject, read-write-subject]make text input read-write: [read-only-subject, read-write-subject]-disable text input: [text, div, div, read-only-subject, read-write-subject]-enable text input: [text, div, div, read-only-subject, read-write-subject]+disable text input: [text, div, div@2, read-only-subject, read-write-subject] + unchanged [div@3]+enable text input: [text, div, div@2, read-only-subject, read-write-subject] + unchanged [div@3]make subtree editable: [editable-subject]make subtree non-editable: [editable-subject]design mode makes elements read-write: rgb(0, 128, 0)diff --git a/Tests/LibWeb/Text/expected/css/style-engine/local-action-document-scale.txt b/Tests/LibWeb/Text/expected/css/style-engine/local-action-document-scale.txtindex db6196bafcc..00169026bdd 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/local-action-document-scale.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/local-action-document-scale.txt@@ -1,8 +1,5 @@-one pass: 1-no full pass: 0-styled: target-changed: target-one hinted element: 1-no hinted subtree: 0-physical work is document-scale invariant: true+passes: PARTIAL+restyled: [target]+changed: [target]+style work is the same at every document size: truelargest document elements: 4097diff --git a/Tests/LibWeb/Text/expected/css/style-engine/local-feature-mutations.txt b/Tests/LibWeb/Text/expected/css/style-engine/local-feature-mutations.txtindex 5eb273bbd11..7823df0e80d 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/local-feature-mutations.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/local-feature-mutations.txt@@ -1,9 +1,9 @@-add a class: []-remove that class: []+add a class: [] + unchanged [item]+remove that class: [] + unchanged [item]add an unmentioned class: []-gain an id: []-lose that id: []-add an attribute: [bare]+gain an id: [] + unchanged [named]+lose that id: [] + unchanged [item]+add an attribute: [bare] + unchanged [item]change its value: [item]remove it: [item, bare]an attribute above a sibling combinator: [classed-next]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/moved-element-neighbour-relations.txt b/Tests/LibWeb/Text/expected/css/style-engine/moved-element-neighbour-relations.txtindex a17a75e43d2..3c7724a91d9 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/moved-element-neighbour-relations.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/moved-element-neighbour-relations.txt@@ -1,2 +1,2 @@-move the previous sibling away: [subject]-keep the old previous neighbour stationary: []+move the previous sibling away: [subject] + unchanged [moved]+keep the old previous neighbour stationary: [] + unchanged [span]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/part-mutations.txt b/Tests/LibWeb/Text/expected/css/style-engine/part-mutations.txtindex f56e62411f2..919a9572914 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/part-mutations.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/part-mutations.txt@@ -1,14 +1,14 @@-focus a control exposed as a part: [panel, control, div, div]-blur it again: [panel, control, div, div]-add the class the host rule names: [panel]-take it away again: [panel]+focus a control exposed as a part: [panel, control, div, div@2] + unchanged [div@3]+blur it again: [panel, control, div, div@2] + unchanged [div@3]+add the class the host rule names: [panel] + unchanged [control]+take it away again: [panel] + unchanged [control]expose another element as the same part: [unexposed]stop exposing it: [unexposed]-rename a part to one nothing selects: [panel]-rename it back: [panel]+rename a part to one nothing selects: [panel] + unchanged [control]+rename it back: [panel] + unchanged [control]insert a rule naming a part of a host with no shadow tree: []delete it: []-insert a rule naming a part that is exposed: [control, div, div]-delete that one: [control, div, div]+insert a rule naming a part that is exposed: [control, div, div@2] + unchanged [div@3]+delete that one: [control, div, div@2] + unchanged [div@3]remove an exposed element: []-put it back: [control, div, div, div]+put it back: [control, div, div@2, div@3]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/positional-move-mutations.txt b/Tests/LibWeb/Text/expected/css/style-engine/positional-move-mutations.txtindex 75061cfb513..0c2899d246e 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/positional-move-mutations.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/positional-move-mutations.txt@@ -1,12 +1,12 @@first-child begins matching (subject): [moved, target]-first-child stops matching (subject): [moved, target]-last-child begins matching (subject): [moved, target]+first-child stops matching (subject): [moved, target] + unchanged [other]+last-child begins matching (subject): [moved, target] + unchanged [other]last-child stops matching (subject): [moved, target]nth-last-child(2) begins matching (subject): [moved, target]-nth-last-child(2) stops matching (subject): [moved, target]-first-child begins matching (descendant): [target]-first-child stops matching (descendant): [target]-last-child begins matching (descendant): [target]-last-child stops matching (descendant): [target]-nth-last-child(2) begins matching (descendant): [target]-nth-last-child(2) stops matching (descendant): [target]+nth-last-child(2) stops matching (subject): [moved, target] + unchanged [other]+first-child begins matching (descendant): [target] + unchanged [moved]+first-child stops matching (descendant): [target] + unchanged [other]+last-child begins matching (descendant): [target] + unchanged [other]+last-child stops matching (descendant): [target] + unchanged [moved]+nth-last-child(2) begins matching (descendant): [target] + unchanged [moved]+nth-last-child(2) stops matching (descendant): [target] + unchanged [other]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/restyle-basic.txt b/Tests/LibWeb/Text/expected/css/style-engine/restyle-basic.txtindex ed84202f7b4..2a8f095ed04 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/restyle-basic.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/restyle-basic.txt@@ -1,4 +1,24 @@-full passes: 0-restyled fewer elements than a full pass each: true-missing records: 0-differences: 0+step 1: PARTIAL [root, div.item, span.b, i.c, span.leaf, div.item@2, span.leaf@2, div.item@3, span.b@2, span.leaf@3, div.item@4, div.item@5, div, span.leaf@4]+step 2: PARTIAL [div.item, span.leaf, span.leaf@2]+step 3: PARTIAL [span.leaf]+step 4: PARTIAL [span.leaf, span.leaf@2, span.leaf@3, span.leaf@4]+step 5: PARTIAL [span.leaf]+step 6: PARTIAL [root, div.item.off, span.b, i.c, span.leaf, div.item.on, span.leaf@2, named, span.b@2, span.leaf@3, div.item, div.item@2, div, span.leaf@4]+step 7: PARTIAL [div.item, div.item.off, span.b, i.c, span.leaf, div.item.on, span.leaf@2, named, span.b@2, span.leaf@3, div.item@2, div.item@3]+step 8: PARTIAL [div.item, div.item@2]+step 9: PARTIAL [div.item, span.leaf]+step 10: PARTIAL [span.leaf, span.leaf@2, span.leaf@3, span.leaf@4]+step 11: (no pass) []+step 12: PARTIAL [div.item.on]+step 13: PARTIAL [span, div.item, div.item.off, span.b, span.leaf, div.item.on, div.item@2, div.item@3]+step 14: PARTIAL [div.item, div.item.on, div.item@2, div.item@3]+step 15: PARTIAL [div.item.on, div.item, div.item@2]+step 16: PARTIAL [div.item.off, span.leaf, span.leaf@2, span.leaf@3]+step 17: (no pass) []+step 18: PARTIAL [root, span, div.item.on, div.item.off, span.b, i.c, span.leaf, div.item.on@2, div.item, span.leaf@2, div.item@2, div, span.leaf@3]+step 19: PARTIAL [root, span, div.item.on, div.item.off, span.b, i.c, span.leaf, div.item.on@2, div.item, span.leaf@2, div.item@2, div, span.leaf@3]+step 20: PARTIAL [p, div.item.off, span.b, span.leaf, div.item.on, div.item, span.leaf@2, div.item@2]+step 21: PARTIAL [div.item.off, span, span.b]+step 22: PARTIAL [span.leaf, span.leaf@2, div.item]+step 23: PARTIAL [div.item.off, span, span.b, span.leaf, div.item.on, div.item, span.leaf@2, div.item@2, div.item@3]+self-check: []diff --git a/Tests/LibWeb/Text/expected/css/style-engine/restyle-shadow.txt b/Tests/LibWeb/Text/expected/css/style-engine/restyle-shadow.txtindex d92c074f91c..2d2e59d1adf 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/restyle-shadow.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/restyle-shadow.txt@@ -1,3 +1,16 @@-full passes: 0-missing records: 0-differences: 0+step 1: PARTIAL [later, span, slot, span.light]+step 2: PARTIAL [card, div.inner]+step 3: PARTIAL [b.light]+step 4: PARTIAL [div.inner, slot]+step 5: PARTIAL [div.inner, slot]+step 6: PARTIAL [span]+step 7: PARTIAL [i.light.picked]+step 8: (no pass) []+step 9: PARTIAL [div.inner, slot]+step 10: PARTIAL [card, div.inner, slot]+step 11: PARTIAL [card, style, div.inner, slot, slot@2, b.light, i.light.picked]+step 12: PARTIAL [div.inner, style]+step 13: PARTIAL [div.inner]+step 14: PARTIAL [card, style, div.inner, slot, slot@2, b.light, i.light.picked, style@2]+step 15: PARTIAL [b.y]+self-check: []diff --git a/Tests/LibWeb/Text/expected/css/style-engine/rule-inserted-after-attach-reaches-engine.txt b/Tests/LibWeb/Text/expected/css/style-engine/rule-inserted-after-attach-reaches-engine.txtindex 468d1725cf5..6cb3341f1ed 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/rule-inserted-after-attach-reaches-engine.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/rule-inserted-after-attach-reaches-engine.txt@@ -1,5 +1,5 @@-full pass: false+passes: PARTIALchanged: [target, item]-styled only what changed: true+restyled but unchanged: []item color: rgb(0, 128, 0)after delete: rgb(0, 0, 0)diff --git a/Tests/LibWeb/Text/expected/css/style-engine/rule-mutations.txt b/Tests/LibWeb/Text/expected/css/style-engine/rule-mutations.txtindex b7c4df11d5c..352f0f35565 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/rule-mutations.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/rule-mutations.txt@@ -10,11 +10,11 @@ edit a rule's declarations: [item]remove a property from a rule: [item]rewrite a rule's whole declaration block: [item]insert a rule at the front of the sheet: [other]-insert the same rule at the back: []+insert the same rule at the back: [] + unchanged [other]delete both copies: [other]insert a rule with a selector list: [other, bare]-widen its selector to everything: [html, head, body, guard, animated, declarer, activation-match, activation-miss, card, error, button, list, row-one, row-two, script, out]-narrow it back to one class: [html, head, body, guard, bare, animated, declarer, activation-match, activation-miss, card, error, button, list, row-one, row-two, script, out]+widen its selector to everything: [html, head, body, guard, animated, declarer, activation-match, activation-miss, card, error, button, list, row-one, row-two, script, out] + unchanged [item, other, bare, consumer]+narrow it back to one class: [html, head, body, guard, bare, animated, declarer, activation-match, activation-miss, card, error, button, list, row-one, row-two, script, out] + unchanged [item, other, consumer]delete the listed rule: [other]insert a rule using :has(): [button]delete the relational rule: [button]@@ -54,9 +54,9 @@ insert the @keyframes the animation names: []edit a keyframe's declarations: []insert @keyframes nothing names: []delete the unused keyframes: []-register a custom property nobody uses: []-unregister it: []-register one that is declared and referenced: [declarer]-unregister that one: [declarer]-register one with an initial value: []-unregister the initialized one: []+register a custom property nobody uses: [] + unchanged [animated]+unregister it: [] + unchanged [animated]+register one that is declared and referenced: [declarer] + unchanged [animated, consumer]+unregister that one: [declarer] + unchanged [animated, consumer]+register one with an initial value: [] + unchanged [animated]+unregister the initialized one: [] + unchanged [animated]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/sheet-mutations.txt b/Tests/LibWeb/Text/expected/css/style-engine/sheet-mutations.txtindex c6003230af0..aca361e1184 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/sheet-mutations.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/sheet-mutations.txt@@ -43,10 +43,10 @@ unadopt it from the document only: [item, slottee]unadopt it from the shadow root too: [inner]adopt the same sheet twice over: [item, slottee]unadopt the doubled sheet: [item, slottee]-detach and reattach a host with an empty shadow tree: [div]-edit its adopted sheet after the round trip: []-adopt a sheet reaching out of its scope: [host, slot, inner]-unadopt the reaching sheet: [host, slot, inner]+detach and reattach a host with an empty shadow tree: [div.item]+edit its adopted sheet after the round trip: [] + unchanged [div.item]+adopt a sheet reaching out of its scope: [host, slot, inner] + unchanged [slottee]+unadopt the reaching sheet: [host, slot, inner] + unchanged [slottee]adopt a sheet into a shadow root nothing has entered yet: []fill the shadow tree: [widget]edit the adopted sheet now that the tree is populated: [widget]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/slot-assignment-mutations.txt b/Tests/LibWeb/Text/expected/css/style-engine/slot-assignment-mutations.txtindex 902fabff0cf..c906b9ce17c 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/slot-assignment-mutations.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/slot-assignment-mutations.txt@@ -1,4 +1,4 @@-assign a slottable to a named slot: []+assign a slottable to a named slot: [] + unchanged [a]rewrite the attribute to the same slot: []send it to a slot that does not exist: [a]send it back to the default slot: [a]diff --git a/Tests/LibWeb/Text/expected/css/style-engine/slotted-mutations.txt b/Tests/LibWeb/Text/expected/css/style-engine/slotted-mutations.txtindex 865334250dd..5ac8d6c81fe 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/slotted-mutations.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/slotted-mutations.txt@@ -1,4 +1,4 @@-disable the slotted element: [slotted, div, div, div]-mark the slotted element: [slotted, div, div, div]-disable an element outside the host: [outside, div, div]+disable the slotted element: [slotted, div, div@2, div@3]+mark the slotted element: [slotted, div, div@2, div@3]+disable an element outside the host: [outside, div, div@2] + unchanged [div@3]mark an element outside the host: []diff --git a/Tests/LibWeb/Text/expected/css/style-engine/top-layer-state-does-not-dirty-style.txt b/Tests/LibWeb/Text/expected/css/style-engine/top-layer-state-does-not-dirty-style.txtindex 017411099f6..39d71694a39 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/top-layer-state-does-not-dirty-style.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/top-layer-state-does-not-dirty-style.txt@@ -1,6 +1,6 @@-shown styled: popover+shown restyled: [popover]shown color: rgb(4, 5, 6)-shown read styled: 0-hidden styled: popover+shown read restyled: []+hidden restyled: [popover]hidden color: rgb(1, 2, 3)-hidden read styled: 0+hidden read restyled: []diff --git a/Tests/LibWeb/Text/expected/css/style-engine/tree-mutations.txt b/Tests/LibWeb/Text/expected/css/style-engine/tree-mutations.txtindex 6c821aac196..2ff473d5a84 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/tree-mutations.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/tree-mutations.txt@@ -10,7 +10,7 @@ remove the element two sibling rules look from: [trail, distant]put it back: [lead, trail, distant]remove a general sibling forest anchor: [forest-after, forest-later]remove an adjacent sibling forest anchor: [adjacent-forest-after]-remove an adjacent sibling with an equivalent replacement: []+remove an adjacent sibling with an equivalent replacement: [] + unchanged [replacement-target]remove a sibling from a longer adjacent chain: [chain-target]move a row to the front without removing it: [third, first, leaf, second]insert under the guard: [arrival]@@ -18,6 +18,6 @@ move it out of the guard: [arrival]disconnect it: []insert a subtree under the guard: [subtree, nested]remove the subtree: []-attach a shadow root: [slot]+attach a shadow root: [slot] + unchanged [host]assign an element to the slot: [slottee]unassign it: []diff --git a/Tests/LibWeb/Text/expected/css/style-invalidation/animated-custom-property-stops-where-descendants-reset-it.txt b/Tests/LibWeb/Text/expected/css/style-invalidation/animated-custom-property-stops-where-descendants-reset-it.txtindex c3dfe9941e1..5a5849b844a 100644--- a/Tests/LibWeb/Text/expected/css/style-invalidation/animated-custom-property-stops-where-descendants-reset-it.txt+++ b/Tests/LibWeb/Text/expected/css/style-invalidation/animated-custom-property-stops-where-descendants-reset-it.txt@@ -1,7 +1,8 @@reader in an element a slot takes: 90degdeep reader below non-readers: 90degdeep reader after a step: 180deg-elements below the reset restyled: 0+elements below the reset restyled: []+elements below the reset kept: [div, div@2, div@3, div@4, div@5, div@6, div@7, div@8, div@9, div@10, div@11, div@12, div@13, div@14, div@15, div@16, div@17, div@18, div@19, div@20, div@21, div@22, div@23, div@24, div@25, div@26, div@27, div@28, div@29, div@30, div@31, div@32, div@33, div@34, div@35, div@36, div@37, div@38, div@39, div@40, div@41, div@42, div@43, div@44, div@45, div@46, div@47, div@48, div@49, div@50]reader below the reset: 0degreader declaring its own below a registered declaration: 90degthat reader after a step: 180degdiff --git a/Tests/LibWeb/Text/expected/css/style-invalidation/user-style-change-restyles-only-readers-in-shadow-trees.txt b/Tests/LibWeb/Text/expected/css/style-invalidation/user-style-change-restyles-only-readers-in-shadow-trees.txtindex d55641d060d..41522c92620 100644--- a/Tests/LibWeb/Text/expected/css/style-invalidation/user-style-change-restyles-only-readers-in-shadow-trees.txt+++ b/Tests/LibWeb/Text/expected/css/style-invalidation/user-style-change-restyles-only-readers-in-shadow-trees.txt@@ -1,4 +1,4 @@-with a user style: styled plainReader sheetReader+with a user style: restyled [plainReader, sheetReader]with a user style: readers rgb(1, 2, 3) rgb(1, 2, 3), animated opacity=0.25-after the user style: styled plainReader sheetReader+after the user style: restyled [plainReader, sheetReader]after the user style: readers rgb(0, 0, 0) rgb(0, 0, 0), animated opacity=0.5diff --git a/Tests/LibWeb/Text/expected/css/style-invalidation/viewport-resize-restyles-axis-readers.txt b/Tests/LibWeb/Text/expected/css/style-invalidation/viewport-resize-restyles-axis-readers.txtindex f9e65cfce53..257f3a0f077 100644--- a/Tests/LibWeb/Text/expected/css/style-invalidation/viewport-resize-restyles-axis-readers.txt+++ b/Tests/LibWeb/Text/expected/css/style-invalidation/viewport-resize-restyles-axis-readers.txt@@ -1,4 +1,4 @@width only: width=50px height=20px dynamicHeight=20px inline=50px smaller=20px calcWidth=60px plain=10px-width only styled: width inline smaller calcWidth+width only restyled: [width, inline, smaller, calcWidth]height only: width=50px height=40px dynamicHeight=40px inline=50px smaller=40px calcWidth=60px plain=10px-height only styled: height dynamicHeight inline smaller+height only restyled: [height, dynamicHeight, inline, smaller]diff --git a/Tests/LibWeb/Text/expected/css/stylesheet-add-remove-imported-broad-invalidation.txt b/Tests/LibWeb/Text/expected/css/stylesheet-add-remove-imported-broad-invalidation.txtindex 27f5f10fd5e..395bc20b603 100644--- a/Tests/LibWeb/Text/expected/css/stylesheet-add-remove-imported-broad-invalidation.txt+++ b/Tests/LibWeb/Text/expected/css/stylesheet-add-remove-imported-broad-invalidation.txt@@ -1,5 +1,4 @@-imported layer-only stylesheet add restyles nothing, last pass styled <= 1: true-imported layer-only stylesheet remove restyles nothing, styled <= 1: true+imported layer-only stylesheet add restyles nothing, restyled: []+imported layer-only stylesheet remove restyles nothing, restyled: []PASS: imported layer reorder reaches the layered element-imported layer reorder stays bounded, last pass styled <= 8: true-imported layer reorder runs no full pass: true+imported layer reorder restyles only the layered element, restyled: [target]diff --git a/Tests/LibWeb/Text/expected/css/user-agent-declarations-intern-once-per-process.txt b/Tests/LibWeb/Text/expected/css/user-agent-declarations-intern-once-per-process.txtindex 90a5528fddf..880d7acf3d6 100644--- a/Tests/LibWeb/Text/expected/css/user-agent-declarations-intern-once-per-process.txt+++ b/Tests/LibWeb/Text/expected/css/user-agent-declarations-intern-once-per-process.txt@@ -1,2 +1,2 @@margin-top from the user-agent sheet: 16px-declarations the frame published: 0+what the frame did to its rules: [rule index built]diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/box-presence-changes-beside-the-layout-that-builds-boxes.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/box-presence-changes-beside-the-layout-that-builds-boxes.htmlindex 8218a3b0633..fdedd5ce567 100644--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/box-presence-changes-beside-the-layout-that-builds-boxes.html+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/box-presence-changes-beside-the-layout-that-builds-boxes.html@@ -79,7 +79,7 @@await twoFramesLanded();}}- println(`differences from a cold pass: ${internals.styleColdPass().differences}`);+ println(`self-check: [${internals.styleSelfCheck().join("; ")}]`);done();});</script>diff --git a/Tests/LibWeb/Text/input/css/animated-non-inherited-property-descendant-invalidation.html b/Tests/LibWeb/Text/input/css/animated-non-inherited-property-descendant-invalidation.htmlindex 864ceb97741..ec5b546e544 100644--- a/Tests/LibWeb/Text/input/css/animated-non-inherited-property-descendant-invalidation.html+++ b/Tests/LibWeb/Text/input/css/animated-non-inherited-property-descendant-invalidation.html@@ -18,33 +18,35 @@<div id="transformInheritor"><span>d</span></div></div><script src="../include.js"></script>+<script src="../work-test.js"></script><script>promiseTest(async () => {const keyframes = [{ transform: "translateY(0)" }, { transform: "translateY(-100px)" }];// What the style engine styled for an animation update of `container`, which composes the animated// values over the record of the container itself without restyling it.- async function styledDuringAnimationUpdate(container) {+ async function restyledDuringAnimationUpdate(container) {const animation = container.animate(keyframes, { duration: 1000 });animation.pause();animation.currentTime = 250;await animation.ready;await animationFrame();- internals.updateStyle();- internals.resetStyleCounters();- animation.currentTime = 500;- getComputedStyle(container).transform;- const styled = { count: internals.styleCounters().styledElements, elements: internals.styleLastPass().styled };+ const work = styleWork(() => {+ animation.currentTime = 500;+ getComputedStyle(container).transform;+ }, internals, { flush: false });animation.cancel();- return styled;+ return `[${work.restyled().map(shortStyleName).join(", ")}]`;}- println(`plain descendants styled <= 0: ${(await styledDuringAnimationUpdate(plainContainer)).count <= 0}`);+ const output = [];+ output.push(`plain descendants restyled: ${await restyledDuringAnimationUpdate(plainContainer)}`);// FIXME: This should style nothing, as the inheritor inherits text-decoration-line, which the// animation does not move, but the style engine restyles an element inheriting a property explicitly// whenever its parent's record changes, whichever properties change.- println(`text-decoration-line inheritor styled: ${(await styledDuringAnimationUpdate(decorationContainer)).count}`);- const transformStyled = await styledDuringAnimationUpdate(transformContainer);- println(`transform inheritor restyled: ${transformStyled.elements.includes("transformInheritor")}`);+ output.push(`text-decoration-line inheritor restyled: ${await restyledDuringAnimationUpdate(decorationContainer)}`);+ output.push(`transform inheritor restyled: ${await restyledDuringAnimationUpdate(transformContainer)}`);+ for (const line of output)+ println(line);});</script>diff --git a/Tests/LibWeb/Text/input/css/disconnected-node-mutation-no-style-invalidation.html b/Tests/LibWeb/Text/input/css/disconnected-node-mutation-no-style-invalidation.htmlindex c8b541a3099..972965b0543 100644--- a/Tests/LibWeb/Text/input/css/disconnected-node-mutation-no-style-invalidation.html+++ b/Tests/LibWeb/Text/input/css/disconnected-node-mutation-no-style-invalidation.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../include.js"></script>+<script src="../work-test.js"></script><style>.red {color: rgb(255, 0, 0);@@ -33,32 +34,28 @@test(() => {const host = document.getElementById("host");- // Settle any pending style work, then reset the counters.- internals.updateStyle();- internals.resetStyleCounters();-// Mutating disconnected elements should not restyle anything.const tree = document.createElement("div");- for (let i = 0; i < 10; ++i) {- const child = document.createElement("span");- child.className = "red";- child.setAttribute("data-green", "");- child.removeAttribute("data-green");- tree.appendChild(child);- }- tree.firstChild.id = "blue";- tree.firstChild.className = "";const custom = document.createElement("my-element");- tree.appendChild(custom);-- // Adding these classes changes no style inputs, because the disconnected tree has no- // style identities yet.- tree.className = "highlight";- tree.children[3].className = "flag";+ const work = styleWork(() => {+ for (let i = 0; i < 10; ++i) {+ const child = document.createElement("span");+ child.className = "red";+ child.setAttribute("data-green", "");+ child.removeAttribute("data-green");+ tree.appendChild(child);+ }+ tree.firstChild.id = "blue";+ tree.firstChild.className = "";+ tree.appendChild(custom);- internals.updateStyle();- println(`no pass after disconnected mutations: ${internals.styleCounters().passes === 0}`);- println(`nothing styled after disconnected mutations: ${internals.styleLastPass().styled.length === 0}`);+ // Adding these classes changes no style inputs, because the disconnected tree has no+ // style identities yet.+ tree.className = "highlight";+ tree.children[3].className = "flag";+ });+ println(`style passes after disconnected mutations: ${work.passes().join(" | ") || "(no pass)"}`);+ println(`restyled after disconnected mutations: [${work.restyled().map(shortStyleName).join(", ")}]`);// Once inserted, all the mutations made while disconnected must still be reflected in computed style.host.appendChild(tree);diff --git a/Tests/LibWeb/Text/input/css/environment-change-restyles-environment-readers.html b/Tests/LibWeb/Text/input/css/environment-change-restyles-environment-readers.htmlindex 5a01049429e..8c2234d4d98 100644--- a/Tests/LibWeb/Text/input/css/environment-change-restyles-environment-readers.html+++ b/Tests/LibWeb/Text/input/css/environment-change-restyles-environment-readers.html@@ -22,43 +22,52 @@<div id="imageSet">x</div><div id="plain"><span id="plainChild">x</span></div><script src="../include.js"></script>+<script src="../work-test.js"></script><script>- const ids = ["lightDark", "systemColor", "declaresScheme", "registered", "thinBorder", "imageSet", "plain", "plainChild"];- function report(label, styled) {- println(`${label}: lightDark=${getComputedStyle(lightDark).color} systemColor=${getComputedStyle(systemColor).backgroundColor} registered=${getComputedStyle(registered).getPropertyValue("--registered-color")} thinBorder=${getComputedStyle(thinBorder).borderTopWidth}`);- println(`${label} styled: ${ids.filter(id => styled.includes(id)).join(" ")}`);+ const output = [];+ function report(label, restyled) {+ output.push(`${label}: lightDark=${getComputedStyle(lightDark).color} systemColor=${getComputedStyle(systemColor).backgroundColor} registered=${getComputedStyle(registered).getPropertyValue("--registered-color")} thinBorder=${getComputedStyle(thinBorder).borderTopWidth}`);+ output.push(`${label} restyled: [${restyled.map(shortStyleName).join(", ")}]`);+ }+ function restyledIn(trace) {+ return [...new Set(parseStyleTrace(trace, { stylePassesOnly: true }).filter(event => event.event === "restyle" && event.outcome !== "kept").map(event => event.element))];}asyncTest(done => {// NB: The preferred color scheme is light to begin with, whatever a test before left it as.internals.setPreferredColorScheme("light");- internals.updateStyle();// The used color scheme stays light, so only the elements resolving against it restyle.const meta = document.createElement("meta");meta.name = "color-scheme";meta.content = "light dark";- document.head.appendChild(meta);- internals.updateStyle();- report("color-scheme meta", internals.styleLastPass().styled);+ report("color-scheme meta", styleWork(() => document.head.appendChild(meta)).restyled());+ // A device pixel ratio change reaches the document's media queries asynchronously, so its window spans+ // the change event.+ const changeDevicePixelRatio = ratio => {+ internals.updateStyle();+ internals.beginStyleTrace();+ internals.setDevicePixelRatio(ratio);+ };const mql = window.matchMedia("(resolution: 2dppx)");mql.addEventListener("change", event => {internals.updateStyle();+ const restyled = restyledIn(internals.takeStyleTrace());if (event.matches) {- report("device pixel ratio 2", internals.styleLastPass().styled);- internals.setDevicePixelRatio(1);+ report("device pixel ratio 2", restyled);+ changeDevicePixelRatio(1);return;}- report("device pixel ratio 1", internals.styleLastPass().styled);+ report("device pixel ratio 1", restyled);// The used color scheme of every element moves with the preferred one.- internals.setPreferredColorScheme("dark");- internals.updateStyle();- report("preferred dark", internals.styleLastPass().styled);+ report("preferred dark", styleWork(() => internals.setPreferredColorScheme("dark")).restyled());internals.setPreferredColorScheme("auto");+ for (const line of output)+ println(line);done();});- internals.setDevicePixelRatio(2);+ changeDevicePixelRatio(2);});</script>diff --git a/Tests/LibWeb/Text/input/css/root-font-change-restyles-root-font-readers.html b/Tests/LibWeb/Text/input/css/root-font-change-restyles-root-font-readers.htmlindex 73933188eb6..ba552118465 100644--- a/Tests/LibWeb/Text/input/css/root-font-change-restyles-root-font-readers.html+++ b/Tests/LibWeb/Text/input/css/root-font-change-restyles-root-font-readers.html@@ -29,6 +29,7 @@<div id="registered"></div><div id="fontSize"><span id="fontSizeChild"></span></div><script src="../include.js"></script>+<script src="../work-test.js"></script><script>test(() => {const ids = ["remWidth", "calcWidth", "pxWidth", "emWidth", "substituted", "registered", "fontSizeChild"];@@ -38,14 +39,8 @@.concat(`pseudo=${getComputedStyle(pseudo, "::before").width}`).join(" ");println(`before: ${widths()}`);- internals.updateStyle();- document.documentElement.style.fontSize = "20px";- internals.updateStyle();- const styled = internals.styleLastPass().styled;+ const work = styleWork(() => document.documentElement.style.fontSize = "20px");println(`after: ${widths()}`);- for (const id of ["remWidth", "calcWidth", "pseudo", "substituted", "registered", "fontSize", "fontSizeChild"])- println(`${id} styled: ${styled.includes(id)}`);- for (const id of ["pxWidth", "emWidth"])- println(`${id} styled: ${styled.includes(id)}`);+ println(`restyled: [${work.restyled().map(shortStyleName).join(", ")}]`);});</script>diff --git a/Tests/LibWeb/Text/input/css/shared-link-style-sheet-compiles-once.html b/Tests/LibWeb/Text/input/css/shared-link-style-sheet-compiles-once.htmlindex 6faeddc2d31..2cd34a01642 100644--- a/Tests/LibWeb/Text/input/css/shared-link-style-sheet-compiles-once.html+++ b/Tests/LibWeb/Text/input/css/shared-link-style-sheet-compiles-once.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../include.js"></script>+<script src="../work-test.js"></script><script>// Components commonly style each shadow tree with a link to the same sheet. Every link loads a sheet of its own,// whose rules the parse cache answers with the same contents; the document compiles those rules once.@@ -30,12 +31,13 @@await addLink(firstRoot).loaded;println(`first: ${color(firstRoot)}`);- const before = internals.styleEngineCounters().styleRulesCompiled;+ internals.beginStyleTrace();const roots = [makeRoot(), makeRoot(), makeRoot()];const links = roots.map(addLink);await Promise.all(links.map(({ loaded }) => loaded));println(`others: ${roots.map(color).join(", ")}`);- println(`rules compiled for the other links: ${internals.styleEngineCounters().styleRulesCompiled - before}`);+ const compiled = parseStyleTrace(internals.takeStyleTrace()).filter(event => event.event === "program" && !event.name.startsWith("rule index"));+ println(`rules compiled for the other links: [${compiled.map(event => (event.times > 1 ? `${event.name} x${event.times}` : event.name)).join(", ")}]`);// Each link's sheet keeps conditions of its own.links[0].link.media = "not all";diff --git a/Tests/LibWeb/Text/input/css/sheet-declarations-intern-once-per-process.html b/Tests/LibWeb/Text/input/css/sheet-declarations-intern-once-per-process.htmlindex da73f58feb8..351ac8e5cb9 100644--- a/Tests/LibWeb/Text/input/css/sheet-declarations-intern-once-per-process.html+++ b/Tests/LibWeb/Text/input/css/sheet-declarations-intern-once-per-process.html@@ -1,12 +1,13 @@<!DOCTYPE html><script src="../include.js"></script>+<script src="../work-test.js"></script><script>// Two frames load the same sheet, as the frames of one site do: the parse cache gives both the same parsed// contents, whose declaration blocks the process interns once.// NB: The process keeps what it interned, so the blocks of each run of this test are its own.const run = crypto.randomUUID();const rules = Array.from({ length: 50 }, (_, index) => `.c${index} { margin-top: ${index}px; color: rgb(${index}, 0, 0); --run: ${run}; }`);- const frame = `<style>${rules.join("\n")}</style><p class=c7>x</p>`;+ const frame = `<script>internals.beginStyleTrace()<\/script><style>${rules.join("\n")}</style><p class=c7>x</p>`;asyncTest(async done => {const load = () =>new Promise(resolve => {@@ -19,10 +20,12 @@const second = await load();for (const [name, iframe] of [["first", first], ["second", second]]) {const p = iframe.contentDocument.querySelector("p");- const counters = iframe.contentWindow.internals.styleEngineCounters();println(`${name} frame margin-top: ${iframe.contentWindow.getComputedStyle(p).marginTop}`);- println(`${name} frame blocks interned: ${counters.sheetDeclarationsInterned}`);- println(`${name} frame blocks shared: ${counters.sheetDeclarationsShared}`);+ iframe.contentWindow.internals.updateStyle();+ const totals = new Map();+ for (const event of parseStyleTrace(iframe.contentWindow.internals.takeStyleTrace()).filter(event => event.event === "program"))+ totals.set(event.name, (totals.get(event.name) ?? 0) + event.times);+ println(`what the ${name} frame did to its rules: [${[...totals].map(([eventName, times]) => (times > 1 ? `${eventName} x${times}` : eventName)).join(", ")}]`);}done();});diff --git a/Tests/LibWeb/Text/input/css/style-engine/arrival-routing-beyond-the-subtree.html b/Tests/LibWeb/Text/input/css/style-engine/arrival-routing-beyond-the-subtree.htmlindex c91e4e0ac6a..8b54eb361a4 100644--- a/Tests/LibWeb/Text/input/css/style-engine/arrival-routing-beyond-the-subtree.html+++ b/Tests/LibWeb/Text/input/css/style-engine/arrival-routing-beyond-the-subtree.html@@ -1,6 +1,7 @@<!DOCTYPE html><meta charset="utf-8"><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><script>// An arriving element's tree delta already plans its whole subtree, so its individual facts arediff --git a/Tests/LibWeb/Text/input/css/style-engine/cascade-topology-equal-winners.html b/Tests/LibWeb/Text/input/css/style-engine/cascade-topology-equal-winners.htmlindex 4582050dd3c..17f4fdd135d 100644--- a/Tests/LibWeb/Text/input/css/style-engine/cascade-topology-equal-winners.html+++ b/Tests/LibWeb/Text/input/css/style-engine/cascade-topology-equal-winners.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style id="layers">@layer a, b;diff --git a/Tests/LibWeb/Text/input/css/style-engine/cascade-topology-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/cascade-topology-mutations.htmlindex 7e270467bc0..6f52b91d5b8 100644--- a/Tests/LibWeb/Text/input/css/style-engine/cascade-topology-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/cascade-topology-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style id="first">@layer base, theme;diff --git a/Tests/LibWeb/Text/input/css/style-engine/cascade-topology-sheet-replacement.html b/Tests/LibWeb/Text/input/css/style-engine/cascade-topology-sheet-replacement.htmlindex 5118458f542..e855d22fa43 100644--- a/Tests/LibWeb/Text/input/css/style-engine/cascade-topology-sheet-replacement.html+++ b/Tests/LibWeb/Text/input/css/style-engine/cascade-topology-sheet-replacement.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style id="layers"></style><div id="first" class="same"></div>diff --git a/Tests/LibWeb/Text/input/css/style-engine/cold-pass-shadow-scopes.html b/Tests/LibWeb/Text/input/css/style-engine/cold-pass-shadow-scopes.htmlindex b5f7d2215a9..3fdca99253a 100644--- a/Tests/LibWeb/Text/input/css/style-engine/cold-pass-shadow-scopes.html+++ b/Tests/LibWeb/Text/input/css/style-engine/cold-pass-shadow-scopes.html@@ -65,13 +65,6 @@// Re-slot an element from the named slot to the default one.document.querySelector("#moving b").removeAttribute("slot");internals.updateStyle();- const report = internals.styleColdPass();- println(`computed every styled element: ${report.computedElements == report.elements}`);-- const live = internals.styleLiveReport(true);- println(`verified shadow tree elements: ${live.verifiedElements > document.querySelectorAll("*").length}`);- println(`missing records: ${live.missingRecords}`);- println(`live differences: ${live.differences}`);- println(`differences: ${report.differences}`);+ println(`self-check: [${internals.styleSelfCheck().join("; ")}]`);});</script>diff --git a/Tests/LibWeb/Text/input/css/style-engine/compound-requirements-in-flux.html b/Tests/LibWeb/Text/input/css/style-engine/compound-requirements-in-flux.htmlindex 7b0c757c0d5..d7befdd7924 100644--- a/Tests/LibWeb/Text/input/css/style-engine/compound-requirements-in-flux.html+++ b/Tests/LibWeb/Text/input/css/style-engine/compound-requirements-in-flux.html@@ -1,6 +1,7 @@<!DOCTYPE html><meta charset="utf-8"><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><script>// Routing rejects a route whose subject compound the element cannot satisfy. Every conjunct ofdiff --git a/Tests/LibWeb/Text/input/css/style-engine/cssom-program-input-precision.html b/Tests/LibWeb/Text/input/css/style-engine/cssom-program-input-precision.htmlindex d1d117e1985..6467026cccb 100644--- a/Tests/LibWeb/Text/input/css/style-engine/cssom-program-input-precision.html+++ b/Tests/LibWeb/Text/input/css/style-engine/cssom-program-input-precision.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><div id="target"></div><div id="host"></div><script>@@ -13,35 +14,28 @@shadow.adoptedStyleSheets = [sheet];internals.updateStyle();- // Print whether the change styled at most `maximum` elements, or, without a bound, how many it- // styled and whether in a full pass.- function mutate(label, mutation, maximum) {- internals.resetStyleCounters();- mutation();- internals.updateStyle();- const lastPass = internals.styleLastPass();- if (maximum === undefined)- println(`${label} styled: ${lastPass.styled.length}, full pass: ${lastPass.fullPass}`);- else- println(`${label} styled <= ${maximum}: ${lastPass.styled.length <= maximum}`);+ // Print the elements the change restyled, and whether in a full pass.+ function mutate(label, mutation) {+ const work = styleWork(mutation);+ println(`${label} restyled: [${work.restyled().map(shortStyleName).join(", ")}]${work.passes().includes("FULL") ? " (full pass)" : ""}`);println(`${label} colors: ${getComputedStyle(target).color}, ${getComputedStyle(shadowTarget).color}`);}// Repeating and removing repeated layer statements restyles nothing, and every other change but the// font feature values only the two targets.- mutate("repeat layers", () => sheet.insertRule("@layer base, theme;", 0), 0);- mutate("remove repeated layers", () => sheet.deleteRule(0), 0);- mutate("reorder layers", () => sheet.insertRule("@layer theme, base;", 0), 2);- mutate("restore layers", () => sheet.deleteRule(0), 2);- mutate("insert style rule", () => sheet.insertRule("#target { color: green; }", sheet.cssRules.length), 2);- mutate("edit declarations", () => sheet.cssRules[sheet.cssRules.length - 1].style.color = "purple", 2);- mutate("replace declarations", () => sheet.cssRules[sheet.cssRules.length - 1].style.cssText = "--color: olive; color: var(--color)", 2);- mutate("edit custom property", () => sheet.cssRules[sheet.cssRules.length - 1].style.setProperty("--color", "green"), 2);- mutate("delete style rule", () => sheet.deleteRule(sheet.cssRules.length - 1), 2);- mutate("insert grouped rules", () => sheet.insertRule("@media all { #target { color: orange; } }", sheet.cssRules.length), 2);- mutate("delete grouped rules", () => sheet.deleteRule(sheet.cssRules.length - 1), 2);- mutate("insert nested rules", () => sheet.insertRule("#target { @media all { color: brown; } }", sheet.cssRules.length), 2);- mutate("delete nested rules", () => sheet.deleteRule(sheet.cssRules.length - 1), 2);+ mutate("repeat layers", () => sheet.insertRule("@layer base, theme;", 0));+ mutate("remove repeated layers", () => sheet.deleteRule(0));+ mutate("reorder layers", () => sheet.insertRule("@layer theme, base;", 0));+ mutate("restore layers", () => sheet.deleteRule(0));+ mutate("insert style rule", () => sheet.insertRule("#target { color: green; }", sheet.cssRules.length));+ mutate("edit declarations", () => sheet.cssRules[sheet.cssRules.length - 1].style.color = "purple");+ mutate("replace declarations", () => sheet.cssRules[sheet.cssRules.length - 1].style.cssText = "--color: olive; color: var(--color)");+ mutate("edit custom property", () => sheet.cssRules[sheet.cssRules.length - 1].style.setProperty("--color", "green"));+ mutate("delete style rule", () => sheet.deleteRule(sheet.cssRules.length - 1));+ mutate("insert grouped rules", () => sheet.insertRule("@media all { #target { color: orange; } }", sheet.cssRules.length));+ mutate("delete grouped rules", () => sheet.deleteRule(sheet.cssRules.length - 1));+ mutate("insert nested rules", () => sheet.insertRule("#target { @media all { color: brown; } }", sheet.cssRules.length));+ mutate("delete nested rules", () => sheet.deleteRule(sheet.cssRules.length - 1));// A @font-feature-values rule for a family nobody uses restyles nothing.mutate("insert font feature values", () => sheet.insertRule("@font-feature-values PrecisionFont { @stylistic { alternate: 1; } }", sheet.cssRules.length));mutate("delete font feature values", () => sheet.deleteRule(sheet.cssRules.length - 1));diff --git a/Tests/LibWeb/Text/input/css/style-engine/custom-property-registration-is-targeted.html b/Tests/LibWeb/Text/input/css/style-engine/custom-property-registration-is-targeted.htmlindex e0c832470e9..6d8c62f8545 100644--- a/Tests/LibWeb/Text/input/css/style-engine/custom-property-registration-is-targeted.html+++ b/Tests/LibWeb/Text/input/css/style-engine/custom-property-registration-is-targeted.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><style id="registrations">.declarer { --registered: 12px; }.reference { width: var(--registered); }@@ -18,18 +19,15 @@sheet.insertRule(":not(*) {}", 0);sheet.deleteRule(0);- internals.updateStyle();- internals.resetStyleCounters();-- document.getElementById("registrations").sheet.insertRule(- "@property --registered { syntax: '<length>'; inherits: false; initial-value: 0px; }"- );- document.getElementById("registrations").sheet.insertRule(":not(*) { color: red; }");- internals.updateStyle();+ const registration = styleWork(() => {+ document.getElementById("registrations").sheet.insertRule(+ "@property --registered { syntax: '<length>'; inherits: false; initial-value: 0px; }"+ );+ document.getElementById("registrations").sheet.insertRule(":not(*) { color: red; }");+ });- // The registration restyles at most the declarer and the reference.- const lastPass = internals.styleLastPass();- println(`@property styled: ${lastPass.styled.length}, full pass: ${lastPass.fullPass}`);+ // The registration restyles only the declarer and the reference.+ println(`@property restyled: [${registration.restyled().map(shortStyleName).join(", ")}], passes: ${registration.passes().join(" | ") || "(no pass)"}`);println(`unrelated registered initial value: ${getComputedStyle(unrelated).getPropertyValue("--registered")}`);document.querySelector(".reference").remove();@@ -41,19 +39,18 @@document.body.appendChild(apiReference);internals.updateStyle();- internals.resetStyleCounters();- CSS.registerProperty({- name: "--api-registered",- syntax: "<length>",- inherits: false,- initialValue: "0px",+ const apiRegistration = styleWork(() => {+ CSS.registerProperty({+ name: "--api-registered",+ syntax: "<length>",+ inherits: false,+ initialValue: "0px",+ });+ document.getElementById("registrations").sheet.insertRule(":not(*) { color: green; }");});- document.getElementById("registrations").sheet.insertRule(":not(*) { color: green; }");- internals.updateStyle();- // This registration restyles at most the API declarer and reference.- const counters = internals.styleCounters();- println(`CSS.registerProperty() styled: ${counters.styledElements}, full passes: ${counters.fullPasses}`);+ // This registration restyles only the API declarer and reference.+ println(`CSS.registerProperty() restyled: [${apiRegistration.restyled().map(shortStyleName).join(", ")}], passes: ${apiRegistration.passes().join(" | ") || "(no pass)"}`);println(`unrelated API initial value: ${getComputedStyle(unrelated).getPropertyValue("--api-registered")}`);});diff --git a/Tests/LibWeb/Text/input/css/style-engine/declaration-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/declaration-mutations.htmlindex 94a8fbddac2..0d501093c20 100644--- a/Tests/LibWeb/Text/input/css/style-engine/declaration-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/declaration-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style>.item { color: green }@@ -46,8 +47,7 @@// Writing the same declarations again moves nothing, so nothing is restyled.item.setAttribute("style", "color: red");- planSetup();- item.setAttribute("style", "color: red");- println(`rewrite the same inline style: [${planPass().styled.join(", ")}]`);+ const rewrite = styleWork(() => item.setAttribute("style", "color: red"));+ println(`rewrite the same inline style: [${rewrite.restyled().map(shortStyleName).join(", ")}]`);});</script>diff --git a/Tests/LibWeb/Text/input/css/style-engine/deferred-selection-style-computation.html b/Tests/LibWeb/Text/input/css/style-engine/deferred-selection-style-computation.htmlindex 70c68a95d57..1d32733998a 100644--- a/Tests/LibWeb/Text/input/css/style-engine/deferred-selection-style-computation.html+++ b/Tests/LibWeb/Text/input/css/style-engine/deferred-selection-style-computation.html@@ -16,33 +16,28 @@rules.sheet.insertRule("*::selection { color: rgb(10, 20, 30); background-color: rgb(40, 50, 60); }");internals.updateStyle();const target = container.firstElementChild;- internals.resetStyleCounters();- println(`unselected query: ${getComputedStyle(target, "::selection").color}`);+ let unselectedColor;+ const query = styleWork(() => unselectedColor = getComputedStyle(target, "::selection").color, internals, { flush: false });+ println(`unselected query: ${unselectedColor}`);// A highlight pseudo-element inherits from its ancestors', so a query computes that chain and nothing else.- println(`query stays local: ${internals.styleCounters().styledElements < container.children.length}`);+ println(`query restyled: [${query.restyled().map(shortStyleName).join(", ")}]`);getComputedStyle(container.lastElementChild, "::selection").backgroundColor;target.getBoundingClientRect();const range = document.createRange();range.selectNodeContents(target);+ let activation;const activationWork = layoutWork(() => {- document.getSelection().addRange(range);- internals.resetStyleCounters();- internals.updateStyle();+ activation = styleWork(() => document.getSelection().addRange(range));target.getBoundingClientRect();});- const activation = internals.styleCounters();- println(`activation preserves element styles: ${internals.styleLastPass().changed.length === 0}`);- println(`activation stays local: ${activation.styledElements < 16}`);+ println(`activation changed: [${activation.changed().map(shortStyleName).join(", ")}]`);+ println(`activation restyled: [${activation.restyled().map(shortStyleName).join(", ")}]`);println(`layout after activation: ${activationWork.passes().join(" | ") || "(no layout)"}`);println(`selected query: ${getComputedStyle(target, "::selection").backgroundColor}`);- internals.updateStyle();- internals.resetStyleCounters();- range.setEnd(target.nextElementSibling.firstChild, 3);- internals.updateStyle();- const extension = internals.styleCounters().styledElements;- println(`extension updates only intersecting subtrees: ${extension > 0 && extension < 16}`);+ const extension = styleWork(() => range.setEnd(target.nextElementSibling.firstChild, 3));+ println(`extension restyled: [${extension.restyled().map(shortStyleName).join(", ")}]`);document.getSelection().removeAllRanges();@@ -50,11 +45,8 @@internals.updateStyle();println(`deselected query: ${getComputedStyle(target, "::selection").backgroundColor}`);- internals.updateStyle();- internals.resetStyleCounters();- document.getSelection().addRange(range);- internals.updateStyle();- println(`reactivation preserves element styles: ${internals.styleLastPass().changed.length === 0}`);+ const reactivation = styleWork(() => document.getSelection().addRange(range));+ println(`reactivation changed: [${reactivation.changed().map(shortStyleName).join(", ")}]`);println(`reactivated query: ${getComputedStyle(target, "::selection").backgroundColor}`);println(`unselected query while active: ${getComputedStyle(container.lastElementChild, "::selection").backgroundColor}`);diff --git a/Tests/LibWeb/Text/input/css/style-engine/deferred-selection-style-restyle.html b/Tests/LibWeb/Text/input/css/style-engine/deferred-selection-style-restyle.htmlindex d07f1d4fb9c..4afc9b47e74 100644--- a/Tests/LibWeb/Text/input/css/style-engine/deferred-selection-style-restyle.html+++ b/Tests/LibWeb/Text/input/css/style-engine/deferred-selection-style-restyle.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><div id="container"></div><script>test(() => {@@ -16,13 +17,10 @@internals.updateStyle();function change(label, callback) {- internals.resetStyleCounters();- callback();- internals.updateStyle();- const counters = internals.styleCounters();- println(`${label} stays selective: ${counters.styledElements < 16}`);+ const work = styleWork(callback);+ println(`${label} restyled: [${work.restyled().map(shortStyleName).join(", ")}]${work.passes().includes("FULL") ? " (full pass)" : ""}`);if (label === "declaration")- println(`selection-only change changes no element styles: ${internals.styleLastPass().changed.length === 0}`);+ println(`selection-only change changed: [${work.changed().map(shortStyleName).join(", ")}]`);println(`${label} color: ${getComputedStyle(target).color}`);println(`${label} selection: ${getComputedStyle(target, "::selection").color}`);}@@ -40,11 +38,8 @@const range = document.createRange();range.selectNodeContents(container.lastElementChild);- document.getSelection().addRange(range);- internals.resetStyleCounters();- internals.updateStyle();- const activated = internals.styleCounters().styledElements;- println(`unqueried selection activated locally: ${activated > 0 && activated < 16}`);+ const activation = styleWork(() => document.getSelection().addRange(range));+ println(`unqueried selection activation restyled: [${activation.restyled().map(shortStyleName).join(", ")}]`);println(`active selection: ${getComputedStyle(container.lastElementChild, "::selection").color}`);document.getSelection().removeAllRanges();});diff --git a/Tests/LibWeb/Text/input/css/style-engine/descendant-combinator-restyles-subjects.html b/Tests/LibWeb/Text/input/css/style-engine/descendant-combinator-restyles-subjects.htmlindex 64f371e8620..ac8d094a098 100644--- a/Tests/LibWeb/Text/input/css/style-engine/descendant-combinator-restyles-subjects.html+++ b/Tests/LibWeb/Text/input/css/style-engine/descendant-combinator-restyles-subjects.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><style>.theme:focus .item { color: green }</style>@@ -12,32 +13,23 @@</div><script>test(() => {- internals.updateStyle();- internals.resetStyleCounters();-// A descendant combinator reaches a whole subtree, but only the elements carrying the// subject's own feature inside it can change. The pass restyles those, not the subtree: the// guard has twelve descendants and exactly one of them is an .item. The guard itself is// restyled because the user-agent sheet styles whatever is focused.const guard = document.getElementById("guard");println(`descendants of the guard: ${guard.querySelectorAll("*").length}`);- guard.focus({ preventScroll: true });- internals.updateStyle();- let pass = internals.styleLastPass();- println(`full pass: ${pass.fullPass}`);- println(`changed: [${pass.changed.join(", ")}]`);- println(`styled only what changed: ${pass.styled.join() === pass.changed.join()}`);+ let work = styleWork(() => guard.focus({ preventScroll: true }));+ println(`passes: ${work.passes().join(" | ") || "(no pass)"}`);+ println(`changed: [${work.changed().map(shortStyleName).join(", ")}]`);+ println(`restyled but unchanged: [${work.restyled().filter(element => !work.changed().includes(element)).map(shortStyleName).join(", ")}]`);// The element an input happened to has to satisfy the rest of the compound that input// occurs in. Focusing an element that is not a .theme reaches the elements the user-agent// sheet styles by focus, and no .item at all. Blur the guard first, so the focus change// takes nothing away from it.guard.blur();- internals.updateStyle();- internals.resetStyleCounters();- document.getElementById("outer").focus({ preventScroll: true });- internals.updateStyle();- pass = internals.styleLastPass();- println(`unguarded focus: full pass ${pass.fullPass}, changed [${pass.changed.join(", ")}], styles the item ${pass.styled.includes("deep")}`);+ work = styleWork(() => document.getElementById("outer").focus({ preventScroll: true }));+ println(`unguarded focus: passes ${work.passes().join(" | ") || "(no pass)"}, changed [${work.changed().map(shortStyleName).join(", ")}], restyled [${work.restyled().map(shortStyleName).join(", ")}]`);});</script>diff --git a/Tests/LibWeb/Text/input/css/style-engine/descendant-restyle-narrows-to-matching-ancestors.html b/Tests/LibWeb/Text/input/css/style-engine/descendant-restyle-narrows-to-matching-ancestors.htmlindex de761edcb9b..cdaed478333 100644--- a/Tests/LibWeb/Text/input/css/style-engine/descendant-restyle-narrows-to-matching-ancestors.html+++ b/Tests/LibWeb/Text/input/css/style-engine/descendant-restyle-narrows-to-matching-ancestors.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><style>#guard:focus [class] span { color: green }</style>@@ -14,18 +15,13 @@</div><script>test(() => {- internals.updateStyle();- internals.resetStyleCounters();-// A region says where a change can reach; it does not say what the selector required on the// way. Focusing the guard reaches every span under it, but only a span with a `[class]`// ancestor can match, and the plan names that one alone.- document.getElementById("guard").focus({ preventScroll: true });- internals.updateStyle();- const pass = internals.styleLastPass();+ const work = styleWork(() => document.getElementById("guard").focus({ preventScroll: true }));println(`spans under the guard: ${document.querySelectorAll("#guard span").length}`);- println(`full pass: ${pass.fullPass}`);- println(`changed: [${pass.changed.join(", ")}]`);- println(`styled only what changed: ${pass.styled.join() === pass.changed.join()}`);+ println(`passes: ${work.passes().join(" | ") || "(no pass)"}`);+ println(`changed: [${work.changed().map(shortStyleName).join(", ")}]`);+ println(`restyled but unchanged: [${work.restyled().filter(element => !work.changed().includes(element)).map(shortStyleName).join(", ")}]`);});</script>diff --git a/Tests/LibWeb/Text/input/css/style-engine/document-rule-skips-shadow-tree.html b/Tests/LibWeb/Text/input/css/style-engine/document-rule-skips-shadow-tree.htmlindex 9366163615d..ffaa4b0bfe9 100644--- a/Tests/LibWeb/Text/input/css/style-engine/document-rule-skips-shadow-tree.html+++ b/Tests/LibWeb/Text/input/css/style-engine/document-rule-skips-shadow-tree.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><style>:checked ~ div > * { color: green }</style>@@ -8,16 +9,12 @@test(() => {const shadowRoot = document.getElementById("host").attachShadow({ mode: "open" });shadowRoot.innerHTML = `<div><input type="checkbox"><label id="label"></label><button id="button"></button></div>`;- internals.updateStyle();- internals.resetStyleCounters();// A document rule never matches inside a shadow tree, so checking a box there restyles// nothing through it.- shadowRoot.querySelector("input").checked = true;- internals.updateStyle();- const pass = internals.styleLastPass();- println(`full pass: ${pass.fullPass}`);- println(`changed: [${pass.changed.join(", ")}]`);- println(`styled only what changed: ${pass.styled.join() === pass.changed.join()}`);+ const work = styleWork(() => shadowRoot.querySelector("input").checked = true);+ println(`passes: ${work.passes().join(" | ") || "(no pass)"}`);+ println(`changed: [${work.changed().map(shortStyleName).join(", ")}]`);+ println(`restyled but unchanged: [${work.restyled().filter(element => !work.changed().includes(element)).map(shortStyleName).join(", ")}]`);});</script>diff --git a/Tests/LibWeb/Text/input/css/style-engine/document-scale-restyle.html b/Tests/LibWeb/Text/input/css/style-engine/document-scale-restyle.htmlindex fe63152514b..fcf11c26188 100644--- a/Tests/LibWeb/Text/input/css/style-engine/document-scale-restyle.html+++ b/Tests/LibWeb/Text/input/css/style-engine/document-scale-restyle.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><style>#descendant-anchor.active #descendant-target { color: red }#sibling-anchor.active ~ #sibling-target { color: red }@@ -19,18 +20,10 @@undo();internals.updateStyle();- internals.resetStyleCounters();- action();- internals.updateStyle();- const counters = internals.styleCounters();- const changed = internals.styleLastPass().changed.join(" ");+ const work = styleWork(action);undo();internals.updateStyle();- return {- styled: counters.styledElements,- changed,- fullPasses: counters.fullPasses,- };+ return work;}const descendantAnchor = document.getElementById("descendant-anchor");@@ -69,10 +62,11 @@}for (const operator of ["descendant", "sibling", "positional", "relational"]) {- const styled = measurements.map(measurement => measurement[operator].styled);- println(`${operator} styled the same at every document size: ${styled.every(count => count === styled[0])}`);- println(`${operator} full passes: ${measurements.map(measurement => measurement[operator].fullPasses).join(", ")}`);- println(`${operator} changed: ${measurements.map(measurement => measurement[operator].changed).join(", ")}`);+ const works = measurements.map(measurement => measurement[operator]);+ const changed = works[0].changed();+ const unchanged = works[0].restyled().filter(element => !changed.includes(element));+ println(`${operator}: passes ${works[0].passes().join(" | ") || "(no pass)"}, changed [${changed.map(shortStyleName).join(", ")}], restyled but unchanged [${unchanged.map(shortStyleName).join(", ")}]`);+ println(`${operator} style work is the same at every document size: ${works.every(work => work.text === works[0].text)}`);}println(`largest unrelated population: ${fillerRoot.childElementCount}`);});diff --git a/Tests/LibWeb/Text/input/css/style-engine/exportparts-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/exportparts-mutations.htmlindex 3b0eace5a2e..6fbab3a6402 100644--- a/Tests/LibWeb/Text/input/css/style-engine/exportparts-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/exportparts-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style>x-outer::part(foo) { color: green }diff --git a/Tests/LibWeb/Text/input/css/style-engine/has-beside-host.html b/Tests/LibWeb/Text/input/css/style-engine/has-beside-host.htmlindex bb2d75a2fc0..a3613ff13c4 100644--- a/Tests/LibWeb/Text/input/css/style-engine/has-beside-host.html+++ b/Tests/LibWeb/Text/input/css/style-engine/has-beside-host.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><div id="host"><template shadowrootmode="open">diff --git a/Tests/LibWeb/Text/input/css/style-engine/has-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/has-mutations.htmlindex 756957b789c..cde7d38adbc 100644--- a/Tests/LibWeb/Text/input/css/style-engine/has-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/has-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style>.card:has(.error) .button { color: green }diff --git a/Tests/LibWeb/Text/input/css/style-engine/host-selector-restyles-host.html b/Tests/LibWeb/Text/input/css/style-engine/host-selector-restyles-host.htmlindex 827f789f460..9885c942aee 100644--- a/Tests/LibWeb/Text/input/css/style-engine/host-selector-restyles-host.html+++ b/Tests/LibWeb/Text/input/css/style-engine/host-selector-restyles-host.html@@ -1,22 +1,19 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><div id="host" tabindex="0"></div><script>test(() => {const host = document.getElementById("host");const shadowRoot = host.attachShadow({ mode: "open" });shadowRoot.innerHTML = "<style>:host(:focus) { color: green }</style><span id=child></span>";- internals.updateStyle();- internals.resetStyleCounters();// `:host()` is a guard on the host, not a combinator: it styles the element it tests. A// change to what it tests reaches that element, and the tree it hosts only through what// that tree inherits from it.- host.focus({ preventScroll: true });- internals.updateStyle();- const pass = internals.styleLastPass();- println(`full pass: ${pass.fullPass}`);- println(`changed: [${pass.changed.join(", ")}]`);- println(`styled only what changed: ${pass.styled.join() === pass.changed.join()}`);+ const work = styleWork(() => host.focus({ preventScroll: true }));+ println(`passes: ${work.passes().join(" | ") || "(no pass)"}`);+ println(`changed: [${work.changed().map(shortStyleName).join(", ")}]`);+ println(`restyled but unchanged: [${work.restyled().filter(element => !work.changed().includes(element)).map(shortStyleName).join(", ")}]`);});</script>diff --git a/Tests/LibWeb/Text/input/css/style-engine/hover-restyle-updates-box.html b/Tests/LibWeb/Text/input/css/style-engine/hover-restyle-updates-box.htmlindex 6095acb3320..cc84bd213f9 100644--- a/Tests/LibWeb/Text/input/css/style-engine/hover-restyle-updates-box.html+++ b/Tests/LibWeb/Text/input/css/style-engine/hover-restyle-updates-box.html@@ -15,7 +15,7 @@println(`${label}: width=${style.width} background=${style.backgroundColor} box.width=${box.getBoundingClientRect().width}`);};internals.updateStyle();- const coldPasses = internals.styleLiveReport(false).coldPasses;+ internals.beginStyleTrace();read("initial");// The render clock hovers on a fork of the render state, which goes on with the style engine// it forked, without a cold pass of its own.@@ -24,7 +24,7 @@return internals.presentedBorderBox(box)?.width;});println(`hovered by the render clock: box width on screen=${onScreen}`);- println(`cold passes since: ${internals.styleLiveReport(false).coldPasses - coldPasses}`);+ println(`style restarted from a cold pass: ${internals.takeStyleTrace().includes("style COLD")}`);internals.mouseMove(20, 20);read("hovered");internals.mouseMove(300, 300);diff --git a/Tests/LibWeb/Text/input/css/style-engine/inherited-color-mix-resolves-against-own-color.html b/Tests/LibWeb/Text/input/css/style-engine/inherited-color-mix-resolves-against-own-color.htmlindex 0feb1b490a3..b28cfd0e462 100644--- a/Tests/LibWeb/Text/input/css/style-engine/inherited-color-mix-resolves-against-own-color.html+++ b/Tests/LibWeb/Text/input/css/style-engine/inherited-color-mix-resolves-against-own-color.html@@ -23,7 +23,7 @@// them declares those colors. The elements hold groups no other element of a different color may share.asyncTest(async done => {const frames = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));- const report = label => println(`${label}: differences from a cold pass: ${internals.styleColdPass().differences}`);+ const report = label => println(`${label}: self-check: [${internals.styleSelfCheck().join("; ")}]`);await frames();report("start");third.classList.add("moved");diff --git a/Tests/LibWeb/Text/input/css/style-engine/install-same-custom-property-values.html b/Tests/LibWeb/Text/input/css/style-engine/install-same-custom-property-values.htmlindex 47866255e2e..7eb4703dd1a 100644--- a/Tests/LibWeb/Text/input/css/style-engine/install-same-custom-property-values.html+++ b/Tests/LibWeb/Text/input/css/style-engine/install-same-custom-property-values.html@@ -31,9 +31,9 @@const style = getComputedStyle(child);if (`${style.color} ${style.width}` !== styles[child.classList[0]]) wrong++;}- const cold = internals.styleColdPass(true);+ const selfCheck = internals.styleSelfCheck();println(`${label}: ${holder.children.length} children, ${wrong} with the style of another`);- println(`${label}: ${cold.differences} installed differently from a cold pass`);+ println(`${label}: self-check: [${selfCheck.join("; ")}]`);};internals.updateStyle();diff --git a/Tests/LibWeb/Text/input/css/style-engine/language-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/language-mutations.htmlindex 611f4363d85..91c4e57380b 100644--- a/Tests/LibWeb/Text/input/css/style-engine/language-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/language-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style>:lang(fr) { color: green }diff --git a/Tests/LibWeb/Text/input/css/style-engine/large-restyle-batch.html b/Tests/LibWeb/Text/input/css/style-engine/large-restyle-batch.htmlindex 89580e57a69..8cf84cf8f3d 100644--- a/Tests/LibWeb/Text/input/css/style-engine/large-restyle-batch.html+++ b/Tests/LibWeb/Text/input/css/style-engine/large-restyle-batch.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style>.theme .item { color: green }@@ -14,11 +15,10 @@guard.appendChild(item);}- planSetup();- guard.classList.add("theme");- const result = planPass();- println(`full pass: ${result.fullPass}`);- println(`changed elements: ${result.changed.length}`);- println(`styled <= 1100: ${result.styled.length <= 1100}`);+ const work = styleWork(() => guard.classList.add("theme"));+ const isItem = element => /^div\.item(@\d+)?$/.test(element);+ println(`passes: ${work.passes().join(" | ")}`);+ println(`every item changed: ${work.changed().length === 1100 && work.changed().every(isItem)}`);+ println(`restyled besides the items: [${work.restyled().filter(element => !isItem(element)).join(", ")}]`);});</script>diff --git a/Tests/LibWeb/Text/input/css/style-engine/live-default-state-fact.html b/Tests/LibWeb/Text/input/css/style-engine/live-default-state-fact.htmlindex 145a179979d..567049699b1 100644--- a/Tests/LibWeb/Text/input/css/style-engine/live-default-state-fact.html+++ b/Tests/LibWeb/Text/input/css/style-engine/live-default-state-fact.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style>#checkbox:default + #checkbox-subject { color: green }diff --git a/Tests/LibWeb/Text/input/css/style-engine/live-state-facts.html b/Tests/LibWeb/Text/input/css/style-engine/live-state-facts.htmlindex d360b1b4c71..4d024552f10 100644--- a/Tests/LibWeb/Text/input/css/style-engine/live-state-facts.html+++ b/Tests/LibWeb/Text/input/css/style-engine/live-state-facts.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style>#checkbox:indeterminate + #indeterminate-subject { color: green }@@ -60,7 +61,7 @@plan("make subtree editable", () => editable.contentEditable = "true");plan("make subtree non-editable", () => editable.contentEditable = "false");- planSetup();+ internals.updateStyle();document.designMode = "on";println(`design mode makes elements read-write: ${getComputedStyle(document.getElementById("design-mode-subject")).color}`);document.designMode = "off";diff --git a/Tests/LibWeb/Text/input/css/style-engine/local-action-document-scale.html b/Tests/LibWeb/Text/input/css/style-engine/local-action-document-scale.htmlindex 87ac8ee6487..8af231d2db4 100644--- a/Tests/LibWeb/Text/input/css/style-engine/local-action-document-scale.html+++ b/Tests/LibWeb/Text/input/css/style-engine/local-action-document-scale.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><style>#target.active { color: red }</style>@@ -19,21 +20,9 @@toggleActive(true);toggleActive(false);- internals.resetStyleCounters();- toggleActive(true);- const counters = internals.styleCounters();- const lastPass = internals.styleLastPass();+ const work = styleWork(() => target.classList.toggle("active", true));toggleActive(false);- return {- passes: counters.passes,- fullPasses: counters.fullPasses,- styled: lastPass.styled,- changed: lastPass.changed,- hintedElements: counters.hintedElements,- hintedSubtrees: counters.hintedSubtrees,- invalidationVisits: counters.invalidationVisits,- invalidationTests: counters.invalidationTests,- };+ return work;}function growTo(size) {@@ -56,14 +45,11 @@measurements.push(measureAddition());}- const baseline = JSON.stringify(measurements[0]);- println(`one pass: ${measurements[0].passes}`);- println(`no full pass: ${measurements[0].fullPasses}`);- println(`styled: ${measurements[0].styled}`);- println(`changed: ${measurements[0].changed}`);- println(`one hinted element: ${measurements[0].hintedElements}`);- println(`no hinted subtree: ${measurements[0].hintedSubtrees}`);- println(`physical work is document-scale invariant: ${measurements.every(measurement => JSON.stringify(measurement) === baseline)}`);+ const baseline = measurements[0];+ println(`passes: ${baseline.passes().join(" | ") || "(no pass)"}`);+ println(`restyled: [${baseline.restyled().map(shortStyleName).join(", ")}]`);+ println(`changed: [${baseline.changed().map(shortStyleName).join(", ")}]`);+ println(`style work is the same at every document size: ${measurements.every(measurement => measurement.text === baseline.text)}`);println(`largest document elements: ${root.childElementCount}`);});</script>diff --git a/Tests/LibWeb/Text/input/css/style-engine/local-feature-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/local-feature-mutations.htmlindex cb0b6873a7e..6b4e1579fe2 100644--- a/Tests/LibWeb/Text/input/css/style-engine/local-feature-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/local-feature-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style>.theme .item { color: green }@@ -70,9 +71,7 @@// Setting an attribute to the value it already has moves nothing, so nothing is restyled.guard.setAttribute("data-mode", "dark");- planSetup();- guard.setAttribute("data-mode", "dark");- const repeat = planPass();- println(`rewrite with the same value: [${repeat.styled.join(", ")}]`);+ const repeat = styleWork(() => guard.setAttribute("data-mode", "dark"));+ println(`rewrite with the same value: [${repeat.restyled().map(shortStyleName).join(", ")}]`);});</script>diff --git a/Tests/LibWeb/Text/input/css/style-engine/moved-element-neighbour-relations.html b/Tests/LibWeb/Text/input/css/style-engine/moved-element-neighbour-relations.htmlindex a42ae55d539..3d83101975a 100644--- a/Tests/LibWeb/Text/input/css/style-engine/moved-element-neighbour-relations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/moved-element-neighbour-relations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style>.moved + .subject { color: green }diff --git a/Tests/LibWeb/Text/input/css/style-engine/part-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/part-mutations.htmlindex 13c743a93ac..99e1021ce26 100644--- a/Tests/LibWeb/Text/input/css/style-engine/part-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/part-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style>#host::part(panel) { color: green }diff --git a/Tests/LibWeb/Text/input/css/style-engine/plan.js b/Tests/LibWeb/Text/input/css/style-engine/plan.jsindex 30301fe3e07..620cfb54301 100644--- a/Tests/LibWeb/Text/input/css/style-engine/plan.js+++ b/Tests/LibWeb/Text/input/css/style-engine/plan.js@@ -2,29 +2,20 @@//// Every way the engine's inputs can move should be provable twice over: that the mutation reaches// the engine at all, and that the elements it changes are exactly the ones whose style it moves.-// The plan names the elements whose records the style pass after the mutation changed.+// The plan names the elements whose records the style passes after the mutation changed. Tests load+// work-test.js before this file.-// Settle everything before the mutation under test, so the pass after it describes that mutation-// and no other. Forcing layout is not enough: layout that is already clean does not flush style,-// and whether it happens to be clean depends on what else the page has been doing. Resetting the-// counters forgets the last pass, so a mutation that restyles nothing reports nothing.-function planSetup() {- internals.updateStyle();- internals.resetStyleCounters();-}--// Run the style pass for the mutations since planSetup(), and report it as { fullPass, styled,-// changed }.-function planPass() {- internals.updateStyle();- return internals.styleLastPass();-}--// Run `mutate`, then report the elements whose records changed.+// Run `mutate`, then report the elements whose records the style passes after it changed, the elements they restyled+// without changing them, and whether one of the passes restyled every element. Everything before the mutation is+// settled first, so the passes describe that mutation and no other.function plan(name, mutate) {- planSetup();- mutate();- println(`${name}: [${planPass().changed.join(", ")}]`);+ const work = styleWork(mutate);+ const changed = work.changed();+ const unchanged = work.restyled().filter(element => !changed.includes(element));+ let line = `${name}: [${changed.map(shortStyleName).join(", ")}]`;+ if (unchanged.length) line += ` + unchanged [${unchanged.map(shortStyleName).join(", ")}]`;+ if (work.passes().includes("FULL")) line += " (full pass)";+ println(line);}function make(tagName, id, options = {}) {diff --git a/Tests/LibWeb/Text/input/css/style-engine/positional-an-plus-b-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/positional-an-plus-b-mutations.htmlindex 5e9bcdd9a0f..9ba1d756be8 100644--- a/Tests/LibWeb/Text/input/css/style-engine/positional-an-plus-b-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/positional-an-plus-b-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><script>test(() => {diff --git a/Tests/LibWeb/Text/input/css/style-engine/positional-move-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/positional-move-mutations.htmlindex acd3e2ad77a..ea00475f921 100644--- a/Tests/LibWeb/Text/input/css/style-engine/positional-move-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/positional-move-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><script>// A `moveBefore()` within one parent is the only mutation that gives an element a new place in adiff --git a/Tests/LibWeb/Text/input/css/style-engine/positional-of-type-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/positional-of-type-mutations.htmlindex 065e5bbaf5f..94a5d15bc6f 100644--- a/Tests/LibWeb/Text/input/css/style-engine/positional-of-type-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/positional-of-type-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><script>test(() => {diff --git a/Tests/LibWeb/Text/input/css/style-engine/restyle-basic.html b/Tests/LibWeb/Text/input/css/style-engine/restyle-basic.htmlindex 9d151e4a248..ca7929aecfe 100644--- a/Tests/LibWeb/Text/input/css/style-engine/restyle-basic.html+++ b/Tests/LibWeb/Text/input/css/style-engine/restyle-basic.html@@ -34,6 +34,7 @@<div class="item"><div><span class="leaf">4</span></div></div></div><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script>test(() => {const root = document.getElementById("root");@@ -43,7 +44,6 @@// next pass, which restyles everything. The steps count from after it.root.setAttribute("data-settled", "");internals.updateStyle();- const before = internals.styleLiveReport(false);const steps = [() => root.classList.add("a"),() => items()[1].classList.add("on"),@@ -69,14 +69,13 @@() => root.lastElementChild.after(Object.assign(document.createElement("div"), { className: "item" })),() => root.querySelector("p").remove(),];- for (const step of steps) {- step();- internals.updateStyle();- }- const report = internals.styleLiveReport(true);- println(`full passes: ${report.fullPasses - before.fullPasses}`);- println(`restyled fewer elements than a full pass each: ${report.styledElements - before.styledElements < (report.passes - before.passes) * report.verifiedElements}`);- println(`missing records: ${report.missingRecords}`);- println(`differences: ${report.differences}`);+ const lines = [];+ steps.forEach((step, index) => {+ const work = styleWork(step);+ lines.push(`step ${index + 1}: ${work.passes().join(" | ") || "(no pass)"} [${work.restyled().map(shortStyleName).join(", ")}]`);+ });+ lines.push(`self-check: [${internals.styleSelfCheck().join("; ")}]`);+ for (const line of lines)+ println(line);});</script>diff --git a/Tests/LibWeb/Text/input/css/style-engine/restyle-shadow.html b/Tests/LibWeb/Text/input/css/style-engine/restyle-shadow.htmlindex 44d4d7a1aa6..04ac4e1791c 100644--- a/Tests/LibWeb/Text/input/css/style-engine/restyle-shadow.html+++ b/Tests/LibWeb/Text/input/css/style-engine/restyle-shadow.html@@ -10,6 +10,7 @@<x-host id="card"><b class="light" slot="named">named</b><i class="light">default</i></x-host><x-outer id="outer"></x-outer><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script>test(() => {const card = document.getElementById("card");@@ -44,7 +45,6 @@// next pass, which restyles everything. The steps count from after it.document.documentElement.setAttribute("data-settled", "");internals.updateStyle();- const before = internals.styleLiveReport(false);const steps = [() => document.getElementById("later").attachShadow({ mode: "open" }).innerHTML =`<span part="label"><slot></slot></span>`,@@ -63,13 +63,13 @@() => adopted.disabled = true,() => outerRoot.querySelector("b").classList.add("y"),];- for (const step of steps) {- step();- internals.updateStyle();- }- const report = internals.styleLiveReport(true);- println(`full passes: ${report.fullPasses - before.fullPasses}`);- println(`missing records: ${report.missingRecords}`);- println(`differences: ${report.differences}`);+ const lines = [];+ steps.forEach((step, index) => {+ const work = styleWork(step);+ lines.push(`step ${index + 1}: ${work.passes().join(" | ") || "(no pass)"} [${work.restyled().map(shortStyleName).join(", ")}]`);+ });+ lines.push(`self-check: [${internals.styleSelfCheck().join("; ")}]`);+ for (const line of lines)+ println(line);});</script>diff --git a/Tests/LibWeb/Text/input/css/style-engine/rule-inserted-after-attach-reaches-engine.html b/Tests/LibWeb/Text/input/css/style-engine/rule-inserted-after-attach-reaches-engine.htmlindex ca113c25f90..1079b3c6748 100644--- a/Tests/LibWeb/Text/input/css/style-engine/rule-inserted-after-attach-reaches-engine.html+++ b/Tests/LibWeb/Text/input/css/style-engine/rule-inserted-after-attach-reaches-engine.html@@ -1,23 +1,22 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><style id="sheet"></style><div id="target" tabindex="0"><span id="item"></span></div><script>test(() => {const sheet = document.getElementById("sheet").sheet;const item = document.getElementById("item");- internals.updateStyle();- internals.resetStyleCounters();// The sheet was empty when it attached. A rule inserted afterwards still has to reach the// engine, or focusing #target routes to nothing and #item keeps the colour it started with.- sheet.insertRule("#target:focus #item { color: rgb(0, 128, 0) }");- document.getElementById("target").focus({ preventScroll: true });- internals.updateStyle();- const pass = internals.styleLastPass();- println(`full pass: ${pass.fullPass}`);- println(`changed: [${pass.changed.join(", ")}]`);- println(`styled only what changed: ${pass.styled.join() === pass.changed.join()}`);+ const work = styleWork(() => {+ sheet.insertRule("#target:focus #item { color: rgb(0, 128, 0) }");+ document.getElementById("target").focus({ preventScroll: true });+ });+ println(`passes: ${work.passes().join(" | ") || "(no pass)"}`);+ println(`changed: [${work.changed().map(shortStyleName).join(", ")}]`);+ println(`restyled but unchanged: [${work.restyled().filter(element => !work.changed().includes(element)).map(shortStyleName).join(", ")}]`);println(`item color: ${getComputedStyle(item).color}`);diff --git a/Tests/LibWeb/Text/input/css/style-engine/rule-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/rule-mutations.htmlindex 8c4f249ac8f..9ed88d0956a 100644--- a/Tests/LibWeb/Text/input/css/style-engine/rule-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/rule-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style id="sheet">.item { color: green }diff --git a/Tests/LibWeb/Text/input/css/style-engine/sheet-attachment-plan.html b/Tests/LibWeb/Text/input/css/style-engine/sheet-attachment-plan.htmlindex 225b3af5fe2..6502ccff80a 100644--- a/Tests/LibWeb/Text/input/css/style-engine/sheet-attachment-plan.html+++ b/Tests/LibWeb/Text/input/css/style-engine/sheet-attachment-plan.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><div id="guard" class="guard"><div id="inside" class="target"></div>diff --git a/Tests/LibWeb/Text/input/css/style-engine/sheet-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/sheet-mutations.htmlindex db5829fb7c3..88e8912a3a3 100644--- a/Tests/LibWeb/Text/input/css/style-engine/sheet-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/sheet-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style id="present">.item { color: green }diff --git a/Tests/LibWeb/Text/input/css/style-engine/slot-assignment-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/slot-assignment-mutations.htmlindex 9fa7f7329d0..586dd42f368 100644--- a/Tests/LibWeb/Text/input/css/style-engine/slot-assignment-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/slot-assignment-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><div id="host"><span id="a" class="hit"></span><span id="b"></span></div><script>diff --git a/Tests/LibWeb/Text/input/css/style-engine/slotted-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/slotted-mutations.htmlindex df2db3bc505..f8e4851d6a8 100644--- a/Tests/LibWeb/Text/input/css/style-engine/slotted-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/slotted-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><div id="host"></div><input id="outside">diff --git a/Tests/LibWeb/Text/input/css/style-engine/state-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/state-mutations.htmlindex 521931a9258..92fdea37c81 100644--- a/Tests/LibWeb/Text/input/css/style-engine/state-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/state-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style>#guard:focus .item { color: green }diff --git a/Tests/LibWeb/Text/input/css/style-engine/top-layer-state-does-not-dirty-style.html b/Tests/LibWeb/Text/input/css/style-engine/top-layer-state-does-not-dirty-style.htmlindex 76acb4b43bb..2849ff9a490 100644--- a/Tests/LibWeb/Text/input/css/style-engine/top-layer-state-does-not-dirty-style.html+++ b/Tests/LibWeb/Text/input/css/style-engine/top-layer-state-does-not-dirty-style.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><style>#popover { color: rgb(1, 2, 3); }#popover:popover-open { color: rgb(4, 5, 6); }@@ -8,22 +9,21 @@<script>test(() => {const popover = document.getElementById("popover");- internals.updateStyle();+ const output = [];+ const restyledNames = work => `[${work.restyled().map(shortStyleName).join(", ")}]`;+ let color;+ const readColor = () => styleWork(() => color = getComputedStyle(popover).color, internals, { flush: false });- internals.resetStyleCounters();- popover.showPopover();- internals.updateStyle();- println(`shown styled: ${internals.styleLastPass().styled}`);- internals.resetStyleCounters();- println("shown color: " + getComputedStyle(popover).color);- println(`shown read styled: ${internals.styleCounters().styledElements}`);+ output.push(`shown restyled: ${restyledNames(styleWork(() => popover.showPopover()))}`);+ const shownRead = readColor();+ output.push("shown color: " + color);+ output.push(`shown read restyled: ${restyledNames(shownRead)}`);- internals.resetStyleCounters();- popover.hidePopover();- internals.updateStyle();- println(`hidden styled: ${internals.styleLastPass().styled}`);- internals.resetStyleCounters();- println("hidden color: " + getComputedStyle(popover).color);- println(`hidden read styled: ${internals.styleCounters().styledElements}`);+ output.push(`hidden restyled: ${restyledNames(styleWork(() => popover.hidePopover()))}`);+ const hiddenRead = readColor();+ output.push("hidden color: " + color);+ output.push(`hidden read restyled: ${restyledNames(hiddenRead)}`);+ for (const line of output)+ println(line);});</script>diff --git a/Tests/LibWeb/Text/input/css/style-engine/tree-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/tree-mutations.htmlindex e90fa7acec0..83e00539dca 100644--- a/Tests/LibWeb/Text/input/css/style-engine/tree-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/tree-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style>#list > .row:first-child { color: green }diff --git a/Tests/LibWeb/Text/input/css/style-engine/unroutable-subject-mutations.html b/Tests/LibWeb/Text/input/css/style-engine/unroutable-subject-mutations.htmlindex 3f291e4db32..5c9e0c04f9d 100644--- a/Tests/LibWeb/Text/input/css/style-engine/unroutable-subject-mutations.html+++ b/Tests/LibWeb/Text/input/css/style-engine/unroutable-subject-mutations.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script src="plan.js"></script><style id="sheet">.settled { color: green }diff --git a/Tests/LibWeb/Text/input/css/style-invalidation/animated-custom-property-stops-where-descendants-reset-it.html b/Tests/LibWeb/Text/input/css/style-invalidation/animated-custom-property-stops-where-descendants-reset-it.htmlindex 1f02a0e8136..a5a47a83917 100644--- a/Tests/LibWeb/Text/input/css/style-invalidation/animated-custom-property-stops-where-descendants-reset-it.html+++ b/Tests/LibWeb/Text/input/css/style-invalidation/animated-custom-property-stops-where-descendants-reset-it.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><style>@property --turn {syntax: "<angle>";@@ -59,13 +60,7 @@div.appendChild(document.createElement("span")).className = "reader";}- const step = (animation, currentTime) => {- internals.updateStyle();- internals.resetStyleCounters();- animation.currentTime = currentTime;- internals.updateStyle();- return internals.styleLastPass().styled;- };+ const step = (animation, currentTime) => styleWork(() => animation.currentTime = currentTime);const animationOf = id => document.getElementById(id).getAnimations()[0];internals.updateStyle();@@ -79,11 +74,14 @@step(animationOf("reading"), 500);println(`deep reader after a step: ${getComputedStyle(document.getElementById("deep-reader")).rotate}`);- const styled = step(animationOf("resetting"), 250);+ const work = step(animationOf("resetting"), 250);// FIXME: Only the animated element and the child that resets the property should compute again, and// no element below that child, but the style engine restyles every element below it too.- const styledBelowReset = styled.filter(name => name !== "resetting" && name !== "reset-child").length;- println(`elements below the reset restyled: ${styledBelowReset}`);+ const belowReset = name => name !== "resetting" && name !== "reset-child";+ const restyledBelowReset = work.restyled().map(shortStyleName).filter(belowReset);+ const keptBelowReset = work.events.filter(event => event.outcome === "kept").map(event => shortStyleName(event.element)).filter(belowReset);+ println(`elements below the reset restyled: [${restyledBelowReset.join(", ")}]`);+ println(`elements below the reset kept: [${keptBelowReset.join(", ")}]`);println(`reader below the reset: ${getComputedStyle(resetChild.querySelector(".reader")).rotate}`);// An element declaring a registered custom property resolves its environment anew on every computation, whichdiff --git a/Tests/LibWeb/Text/input/css/style-invalidation/user-style-change-restyles-only-readers-in-shadow-trees.html b/Tests/LibWeb/Text/input/css/style-invalidation/user-style-change-restyles-only-readers-in-shadow-trees.htmlindex e5543e02720..50a31ea04b8 100644--- a/Tests/LibWeb/Text/input/css/style-invalidation/user-style-change-restyles-only-readers-in-shadow-trees.html+++ b/Tests/LibWeb/Text/input/css/style-invalidation/user-style-change-restyles-only-readers-in-shadow-trees.html@@ -4,6 +4,7 @@@keyframes probe { from { opacity: 0.5; } to { opacity: 0.5; } }</style><script src="../../include.js"></script>+<script src="../../work-test.js"></script><div id="plainHost"></div><div id="sheetHost"></div><script>@@ -16,23 +17,16 @@sheet.replaceSync(".other { width: 10px; }");sheetRoot.adoptedStyleSheets = [sheet];sheetRoot.innerHTML = `<div id="sheetReader" class="reader">x</div><div id="sheetOther" class="other">x</div>`;- const ids = ["plainReader", "plainOther", "plainAnimated", "sheetReader", "sheetOther"];const element = id => plainRoot.getElementById(id) || sheetRoot.getElementById(id);- const report = label => {- const styled = internals.styleLastPass().styled;- println(`${label}: styled ${ids.filter(id => styled.includes(id)).join(" ") || "none"}`);+ const report = (label, work) => {+ println(`${label}: restyled [${work.restyled().map(shortStyleName).join(", ")}]`);println(`${label}: readers ${getComputedStyle(element("plainReader")).color} ${getComputedStyle(element("sheetReader")).color}, animated opacity=${getComputedStyle(element("plainAnimated")).opacity}`);};- internals.updateStyle();// A user rule reaches the shadow trees' elements it matches, and its keyframes the// animations naming them, while the other elements keep their styles.- internals.setUserStyle(".reader { color: rgb(1, 2, 3); } @keyframes probe { from { opacity: 0.25; } to { opacity: 0.25; } }");- internals.updateStyle();- report("with a user style");+ report("with a user style", styleWork(() => internals.setUserStyle(".reader { color: rgb(1, 2, 3); } @keyframes probe { from { opacity: 0.25; } to { opacity: 0.25; } }")));- internals.setUserStyle("");- internals.updateStyle();- report("after the user style");+ report("after the user style", styleWork(() => internals.setUserStyle("")));});</script>diff --git a/Tests/LibWeb/Text/input/css/style-invalidation/viewport-resize-restyles-axis-readers.html b/Tests/LibWeb/Text/input/css/style-invalidation/viewport-resize-restyles-axis-readers.htmlindex 9d410508000..fa7948fdd28 100644--- a/Tests/LibWeb/Text/input/css/style-invalidation/viewport-resize-restyles-axis-readers.html+++ b/Tests/LibWeb/Text/input/css/style-invalidation/viewport-resize-restyles-axis-readers.html@@ -1,5 +1,6 @@<!DOCTYPE html><script src="../../include.js"></script>+<script src="../../work-test.js"></script><script>function animationFrame() {return new Promise(resolve => requestAnimationFrame(resolve));@@ -41,18 +42,19 @@const resize = async (label, property, value) => {child.internals.updateStyle();child.document.body.offsetWidth;+ child.internals.beginStyleTrace();iframe.style[property] = value;document.body.offsetWidth;await animationFrame();child.document.body.offsetWidth;child.internals.updateStyle();- const styled = child.internals.styleLastPass().styled;+ const restyled = [...new Set(parseStyleTrace(child.internals.takeStyleTrace(), { stylePassesOnly: true }).filter(event => event.event === "restyle" && event.outcome !== "kept").map(event => shortStyleName(event.element)))];const sizes = ids.map(id => {const property = id.toLowerCase().includes("height") ? "height" : "width";return `${id}=${child.getComputedStyle(child.document.getElementById(id))[property]}`;});println(`${label}: ${sizes.join(" ")}`);- println(`${label} styled: ${ids.filter(id => styled.includes(id)).join(" ")}`);+ println(`${label} restyled: [${restyled.join(", ")}]`);};await resize("width only", "width", "500px");diff --git a/Tests/LibWeb/Text/input/css/stylesheet-add-remove-imported-broad-invalidation.html b/Tests/LibWeb/Text/input/css/stylesheet-add-remove-imported-broad-invalidation.htmlindex 776f06d70ce..3cbaf1e0466 100644--- a/Tests/LibWeb/Text/input/css/stylesheet-add-remove-imported-broad-invalidation.html+++ b/Tests/LibWeb/Text/input/css/stylesheet-add-remove-imported-broad-invalidation.html@@ -1,33 +1,23 @@<!DOCTYPE html><script src="../include.js"></script>+<script src="../work-test.js"></script><div id="target">target</div><script>- function settleAndReset(triggerElement) {+ function settleAndBeginTrace(triggerElement) {getComputedStyle(triggerElement).color;getComputedStyle(triggerElement).color;internals.updateStyle();- internals.resetStyleCounters();+ internals.beginStyleTrace();}- // Print whether the style engine styled at most `maximum` elements since its counters were reset, or,- // without a bound, how many it styled.- function verifyStyledStaysBounded(label, maximum) {- const styled = internals.styleCounters().styledElements;- if (maximum === undefined)- println(`${label}, styled: ${styled}`);- else- println(`${label}, styled <= ${maximum}: ${styled <= maximum}`);- }-- // The same for the last pass alone. Where a style element arrives with an @import, the style engine- // restyles for the element and for the imported sheet in one pass or in two, depending on when- // the import loads, so only the pass that took the imported sheet is counted.- function verifyLastPassStaysBounded(label, maximum) {- const lastPass = internals.styleLastPass();- if (maximum === undefined)- println(`${label}, last pass styled: ${lastPass.styled.length}`);- else- println(`${label}, last pass styled <= ${maximum}: ${lastPass.styled.length <= maximum}`);+ // Print the elements the passes since the trace began restyled, and whether one of them restyled every element.+ // Where a style element arrives with an @import, the style engine restyles for the element and for the imported+ // sheet in one pass or in two, depending on when the import loads, so the passes are not told apart.+ function verifyRestyled(label, trace = internals.takeStyleTrace()) {+ const events = parseStyleTrace(trace, { stylePassesOnly: true });+ const restyled = [...new Set(events.filter(event => event.event === "restyle" && event.outcome !== "kept").map(event => shortStyleName(event.element)))];+ const fullPass = events.some(event => event.event === "pass" && event.kind === "FULL");+ println(`${label}, restyled: [${restyled.join(", ")}]${fullPass ? " (full pass)" : ""}`);}function verifyTargetWasRecomputed(label) {@@ -45,7 +35,7 @@promiseTest(async () => {const target = document.getElementById("target");- settleAndReset(target);+ settleAndBeginTrace(target);const layerImportStyle = document.createElement("style");layerImportStyle.textContent = `@import "data:text/css;base64,${btoa("@layer B, A;")}";`;@@ -54,27 +44,27 @@getComputedStyle(target).color;// A layer order change can only move declarations that sit in layers, and nothing here does.- verifyLastPassStaysBounded("imported layer-only stylesheet add restyles nothing", 1);+ verifyRestyled("imported layer-only stylesheet add restyles nothing");- settleAndReset(target);+ settleAndBeginTrace(target);layerImportStyle.remove();getComputedStyle(target).color;- verifyStyledStaysBounded("imported layer-only stylesheet remove restyles nothing", 1);+ verifyRestyled("imported layer-only stylesheet remove restyles nothing");// With a declaration in a layer, reordering the layers has to reach the element it decides// for - and still not the whole document.const layeredStyle = document.createElement("style");layeredStyle.textContent = "@layer A, B; @layer A { #target { color: green } } @layer B { #target { color: blue } }";document.head.appendChild(layeredStyle);- settleAndReset(target);+ settleAndBeginTrace(target);document.head.insertBefore(layerImportStyle, layeredStyle);await waitForImportedSheet(layerImportStyle);getComputedStyle(target).color;+ const reorderTrace = internals.takeStyleTrace();verifyTargetWasRecomputed("imported layer reorder reaches the layered element");- verifyLastPassStaysBounded("imported layer reorder stays bounded", 8);- println(`imported layer reorder runs no full pass: ${!internals.styleLastPass().fullPass}`);+ verifyRestyled("imported layer reorder restyles only the layered element", reorderTrace);});</script>diff --git a/Tests/LibWeb/Text/input/css/user-agent-declarations-intern-once-per-process.html b/Tests/LibWeb/Text/input/css/user-agent-declarations-intern-once-per-process.htmlindex dfc01f38233..476d50ff5d9 100644--- a/Tests/LibWeb/Text/input/css/user-agent-declarations-intern-once-per-process.html+++ b/Tests/LibWeb/Text/input/css/user-agent-declarations-intern-once-per-process.html@@ -1,6 +1,7 @@<!DOCTYPE html><script src="../include.js"></script>-<iframe srcdoc="<p>x</p>"></iframe>+<script src="../work-test.js"></script>+<iframe srcdoc="<script>internals.beginStyleTrace()</script><p>x</p>"></iframe><script>// Have this document attach the user agent sheets, which has the process keep their rules.internals.updateStyle();@@ -10,8 +11,9 @@// The frame reads the rules the process keeps, without recording or interning any of them itself.const p = iframe.contentDocument.querySelector("p");println(`margin-top from the user-agent sheet: ${iframe.contentWindow.getComputedStyle(p).marginTop}`);- const counters = iframe.contentWindow.internals.styleEngineCounters();- println(`declarations the frame published: ${counters.sheetDeclarationsInterned + counters.sheetDeclarationsShared}`);+ iframe.contentWindow.internals.updateStyle();+ const program = parseStyleTrace(iframe.contentWindow.internals.takeStyleTrace()).filter(event => event.event === "program");+ println(`what the frame did to its rules: [${program.map(event => (event.times > 1 ? `${event.name} x${event.times}` : event.name)).join(", ")}]`);done();};});diff --git a/Tests/LibWeb/Text/input/work-test.js b/Tests/LibWeb/Text/input/work-test.jsindex 41d49d9edc1..dde6514fe37 100644--- a/Tests/LibWeb/Text/input/work-test.js+++ b/Tests/LibWeb/Text/input/work-test.js@@ -38,6 +38,12 @@ function loadFixture(html) {// The traced stages in pipeline order. Settling a stage brings every stage before it up to date as well.const workStages = [+ {+ name: "style",+ begin: testInternals => testInternals.beginStyleTrace(),+ take: testInternals => testInternals.takeStyleTrace(),+ settle: testInternals => testInternals.updateStyle(),+ },{name: "layout",begin: testInternals => testInternals.beginLayoutTrace(),@@ -155,6 +161,10 @@ function layoutTest(spec) {workTest(spec, { stage: "layout" });}+function styleTest(spec) {+ workTest(spec, { stage: "style" });+}+function displayListTest(spec) {workTest(spec, { stage: "displayList", hideOutputAfterSetup: true });}@@ -248,3 +258,84 @@ function layoutWork(mutate, testInternals = internals, options = {}) {passes: () => matching({ event: "layout" }).map(event => (event.partial ? `PARTIAL ${event.box}` : "FULL")),};}++// Parses a style trace into one event per line:+// pass `kind` ("FULL", "PARTIAL", "COLD", "ANIMATION" for the animation samples the host composed, or+// "PROGRAM" for what the engine did to the rules it styles from)+// program `name` of what the engine did to its rules, `times` it did so in a row+// restyle `element`, `outcome` ("computed", "shared", "reused", "declined", "kept" for an element that only took+// the custom properties its parent hands down now, "sampled" or "sampled every group" in an ANIMATION+// block), `changed`+// With `stylePassesOnly`, the PROGRAM and ANIMATION blocks are left out.+function parseStyleTrace(text, { stylePassesOnly = false } = {}) {+ const events = [];+ for (const line of text.replace(/\r/g, "").split("\n")) {+ if (!line.trim()) continue;+ let match = line.match(/^style (FULL|PARTIAL|COLD|ANIMATION|PROGRAM)$/);+ if (match) {+ events.push({ event: "pass", kind: match[1] });+ continue;+ }+ match = line.match(+ /^ ((?:rule index|user agent rule index|selectors|style rules|sheet declarations) [a-z ]+?)(?: x(\d+))?$/+ );+ if ((match && events.at(-1)?.kind === "PROGRAM") || (match && events.at(-1)?.event === "program")) {+ events.push({ event: "program", name: match[1], times: match[2] ? Number(match[2]) : 1 });+ continue;+ }+ match = line.match(/^ (\S+)(?: \(([^)]*)\))?$/);+ if (!match) throw new Error(`unrecognized style trace line: ${JSON.stringify(line)}`);+ const notes = match[2] ? match[2].split(", ") : [];+ events.push({+ event: "restyle",+ element: match[1],+ outcome: notes.find(note => note !== "changed"),+ changed: notes.includes("changed"),+ });+ }+ if (!stylePassesOnly) return events;+ let inStylePass = false;+ return events.filter(event => {+ if (event.event === "pass") inStylePass = ["FULL", "PARTIAL", "COLD"].includes(event.kind);+ return inStylePass;+ });+}++// The id of a traced element, or its whole name where it has none.+function shortStyleName(element) {+ return element.match(/#([^.@]+)/)?.[1] ?? element;+}++// Settles style, then runs `mutate` and settles style again, tracing only the passes the mutation causes. Answers the+// trace and its events, with queries over them.+function styleWork(mutate, testInternals = internals, options = {}) {+ const text = traceWork("style", mutate, testInternals, options);+ const events = parseStyleTrace(text);+ const matching = filter => events.filter(event => workEventMatches(event, filter));+ const elements = filter => [...new Set(matching(filter).map(event => event.element))];+ return {+ text,+ events,+ count: filter => matching(filter).length,+ // The kinds of the style passes, in order, leaving out the PROGRAM and ANIMATION blocks.+ passes: () =>+ matching(event => event.event === "pass" && ["FULL", "PARTIAL", "COLD"].includes(event.kind)).map(+ event => event.kind+ ),+ // What the engine did to the rules it styles from, in order, each with how many times it did so in a row.+ program: () =>+ matching({ event: "program" }).map(event =>+ event.times > 1 ? `${event.name} x${event.times}` : event.name+ ),+ // The elements whose animations the host composed over their records, each once.+ sampled: () => elements(event => event.event === "restyle" && event.outcome?.startsWith("sampled")),+ // The elements the passes styled, each once, in the order they first appear.+ restyled: () =>+ elements(+ event =>+ event.event === "restyle" && !["kept", "sampled", "sampled every group"].includes(event.outcome)+ ),+ // The elements whose records the passes changed, each once.+ changed: () => elements({ event: "restyle", changed: true }),+ };+}