Skip to content

Truly independent web browser

LibWeb: Dump style records instead of counting style sharing

Aliaksandr Kalenik641314677e98
diff --git a/Libraries/LibWeb/CSS/StyleEngineBridge.h b/Libraries/LibWeb/CSS/StyleEngineBridge.h
index 44ee427ee02..f93d48c9fda 100644
--- a/Libraries/LibWeb/CSS/StyleEngineBridge.h
+++ b/Libraries/LibWeb/CSS/StyleEngineBridge.h
@@ -105,8 +105,6 @@ bool style_engine_pending_transaction_may_affect_layout_geometry(DocumentHost co
void 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_style_counter(DocumentHost const*, BegunRead const*, u32 index);
-bool style_engine_reset_style_counters(DocumentHost const*, BegunRead const*);
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*);
diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cpp
index 6ae6973d2f9..5c450fc9ef1 100644
--- a/Libraries/LibWeb/Internals/Internals.cpp
+++ b/Libraries/LibWeb/Internals/Internals.cpp
@@ -3179,24 +3179,6 @@ GC::Ref<JS::Object> Internals::style_engine_counters()
return object;
}
-u64 Internals::style_record_identity(DOM::Element& element)
-{
- return element.style_record_identity().value();
-}
-
-u64 Internals::custom_property_environment_identity(DOM::Element& element)
-{
- return element.installed_style().custom_property_environment();
-}
-
-u64 Internals::layout_style_record_identity(DOM::Element& element)
-{
- Layout::ForcedReadScope read { element.document() };
- element.document().update_layout(DOM::UpdateLayoutReason::Debugging);
- auto const* layout_node = element.layout_node(read);
- return layout_node ? layout_node->style_record_identity().value() : 0;
-}
-
u64 Internals::layout_node_identity(DOM::Node& node)
{
Layout::ForcedReadScope read { node.document() };
@@ -3314,47 +3296,6 @@ Utf16String Internals::take_style_trace()
return builder.to_string();
}
-GC::Ref<JS::Object> Internals::style_counters()
-{
- // 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 host = window().associated_document().style_computer().style_engine().host();
- // NB: In the order of StyleCounter in the Rust style engine.
- static constexpr Array field_names {
- "passes"sv,
- "fullPasses"sv,
- "styledElements"sv,
- "changedElements"sv,
- "hintedElements"sv,
- "hintedSubtrees"sv,
- "invalidationVisits"sv,
- "invalidationTests"sv,
- "coldPasses"sv,
- "sharedElements"sv,
- "reusedElements"sv,
- "indexBuilds"sv,
- "indexedEntries"sv,
- "compiledSelectors"sv,
- "userAgentIndexBuilds"sv,
- "matchedElements"sv,
- "relativeWalks"sv,
- };
- for (u32 index = 0; index < field_names.size(); ++index) {
- auto value = CSS::StyleEngineFFI::style_engine_style_counter(host, read, index);
- object->define_direct_property(Utf16FlyString::from_utf8(field_names[index]), JS::Value(static_cast<double>(value)), JS::default_attributes);
- }
- return object;
-}
-
-void Internals::reset_style_counters()
-{
- // A script reads the render state, which waits for a frame in flight.
- Layout::ForcedReadScope read { window().associated_document() };
- (void)CSS::StyleEngineFFI::style_engine_reset_style_counters(window().associated_document().style_computer().style_engine().host(), read);
-}
-
// 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)
@@ -3478,25 +3419,67 @@ Utf16String Internals::style_engine_matched_rules()
return builder.to_string();
}
-GC::Ref<JS::Object> Internals::style_group_sharing_info(DOM::Element& element)
+Utf16String Internals::dump_style_records(GC::Ptr<DOM::Node> root, Bindings::StyleRecordsDumpOptions const& options)
{
- auto& realm = HTML::relevant_realm(window());
- auto object = JS::Object::create(realm, nullptr);
- auto computed_values = element.computed_style();
- if (!computed_values)
- return object;
- auto parent = element.parent_element();
- auto parent_values = parent ? parent->computed_style() : CSS::ComputedStyleRecordView {};
- size_t group_index = 0;
- computed_values->for_each_style_group_sharing_state(parent_values ? &*parent_values : nullptr, [&](StringView name, bool shared_with_parent, bool is_default) {
- auto group = JS::Object::create(realm, nullptr);
- group->define_direct_property("sharedWithParent"_utf16_fly_string, JS::Value(shared_with_parent), JS::default_attributes);
- group->define_direct_property("isDefault"_utf16_fly_string, JS::Value(is_default), JS::default_attributes);
- auto* payload = computed_values->style_group_payload(static_cast<CSS::StyleGroupIndex>(group_index++));
- group->define_direct_property("payloadIdentity"_utf16_fly_string, JS::PrimitiveString::create(vm(), Utf16String::from_utf8(MUST(String::formatted("{:p}", payload)))), JS::default_attributes);
- object->define_direct_property(Utf16FlyString::from_utf8(name), group, JS::default_attributes);
- });
- return object;
+ auto& document = window().associated_document();
+ Layout::ForcedReadScope read { document };
+ if (options.layout)
+ document.update_layout(DOM::UpdateLayoutReason::Debugging);
+ else
+ document.update_style();
+ HashMap<u64, size_t> record_numbers;
+ HashMap<u64, size_t> environment_numbers;
+ HashMap<void const*, size_t> payload_numbers;
+ auto number = [](auto& numbers, auto key) { return numbers.ensure(key, [&] { return numbers.size() + 1; }); };
+ StringBuilder builder;
+ Function<void(DOM::Node const&, size_t)> dump = [&](DOM::Node const& node, size_t depth) {
+ auto const* element = as_if<DOM::Element>(node);
+ if (element) {
+ builder.append_repeated(" "sv, depth);
+ builder.appendff("{}", element->debug_description());
+ auto record = element->style_record_identity().value();
+ if (record == 0)
+ builder.append(" no record"sv);
+ else
+ builder.appendff(" record {}", number(record_numbers, record));
+ if (options.custom_property_environments && record != 0) {
+ auto environment = element->installed_style().custom_property_environment();
+ builder.appendff(" environment {}", environment ? number(environment_numbers, environment) : 0);
+ }
+ if (options.layout) {
+ auto const* layout_node = element->layout_node(read);
+ if (!layout_node)
+ builder.append(", no box"sv);
+ else if (auto layout_record = layout_node->style_record_identity().value())
+ builder.appendff(", box record {}", number(record_numbers, layout_record));
+ else
+ builder.append(", box holds no record"sv);
+ }
+ if (options.groups) {
+ if (auto computed_values = element->computed_style()) {
+ auto parent = element->parent_element();
+ auto parent_values = parent ? parent->computed_style() : CSS::ComputedStyleRecordView {};
+ size_t group_index = 0;
+ computed_values->for_each_style_group_sharing_state(parent_values ? &*parent_values : nullptr, [&](StringView name, bool shared_with_parent, bool is_default) {
+ auto const* payload = computed_values->style_group_payload(static_cast<CSS::StyleGroupIndex>(group_index++));
+ if (shared_with_parent)
+ builder.appendff(" {}=parent", name);
+ else if (is_default)
+ builder.appendff(" {}=default", name);
+ else
+ builder.appendff(" {}={}", name, number(payload_numbers, payload));
+ });
+ }
+ }
+ builder.append('\n');
+ if (auto shadow_root = element->shadow_root())
+ dump(*shadow_root, depth + 1);
+ }
+ for (auto const* child = node.first_child(); child; child = child->next_sibling())
+ dump(*child, element ? depth + 1 : depth);
+ };
+ dump(root ? *root : static_cast<DOM::Node const&>(document), 0);
+ return Utf16String::from_utf8_without_validation(builder.string_view());
}
void Internals::update_style()
diff --git a/Libraries/LibWeb/Internals/Internals.h b/Libraries/LibWeb/Internals/Internals.h
index 7a13fffd6be..2b04ba74cb3 100644
--- a/Libraries/LibWeb/Internals/Internals.h
+++ b/Libraries/LibWeb/Internals/Internals.h
@@ -341,18 +341,13 @@ public:
GC::Ref<JS::Object> style_engine_counters();
GC::Ref<JS::Object> style_memory_report();
u64 style_memory_of_frames();
- u64 style_record_identity(DOM::Element&);
- u64 custom_property_environment_identity(DOM::Element&);
- u64 layout_style_record_identity(DOM::Element&);
u64 layout_node_identity(DOM::Node&);
void panic_render_state_for_testing();
- GC::Ref<JS::Object> style_counters();
- void reset_style_counters();
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&);
+ Utf16String dump_style_records(GC::Ptr<DOM::Node> root, Bindings::StyleRecordsDumpOptions const&);
void update_style();
void set_user_style(Utf16String const& source);
void set_preferred_color_scheme(Utf16String const& color_scheme);
diff --git a/Libraries/LibWeb/Internals/Internals.idl b/Libraries/LibWeb/Internals/Internals.idl
index e652d5627e5..91d3dcd6343 100644
--- a/Libraries/LibWeb/Internals/Internals.idl
+++ b/Libraries/LibWeb/Internals/Internals.idl
@@ -433,22 +433,11 @@ interface Internals {
// What the style engines of the document and the documents in its frames hold on the heap, each allocation counted
// once however many of them share it.
unsigned long long styleMemoryOfFrames();
- unsigned long long styleRecordIdentity(Element element);
- unsigned long long customPropertyEnvironmentIdentity(Element element);
- unsigned long long layoutStyleRecordIdentity(Element element);
// Stable for the lifetime of a layout node, and zero when the DOM node has no principal
// layout node. Useful for asserting that incremental tree builds preserve unaffected nodes.
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();
- // 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,
- // reusedElements, indexBuilds, indexedEntries, compiledSelectors, userAgentIndexBuilds (see
- // StyleCounter in pipeline/counters.rs).
- object styleCounters();
- // Zeroes the counters styleCounters() reports and forgets the last pass.
- undefined resetStyleCounters();
// 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();
@@ -461,10 +450,11 @@ interface Internals {
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 the
- // group payload is shared with the parent element, whether it is the default payload,
- // and its identity for comparisons while the computed style remains alive.
- object styleGroupSharingInfo(Element element);
+ // Every element under the root, the document by default, shadow trees included, one per line in tree order indented
+ // by depth: its style record, numbered by first appearance so that elements sharing one show the same number, or "no
+ // record". With options, also the custom property environment it computes under, the record its layout node holds,
+ // and, per group of its computed style, whether it shares its parent's, holds the default, or which payload it holds.
+ DOMString dumpStyleRecords(optional Node? root = null, optional StyleRecordsDumpOptions options = {});
// Flushes pending style work without forcing layout.
undefined updateStyle();
undefined setUserStyle(DOMString source);
@@ -534,6 +524,12 @@ enum SpellingMenuItem { "none", "guess", "ignore", "learn" };
enum ScrollGesturePhase { "none", "ongoing", "momentum", "ended" };
enum MouseEventThroughUIProcessType { "mousedown", "mouseup", "mousemove", "mouseleave" };
+dictionary StyleRecordsDumpOptions {
+ boolean customPropertyEnvironments = false;
+ boolean layout = false;
+ boolean groups = false;
+};
+
// How many wheel ticks a wheel step amounts to on each axis. By default, they are counted from the pixel delta.
dictionary WheelTicks {
double x;
diff --git a/Libraries/LibWeb/Rust/src/css/style/boundary.rs b/Libraries/LibWeb/Rust/src/css/style/boundary.rs
index dfbf77d2dee..0a795a0d81a 100644
--- a/Libraries/LibWeb/Rust/src/css/style/boundary.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/boundary.rs
@@ -507,11 +507,6 @@ style_boundary! {
defer_pending_transaction_for_geometry_read() -> ();
begin_deferred_geometry_transaction_flush() -> bool;
has_deferred_geometry_transaction() -> bool;
- style_counter(index: u32) -> u64 => engine.retained.live_counters.get(index);
- reset_style_counters() -> bool => {
- engine.retained.live_counters.reset();
- true
- };
begin_style_trace() -> bool => {
engine.retained.live_counters.begin_trace();
true
diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/counters.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/counters.rs
index feabb0db816..c695dabfc7c 100644
--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/counters.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/counters.rs
@@ -324,9 +324,8 @@ impl OutcomeCounts {
}
}
-/// 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.
+/// What the engine did on a document's render state, 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],
@@ -412,15 +411,11 @@ impl Counters {
}
/// The counter of index `index` of [`StyleCounter`], or zero for none.
+ #[cfg(test)]
pub(in super::super) fn get(&self, index: u32) -> u64 {
self.counts.get(index as usize).copied().unwrap_or(0)
}
- /// Zero the counters.
- pub(in super::super) fn reset(&mut self) {
- self.counts = [0; StyleCounter::COUNT];
- }
-
/// Start tracing the passes of the engine anew.
pub(in super::super) fn begin_trace(&mut self) {
*self.trace = Some(Default::default());
diff --git a/Tests/LibWeb/Text/expected/css/computed-values-group-sharing.txt b/Tests/LibWeb/Text/expected/css/computed-values-group-sharing.txt
index fd4b2f38ba1..fb562b7fe63 100644
--- a/Tests/LibWeb/Text/expected/css/computed-values-group-sharing.txt
+++ b/Tests/LibWeb/Text/expected/css/computed-values-group-sharing.txt
@@ -1,21 +1,7 @@
-unstyled child animation at default: true
-unstyled child grid at default: true
-unstyled child svgReset at default: true
-unstyled child mask at default: true
-unstyled child anchor at default: true
-unstyled child content at default: true
-unstyled child transform at default: true
-unstyled child effects at default: true
-unstyled child inheritedListTable at default: true
-unstyled child inheritedSVG at default: true
-color-styled child inheritedText at default: false
-color-styled child inheritedText shared with parent: false
-color-styled child grid still at default: true
-grid-styled child grid at default: false
-unstyled-again child inheritedListTable shared with parent: true
-unstyled-again child inheritedText shared with parent: true
-unstyled-again child font shared with parent: true
-unstyled-again child inheritedUI shared with parent: true
+unstyled child: div#child record 1 inheritedListTable=parent inheritedUI=parent inheritedSVG=parent inheritedText=parent font=parent animation=parent svgReset=parent grid=parent anchor=parent content=parent alignment=parent miscLayout=parent miscInteraction=parent effects=parent mask=parent textReset=parent transform=parent background=parent border=parent sizing=parent surround=parent box=parent
+color-styled child: div#child record 1 inheritedListTable=parent inheritedUI=parent inheritedSVG=parent inheritedText=1 font=parent animation=parent svgReset=parent grid=parent anchor=parent content=parent alignment=parent miscLayout=parent miscInteraction=parent effects=parent mask=parent textReset=parent transform=parent background=parent border=parent sizing=parent surround=parent box=parent
+grid-styled child: div#child record 1 inheritedListTable=parent inheritedUI=parent inheritedSVG=parent inheritedText=1 font=parent animation=parent svgReset=parent grid=2 anchor=parent content=parent alignment=parent miscLayout=parent miscInteraction=parent effects=parent mask=parent textReset=parent transform=parent background=parent border=parent sizing=parent surround=parent box=parent
+unstyled-again child: div#child record 1 inheritedListTable=parent inheritedUI=parent inheritedSVG=parent inheritedText=parent font=parent animation=parent svgReset=parent grid=1 anchor=parent content=parent alignment=parent miscLayout=parent miscInteraction=parent effects=parent mask=parent textReset=parent transform=parent background=parent border=parent sizing=parent surround=parent box=parent
writing-mode parent: child writing-mode: vertical-rl
writing-mode parent: child visibility: hidden
visibility-overriding child visibility: visible
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/children-waiting-in-hidden-subtree.txt b/Tests/LibWeb/Text/expected/css/style-engine/children-waiting-in-hidden-subtree.txt
index 211c50dc7ff..dcf3f7bf3c1 100644
--- a/Tests/LibWeb/Text/expected/css/style-engine/children-waiting-in-hidden-subtree.txt
+++ b/Tests/LibWeb/Text/expected/css/style-engine/children-waiting-in-hidden-subtree.txt
@@ -13,8 +13,15 @@ empty host display: block
host display with content: none
revealed height after joins: 30
animated reveal height: 20
-animated waiting element styled: true
+animated waiting element:
+div.hidden record 1
+ div record 2
+ div.item no record
+ span no record
+ div.item record 3
+ span record 4
revealed shadow host height: 15
-waiting dialog styled as an arrived one is: true
+waiting dialog: dialog no record
+arrived dialog: dialog no record
moved height: 30
reinserted height: 30
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/computed-closure-after-style-sharing.txt b/Tests/LibWeb/Text/expected/css/style-engine/computed-closure-after-style-sharing.txt
index 4dd49c73aaa..ae46e1c22a2 100644
--- a/Tests/LibWeb/Text/expected/css/style-engine/computed-closure-after-style-sharing.txt
+++ b/Tests/LibWeb/Text/expected/css/style-engine/computed-closure-after-style-sharing.txt
@@ -1,4 +1,6 @@
-shared initial style: true
-styled only the changed element: true
+initial records:
+ span#first record 2
+ span#second record 2
+restyled: [second]
first background: rgba(0, 0, 0, 0)
second background: rgb(0, 0, 255)
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/hidden-inheritance-scheduling-rows-stay-unstyled.txt b/Tests/LibWeb/Text/expected/css/style-engine/hidden-inheritance-scheduling-rows-stay-unstyled.txt
index 41aa41ef360..be433afcd1b 100644
--- a/Tests/LibWeb/Text/expected/css/style-engine/hidden-inheritance-scheduling-rows-stay-unstyled.txt
+++ b/Tests/LibWeb/Text/expected/css/style-engine/hidden-inheritance-scheduling-rows-stay-unstyled.txt
@@ -1,8 +1,24 @@
-light scheduling nodes stay unstyled: true
+light hidden:
+div.hidden.changed record 1
+ div no record
+ span.target no record
hidden padding: 13px
visible padding: 13px
-visible ancestors have styles: true
-shadow scheduling nodes stay unstyled: true
+light visible:
+div.changed record 1
+ div record 1
+ span.target record 2
+shadow hidden:
+div.hidden.changed record 1
+ div no record
+ a no record
+ slot no record
+ span.target no record
hidden padding: 13px
visible padding: 13px
-visible ancestors have styles: true
+shadow visible:
+div.changed record 1
+ div record 1
+ a record 2
+ slot record 3
+ span.target record 4
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/hidden-subtree-styles-are-not-recomputed.txt b/Tests/LibWeb/Text/expected/css/style-engine/hidden-subtree-styles-are-not-recomputed.txt
index 4fef4bf6219..1de2e1bbb91 100644
--- a/Tests/LibWeb/Text/expected/css/style-engine/hidden-subtree-styles-are-not-recomputed.txt
+++ b/Tests/LibWeb/Text/expected/css/style-engine/hidden-subtree-styles-are-not-recomputed.txt
@@ -1,5 +1,10 @@
hidden grandchild color: rgb(255, 0, 0)
-hidden grandchild has style after read: true
-hidden grandchild style is cleared: true
-hidden child style is cleared: true
+after read:
+div#hidden record 1
+ div#child record 2
+ span#grandchild record 3
+after move:
+div#hidden record 1
+ div#child no record
+ span#grandchild no record
hidden grandchild color after move: rgb(0, 128, 0)
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/hidden-svg-resource-styles.txt b/Tests/LibWeb/Text/expected/css/style-engine/hidden-svg-resource-styles.txt
index c549eb1bce1..49e9d77b56a 100644
--- a/Tests/LibWeb/Text/expected/css/style-engine/hidden-svg-resource-styles.txt
+++ b/Tests/LibWeb/Text/expected/css/style-engine/hidden-svg-resource-styles.txt
@@ -1,8 +1,11 @@
-inheritance-parent has style after hiding: true
-filter has style after hiding: true
-flood has style after hiding: true
-gradient has style after hiding: true
-stop has style after hiding: true
-ordinary hidden style is cleared: true
-hidden inherited style was updated: true
+style records after hiding:
+div#ancestor record 1
+ div#inheritance-parent record 2
+ svg record 3
+ filter#filter record 4
+ feflood#flood record 5
+ lineargradient#gradient record 6
+ stop#stop record 7
+ span#ordinary no record
+hidden styles disagreeing with a cold pass: []
hidden inherited color: rgb(0, 128, 0)
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/hidden-svg-style-records-only-for-referenceable-elements.txt b/Tests/LibWeb/Text/expected/css/style-engine/hidden-svg-style-records-only-for-referenceable-elements.txt
index 3ae01f677ee..09975341e68 100644
--- a/Tests/LibWeb/Text/expected/css/style-engine/hidden-svg-style-records-only-for-referenceable-elements.txt
+++ b/Tests/LibWeb/Text/expected/css/style-engine/hidden-svg-style-records-only-for-referenceable-elements.txt
@@ -1,9 +1,28 @@
-hidden icon has no style records: true
-hidden linearGradient and its content have style records: true
-hidden pattern and its content have style records: true
-hidden clipPath and its content have style records: true
-hidden mask and its content have style records: true
-hidden filter and its content have style records: true
+hidden icon:
+div#hidden record 1
+ svg#icon no record
+ g#group no record
+ path no record
+hidden resources:
+div#hidden record 1
+ svg record 2
+ defs record 3
+ lineargradient#gradient record 4
+ stop record 5
+ pattern#pattern record 6
+ rect record 7
+ clippath#clip record 8
+ rect record 9
+ mask#mask record 10
+ rect record 11
+ filter#filter record 12
+ feflood record 13
text on the hidden path is laid out: true
-hidden path given an id later has a style record: true
-icon hidden later has no style records: true
+hidden path given an id later:
+div#hidden record 1
+ svg record 2
+ path#pathGivenIdLater record 3
+icon hidden later:
+div#hiddenLater record 1
+ svg#iconHiddenLater no record
+ path no record
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/inheritable-custom-property-environment-identity.txt b/Tests/LibWeb/Text/expected/css/style-engine/inheritable-custom-property-environment-identity.txt
index bc6c58a6a31..451775ff8dc 100644
--- a/Tests/LibWeb/Text/expected/css/style-engine/inheritable-custom-property-environment-identity.txt
+++ b/Tests/LibWeb/Text/expected/css/style-engine/inheritable-custom-property-environment-identity.txt
@@ -1,4 +1,8 @@
-same child environment: true
+div#root record 1 environment 1
+ div record 2 environment 2
+ span#first record 3 environment 1
+ div record 4 environment 3
+ span#second record 5 environment 1
inherited value: 15
inherited importance does not block animation: 3
registration change: red, blue
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/layout-style-record-publication.txt b/Tests/LibWeb/Text/expected/css/style-engine/layout-style-record-publication.txt
index 8141628e165..da7fe797878 100644
--- a/Tests/LibWeb/Text/expected/css/style-engine/layout-style-record-publication.txt
+++ b/Tests/LibWeb/Text/expected/css/style-engine/layout-style-record-publication.txt
@@ -1,15 +1,25 @@
-layout follows installed record: true
+layout follows installed record: div#target record 1, box record 1
paint background: rgb(255, 0, 0)
kept box width: 20
named: assigned colors: true
-named: layout records follow installed records: true
+named: layout records follow installed records:
+div record 1, box record 1
+ style record 2, no box
+ slot record 3, no box
+ div record 4, box record 4 x40
named: assigned box widths: true
manual: assigned colors: true
-manual: layout records follow installed records: true
+manual: layout records follow installed records:
+div record 1, box record 1
+ style record 2, no box
+ slot record 3, no box
+ div record 4, box record 4 x40
manual: assigned box widths: true
anonymous content inherits color: rgb(0, 0, 255)
anonymous table layout stays consistent: true
animated opacity reaches kept box: 0.5
-animated layout record follows installed record: true
+animated layout record follows installed record: div#target record 1, box record 1
+ span record 2, box record 2
base opacity restored: 1
-restored layout record follows installed record: true
+restored layout record follows installed record: div#target record 1, box record 1
+ span record 2, box record 2
diff --git a/Tests/LibWeb/Text/expected/css/style-invalidation/inherited-half-decides-who-shares-a-style.txt b/Tests/LibWeb/Text/expected/css/style-invalidation/inherited-half-decides-who-shares-a-style.txt
index 2582f24371a..0900b5a4d44 100644
--- a/Tests/LibWeb/Text/expected/css/style-invalidation/inherited-half-decides-who-shares-a-style.txt
+++ b/Tests/LibWeb/Text/expected/css/style-invalidation/inherited-half-decides-who-shares-a-style.txt
@@ -1,3 +1,16 @@
-PASS: children reading only the inherited half share a style: true
-PASS: the second plain child reuses the first one's record: true
+section record 1
+ div.red record 2
+ div.plain-kid record 3
+ div.inheriting-kid record 4
+ div.green record 5
+ div.plain-kid record 3
+ div.inheriting-kid record 6
+style PARTIAL
+ section (computed, changed)
+ div.red (computed, changed)
+ div.plain-kid (computed, changed)
+ div.inheriting-kid (computed, changed)
+ div.green (computed, changed)
+ div.plain-kid@2 (reused, changed)
+ div.inheriting-kid@2 (computed, changed)
PASS: a child that reads the other half is not offered another parent's answer
diff --git a/Tests/LibWeb/Text/expected/css/style-invalidation/shared-style-keeps-its-own-custom-properties.txt b/Tests/LibWeb/Text/expected/css/style-invalidation/shared-style-keeps-its-own-custom-properties.txt
index 90da370fb22..c3582c37ff1 100644
--- a/Tests/LibWeb/Text/expected/css/style-invalidation/shared-style-keeps-its-own-custom-properties.txt
+++ b/Tests/LibWeb/Text/expected/css/style-invalidation/shared-style-keeps-its-own-custom-properties.txt
@@ -1,2 +1,7 @@
-PASS: children that read no custom property share a style: true
+children that read no custom property share a style:
+section record 1 environment 0 inheritedListTable=parent inheritedUI=parent inheritedSVG=parent inheritedText=1 font=parent animation=parent svgReset=parent grid=parent anchor=parent content=parent alignment=parent miscLayout=parent miscInteraction=parent effects=parent mask=parent textReset=parent transform=parent background=parent border=parent sizing=parent surround=default box=parent
+ div.red-theme record 2 environment 1 inheritedListTable=parent inheritedUI=parent inheritedSVG=parent inheritedText=parent font=parent animation=parent svgReset=parent grid=parent anchor=parent content=parent alignment=parent miscLayout=parent miscInteraction=parent effects=parent mask=parent textReset=parent transform=parent background=parent border=parent sizing=parent surround=parent box=parent
+ div.plain-kid record 3 environment 1 inheritedListTable=parent inheritedUI=parent inheritedSVG=parent inheritedText=parent font=parent animation=parent svgReset=parent grid=parent anchor=parent content=parent alignment=parent miscLayout=parent miscInteraction=parent effects=parent mask=parent textReset=parent transform=parent background=parent border=parent sizing=parent surround=parent box=parent
+ div.blue-theme record 4 environment 2 inheritedListTable=parent inheritedUI=parent inheritedSVG=parent inheritedText=parent font=parent animation=parent svgReset=parent grid=parent anchor=parent content=parent alignment=parent miscLayout=parent miscInteraction=parent effects=parent mask=parent textReset=parent transform=parent background=parent border=parent sizing=parent surround=parent box=parent
+ div.plain-kid record 5 environment 2 inheritedListTable=parent inheritedUI=parent inheritedSVG=parent inheritedText=parent font=parent animation=parent svgReset=parent grid=parent anchor=parent content=parent alignment=parent miscLayout=parent miscInteraction=parent effects=parent mask=parent textReset=parent transform=parent background=parent border=parent sizing=parent surround=parent box=parent
PASS: each of them still inherits its own parent's custom properties
diff --git a/Tests/LibWeb/Text/expected/style-engine-finished-animation-element-inserted-under-hidden-ancestor.txt b/Tests/LibWeb/Text/expected/style-engine-finished-animation-element-inserted-under-hidden-ancestor.txt
index 9df69003005..9d269760203 100644
--- a/Tests/LibWeb/Text/expected/style-engine-finished-animation-element-inserted-under-hidden-ancestor.txt
+++ b/Tests/LibWeb/Text/expected/style-engine-finished-animation-element-inserted-under-hidden-ancestor.txt
@@ -1,2 +1,4 @@
-animated element styled: true
-its parent styled: true
+div#hidden record 1
+ div#styled record 2
+ span record 3
+ div#animated record 4
diff --git a/Tests/LibWeb/Text/input/css/computed-values-group-sharing.html b/Tests/LibWeb/Text/input/css/computed-values-group-sharing.html
index fa4bf139091..b6821e82342 100644
--- a/Tests/LibWeb/Text/input/css/computed-values-group-sharing.html
+++ b/Tests/LibWeb/Text/input/css/computed-values-group-sharing.html
@@ -6,27 +6,19 @@
const child = document.getElementById("child");
internals.updateStyle();
- let info = internals.styleGroupSharingInfo(child);
- for (const group of ["animation", "grid", "svgReset", "mask", "anchor", "content", "transform", "effects", "inheritedListTable", "inheritedSVG"])
- println(`unstyled child ${group} at default: ${info[group].isDefault}`);
+ println(`unstyled child: ${internals.dumpStyleRecords(child, { groups: true }).trimEnd()}`);
child.style.color = "red";
internals.updateStyle();
- info = internals.styleGroupSharingInfo(child);
- println(`color-styled child inheritedText at default: ${info.inheritedText.isDefault}`);
- println(`color-styled child inheritedText shared with parent: ${info.inheritedText.sharedWithParent}`);
- println(`color-styled child grid still at default: ${info.grid.isDefault}`);
+ println(`color-styled child: ${internals.dumpStyleRecords(child, { groups: true }).trimEnd()}`);
child.style.gridTemplateColumns = "1fr 2fr";
internals.updateStyle();
- info = internals.styleGroupSharingInfo(child);
- println(`grid-styled child grid at default: ${info.grid.isDefault}`);
+ println(`grid-styled child: ${internals.dumpStyleRecords(child, { groups: true }).trimEnd()}`);
child.style.color = "";
internals.updateStyle();
- info = internals.styleGroupSharingInfo(child);
- for (const group of ["inheritedListTable", "inheritedText", "font", "inheritedUI"])
- println(`unstyled-again child ${group} shared with parent: ${info[group].sharedWithParent}`);
+ println(`unstyled-again child: ${internals.dumpStyleRecords(child, { groups: true }).trimEnd()}`);
// The writing mode and visibility a child inherits unchanged are its parent's, and one it
// overrides is its own.
diff --git a/Tests/LibWeb/Text/input/css/style-engine/children-waiting-in-hidden-subtree.html b/Tests/LibWeb/Text/input/css/style-engine/children-waiting-in-hidden-subtree.html
index accb655a6b8..e5af61b8910 100644
--- a/Tests/LibWeb/Text/input/css/style-engine/children-waiting-in-hidden-subtree.html
+++ b/Tests/LibWeb/Text/input/css/style-engine/children-waiting-in-hidden-subtree.html
@@ -157,7 +157,7 @@ test(() => {
const animated = container.children[1].firstChild;
animated.animate([{ opacity: 0 }, { opacity: 1 }], 100).finish();
internals.updateStyle();
- println(`animated waiting element styled: ${internals.styleRecordIdentity(animated) !== 0}`);
+ println(`animated waiting element:\n${internals.dumpStyleRecords(parent).trimEnd()}`);
parent.remove();
}
@@ -179,7 +179,7 @@ test(() => {
// A dialog that waited enters the top layer as one that arrived in full before its parent was hidden does.
{
- const styled = [];
+ const dialogRecords = [];
for (const waits of [true, false]) {
const parent = document.createElement("div");
if (waits)
@@ -198,11 +198,12 @@ test(() => {
}
dialog.showModal();
internals.updateStyle();
- styled.push(internals.styleRecordIdentity(dialog) !== 0);
+ dialogRecords.push(internals.dumpStyleRecords(dialog).trimEnd());
dialog.close();
parent.remove();
}
- println(`waiting dialog styled as an arrived one is: ${styled[0] === styled[1]}`);
+ println(`waiting dialog: ${dialogRecords[0]}`);
+ println(`arrived dialog: ${dialogRecords[1]}`);
}
// A subtree whose children waited arrives in full where it moves to be seen.
diff --git a/Tests/LibWeb/Text/input/css/style-engine/computed-closure-after-style-sharing.html b/Tests/LibWeb/Text/input/css/style-engine/computed-closure-after-style-sharing.html
index 121507b750c..b4580dff775 100644
--- a/Tests/LibWeb/Text/input/css/style-engine/computed-closure-after-style-sharing.html
+++ b/Tests/LibWeb/Text/input/css/style-engine/computed-closure-after-style-sharing.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../../include.js"></script>
+<script src="../../work-test.js"></script>
<style>
.changed { background-color: blue }
</style>
@@ -9,14 +10,11 @@
test(() => {
internals.updateStyle();
- const shared = internals.styleRecordIdentity(first) === internals.styleRecordIdentity(second);
- internals.resetStyleCounters();
- second.className = "changed";
- internals.updateStyle();
- const styled = internals.styleCounters().styledElements;
+ const records = internals.dumpStyleRecords(document.body).split("\n").filter(line => line.includes("span#")).join("\n");
+ const work = styleWork(() => (second.className = "changed"));
- println(`shared initial style: ${shared}`);
- println(`styled only the changed element: ${styled <= 1}`);
+ println(`initial records:\n${records}`);
+ println(`restyled: [${work.restyled().map(shortStyleName).join(", ")}]`);
println(`first background: ${getComputedStyle(first).backgroundColor}`);
println(`second background: ${getComputedStyle(second).backgroundColor}`);
});
diff --git a/Tests/LibWeb/Text/input/css/style-engine/counter-style-consumers-per-scope.html b/Tests/LibWeb/Text/input/css/style-engine/counter-style-consumers-per-scope.html
index dc2ea67cffd..70e46f0e6a4 100644
--- a/Tests/LibWeb/Text/input/css/style-engine/counter-style-consumers-per-scope.html
+++ b/Tests/LibWeb/Text/input/css/style-engine/counter-style-consumers-per-scope.html
@@ -28,11 +28,11 @@
const first = append_items(first_root);
const second = append_items(second_root);
internals.updateStyle();
- const record = element => internals.styleRecordIdentity(element);
const width = element => element.getBoundingClientRect().width;
// NB: Whether two consumers of one scope's counter style hold one record is up to the caches, which may have no
// room for it. No record answers for a consumer of the other scope's, and each consumer shows its own.
- println(`scopes' consumers hold different records: ${first.every(a => second.every(b => record(a) !== record(b)))}`);
+ const records = new Map(internals.dumpStyleRecords(document.body).split("\n").filter(line => line.includes("div.item")).map((line, index) => [index < 3 ? first[index] : second[index - 3], line.match(/record (\d+)/)[1]]));
+ println(`scopes' consumers hold different records: ${first.every(a => second.every(b => records.get(a) !== records.get(b)))}`);
println(`first scope's consumers look alike: ${first.every(item => width(item) === width(first[0]))}`);
println(`second scope's consumers look alike: ${second.every(item => width(item) === width(second[0]))}`);
println(`each scope's consumers use its counter style: ${first.every(a => second.every(b => width(b) > width(a)))}`);
diff --git a/Tests/LibWeb/Text/input/css/style-engine/hidden-inheritance-scheduling-rows-stay-unstyled.html b/Tests/LibWeb/Text/input/css/style-engine/hidden-inheritance-scheduling-rows-stay-unstyled.html
index ae698fda173..48651111288 100644
--- a/Tests/LibWeb/Text/input/css/style-engine/hidden-inheritance-scheduling-rows-stay-unstyled.html
+++ b/Tests/LibWeb/Text/input/css/style-engine/hidden-inheritance-scheduling-rows-stay-unstyled.html
@@ -16,25 +16,21 @@
outer.append(middle);
document.body.append(outer);
- const schedulingNodes = [middle];
- if (shadow) {
- const root = middle.attachShadow({ mode: "open" });
- root.innerHTML = "<a><slot></slot></a>";
- schedulingNodes.push(...root.querySelectorAll("a, slot"));
- }
+ if (shadow)
+ middle.attachShadow({ mode: "open" }).innerHTML = "<a><slot></slot></a>";
document.body.offsetWidth;
// The outer and target have selector reactions, while the intervening nodes only
// carry inherited reactions through the batch. Hiding the outer clears their styles.
outer.className = "hidden changed";
internals.updateStyle();
- println(`${shadow ? "shadow" : "light"} scheduling nodes stay unstyled: ${schedulingNodes.every(node => internals.styleRecordIdentity(node) === 0)}`);
+ println(`${shadow ? "shadow" : "light"} hidden:\n${internals.dumpStyleRecords(outer).trimEnd()}`);
println(`hidden padding: ${getComputedStyle(target).paddingLeft}`);
outer.className = "changed";
document.body.offsetWidth;
println(`visible padding: ${getComputedStyle(target).paddingLeft}`);
- println(`visible ancestors have styles: ${schedulingNodes.every(node => internals.styleRecordIdentity(node) !== 0)}`);
+ println(`${shadow ? "shadow" : "light"} visible:\n${internals.dumpStyleRecords(outer).trimEnd()}`);
outer.remove();
}
});
diff --git a/Tests/LibWeb/Text/input/css/style-engine/hidden-subtree-styles-are-not-recomputed.html b/Tests/LibWeb/Text/input/css/style-engine/hidden-subtree-styles-are-not-recomputed.html
index d820fc3461b..fc9e4299aa6 100644
--- a/Tests/LibWeb/Text/input/css/style-engine/hidden-subtree-styles-are-not-recomputed.html
+++ b/Tests/LibWeb/Text/input/css/style-engine/hidden-subtree-styles-are-not-recomputed.html
@@ -12,13 +12,12 @@ test(() => {
// A CSSOM read materializes the styles of a hidden subtree.
println(`hidden grandchild color: ${getComputedStyle(grandchild).color}`);
- println(`hidden grandchild has style after read: ${internals.styleRecordIdentity(grandchild) !== 0}`);
+ println(`after read:\n${internals.dumpStyleRecords(hidden).trimEnd()}`);
// A moved inherited value of the hidden root clears the subtree's styles rather than computing them again.
hidden.style.color = "green";
internals.updateStyle();
- println(`hidden grandchild style is cleared: ${internals.styleRecordIdentity(grandchild) === 0}`);
- println(`hidden child style is cleared: ${internals.styleRecordIdentity(child) === 0}`);
+ println(`after move:\n${internals.dumpStyleRecords(hidden).trimEnd()}`);
println(`hidden grandchild color after move: ${getComputedStyle(grandchild).color}`);
});
</script>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/hidden-svg-resource-styles.html b/Tests/LibWeb/Text/input/css/style-engine/hidden-svg-resource-styles.html
index b7be093f92c..77f0186a511 100644
--- a/Tests/LibWeb/Text/input/css/style-engine/hidden-svg-resource-styles.html
+++ b/Tests/LibWeb/Text/input/css/style-engine/hidden-svg-resource-styles.html
@@ -14,21 +14,15 @@
</div>
<script>
test(() => {
- const resources = ["inheritance-parent", "filter", "flood", "gradient", "stop"].map(id => document.getElementById(id));
internals.updateStyle();
- const beforeHiding = internals.getStyleInvalidationCounters();
ancestor.style.display = "none";
internals.updateStyle();
- const afterHiding = internals.getStyleInvalidationCounters();
- for (const resource of resources)
- println(`${resource.id} has style after hiding: ${internals.styleRecordIdentity(resource) !== 0}`);
- println(`ordinary hidden style is cleared: ${internals.styleRecordIdentity(ordinary) === 0}`);
+ println("style records after hiding:");
+ println(internals.dumpStyleRecords(ancestor).trimEnd());
- const flood = document.getElementById("flood");
- const previousStyle = internals.styleRecordIdentity(flood);
ancestor.style.color = "green";
internals.updateStyle();
- println(`hidden inherited style was updated: ${internals.styleRecordIdentity(flood) !== previousStyle}`);
+ println(`hidden styles disagreeing with a cold pass: [${internals.styleSelfCheck().join(", ")}]`);
println(`hidden inherited color: ${getComputedStyle(flood).color}`);
});
</script>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/hidden-svg-style-records-only-for-referenceable-elements.html b/Tests/LibWeb/Text/input/css/style-engine/hidden-svg-style-records-only-for-referenceable-elements.html
index 835e1ad4870..a9af154d23f 100644
--- a/Tests/LibWeb/Text/input/css/style-engine/hidden-svg-style-records-only-for-referenceable-elements.html
+++ b/Tests/LibWeb/Text/input/css/style-engine/hidden-svg-style-records-only-for-referenceable-elements.html
@@ -6,12 +6,11 @@
<div id="hiddenLater"></div>
<script>
test(() => {
- const hasRecord = element => internals.styleRecordIdentity(element) !== 0;
document.body.offsetWidth;
hidden.innerHTML = `<svg id="icon"><g id="group"><path d="M 0 0 L 24 24" /></g></svg>`;
internals.updateStyle();
- println(`hidden icon has no style records: ${!hasRecord(icon) && !hasRecord(group) && !hasRecord(group.firstElementChild)}`);
+ println(`hidden icon:\n${internals.dumpStyleRecords(hidden).trimEnd()}`);
hidden.innerHTML = `<svg><defs>
<linearGradient id="gradient"><stop /></linearGradient>
@@ -21,8 +20,7 @@
<filter id="filter"><feFlood /></filter>
</defs></svg>`;
internals.updateStyle();
- for (const resource of [gradient, pattern, clip, mask, filter])
- println(`hidden ${resource.localName} and its content have style records: ${hasRecord(resource) && hasRecord(resource.firstElementChild)}`);
+ println(`hidden resources:\n${internals.dumpStyleRecords(hidden).trimEnd()}`);
println(`text on the hidden path is laid out: ${textOnHiddenPath.getBBox().width > 0}`);
@@ -31,12 +29,12 @@
const pathGivenIdLater = hidden.querySelector("path");
pathGivenIdLater.id = "pathGivenIdLater";
internals.updateStyle();
- println(`hidden path given an id later has a style record: ${hasRecord(pathGivenIdLater)}`);
+ println(`hidden path given an id later:\n${internals.dumpStyleRecords(hidden).trimEnd()}`);
hiddenLater.innerHTML = `<svg id="iconHiddenLater"><path d="M 0 0 L 24 24" /></svg>`;
internals.updateStyle();
hiddenLater.style.display = "none";
internals.updateStyle();
- println(`icon hidden later has no style records: ${!hasRecord(iconHiddenLater) && !hasRecord(iconHiddenLater.firstElementChild)}`);
+ println(`icon hidden later:\n${internals.dumpStyleRecords(hiddenLater).trimEnd()}`);
});
</script>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/inheritable-custom-property-environment-identity.html b/Tests/LibWeb/Text/input/css/style-engine/inheritable-custom-property-environment-identity.html
index da8cdb4934e..dbf6164586c 100644
--- a/Tests/LibWeb/Text/input/css/style-engine/inheritable-custom-property-environment-identity.html
+++ b/Tests/LibWeb/Text/input/css/style-engine/inheritable-custom-property-environment-identity.html
@@ -15,7 +15,7 @@ test(() => {
root.style.setProperty(`--inherited-${index}`, index);
root.style.setProperty('--number', '1', 'important');
internals.updateStyle();
- println(`same child environment: ${internals.customPropertyEnvironmentIdentity(first) === internals.customPropertyEnvironmentIdentity(second)}`);
+ println(internals.dumpStyleRecords(root, { customPropertyEnvironments: true }).trimEnd());
println(`inherited value: ${getComputedStyle(first).getPropertyValue('--inherited-15')}`);
const animation = first.animate({'--number': ['2', '4']}, {duration: 1000, fill: 'both'});
diff --git a/Tests/LibWeb/Text/input/css/style-engine/layout-style-record-publication.html b/Tests/LibWeb/Text/input/css/style-engine/layout-style-record-publication.html
index fa58698b6c6..8d9d06b1eac 100644
--- a/Tests/LibWeb/Text/input/css/style-engine/layout-style-record-publication.html
+++ b/Tests/LibWeb/Text/input/css/style-engine/layout-style-record-publication.html
@@ -5,13 +5,24 @@
</style>
<div id="target">target</div>
<script>
+ function layoutRecords(root) {
+ const lines = [];
+ for (const line of internals.dumpStyleRecords(root, { layout: true }).trimEnd().split("\n")) {
+ if (lines.at(-1)?.line === line)
+ ++lines.at(-1).count;
+ else
+ lines.push({ line, count: 1 });
+ }
+ return lines.map(({ line, count }) => (count > 1 ? `${line} x${count}` : line)).join("\n");
+ }
+
test(() => {
const target = document.getElementById("target");
target.getBoundingClientRect();
internals.updateStyle();
target.style.backgroundColor = "red";
internals.updateStyle();
- println(`layout follows installed record: ${internals.layoutStyleRecordIdentity(target) === internals.styleRecordIdentity(target)}`);
+ println(`layout follows installed record: ${layoutRecords(target)}`);
println(`paint background: ${getComputedStyle(target).backgroundColor}`);
println(`kept box width: ${target.getBoundingClientRect().width}`);
@@ -34,7 +45,7 @@
slot.style.color = "green";
internals.updateStyle();
println(`${mode}: assigned colors: ${children.every(child => getComputedStyle(child).color === "rgb(0, 128, 0)")}`);
- println(`${mode}: layout records follow installed records: ${children.every(child => internals.layoutStyleRecordIdentity(child) === internals.styleRecordIdentity(child))}`);
+ println(`${mode}: layout records follow installed records:\n${layoutRecords(host)}`);
println(`${mode}: assigned box widths: ${children.every(child => child.getBoundingClientRect().width === 10)}`);
host.remove();
}
@@ -55,10 +66,10 @@
animation.currentTime = 500;
internals.updateStyle();
println(`animated opacity reaches kept box: ${getComputedStyle(target).opacity}`);
- println(`animated layout record follows installed record: ${internals.layoutStyleRecordIdentity(target) === internals.styleRecordIdentity(target)}`);
+ println(`animated layout record follows installed record: ${layoutRecords(target)}`);
animation.cancel();
internals.updateStyle();
println(`base opacity restored: ${getComputedStyle(target).opacity}`);
- println(`restored layout record follows installed record: ${internals.layoutStyleRecordIdentity(target) === internals.styleRecordIdentity(target)}`);
+ println(`restored layout record follows installed record: ${layoutRecords(target)}`);
});
</script>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/removing-stylesheet-preserves-non-layout-descendant-record.html b/Tests/LibWeb/Text/input/css/style-engine/removing-stylesheet-preserves-non-layout-descendant-record.html
index 9e120c7ba4d..02dd87b5191 100644
--- a/Tests/LibWeb/Text/input/css/style-engine/removing-stylesheet-preserves-non-layout-descendant-record.html
+++ b/Tests/LibWeb/Text/input/css/style-engine/removing-stylesheet-preserves-non-layout-descendant-record.html
@@ -66,12 +66,14 @@
const pseudoColor = getComputedStyle(pseudoTarget, "::before").color;
const fontLoadPromise = document.fonts.load("16px SlowAhem", "X").catch(() => {});
+ const hasStyleRecord = element => !internals.dumpStyleRecords(element).trimEnd().endsWith(" no record");
+ const hasBox = node => internals.dumpLayoutTree(node) !== "(no layout node)";
println(`font status before removal: ${document.fonts.status}`);
- println(`later link has style record before removal: ${internals.styleRecordIdentity(laterLink) !== 0}`);
- println(`later link has layout before removal: ${internals.layoutNodeIdentity(laterLink) !== 0}`);
+ println(`later link has style record before removal: ${hasStyleRecord(laterLink)}`);
+ println(`later link has layout before removal: ${hasBox(laterLink)}`);
println(`non-layout pseudo-element has computed style before removal: ${pseudoColor === "rgb(7, 8, 9)"}`);
- println(`shadow link has style record before removal: ${internals.styleRecordIdentity(shadowLaterLink) !== 0}`);
- println(`shadow link has layout before removal: ${internals.layoutNodeIdentity(shadowLaterLink) !== 0}`);
+ println(`shadow link has style record before removal: ${hasStyleRecord(shadowLaterLink)}`);
+ println(`shadow link has layout before removal: ${hasBox(shadowLaterLink)}`);
await new Promise(requestAnimationFrame);
churnTarget.dataset.color = "rgb(1, 2, 3)";
diff --git a/Tests/LibWeb/Text/input/css/style-invalidation/inherited-half-decides-who-shares-a-style.html b/Tests/LibWeb/Text/input/css/style-invalidation/inherited-half-decides-who-shares-a-style.html
index 4046e7bebc8..f95c0d722a9 100644
--- a/Tests/LibWeb/Text/input/css/style-invalidation/inherited-half-decides-who-shares-a-style.html
+++ b/Tests/LibWeb/Text/input/css/style-invalidation/inherited-half-decides-who-shares-a-style.html
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="../../include.js"></script>
+<script src="../../work-test.js"></script>
<script src="structural-matrix.js"></script>
<script>
test(() => {
@@ -20,11 +21,7 @@
parent.appendChild(makeElement("div", { className: "inheriting-kid" }));
box.appendChild(parent);
}
- document.body.append(box);
-
- resetStyleCounters();
- internals.updateStyle();
- const reused = internals.styleCounters().reusedElements;
+ const work = styleWork(() => document.body.append(box));
const [redPlain, redInheriting, greenPlain, greenInheriting] = box.querySelectorAll("div div");
const color = element => getComputedStyle(element).borderTopColor;
@@ -33,9 +30,9 @@
// child that reads nothing of that, so both plain children compute one style between them.
assertEqual("a plain child of the red parent", color(redPlain), "rgb(0, 0, 0)");
assertEqual("a plain child of the green parent", color(greenPlain), "rgb(0, 0, 0)");
- println(`PASS: children reading only the inherited half share a style: ${internals.styleRecordIdentity(redPlain) === internals.styleRecordIdentity(greenPlain)}`);
+ println(internals.dumpStyleRecords(box).trimEnd());
// Their parents differ, so the second takes the first one's record by its cascade, not by sharing.
- println(`PASS: the second plain child reuses the first one's record: ${reused >= 1}`);
+ println(work.text.trimEnd());
// `border-color: inherit` reads the half of the parent's style those two parents differ in,
// so each of these children answers for itself.
diff --git a/Tests/LibWeb/Text/input/css/style-invalidation/shared-style-keeps-its-own-custom-properties.html b/Tests/LibWeb/Text/input/css/style-invalidation/shared-style-keeps-its-own-custom-properties.html
index f8c8488a97b..83842edd81d 100644
--- a/Tests/LibWeb/Text/input/css/style-invalidation/shared-style-keeps-its-own-custom-properties.html
+++ b/Tests/LibWeb/Text/input/css/style-invalidation/shared-style-keeps-its-own-custom-properties.html
@@ -24,10 +24,8 @@
// Neither child reads a custom property, so what their parents declare cannot decide
// anything about them and they compute one style between them.
const [redKid, blueKid] = box.querySelectorAll(".plain-kid");
- const redGroups = internals.styleGroupSharingInfo(redKid);
- const blueGroups = internals.styleGroupSharingInfo(blueKid);
- const shared = Object.keys(redGroups).every(name => redGroups[name].payloadIdentity === blueGroups[name].payloadIdentity);
- println(`PASS: children that read no custom property share a style: ${shared}`);
+ println("children that read no custom property share a style:");
+ println(internals.dumpStyleRecords(box, { customPropertyEnvironments: true, groups: true }).trimEnd());
// Taking the other child's style must not take the other parent's environment with it.
assertEqual("the red parent's child", getComputedStyle(redKid).getPropertyValue("--theme"), "red");
diff --git a/Tests/LibWeb/Text/input/style-engine-finished-animation-element-inserted-under-hidden-ancestor.html b/Tests/LibWeb/Text/input/style-engine-finished-animation-element-inserted-under-hidden-ancestor.html
index f94fcbfda95..73afc3f5b89 100644
--- a/Tests/LibWeb/Text/input/style-engine-finished-animation-element-inserted-under-hidden-ancestor.html
+++ b/Tests/LibWeb/Text/input/style-engine-finished-animation-element-inserted-under-hidden-ancestor.html
@@ -13,7 +13,6 @@
styled.innerHTML = `<span><div id="animated"></div></span>`;
animated.animate([{ opacity: 0 }, { opacity: 1 }], 100).finish();
internals.updateStyle();
- println(`animated element styled: ${internals.styleRecordIdentity(animated) !== 0}`);
- println(`its parent styled: ${internals.styleRecordIdentity(animated.parentElement) !== 0}`);
+ println(internals.dumpStyleRecords(hidden).trimEnd());
});
</script>