Skip to content

Truly independent web browser

LibWeb: Install styles on the render side and run its clock there

Andreas Kling84f798b8c829
diff --git a/Libraries/LibCompositing/Rust/src/visual_context/mod.rs b/Libraries/LibCompositing/Rust/src/visual_context/mod.rs
index 98a84823dbe..442836340c7 100644
--- a/Libraries/LibCompositing/Rust/src/visual_context/mod.rs
+++ b/Libraries/LibCompositing/Rust/src/visual_context/mod.rs
@@ -657,8 +657,32 @@ pub fn resolve_leaf_to_context_matrices(
matrices
}
+/// A number no other copy of a tree has had: what a holder of no reference to a tree can tell it by, where another tree
+/// can take the address of one that is gone. Every copy takes a number of its own, so a write to a tree someone shares,
+/// which copies it, moves the number.
+#[derive(Debug, PartialEq, Eq)]
+pub struct VisualContextTreeCopy(u64);
+
+impl VisualContextTreeCopy {
+ fn new() -> Self {
+ // NB: The process's counter numbers nothing but what its numbers are told apart from.
+ Self(allocate_structural_epoch())
+ }
+
+ pub fn number(&self) -> u64 {
+ self.0
+ }
+}
+
+impl Clone for VisualContextTreeCopy {
+ fn clone(&self) -> Self {
+ Self::new()
+ }
+}
+
#[derive(Clone)]
pub struct VisualContextTree {
+ pub copy: VisualContextTreeCopy,
pub spatial_nodes: Vec<SpatialNode>,
pub clip_nodes: Vec<ClipNode>,
pub effect_nodes: Vec<EffectNode>,
@@ -821,6 +845,7 @@ impl VisualContextTree {
clip_nodes: Vec::new(),
effect_nodes: Vec::new(),
root_isolation_effect: None,
+ copy: VisualContextTreeCopy::new(),
structural_epoch: allocate_structural_epoch(),
spatial_slots: SlotAccounting {
live_count: 1,
@@ -855,6 +880,7 @@ impl VisualContextTree {
clip_nodes,
effect_nodes,
root_isolation_effect,
+ copy: VisualContextTreeCopy::new(),
structural_epoch,
sampled_background_colors: HashMap::new(),
visual_animations: std::sync::Arc::from(Vec::new()),
diff --git a/Libraries/LibWeb/Animations/Animatable.cpp b/Libraries/LibWeb/Animations/Animatable.cpp
index c0e9907b4e9..e5edcbb8c5d 100644
--- a/Libraries/LibWeb/Animations/Animatable.cpp
+++ b/Libraries/LibWeb/Animations/Animatable.cpp
@@ -312,7 +312,10 @@ void Animatable::cancel_css_animations_and_transitions()
bool Animatable::has_matching_transition_property_entry(Optional<CSS::PseudoElement> pseudo_element) const
{
auto const& style = static_cast<DOM::Element const&>(*this).installed_style(pseudo_element);
- return style && CSS::StyleValueFFI::rust_transition_has_matching_entries(style.view().longhand_table, has_existing_transitions(pseudo_element));
+ if (!style)
+ return false;
+ auto view = style.view();
+ return CSS::StyleEngineFFI::style_engine_view_has_matching_transition_entries(&view, has_existing_transitions(pseudo_element));
}
bool Animatable::has_existing_transitions(Optional<CSS::PseudoElement> pseudo_element) const
diff --git a/Libraries/LibWeb/Animations/AnimationEffect.cpp b/Libraries/LibWeb/Animations/AnimationEffect.cpp
index 7aaef5273c9..e483d48f499 100644
--- a/Libraries/LibWeb/Animations/AnimationEffect.cpp
+++ b/Libraries/LibWeb/Animations/AnimationEffect.cpp
@@ -36,8 +36,8 @@ GC_DEFINE_ALLOCATOR(AnimationEffect);
AnimationUpdateContext::ElementData::ElementData() = default;
-AnimationUpdateContext::ElementData::ElementData(CSS::StyleRecordID style_record_before_update, RefPtr<CSS::ComputedStyleWorkingSet> target_style)
- : style_record_before_update(style_record_before_update)
+AnimationUpdateContext::ElementData::ElementData(CSS::InstalledStyle style_before_update, RefPtr<CSS::ComputedStyleWorkingSet> target_style)
+ : style_before_update(move(style_before_update))
, target_style(move(target_style))
{
}
@@ -852,6 +852,19 @@ AnimationUpdateContext::~AnimationUpdateContext()
publish();
}
+template<typename Iterator, typename Callback>
+static void at_times_observed_ahead(Iterator timelines, Iterator end, Callback const& callback)
+{
+ if (timelines == end)
+ return callback();
+ auto& timeline = **timelines;
+ ++timelines;
+ if (!timeline.was_observed_ahead_in_current_task())
+ return at_times_observed_ahead(timelines, end, callback);
+ AnimationTimeline::CurrentTimeOverrideScope override { timeline, timeline.current_time_for_observation() };
+ at_times_observed_ahead(timelines, end, callback);
+}
+
void AnimationUpdateContext::publish()
{
// Each element's effects, sampled over the style it holds.
@@ -915,32 +928,41 @@ void AnimationUpdateContext::publish()
size_t end = first;
for (; end < samples.size() && &samples[end].element.document() == &document; ++end) {
auto& sample = samples[end];
- if (!sample.effects.is_empty() && sample.element.style_record_identity() == sample.data.style_record_before_update)
+ if (sample.element.installed_style() != sample.data.style_before_update)
+ continue;
+ // NB: An element left with no effects, as where its style just removed its last animation, has nothing to
+ // sample, and what it animated of its custom properties ends here.
+ if (sample.effects.is_empty())
+ style_computer.stop_publishing_animated_custom_properties(sample.element);
+ else
requests.append({ sample.element, sample.effects.span(), *sample.data.target_style });
}
- style_computer.refresh_animations_into_each(read, requests);
+ // A timeline script observed ahead of its current time in this task is sampled at that time, as an update of the
+ // effects needing it is, or the style installed here and the one that update sampled would keep disagreeing about
+ // an effect that ended between the two times.
+ at_times_observed_ahead(document.associated_animation_timelines().begin(), document.associated_animation_timelines().end(), [&] {
+ style_computer.refresh_animations_into_each(read, requests);
+ });
publications.clear_with_capacity();
overlays.clear_with_capacity();
for (auto& sample : samples.span().slice(first, end - first)) {
auto const& style = *sample.data.target_style;
- if (sample.element.style_record_identity() != sample.data.style_record_before_update
+ if (sample.element.installed_style() != sample.data.style_before_update
|| !sample.element.installed_style().animation_overlay_changed(style.animated_overlay()))
continue;
- // The publication can release the record a pseudo-element installed, which the update still reads: as a
- // transition baseline once the publication is compared with it, and from its originating element, whose
- // entry may install first and recompute its pseudo-element styles. An element holds its record until it
- // installs the published one, but a pseudo-element holds it nowhere, so the update pins it until its own
- // entry ends.
bool const may_record_baseline = style.animated_overlay() && !CSS::ComputedValuesFFI::rust_animated_overlay_is_empty(style.animated_overlay())
&& document.is_in_style_stabilization_epoch();
- if (sample.element.pseudo_element().has_value())
- CSS::StyleEngineFFI::style_engine_pin_style_record(style_computer.style_engine().host(), sample.data.style_record_before_update.value());
publications.append({ sample, may_record_baseline });
overlays.append({ sample.element, style });
}
published.resize(overlays.size());
style_computer.publish_sampled_animation_overlays(read, overlays, published);
+ // NB: Each publication hands over a reference to the style it published, which a later one can retire.
+ Vector<CSS::InstalledStyle> published_styles;
+ published_styles.ensure_capacity(published.size());
+ for (auto const& publication : published)
+ published_styles.unchecked_append(CSS::InstalledStyle::adopt(publication.record));
first = end;
for (size_t i = 0; i < publications.size(); ++i) {
@@ -950,17 +972,13 @@ void AnimationUpdateContext::publish()
auto const& data = sample.data;
GC::Ref<DOM::Element> target = element.element();
// An earlier entry already republished this style with the current animation values.
- bool const republished = element.style_record_identity() != data.style_record_before_update;
+ bool const republished = element.installed_style() != data.style_before_update;
if (!republished && may_record_baseline && (document.style_stabilization_has_style_reactions() || animated_property_invalidation.requires_base_style_recomputation))
- style_computer.record_transition_stabilization_baseline(element, data.style_record_before_update);
- ScopeGuard unpin_installed_record = [&] {
- if (element.pseudo_element().has_value())
- CSS::StyleEngineFFI::style_engine_unpin_style_record(style_computer.style_engine().host(), data.style_record_before_update.value());
- };
+ style_computer.record_transition_stabilization_baseline(element, data.style_before_update);
if (republished)
continue;
auto invalidation = CSS::decode_style_invalidation(animated_property_invalidation.invalidation);
- target->refresh_computed_style(element.pseudo_element(), CSS::StyleRecordID { published[i].publication.new_style_record });
+ target->refresh_computed_style(read, element.pseudo_element(), move(published_styles[i]));
if (auto* svg_element = as_if<SVG::SVGElement>(*target); svg_element && !element.pseudo_element().has_value())
svg_element->note_svg_paint_resource_description_may_have_changed();
@@ -971,57 +989,8 @@ void AnimationUpdateContext::publish()
if (animated_property_invalidation.requires_base_style_recomputation && !data.base_is_current)
target->document().style_computer().style_engine().record_derived_element_style_input_change(target->style_node_id(), CSS::StyleEngine::PublishedStyle | CSS::StyleEngine::RecomputeStyle);
- if (!data.inherited_style_update_owned_by_reaction && !element.pseudo_element().has_value() && invalidation.inherited_style_changed()) {
- // Recomputing pseudo-element styles can start transitions, which stay provisional until a stabilization
- // epoch commits them. This update also runs outside any style update (for example when an inert animation
- // is disassociated from its target), so hold an epoch open around it.
- auto& document = target->document();
- document.begin_style_stabilization_epoch();
- ScopeGuard end_stabilization_epoch = [&] {
- document.end_style_stabilization_epoch();
- };
- invalidation |= target->recompute_pseudo_element_styles(read);
- }
-
- // An animated value can be inherited through shadow and slot boundaries. Publish the exact
- // flat-tree descendants as one feedback batch; the ordinary transaction owns their style
- // materialization and observer consequences.
- if (!element.pseudo_element().has_value()) {
- // NB: An enclosing reaction compares the previous and final inherited groups. Keep the feedback for
- // explicit non-inherited dependencies and structural changes, which that comparison does not cover.
- auto inherited_style_groups = data.inherited_style_update_owned_by_reaction ? u8 { 0 } : invalidation.inherited_style_groups_changed();
- if (!invalidation.inherited_style_changed() || data.inherited_style_update_owned_by_reaction) {
- auto shadow_root = target->shadow_root();
- auto child_explicit_inheritance_groups = target->children_explicitly_inherited_non_inherited_style_groups();
- if (shadow_root)
- child_explicit_inheritance_groups |= shadow_root->children_explicitly_inherited_non_inherited_style_groups();
- auto descendants_may_observe_non_inherited_properties = (child_explicit_inheritance_groups & animated_property_invalidation.changed_non_inherited_style_groups) != 0
- || invalidation.recompute_descendant_styles
- || invalidation.needs_layout_tree_rebuild();
- if (auto* slot = as_if<HTML::HTMLSlotElement>(*target); slot && !descendants_may_observe_non_inherited_properties) {
- slot->assign_slottables_if_needed();
- // NB: Assigned elements leave explicit inheritance marks on their DOM parent,
- // including values that substitute to inherit, rather than on the slot. Every
- // assigned element is a child of the shadow host, so the first one's parent
- // holds the marks of all of them.
- for (auto const& slottable : slot->assigned_nodes_internal()) {
- auto const* assigned = slottable.get_pointer<GC::Ref<DOM::Element>>();
- if (!assigned)
- continue;
- auto* parent = (*assigned)->parent();
- descendants_may_observe_non_inherited_properties = parent && (parent->children_explicitly_inherited_non_inherited_style_groups() & animated_property_invalidation.changed_non_inherited_style_groups) != 0;
- break;
- }
- }
- if (descendants_may_observe_non_inherited_properties)
- inherited_style_groups = CSS::RequiredInvalidationAfterStyleChange::all_inherited_style_groups;
- }
- if (inherited_style_groups != 0)
- target->document().style_computer().style_engine().record_flat_tree_descendant_style_input_changes(
- target->style_node_id(),
- CSS::StyleEngine::InheritedStyle,
- inherited_style_groups);
- }
+ // NB: Publishing the composition had the style engine restyle the element's pseudo-elements and the
+ // children that compute from what the composition moved, in its next pass.
// NB: refresh_computed_style() already publishes the new record to the layout node. Only
// inherited values and image resources require the additional C++ style side effects.
diff --git a/Libraries/LibWeb/Animations/AnimationEffect.h b/Libraries/LibWeb/Animations/AnimationEffect.h
index 47864a88ab3..d8c769076f2 100644
--- a/Libraries/LibWeb/Animations/AnimationEffect.h
+++ b/Libraries/LibWeb/Animations/AnimationEffect.h
@@ -16,8 +16,8 @@
#include <LibWeb/Bindings/AnimationEffect.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/CSS/EasingFunction.h>
+#include <LibWeb/CSS/InstalledStyle.h>
#include <LibWeb/CSS/PropertyNameAndID.h>
-#include <LibWeb/CSS/StyleRecordID.h>
namespace Web::Animations {
@@ -41,19 +41,17 @@ Bindings::OptionalEffectTiming to_optional_effect_timing(Bindings::EffectTiming
struct AnimationUpdateContext {
struct ElementData {
ElementData();
- ElementData(CSS::StyleRecordID, RefPtr<CSS::ComputedStyleWorkingSet>);
+ ElementData(CSS::InstalledStyle, RefPtr<CSS::ComputedStyleWorkingSet>);
ElementData(ElementData&&);
ElementData& operator=(ElementData&&);
~ElementData();
- CSS::StyleRecordID style_record_before_update;
+ CSS::InstalledStyle style_before_update;
RefPtr<CSS::ComputedStyleWorkingSet> target_style;
GC::RootVector<GC::Ref<KeyframeEffect>> effects;
// Whether the record the update samples over was computed by this style update, so that the base
// adjustments the sampled values feed into were made over the values the element holds now.
bool base_is_current { false };
- // NB: The enclosing style reaction propagates inherited changes after its final composition is installed.
- bool inherited_style_update_owned_by_reaction { false };
};
AnimationUpdateContext();
diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Libraries/LibWeb/Animations/KeyframeEffect.cpp
index 1eb794568b6..e5b91800e73 100644
--- a/Libraries/LibWeb/Animations/KeyframeEffect.cpp
+++ b/Libraries/LibWeb/Animations/KeyframeEffect.cpp
@@ -18,6 +18,7 @@
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/CSS/StyleComputer.h>
+#include <LibWeb/CSS/StyleEngineInput.h>
#include <LibWeb/CSS/StyleValues/KeywordStyleValue.h>
#include <LibWeb/ComputedValuesRustFFI.h>
#include <LibWeb/DOM/AbstractElement.h>
@@ -856,6 +857,8 @@ void KeyframeEffect::set_target(GC::Ptr<DOM::Element> target)
m_target_element = target;
invalidate_animation_preparation();
+ if (m_target_element)
+ CSS::record_attr_names_read_by_keyframes(*m_target_element, *this);
invalidate_effect();
// FIXME: We don't remove the animated style from the old target element as part of normal animated style update and
// it will remain "stuck" until it's style is fully invalidated for some other reason.
@@ -898,6 +901,7 @@ void KeyframeEffect::set_target(DOM::AbstractElement abstract_element, Invalidat
} else {
VERIFY(!associated_animation());
m_target_element = &abstract_element.element();
+ CSS::record_attr_names_read_by_keyframes(*m_target_element, *this);
}
m_target_pseudo_selector = abstract_element.pseudo_element().map([](auto it) { return CSS::Selector::PseudoElementSelector { it }; });
}
@@ -929,6 +933,8 @@ void KeyframeEffect::set_key_frame_set(RefPtr<KeyFrameSet const> key_frame_set)
}
}
m_key_frame_set = move(key_frame_set);
+ if (m_target_element)
+ CSS::record_attr_names_read_by_keyframes(*m_target_element, *this);
invalidate_animation_preparation();
invalidate_effect();
}
@@ -1049,6 +1055,8 @@ void KeyframeEffect::set_keyframes(Vector<BaseKeyframe> keyframes)
generate_initial_and_final_frames(keyframe_set, m_target_properties);
m_key_frame_set = keyframe_set;
+ if (m_target_element)
+ CSS::record_attr_names_read_by_keyframes(*m_target_element, *this);
invalidate_animation_preparation();
invalidate_effect();
@@ -1312,14 +1320,13 @@ void KeyframeEffect::update_computed_properties(AnimationUpdateContext& context)
void KeyframeEffect::update_computed_properties_for_style(AnimationUpdateContext& context, DOM::AbstractElement abstract_element)
{
- Layout::ForcedReadScope read { abstract_element.document() };
auto& style_computer = abstract_element.element().document().style_computer();
- auto& element_data = context.elements.ensure(abstract_element, [&abstract_element, &style_computer, &read] {
- auto style_record = abstract_element.style_record_identity();
- if (!style_record)
+ auto& element_data = context.elements.ensure(abstract_element, [&abstract_element, &style_computer] {
+ auto const& style = abstract_element.installed_style();
+ if (!style)
return AnimationUpdateContext::ElementData {};
- auto computed_properties = style_computer.reconstruct_computed_properties_for_animation(read, style_record);
- return AnimationUpdateContext::ElementData { style_record, move(computed_properties) };
+ auto computed_properties = style_computer.reconstruct_computed_properties_for_animation(style);
+ return AnimationUpdateContext::ElementData { style, move(computed_properties) };
});
if (!element_data.target_style)
diff --git a/Libraries/LibWeb/CSS/StyleEngineInput.cpp b/Libraries/LibWeb/CSS/StyleEngineInput.cpp
index 37b84903d1a..156020fec0a 100644
--- a/Libraries/LibWeb/CSS/StyleEngineInput.cpp
+++ b/Libraries/LibWeb/CSS/StyleEngineInput.cpp
@@ -753,7 +753,7 @@ static void record_subtree_arrivals(DOM::Document& document, ReadonlySpan<Pendin
// yet, so the mark is made here, as the insertion would have made it.
for (auto const& root : roots) {
auto const* parent = root.node->parent();
- if (parent && (parent->is_html_style_element() || parent->is_svg_style_element()) && !parent->has_layout_box())
+ if (parent && (parent->is_html_style_element() || parent->is_svg_style_element()) && !parent->may_have_layout_box())
continue;
root.node->set_needs_layout_tree_update(true, DOM::SetNeedsLayoutTreeUpdateReason::NodeInsertBefore);
}
diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp
index f93547c06dd..f29a0509ec6 100644
--- a/Libraries/LibWeb/DOM/Node.cpp
+++ b/Libraries/LibWeb/DOM/Node.cpp
@@ -494,7 +494,7 @@ WebIDL::ExceptionOr<void> Node::set_text_content(Optional<Utf16String> const& ma
// Otherwise, do nothing.
- auto is_boxless_style_element = (is_html_style_element() || is_svg_style_element()) && !has_layout_box();
+ auto is_boxless_style_element = (is_html_style_element() || is_svg_style_element()) && !may_have_layout_box();
if (is_connected() && !is_boxless_style_element)
set_needs_layout_tree_update(true, SetNeedsLayoutTreeUpdateReason::NodeSetTextContent);
@@ -1176,7 +1176,7 @@ void Node::insert_nodes_before(ReadonlySpan<GC::Ref<Node>> nodes, GC::Ptr<Node>
&& any_of(nodes, [](auto const& node) { return node->is_connected(); }))
run_post_connection_steps(nodes);
- auto is_boxless_style_element = (is_html_style_element() || is_svg_style_element()) && !has_layout_box();
+ auto is_boxless_style_element = (is_html_style_element() || is_svg_style_element()) && !may_have_layout_box();
if (is_connected() && !is_boxless_style_element) {
// NB: Called during DOM insertion, layout is not up to date. The element's installed style is read.
auto is_display_contents = [&] {
@@ -1360,9 +1360,19 @@ void Node::run_node_iterator_pre_removing_steps()
});
}
+// NB: A node hears of a box the frame in flight built for it as the frame lands, so it may have one already. Only an
+// element or a text node can.
+bool Node::may_have_layout_box() const
+{
+ if (has_layout_box())
+ return true;
+ auto const* arena = document().layout_node_arena_if_created();
+ return arena && arena->render_document().waits_for_frame() && (is<Element>(*this) || is<Text>(*this));
+}
+
static bool node_contributes_to_layout_tree(Node const& node)
{
- if (node.has_layout_box())
+ if (node.may_have_layout_box())
return true;
auto const* element = as_if<Element>(node);
@@ -2980,7 +2990,7 @@ void Node::update_inside_blocking_wheel_event_handler_state_for_subtree()
}
// A top layer element's boxes are outside the subtree's box.
- auto marks_subtree = has_layout_box();
+ auto marks_subtree = may_have_layout_box();
Layout::RustFFI::FfiBoxMarks subtree_marks {};
subtree_marks.repaint_subtree = true;
auto top_layer_marks = subtree_marks;
diff --git a/Libraries/LibWeb/DOM/Node.h b/Libraries/LibWeb/DOM/Node.h
index 4e2c0054793..22ba2cf6283 100644
--- a/Libraries/LibWeb/DOM/Node.h
+++ b/Libraries/LibWeb/DOM/Node.h
@@ -465,6 +465,7 @@ public:
// that only needs to know whether there is a box should ask these instead of reaching for the box. The layout
// node arena writes both as it changes the boxes they describe, so asking reads the node, not the arena.
[[nodiscard]] bool has_layout_box() const { return m_has_layout_box; }
+ [[nodiscard]] bool may_have_layout_box() const;
[[nodiscard]] bool is_rendered() const { return m_has_committed_box; }
void set_box_presence(Badge<Layout::NodeArena>, bool has_layout_box, bool has_committed_box)
{
diff --git a/Libraries/LibWeb/HTML/EventLoop/ClockPlan.cpp b/Libraries/LibWeb/HTML/EventLoop/ClockPlan.cpp
index 7bb4f486b45..995f4f53e95 100644
--- a/Libraries/LibWeb/HTML/EventLoop/ClockPlan.cpp
+++ b/Libraries/LibWeb/HTML/EventLoop/ClockPlan.cpp
@@ -142,7 +142,7 @@ bool hover_lane_is_enabled()
return enabled;
}
-// The page's cursor, as a hover of the render clock asks it to show the cursor of what it hovers, on the StyleLayout
+// The page's cursor, as a hover of the render clock asks it to show the cursor of what it hovers, on the Render
// thread.
static Layout::RustFFI::FfiPageCursor ffi_page_cursor(PageCursor& cursor)
{
diff --git a/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp b/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
index f0bf76edae6..99131b815d3 100644
--- a/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
+++ b/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
@@ -133,7 +133,7 @@ void EventLoop::spin_until(GC::Ref<GC::Function<bool()>> goal_condition)
vm.save_execution_context_stack();
vm.clear_execution_context_stack();
- // AD-HOC: A rendering update whose style transaction flies finishes first, as a pause that updates the rendering
+ // AD-HOC: A rendering update whose style update flies finishes first, as a pause that updates the rendering
// finishes it: the tasks the nested event loop runs come after the whole of it.
finish_rendering_update_in_flight();
@@ -185,7 +185,7 @@ void EventLoop::process()
m_task_generation++;
- // AD-HOC: A rendering update's style transaction and recording fly beside the tasks after it, and each is taken in
+ // AD-HOC: A rendering update's style update and recording fly beside the tasks after it, and each is taken in
// once it has finished, between two tasks.
take_finished_frames_in();
@@ -573,7 +573,7 @@ enum class HeldTasks : u8 {
All,
};
-// A rendering update whose style transaction flies for its last document, with what its steps from that document's style
+// A rendering update whose style update flies for its last document, with what its steps from that document's style
// and layout on read.
struct EventLoop::RenderingUpdateInFlight {
AK_ALLOC_WITH_KMALLOC;
@@ -662,6 +662,14 @@ static bool rendering_update_makes_ready(Animations::Animation const& animation)
return animation.pending() && (animation.is_css_animation() || animation.is_css_transition()) && effect && !effect->may_run_on_the_compositor();
}
+// Whether `animation` runs on the compositor, whose animations, the wake-ups they arm and the ones that leave it, a
+// rendering update publishes with its frame.
+static bool runs_on_the_compositor(Animations::Animation const& animation)
+{
+ auto const* effect = as_if<Animations::KeyframeEffect>(animation.effect().ptr());
+ return effect && effect->is_compositor_driven();
+}
+
enum class StyleTakenIn : u8 {
No,
Yes,
@@ -672,11 +680,12 @@ enum class LayoutHeldForTesting : bool {
Yes,
};
-// Which tasks a rendering update whose style transaction flies for its last doc holds back until the whole of it has
+// Which tasks a rendering update whose style update flies for its last doc holds back until the whole of it has
// run, as the steps after its style and layout deliver to script what comes before any task: the intersection
// observations of every doc, whose roots and targets the script of any document may reach, rendered or not, the resize
// observations the last doc's layout answers, and the animations it samples and transitions it starts, whose timing
-// script sees follow the update. Once the transaction is taken in, those are the ones its style began.
+// script sees follow the update. Once the transaction is taken in, those are the ones its style began, and the ones
+// running on the compositor, which the update's frame publishes.
// AD-HOC: The render clock's lanes of the docs the update took in present nothing until its frame: a task beside the
// update would leave the pointer unhovered and the animations still for as long as it runs, where the lanes
// would hover or animate beside it. A test that holds the layout that flies runs the doc's tasks beside it.
@@ -702,7 +711,7 @@ static HeldTasks tasks_rendering_update_holds(Vector<GC::Root<DOM::Document>> co
return HeldTasks::OfLastDocument;
for (auto const& timeline : document.associated_animation_timelines()) {
for (auto const& animation : timeline->associated_animations()) {
- if (style_taken_in == StyleTakenIn::No || rendering_update_makes_ready(animation))
+ if (style_taken_in == StyleTakenIn::No || rendering_update_makes_ready(animation) || runs_on_the_compositor(animation))
return HeldTasks::OfLastDocument;
}
}
@@ -880,7 +889,7 @@ void EventLoop::update_the_rendering()
++m_rendering_scheduler_counters.updates_run;
++m_rendering_update_serial;
- // AD-HOC: The last rendering update may have ended as its style transaction flew. Its layout runs beside this
+ // AD-HOC: The last rendering update may have ended as its style update flew. Its layout runs beside this
// update's steps up to step 16, which takes the rest of it in, or the rest of it runs now.
if (m_rendering_update_in_flight && !m_rendering_update_in_flight->held_for_testing && !m_rendering_update_in_flight->layout_flew
&& !let_layout_of_rendering_update_fly())
@@ -1009,7 +1018,7 @@ void EventLoop::update_the_rendering()
// 16. For each doc of docs:
for (size_t document_index = 0; document_index < docs.size(); ++document_index) {
- // AD-HOC: The style transaction of the last doc of docs flies beside the event loop where nothing keeps it in
+ // AD-HOC: The style update of the last doc of docs flies beside the event loop where nothing keeps it in
// step, and the update ends its task here: it goes on with the doc's style and layout once the event
// loop takes the transaction in, between two tasks. A styled doc with no style to change lets the
// first round of its layout fly the same way. Every doc before it, its container's included, is laid
@@ -1416,7 +1425,7 @@ void EventLoop::resume_rendering_update_in_flight()
}
}
-// The rest of the last rendering update, which ended as its style transaction flew, runs before anything of the next
+// The rest of the last rendering update, which ended as its style update flew, runs before anything of the next
// one's style and layout. Where its layout flew as well, its steps go on from that layout, as it left the document: what
// the next update wrote since is that update's, which the render state takes in behind them.
void EventLoop::finish_ended_rendering_update_in_flight()
@@ -1460,7 +1469,7 @@ u64 EventLoop::first_rendering_update_to_gather_resize_observations_of(DOM::Docu
void EventLoop::finish_rendering_update_in_flight()
{
- // The steps after the style transaction take it in, waiting for it to land.
+ // The steps after the style update take it in, waiting for it to land.
if (m_rendering_update_in_flight)
resume_rendering_update_in_flight();
}
@@ -1540,7 +1549,7 @@ bool EventLoop::rendering_update_in_flight_holds_tasks_of(DOM::Document const* d
VERIFY_NOT_REACHED();
}
-// The layout of the doc whose style transaction flew runs beside the event loop as well, once the event loop has taken
+// The layout of the doc whose style update flew runs beside the event loop as well, once the event loop has taken
// the transaction in. Answers whether it flies.
bool EventLoop::let_layout_of_rendering_update_fly()
{
@@ -1557,17 +1566,22 @@ bool EventLoop::let_layout_of_rendering_update_fly()
void EventLoop::take_finished_frames_in()
{
- // A rendering update whose style transaction, then layout, has landed goes on; the tasks before that run beside it,
+ // A rendering update whose style update, then layout, has landed goes on; the tasks before that run beside it,
// but for those it holds back, which wait. None is in flight in a nested event loop, which finishes it as it begins,
// and a paused event loop does not come here.
if (m_rendering_update_in_flight && !m_rendering_update_in_flight->held_for_testing
- && !CSS::StyleEngineFFI::style_engine_style_transaction_flies(m_rendering_update_in_flight->document().style_computer().style_engine().host())
+ && !CSS::StyleEngineFFI::style_engine_style_update_flies(m_rendering_update_in_flight->document().style_computer().style_engine().host())
&& (m_rendering_update_in_flight->layout_flew || !let_layout_of_rendering_update_fly()))
resume_rendering_update_in_flight();
// A frame that was taken in leaves the list as it is, which moves only the entries after it.
for (size_t index = m_navigables_with_frames_in_flight.size(); index-- > 0;)
(void)m_navigables_with_frames_in_flight[index]->take_recording_in_flight_in(LocalNavigable::TakeIn::IfFinished);
+
+ // NB: This runs between tasks, so no end of a task takes what the style drains above queued, such as the reaction
+ // to a promise an animation resolved, and no task may follow for a long time.
+ if (!m_microtask_queue.is_empty() && vm().execution_context_stack().is_empty())
+ perform_a_microtask_checkpoint();
}
// AD-HOC: The render clock's lanes follow the frames a document presents: they hover what is under the pointer whenever
@@ -1667,6 +1681,11 @@ void EventLoop::perform_a_microtask_checkpoint()
if (execution_paused())
return;
+ // NB: The checkpoint at the end of the task, or of taking finished frames in between tasks, takes what is queued
+ // meanwhile.
+ if (m_microtask_checkpoint_deferrals > 0)
+ return;
+
// 1. If the event loop's performing a microtask checkpoint is true, then return.
if (m_performing_a_microtask_checkpoint)
return;
@@ -1928,7 +1947,7 @@ EventLoop::PauseHandle EventLoop::pause(UpdateTheRendering should_update_the_ren
// 3. If necessary, update the rendering or user interface of any Document or navigable to reflect the current state.
// NB: UpdateTheRendering::No skips this step, for a caller that must not run author callbacks (e.g., rAF callbacks)
// while it's blocked — a sync XHR send(), which may itself have been invoked from within a microtask.
- // A rendering update whose style transaction flies finishes first, as the update whose rendering the user sees.
+ // A rendering update whose style update flies finishes first, as the update whose rendering the user sees.
if (should_update_the_rendering == UpdateTheRendering::Yes && m_rendering_update_in_flight) {
finish_rendering_update_in_flight();
} else if (should_update_the_rendering == UpdateTheRendering::Yes && !m_running_rendering_task) {
diff --git a/Libraries/LibWeb/HTML/EventLoop/EventLoop.h b/Libraries/LibWeb/HTML/EventLoop/EventLoop.h
index 2a1ef701d60..863497c084e 100644
--- a/Libraries/LibWeb/HTML/EventLoop/EventLoop.h
+++ b/Libraries/LibWeb/HTML/EventLoop/EventLoop.h
@@ -60,7 +60,7 @@ class WEB_API EventLoop : public JS::Cell {
};
public:
- // Whether the style transaction of a document in a rendering update may fly beside the event loop, or what keeps it
+ // Whether the style update of a document in a rendering update may fly beside the event loop, or what keeps it
// in step.
Layout::RustFFI::FfiFlightBlocker style_flight_blocker(DOM::Document&) const;
@@ -136,6 +136,15 @@ public:
void perform_a_microtask_checkpoint();
+ // NB: Style and layout run no script. A temporary execution context they use ends with an empty stack, which would
+ // otherwise perform a checkpoint in the middle of them, for microtasks queued outside any script.
+ void defer_microtask_checkpoints() { ++m_microtask_checkpoint_deferrals; }
+ void resume_microtask_checkpoints()
+ {
+ VERIFY(m_microtask_checkpoint_deferrals > 0);
+ --m_microtask_checkpoint_deferrals;
+ }
+
void register_document(Badge<DOM::Document>, DOM::Document&);
void unregister_document(Badge<DOM::Document>, DOM::Document&);
void document_navigable_did_change(Badge<DOM::Document>);
@@ -168,8 +177,8 @@ public:
bool running_rendering_task() const { return m_running_rendering_task; }
- // A rendering update's style transaction and its frame fly beside the event loop until the event loop takes them in
- // between two tasks. A rendering update whose style transaction flies runs its steps from its style and layout on
+ // A rendering update's style update and its frame fly beside the event loop until the event loop takes them in
+ // between two tasks. A rendering update whose style update flies runs its steps from its style and layout on
// once the transaction is taken in.
void did_commit_frame(LocalNavigable&, CommittedFrameRecords);
void did_take_frame_in(LocalNavigable&);
@@ -184,7 +193,7 @@ public:
bool has_rendering_update_in_flight() const { return m_rendering_update_in_flight; }
// Whether the layout of the rendering update in flight runs, or ran, beside the event loop.
bool lays_out_rendering_update_in_flight() const;
- // Runs the steps of the rendering update whose style transaction flies, which take the transaction in.
+ // Runs the steps of the rendering update whose style update flies, which take the transaction in.
void finish_rendering_update_in_flight();
// The serial number of the first rendering update that may gather a resize observation of `document` made now. A
// task beside a rendering update whose style and layout of the document have yet to run comes after the whole of it.
@@ -256,6 +265,7 @@ private:
// https://html.spec.whatwg.org/multipage/webappapis.html#performing-a-microtask-checkpoint
bool m_performing_a_microtask_checkpoint { false };
+ u32 m_microtask_checkpoint_deferrals { 0 };
mutable Vector<GC::Weak<DOM::Document>> m_documents;
mutable bool m_documents_sort_dirty { false };
diff --git a/Libraries/LibWeb/Layout/LayoutRustBridge.cpp b/Libraries/LibWeb/Layout/LayoutRustBridge.cpp
index ca824df1011..0a7074ca3b3 100644
--- a/Libraries/LibWeb/Layout/LayoutRustBridge.cpp
+++ b/Libraries/LibWeb/Layout/LayoutRustBridge.cpp
@@ -64,13 +64,11 @@
namespace Web::Layout {
-static_assert(to_underlying(CSS::StyleGroupIndex::Count) == RustFFI::STYLE_GROUP_COUNT);
static_assert(to_underlying(CSS::StyleGroupIndex::GridValues) == RustFFI::STYLE_GROUP_INDEX_GRID);
static_assert(to_underlying(CSS::StyleGroupIndex::ContentValues) == RustFFI::STYLE_GROUP_INDEX_CONTENT);
static_assert(to_underlying(CSS::StyleGroupIndex::AnchorValues) == RustFFI::STYLE_GROUP_INDEX_ANCHOR);
-static_assert(to_underlying(CSS::StyleGroupIndex::InheritedTableValues) == RustFFI::STYLE_GROUP_INDEX_INHERITED_TABLE);
+static_assert(to_underlying(CSS::StyleGroupIndex::InheritedListTableValues) == RustFFI::STYLE_GROUP_INDEX_INHERITED_LIST_TABLE);
static_assert(to_underlying(CSS::StyleGroupIndex::InheritedTextValues) == RustFFI::STYLE_GROUP_INDEX_INHERITED_TEXT);
-static_assert(to_underlying(CSS::StyleGroupIndex::InheritedBoxValues) == RustFFI::STYLE_GROUP_INDEX_INHERITED_BOX);
static_assert(to_underlying(CSS::StyleGroupIndex::FontValues) == RustFFI::STYLE_GROUP_INDEX_FONT);
static_assert(to_underlying(CSS::StyleGroupIndex::SVGResetValues) == RustFFI::STYLE_GROUP_INDEX_SVG_RESET);
static_assert(to_underlying(CSS::StyleGroupIndex::BorderValues) == RustFFI::STYLE_GROUP_INDEX_BORDER);
@@ -144,20 +142,17 @@ static CSS::StyleAtomID svg_style_reference_fragment_atom(DOM::Element& element,
// The four resources `mask`, `clip-path`, `fill` and `stroke` name. Read from the record's group payloads rather than
// through a materialized view: this runs for every SVG graphics element whose style record is replaced, and pinning a
// record to look at four properties is most of the cost of looking at them.
-static Array<Optional<CSS::URL>, 4> svg_style_reference_urls(void const* record_payloads)
+static Array<Optional<CSS::URL>, 4> svg_style_reference_urls(void const* record_groups)
{
- auto const* payloads = static_cast<void const* const*>(record_payloads);
- if (!payloads)
- return {};
- auto const* mask_payload = static_cast<CSS::ComputedValues::MaskValues const*>(payloads[CSS::ComputedValues::MaskValues::style_group_index]);
- auto const* svg_payload = static_cast<CSS::ComputedValues::InheritedSVGValues const*>(payloads[CSS::ComputedValues::InheritedSVGValues::style_group_index]);
- if (!mask_payload || !svg_payload)
+ if (!record_groups)
return {};
+ auto const& mask = CSS::style_record_group<CSS::ComputedValues::MaskValues>(record_groups);
+ auto const& svg = CSS::style_record_group<CSS::ComputedValues::InheritedSVGValues>(record_groups);
return {
- mask_payload->mask_url_value(),
- mask_payload->clip_path_value(),
- svg_payload->fill_url_value(),
- svg_payload->stroke_url_value(),
+ mask.mask_url_value(),
+ mask.clip_path_value(),
+ svg.fill_url_value(),
+ svg.stroke_url_value(),
};
}
@@ -165,7 +160,7 @@ static Array<CSS::StyleAtomID, 4> svg_style_reference_atoms(DOM::Element& elemen
{
if (!is<SVG::SVGGraphicsElement>(element))
return {};
- auto urls = svg_style_reference_urls(element.style_record_payloads());
+ auto urls = svg_style_reference_urls(element.style_record_groups());
return {
svg_style_reference_fragment_atom(element, urls[0]),
svg_style_reference_fragment_atom(element, urls[1]),
@@ -176,15 +171,15 @@ static Array<CSS::StyleAtomID, 4> svg_style_reference_atoms(DOM::Element& elemen
bool svg_style_references_differ(CSS::InstalledStyle const& old_style, CSS::InstalledStyle const& new_style)
{
- auto const* old_payloads = static_cast<void const* const*>(old_style.payloads());
- auto const* new_payloads = static_cast<void const* const*>(new_style.payloads());
- if (old_payloads && new_payloads
- && old_payloads[CSS::ComputedValues::MaskValues::style_group_index] == new_payloads[CSS::ComputedValues::MaskValues::style_group_index]
- && old_payloads[CSS::ComputedValues::InheritedSVGValues::style_group_index] == new_payloads[CSS::ComputedValues::InheritedSVGValues::style_group_index])
+ auto const* old_groups = old_style.groups();
+ auto const* new_groups = new_style.groups();
+ if (old_groups && new_groups
+ && CSS::style_record_group_payload<CSS::ComputedValues::MaskValues::style_group_index>(old_groups) == CSS::style_record_group_payload<CSS::ComputedValues::MaskValues::style_group_index>(new_groups)
+ && CSS::style_record_group_payload<CSS::ComputedValues::InheritedSVGValues::style_group_index>(old_groups) == CSS::style_record_group_payload<CSS::ComputedValues::InheritedSVGValues::style_group_index>(new_groups))
return false;
- auto old_urls = svg_style_reference_urls(old_payloads);
- auto new_urls = svg_style_reference_urls(new_payloads);
+ auto old_urls = svg_style_reference_urls(old_groups);
+ auto new_urls = svg_style_reference_urls(new_groups);
for (size_t i = 0; i < old_urls.size(); ++i) {
if (old_urls[i].has_value() != new_urls[i].has_value())
return true;
diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cpp
index 452a9e4bdee..822a5cedd39 100644
--- a/Libraries/LibWeb/Layout/Node.cpp
+++ b/Libraries/LibWeb/Layout/Node.cpp
@@ -38,6 +38,12 @@
#include <LibWeb/SVG/SVGPatternElement.h>
#include <LibWeb/SVG/SVGTextContentElement.h>
+#ifndef NDEBUG
+# define LIBWEB_CHECK_RENDER_STATE_INSTALLS 1
+#else
+# define LIBWEB_CHECK_RENDER_STATE_INSTALLS 0
+#endif
+
namespace Web::Layout {
u8 Node::dom_paint_facts_of(DOM::Node const* node)
@@ -234,9 +240,9 @@ NodeWithStyle::NodeWithStyle(DOM::Document& document, BindToPreparedArenaSlot bi
{
m_style_record_identity = CSS::StyleRecordID { RustFFI::layout_row_style_record(document_host(), slot) };
VERIFY(m_style_record_identity);
- // The layout node reads its style through the row's payloads, which the row's live record keeps.
- m_style_payloads = RustFFI::layout_row_style_payloads(document_host(), slot);
- VERIFY(m_style_payloads);
+ // The layout node reads its style through the row's style, which the row's live record keeps.
+ m_style_record = RustFFI::layout_row_style(document_host(), slot);
+ VERIFY(m_style_record);
m_has_layout_derived_style = RustFFI::layout_row_style_is_derived(document_host(), slot);
}
@@ -387,8 +393,16 @@ NodeWithStyle::ImageObserver const* NodeWithStyle::border_image_source_observer(
namespace Web::Layout {
+bool style_record_installed_by_render_state(NodeWithStyle const& node, CSS::StyleRecordID style_record_identity)
+{
+ return style_record_identity.value() != 0 && RustFFI::render_state_installed_style_record(node.document_host(), Node::slot_id(&node)) == style_record_identity.value();
+}
+
void NodeWithStyle::apply_style(CSS::StyleRecordID style_record_identity)
{
+ // The render side installed the record in this node's row ahead of the host, with everything below that follows
+ // from it in the layout tree: the node adopts it as its own.
+ bool const installed_by_render_state = style_record_installed_by_render_state(*this, style_record_identity);
bool const changes_published_record = m_style_record_identity != style_record_identity || m_has_layout_derived_style;
release_pinned_style_record();
m_background_images.clear();
@@ -398,27 +412,30 @@ void NodeWithStyle::apply_style(CSS::StyleRecordID style_record_identity)
m_style_record_identity = style_record_identity;
// OPTIMIZATION: Installing the DOM record already published a followed layout node's record. Applying its
// rendering consequences need not enqueue the same record again.
- if (changes_published_record)
+ if (installed_by_render_state)
+ adopt_style_record_installed_by_render_state();
+ else if (changes_published_record)
publish_style_record_to_node_data();
else
did_update_style_record();
set_flag(RustFFI::NodeFlag::HasAnimatedOpacityOrTransform, false);
// A style change can introduce the properties that make a node carry replaced-content facts,
// such as size containment arriving on a kept layout node.
- RustFFI::render_state_reinherit_anonymous_descendants(document_host(), slot_id(this), display().is_table_inside());
+ if (!installed_by_render_state)
+ RustFFI::render_state_reinherit_anonymous_descendants(document_host(), slot_id(this), display().is_table_inside());
attach_style_resources();
// A pseudo layout node can outlive replacement of the DOM pseudo's record until the layout
// tree is rebuilt. Root its record across that gap, including metadata-only style changes that
// keep the existing layout node.
if (is_generated_for_pseudo_element())
pin_style_record_for_cxx_consumers();
- if (auto const* element = as_if<DOM::Element>(dom_node()); element && element->is_viewport_propagation_source())
+ if (auto const* element = as_if<DOM::Element>(dom_node()); !installed_by_render_state && element && element->is_viewport_propagation_source())
RustFFI::render_state_propagate_root_styles_to_viewport(document_host());
}
-static bool style_record_holds_image_values(Layout::BegunRead const& read, CSS::StyleEngine const& style_engine, CSS::StyleRecordID style_record)
+static bool style_record_holds_image_values(Layout::BegunRead const& read, CSS::StyleComputer const& style_computer, CSS::StyleRecordID style_record)
{
- return has_flag(style_engine.style_record_dependency_flags(read, style_record), CSS::StyleRecordDependencyFlag::HoldsImageValues);
+ return has_flag(style_computer.install_style(read, style_record).dependency_flags(), CSS::StyleRecordDependencyFlag::HoldsImageValues);
}
void NodeWithStyle::attach_style_resources()
@@ -426,7 +443,7 @@ void NodeWithStyle::attach_style_resources()
// The style engine notes at publication whether a record holds an <image> anywhere this node would load and
// observe one. Nearly every style holds none, and that answer is one flag read; the walk below stays for the
// styles that do.
- auto holds_image_values = style_record_holds_image_values(held_read(), document().style_computer().style_engine(), m_style_record_identity);
+ auto holds_image_values = style_record_holds_image_values(held_read(), document().style_computer(), m_style_record_identity);
attach_style_resources(m_style_record_identity, holds_image_values ? Painting::StyleHoldsImageValues::Yes : Painting::StyleHoldsImageValues::No);
}
@@ -483,7 +500,7 @@ void NodeWithStyle::refresh_style_from_arena(CSS::StyleRecordID record, void con
{
release_pinned_style_record();
m_style_record_identity = record;
- m_style_payloads = payloads;
+ m_style_record = payloads;
m_has_layout_derived_style = derived;
m_background_images.clear();
m_mask_images.clear();
@@ -562,7 +579,10 @@ void NodeWithStyle::set_style_record_identity(CSS::StyleRecordID style_record_id
m_border_image_source.clear();
m_list_style_image.clear();
m_style_record_identity = style_record_identity;
- publish_style_record_to_node_data();
+ if (style_record_installed_by_render_state(*this, style_record_identity))
+ adopt_style_record_installed_by_render_state();
+ else
+ publish_style_record_to_node_data();
if (should_repin_style_record)
pin_style_record_for_cxx_consumers();
@@ -602,12 +622,25 @@ static Node const* scroll_snap_container_of(NodeWithStyle const& node)
void NodeWithStyle::publish_style_record_to_node_data()
{
+ // A row the render side styled is never published with another record behind its back.
+ if constexpr (LIBWEB_CHECK_RENDER_STATE_INSTALLS) {
+ auto const installed = RustFFI::render_state_installed_style_record(document_host(), slot_id(this));
+ VERIFY(installed == 0 || installed == m_style_record_identity.value());
+ }
++document().style_invalidation_counters().layout_style_record_publications;
- auto const view = document().style_computer().style_engine().style_record_view(held_read(), m_style_record_identity);
- VERIFY(view.present);
- auto const* payloads = view.payloads;
- m_style_payloads = payloads;
- RustFFI::render_state_set_node_style(document_host(), slot_id(this), m_style_record_identity.value(), payloads);
+ auto const style = document().style_computer().install_style(held_read(), m_style_record_identity);
+ VERIFY(style);
+ m_style_record = style.groups();
+ RustFFI::render_state_set_node_style(document_host(), slot_id(this), m_style_record_identity.value(), style.groups());
+ m_has_layout_derived_style = false;
+ did_update_style_record();
+}
+
+void NodeWithStyle::adopt_style_record_installed_by_render_state()
+{
+ auto const style = document().style_computer().install_style(held_read(), m_style_record_identity);
+ VERIFY(style);
+ m_style_record = style.groups();
m_has_layout_derived_style = false;
did_update_style_record();
}
@@ -617,7 +650,7 @@ void NodeWithStyle::did_update_style_record()
if (auto const* element = as_if<DOM::Element>(dom_node()); element && (element->has_style(CSS::PseudoElement::Selection) || element->has_style(CSS::PseudoElement::SearchText) || element->has_style(CSS::PseudoElement::SearchTextCurrent) || element->has_style(CSS::PseudoElement::SpellingError)))
Painting::push_highlight_pseudo_styles(*element);
- if (style_group<CSS::ComputedValues::MiscResetValues>().scroll_snap_strictness_value() != CSS::ScrollSnapStrictness::None)
+ if (style_group<CSS::ComputedValues::MiscInteractionValues>().scroll_snap_strictness_value() != CSS::ScrollSnapStrictness::None)
document().set_may_have_scroll_snap_areas();
// NB: The root element's style can be published before the layout tree gives the document a viewport to snap
diff --git a/Libraries/LibWeb/Layout/Node.h b/Libraries/LibWeb/Layout/Node.h
index 596f20ed69e..f38714c9648 100644
--- a/Libraries/LibWeb/Layout/Node.h
+++ b/Libraries/LibWeb/Layout/Node.h
@@ -369,12 +369,10 @@ public:
template<typename StyleGroup>
StyleGroup const& style_group() const
{
- VERIFY(m_style_payloads);
- auto const* payloads = static_cast<void const* const*>(m_style_payloads);
- auto const* payload = payloads[StyleGroup::style_group_index];
- VERIFY(payload);
- return *static_cast<StyleGroup const*>(payload);
+ return CSS::style_record_group<StyleGroup>(m_style_record);
}
+ // The inherited longhands the style holds as bits, and its effective zoom.
+ CSS::ComputedValuesFFI::InheritedSetValues const& inherited_set_values() const { return CSS::style_record_inherited_values(m_style_record); }
static CSS::LengthPercentageOrAuto length_percentage_or_auto(CSS::ComputedValuesFFI::ComputedLengthPercentageOrAuto const& value)
{
@@ -394,20 +392,21 @@ public:
}
CSS::Display display() const { return CSS::display_from_ffi_display(style_group<CSS::ComputedValues::BoxValues>().display); }
- CSS::Float float_() const { return static_cast<CSS::Float>(style_group<CSS::ComputedValues::BoxValues>().float_); }
- CSS::Positioning position() const { return static_cast<CSS::Positioning>(style_group<CSS::ComputedValues::BoxValues>().position); }
- CSS::BoxSizing box_sizing() const { return static_cast<CSS::BoxSizing>(style_group<CSS::ComputedValues::BoxValues>().box_sizing); }
- CSS::Overflow overflow_x() const { return static_cast<CSS::Overflow>(style_group<CSS::ComputedValues::BoxValues>().overflow_x); }
- CSS::Overflow overflow_y() const { return static_cast<CSS::Overflow>(style_group<CSS::ComputedValues::BoxValues>().overflow_y); }
+ CSS::ComputedValuesFFI::ResetBits reset_bits() const { return CSS::style_record_reset_bits(m_style_record); }
+ CSS::Float float_() const { return CSS::float_from_reset_bits(reset_bits()); }
+ CSS::Positioning position() const { return CSS::position_from_reset_bits(reset_bits()); }
+ CSS::BoxSizing box_sizing() const { return CSS::box_sizing_from_reset_bits(reset_bits()); }
+ CSS::Overflow overflow_x() const { return CSS::overflow_x_from_reset_bits(reset_bits()); }
+ CSS::Overflow overflow_y() const { return CSS::overflow_y_from_reset_bits(reset_bits()); }
CSS::Resize resize() const { return static_cast<CSS::Resize>(style_group<CSS::ComputedValues::BoxValues>().resize); }
CSS::Containment contain() const
{
auto const& values = style_group<CSS::ComputedValues::BoxValues>();
return { values.size_containment, values.inline_size_containment, values.layout_containment, values.style_containment, values.paint_containment };
}
- CSS::ContentVisibility content_visibility() const { return static_cast<CSS::ContentVisibility>(style_group<CSS::ComputedValues::InheritedBoxValues>().content_visibility); }
- CSS::Direction direction() const { return static_cast<CSS::Direction>(style_group<CSS::ComputedValues::InheritedBoxValues>().direction); }
- CSS::WritingMode writing_mode() const { return static_cast<CSS::WritingMode>(style_group<CSS::ComputedValues::InheritedBoxValues>().writing_mode); }
+ CSS::ContentVisibility content_visibility() const { return static_cast<CSS::ContentVisibility>(style_group<CSS::ComputedValues::MiscLayoutValues>().content_visibility); }
+ CSS::Direction direction() const { return CSS::direction_from_inherited_bits(inherited_set_values().bits); }
+ CSS::WritingMode writing_mode() const { return CSS::writing_mode_from_inherited_bits(inherited_set_values().bits); }
bool inline_axis_is_reverse() const
{
switch (writing_mode()) {
@@ -421,25 +420,24 @@ public:
}
VERIFY_NOT_REACHED();
}
- CSS::Visibility visibility() const { return static_cast<CSS::Visibility>(style_group<CSS::ComputedValues::InheritedBoxValues>().visibility); }
+ CSS::Visibility visibility() const { return CSS::visibility_from_inherited_bits(inherited_set_values().bits); }
// https://drafts.csswg.org/css-ui-4/#caret-color
// auto: "User agents should use currentColor." It computes to auto, so the box's own color is read here.
Color caret_color() const
{
- auto const& ui = style_group<CSS::ComputedValues::InheritedUIValues>();
- return ui.caret_color.is_auto ? color() : ui.caret_color_value();
+ return style_group<CSS::ComputedValues::InheritedUIValues>().caret_color_value(color());
}
CSS::PreferredColorScheme color_scheme() const { return style_group<CSS::ComputedValues::InheritedUIValues>().color_scheme_value(); }
ReadonlySpan<Utf16FlyString> color_schemes() const { return style_group<CSS::ComputedValues::InheritedUIValues>().color_schemes_span(); }
bool color_scheme_only() const { return style_group<CSS::ComputedValues::InheritedUIValues>().color_scheme_only; }
ReadonlySpan<CSS::ComputedValuesFFI::ComputedCursor> cursor() const { return style_group<CSS::ComputedValues::InheritedUIValues>().cursor_span(); }
ReadonlySpan<RefPtr<CSS::CursorStyleValue const>> cursor_style_values() const;
- CSS::PointerEvents pointer_events() const { return style_group<CSS::ComputedValues::InheritedUIValues>().pointer_events_value(); }
- CSS::UserSelect user_select() const { return static_cast<CSS::UserSelect>(style_group<CSS::ComputedValues::MiscResetValues>().user_select); }
- Optional<Utf16FlyString> view_transition_name() const { return style_group<CSS::ComputedValues::MiscResetValues>().view_transition_name_value(); }
- Color outline_color() const { return Color::from_bgra(style_group<CSS::ComputedValues::MiscResetValues>().outline_color); }
- Color column_rule_color() const { return Color::from_bgra(style_group<CSS::ComputedValues::MiscResetValues>().column_rule_color); }
- Color background_color() const { return style_group<CSS::ComputedValues::BackgroundValues>().background_color_value(); }
+ CSS::PointerEvents pointer_events() const { return CSS::pointer_events_from_inherited_bits(inherited_set_values().bits); }
+ CSS::UserSelect user_select() const { return static_cast<CSS::UserSelect>(style_group<CSS::ComputedValues::MiscInteractionValues>().user_select); }
+ Optional<Utf16FlyString> view_transition_name() const { return style_group<CSS::ComputedValues::MiscInteractionValues>().view_transition_name_value(); }
+ Color outline_color() const { return CSS::resolve_style_color(style_group<CSS::ComputedValues::MiscLayoutValues>().outline_color, color()); }
+ Color column_rule_color() const { return CSS::resolve_style_color(style_group<CSS::ComputedValues::MiscLayoutValues>().column_rule_color, color()); }
+ Color background_color() const { return style_group<CSS::ComputedValues::BackgroundValues>().background_color_value(color()); }
// One image per background layer, null where the layer has no image.
ReadonlySpan<RefPtr<CSS::AbstractImageStyleValue const>> background_images() const
{
@@ -457,7 +455,7 @@ public:
CSS::AbstractImageStyleValue const* list_style_image() const
{
if (!m_list_style_image.has_value())
- m_list_style_image = style_group<CSS::ComputedValues::InheritedListValues>().list_style_image_value();
+ m_list_style_image = style_group<CSS::ComputedValues::InheritedListTableValues>().list_style_image_value();
return m_list_style_image->ptr();
}
CSS::ComputedFilterView backdrop_filter() const { return style_group<CSS::ComputedValues::EffectsValues>().backdrop_filter_value(); }
@@ -465,10 +463,10 @@ public:
CSS::MixBlendMode mix_blend_mode() const { return style_group<CSS::ComputedValues::EffectsValues>().mix_blend_mode_value(); }
float opacity() const { return style_group<CSS::ComputedValues::EffectsValues>().opacity; }
ReadonlySpan<CSS::ShadowData> box_shadow() const { return style_group<CSS::ComputedValues::EffectsValues>().box_shadow_span(); }
- CSS::BorderData const& border_left() const { return style_group<CSS::ComputedValues::BorderValues>().border_left_value(); }
- CSS::BorderData const& border_top() const { return style_group<CSS::ComputedValues::BorderValues>().border_top_value(); }
- CSS::BorderData const& border_right() const { return style_group<CSS::ComputedValues::BorderValues>().border_right_value(); }
- CSS::BorderData const& border_bottom() const { return style_group<CSS::ComputedValues::BorderValues>().border_bottom_value(); }
+ CSS::BorderData border_left() const { return style_group<CSS::ComputedValues::BorderValues>().border_left_value(color()); }
+ CSS::BorderData border_top() const { return style_group<CSS::ComputedValues::BorderValues>().border_top_value(color()); }
+ CSS::BorderData border_right() const { return style_group<CSS::ComputedValues::BorderValues>().border_right_value(color()); }
+ CSS::BorderData border_bottom() const { return style_group<CSS::ComputedValues::BorderValues>().border_bottom_value(color()); }
CSS::AbstractImageStyleValue const* border_image_source() const
{
if (!m_border_image_source.has_value())
@@ -479,8 +477,8 @@ public:
Color webkit_text_fill_color() const { return style_group<CSS::ComputedValues::InheritedTextValues>().webkit_text_fill_color_value(); }
CSSPixels letter_spacing() const { return style_group<CSS::ComputedValues::InheritedTextValues>().letter_spacing_value(); }
ReadonlySpan<CSS::ShadowData> text_shadow() const { return style_group<CSS::ComputedValues::InheritedTextValues>().text_shadow_span(); }
- Color text_decoration_color() const { return Color::from_bgra(style_group<CSS::ComputedValues::TextResetValues>().text_decoration_color); }
- CSSPixels line_height() const { return style_group<CSS::ComputedValues::FontValues>().line_height_used; }
+ Color text_decoration_color() const { return CSS::resolve_style_color(style_group<CSS::ComputedValues::TextResetValues>().text_decoration_color, color()); }
+ CSSPixels line_height() const { return style_group<CSS::ComputedValues::FontValues>().line_height_used_value(); }
CSSPixels font_size() const { return style_group<CSS::ComputedValues::FontValues>().font_size; }
Gfx::FontCascadeList const& font_list() const { return style_group<CSS::ComputedValues::FontValues>().font_list_value(); }
CSS::LengthBox inset() const { return length_box(style_group<CSS::ComputedValues::SurroundValues>().inset); }
@@ -546,11 +544,12 @@ private:
virtual bool is_node_with_style() const final { return true; }
void publish_style_record_to_node_data();
+ void adopt_style_record_installed_by_render_state();
void did_update_style_record();
void rebuild_image_observers(Vector<RefPtr<CSS::CursorStyleValue const>>);
ImageObserverSlots const* image_observers() const;
- void const* m_style_payloads { nullptr };
+ void const* m_style_record { nullptr };
// Whether the row holds a pin of its style record for C++'s readers, which only this layout node takes and drops.
bool m_style_record_pinned_for_cxx_consumers { false };
// Whether the arena derived the row's style record. Only this layout node publishes a record of its node to the row
@@ -596,4 +595,8 @@ inline Gfx::Font const& NodeWithStyle::first_available_font() const
bool overflow_value_makes_box_a_scroll_container(CSS::Overflow overflow);
+// Whether the render side installed `style_record_identity` in the row of `node` ahead of the host, with the relayout
+// and the repaint the move asks for, as it installs a style update.
+bool style_record_installed_by_render_state(NodeWithStyle const& node, CSS::StyleRecordID style_record_identity);
+
}
diff --git a/Libraries/LibWeb/Layout/RenderDocument.cpp b/Libraries/LibWeb/Layout/RenderDocument.cpp
index 930a81e2832..169d5623c56 100644
--- a/Libraries/LibWeb/Layout/RenderDocument.cpp
+++ b/Libraries/LibWeb/Layout/RenderDocument.cpp
@@ -38,7 +38,7 @@ ForcedReadScope::ForcedReadScope(DOM::Document const& document)
}
// The lowest address of the calling thread's stack, which the render state asks for before it runs a job on a host's
-// thread rather than the StyleLayout thread's larger stack.
+// thread rather than the Render thread's larger stack.
extern "C" FlatPtr web_current_thread_stack_base();
extern "C" FlatPtr web_current_thread_stack_base()
{
diff --git a/Libraries/LibWeb/Layout/SearchableText.cpp b/Libraries/LibWeb/Layout/SearchableText.cpp
index 33a8515af96..176b4266126 100644
--- a/Libraries/LibWeb/Layout/SearchableText.cpp
+++ b/Libraries/LibWeb/Layout/SearchableText.cpp
@@ -192,8 +192,8 @@ SearchableText SearchableText::collect(Viewport& viewport)
return {};
auto* parent = text->parent_or_shadow_host_element();
- auto const* parent_inherited_box_values = parent ? parent->style_group<CSS::ComputedValues::InheritedBoxValues>() : nullptr;
- if (!parent_inherited_box_values || static_cast<CSS::Visibility>(parent_inherited_box_values->visibility) != CSS::Visibility::Visible)
+ auto const* parent_inherited_values = parent ? parent->style_inherited_set_values() : nullptr;
+ if (!parent_inherited_values || CSS::visibility_from_inherited_bits(parent_inherited_values->bits) != CSS::Visibility::Visible)
return {};
// AD-HOC: Revealable hidden content does not have a layout node yet, so its hidden state
@@ -207,11 +207,11 @@ SearchableText SearchableText::collect(Viewport& viewport)
auto append_visible_text_node = [&](DOM::Text& text, Searchability searchability) {
auto* parent = text.parent_or_shadow_host_element();
VERIFY(parent);
- auto const* parent_inherited_text_values = parent->style_group<CSS::ComputedValues::InheritedTextValues>();
- VERIFY(parent_inherited_text_values);
+ auto const* parent_inherited_values = parent->style_inherited_set_values();
+ VERIFY(parent_inherited_values);
auto const append_text = [&](Utf16View text_to_append, size_t dom_start_offset, TextNode const* layout_text_node = nullptr, Vector<RenderedTextOffset> const* offset_mapping = nullptr) {
- auto const white_space_collapse = parent_inherited_text_values->white_space_collapse_value();
+ auto const white_space_collapse = CSS::white_space_collapse_from_inherited_bits(parent_inherited_values->bits);
auto const should_collapse = first_is_one_of(
white_space_collapse,
CSS::WhiteSpaceCollapse::Collapse,
diff --git a/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Libraries/LibWeb/Layout/TreeBuilder.cpp
index 94bc03d7946..e7c9ef3d1fe 100644
--- a/Libraries/LibWeb/Layout/TreeBuilder.cpp
+++ b/Libraries/LibWeb/Layout/TreeBuilder.cpp
@@ -235,9 +235,9 @@ bool attach_owed_generated_image(Layout::BegunRead const& read, DOM::Document& d
auto& marker = as<NodeWithStyle>(*static_cast<Node*>(RustFFI::render_state_node_shell_if_live(arena.host(), &read, generated_image.marker)));
return *marker.list_style_image();
}
- auto const* payloads = DOM::AbstractElement { *element, css_pseudo_element(ffi_pseudo) }.style_record_payloads();
- VERIFY(payloads);
- auto content = CSS::style_group_from_payloads<CSS::ComputedValues::ContentValues>(payloads)->computed_content_value();
+ auto const* groups = DOM::AbstractElement { *element, css_pseudo_element(ffi_pseudo) }.style_record_groups();
+ VERIFY(groups);
+ auto content = CSS::style_record_group<CSS::ComputedValues::ContentValues>(groups).computed_content_value();
return content->as_content().content().values()[generated_image.content_index]->as_abstract_image();
}();
attach_owned_image_provider(image_box, const_cast<CSS::AbstractImageStyleValue&>(*image));
diff --git a/Libraries/LibWeb/Layout/UpdateLayout.cpp b/Libraries/LibWeb/Layout/UpdateLayout.cpp
index 67c9a96c627..e2bfb3a62c8 100644
--- a/Libraries/LibWeb/Layout/UpdateLayout.cpp
+++ b/Libraries/LibWeb/Layout/UpdateLayout.cpp
@@ -5,6 +5,7 @@
*/
#include <AK/Array.h>
+#include <AK/Format.h>
#include <AK/ScopeGuard.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
@@ -28,129 +29,6 @@
namespace Web::DOM {
-// Describes the node a style node names, for the panic of a layout update that ran out of passes: the node and its
-// flat tree ancestors, each with whether it is styled and the display of its box, what the style engine knows of it,
-// and the marks and attributes that bear on whether it can be styled, as a NUL-terminated ASCII string in the buffer,
-// which the panic's message quotes.
-static void describe_node_for_bound_failure(Document& document, Layout::BegunRead const& read, u32 style_node, Bytes buffer)
-{
- StringBuilder builder;
- GC::Ptr<Node> node;
- if (style_node)
- node = document.style_computer().node_for_style_node(CSS::StyleNodeID { style_node });
- if (!node) {
- builder.append("none"sv);
- } else {
- auto const* engine_host = document.style_computer().style_engine().host();
- int depth = 0;
- for (Node* current = node.ptr(); current && depth < 6; current = current->flat_tree_parent(), ++depth) {
- if (depth)
- builder.append(" < "sv);
- auto* element = as_if<Element>(*current);
- if (!element) {
- if (current->is_document())
- builder.append("document"sv);
- else if (current->is_text())
- builder.append("#text"sv);
- else
- builder.append("node"sv);
- continue;
- }
- builder.appendff("{}", element->local_name());
- if (element->id().has_value())
- builder.appendff("#{}", element->id().value());
- for (auto const& class_name : element->class_names())
- builder.appendff(".{}", class_name);
- if (!element->has_style())
- builder.append("{unstyled}"sv);
- else if (auto const* layout_node = element->unsafe_layout_node(read))
- builder.appendff("{{{}}}", layout_node->display().to_string());
- else
- builder.append("{no box}"sv);
- // The DOM-side marks that bear on styling the element, and the engine's view of it.
- builder.append('[');
- if (element->style_arrival_pending())
- builder.append("arrival-pending,"sv);
- if (element->child_style_arrivals_wait())
- builder.append("children-wait,"sv);
- if (element->descendant_style_arrival_pending())
- builder.append("descendant-pending,"sv);
- if (is<ShadowRoot>(element->root()))
- builder.append("in-shadow,"sv);
- if (element->has_assigned_slot())
- builder.append("slotted,"sv);
- if (element->style_node_id() == 0) {
- builder.append("no-style-node"sv);
- } else {
- auto facts = CSS::StyleEngineFFI::style_engine_bound_failure_node_facts(engine_host, &read, element->style_node_id().value());
- static constexpr Array displays { "-"sv, "none"sv, "contents"sv, "box"sv };
- static constexpr Array answers { "record"sv, "absent"sv, "refused"sv, "suspended"sv, "awaits-parent"sv };
- builder.appendff("engine:{},{},{},demand:{}", facts.is_live ? "live"sv : "dead"sv, facts.has_published_record ? "record"sv : "no-record"sv, displays[min<size_t>(facts.published_display, 3)], answers[min<size_t>(facts.read_demand_answer, 4)]);
- if (facts.owes_style_input)
- builder.append(",owes-input"sv);
- if (facts.ancestor_owes_style_input)
- builder.append(",ancestor-owes-input"sv);
- // The record the engine holds the node on against the one the element holds, the environment the
- // engine holds for it, whether its record has a cascade state, and the derived records the host
- // has not taken.
- builder.appendff(",rec:{}/{},env:{},cs:{}", facts.assigned_record, element->style_record_identity().value(), facts.environment, facts.has_cascade_state ? 1 : 0);
- if (facts.pending_records)
- builder.appendff(",pending:{}({}>{})", facts.pending_records, facts.pending_old_record, facts.pending_new_record);
- auto* flat_tree_parent_element = element->flat_tree_parent_element();
- u32 flat_tree_parent_style_node = flat_tree_parent_element ? flat_tree_parent_element->style_node_id().value() : 0;
- if (facts.inheritance_parent != flat_tree_parent_style_node || facts.flat_tree_parent != flat_tree_parent_style_node)
- builder.appendff(",engine-parents:{}/{},dom-parent:{}", facts.inheritance_parent, facts.flat_tree_parent, flat_tree_parent_style_node);
- }
- builder.append(']');
- if (depth == 0) {
- if (auto style = element->get_attribute(HTML::AttributeNames::style); style.has_value())
- builder.appendff(" style=\"{:.60}\"", style.value());
- for (auto const& name : { HTML::AttributeNames::hidden, HTML::AttributeNames::popover, HTML::AttributeNames::slot }) {
- if (element->has_attribute(name))
- builder.appendff(" {}", name);
- }
- // What one more targeted style update of the element answers now, with the engine's trace of the
- // update and the engine counters the update moved.
- auto& style_engine = document.style_computer().style_engine();
- Vector<u64> counters_before;
- for (size_t index = 0;; ++index) {
- StringView name;
- u64 value = 0;
- if (!style_engine.counter(read, index, name, value))
- break;
- counters_before.append(value);
- }
- CSS::StyleEngineFFI::style_engine_begin_bound_failure_trace(engine_host);
- bool styled = document.update_style_for_element(AbstractElement { *element });
- Array<u8, 512> trace_buffer;
- auto trace_length = CSS::StyleEngineFFI::style_engine_end_bound_failure_trace(engine_host, trace_buffer.span());
- builder.appendff(" targeted-update:{} trace:[{}] counters:[", styled ? "styled"sv : "unstyled"sv, StringView { reinterpret_cast<char const*>(trace_buffer.data()), trace_length });
- bool first_counter = true;
- for (size_t index = 0; index < counters_before.size(); ++index) {
- StringView name;
- u64 value = 0;
- if (!style_engine.counter(read, index, name, value))
- break;
- if (value == counters_before[index])
- continue;
- // Only the counters about deriving records and answering demands: a targeted update moves dozens
- // of others, which would crowd these out of the report.
- if (!name.contains("engineComputedRecord"sv) && !name.contains("Demand"sv) && !name.contains("Bail"sv) && !name.contains("Abandon"sv))
- continue;
- auto delta = static_cast<i64>(value) - static_cast<i64>(counters_before[index]);
- builder.appendff("{}{}{}{}", first_counter ? ""sv : ","sv, name, delta > 0 ? "+"sv : ""sv, delta);
- first_counter = false;
- }
- builder.append(']');
- }
- }
- }
- auto text = builder.string_view();
- auto length = min(text.length(), buffer.size() - 1);
- memcpy(buffer.data(), text.characters_without_null_termination(), length);
- buffer[length] = 0;
-}
-
// The document-side steps of the layout update, which the Rust loop drives through this table.
Layout::RustFFI::FfiLayoutUpdateHostCallbacks Document::layout_update_host_callbacks()
{
@@ -209,27 +87,22 @@ Layout::RustFFI::FfiLayoutUpdateHostCallbacks Document::layout_update_host_callb
.after_layout_commit = [](void* context, Layout::BegunRead const* read, bool layout_tree_changed) { static_cast<Document*>(context)->after_layout_commit(*read, layout_tree_changed ? LayoutTreeChanged::Yes : LayoutTreeChanged::No); },
.note_full_layout_performed = [](void* context) { static_cast<Document*>(context)->style_invalidation_counters().relayouts_performed++; },
.evaluate_pending_container_queries = [](void* context, Layout::BegunRead const* read) { static_cast<Document*>(context)->style_computer().style_engine().evaluate_size_containers_needing_evaluation_after_layout(*read); },
- .record_stabilization_bound_failure = [](void* context, Layout::BegunRead const* read, u32 last_unstyled_element, u32 last_rebuild_request) -> Layout::RustFFI::FfiStabilizationBoundFailureHostFacts {
+ .record_stabilization_bound_failure = [](void* context, Layout::BegunRead const* read) -> Layout::RustFFI::FfiStabilizationBoundFailureHostFacts {
auto& document = *static_cast<Document*>(context);
++document.m_style_invalidation_counters.style_stabilization_bound_failures;
auto navigable = document.navigable();
- Layout::RustFFI::FfiStabilizationBoundFailureHostFacts facts {
+ return {
.document_is_top_level = navigable && navigable->is_top_level_traversable(),
.needs_animated_style_update = document.m_needs_animated_style_update,
- .has_pending_style_transaction = document.style_computer().style_engine().has_pending_transaction(*read),
- .has_flown_style_transaction = document.has_flown_style_transaction(),
+ .has_pending_style_update = document.style_computer().style_engine().has_pending_transaction(*read),
+ .has_flown_style_update = document.has_flown_style_update(),
.size_containers_await_evaluation = document.has_size_containers_needing_evaluation_after_layout(*read),
.list_items_await_renumbering = !document.m_list_owners_pending_item_renumber.is_empty(),
.top_layer_zone_rebuild_pending = document.m_top_layer_needs_layout_zone_rebuild,
.top_layer_membership_changes_pending = !document.m_elements_with_pending_top_layer_membership_change.is_empty(),
.document_needs_layout_tree_update = document.needs_layout_tree_update(),
.document_child_needs_layout_tree_update = document.child_needs_layout_tree_update(),
- .last_unstyled_element = {},
- .last_rebuild_request = {},
- };
- describe_node_for_bound_failure(document, *read, last_unstyled_element, { facts.last_unstyled_element, sizeof(facts.last_unstyled_element) });
- describe_node_for_bound_failure(document, *read, last_rebuild_request, { facts.last_rebuild_request, sizeof(facts.last_rebuild_request) });
- return facts; },
+ }; },
.attach_style_resources = [](void* context, Layout::BegunRead const* read, Compositing::RustFFI::NodeSlotId slot, bool owns_content_replacement_image, Layout::RustFFI::FfiStyleImageFacts images) {
auto& document = *static_cast<Document*>(context);
if (Layout::attach_owed_style_resources(*read, document, slot, owns_content_replacement_image, images))
@@ -261,7 +134,7 @@ void Document::update_layout(UpdateLayoutReason reason, ThrottledAnimationSampli
// The update's waits for the render state are one read, which takes a frame in flight in.
Layout::ForcedReadScope read { style_computer().style_engine().render_document() };
- drain_flown_style_transaction(read);
+ drain_flown_style_update(read);
// An image box that owns its image's provider is handed it once the layout update that built the box is over, and
// the update lays it out without an image. If the image was already there, the box lays out again with it before
@@ -284,26 +157,6 @@ void Document::update_layout(UpdateLayoutReason reason, ThrottledAnimationSampli
update_style_and_layout();
}
-// The first round of the rendering update's layout reads the document's facts as they are before its style flies, and
-// runs after the style in the frame. List items that wait to be renumbered and top layer work are the layout update's
-// to do first, so nothing is sealed while either waits.
-void Document::seal_first_layout_round(Layout::BegunRead const& read)
-{
- if (!may_seal_first_layout_round())
- return;
- update_highlight_states_if_needed(read);
- auto inputs = first_layout_round_inputs();
- Layout::RustFFI::render_state_seal_first_layout_round(m_layout_node_arena->host(), &read, &inputs);
-}
-
-bool Document::may_seal_first_layout_round() const
-{
- auto navigable = this->navigable();
- if (!navigable || navigable->active_document().ptr() != this || !m_layout_node_arena)
- return false;
- return m_list_owners_pending_item_renumber.is_empty() && m_elements_with_pending_top_layer_membership_change.is_empty() && !m_top_layer_needs_layout_zone_rebuild;
-}
-
Layout::RustFFI::FfiLayoutUpdateInputs Document::first_layout_round_inputs() const
{
return {
diff --git a/Libraries/LibWeb/Page/PageCursor.h b/Libraries/LibWeb/Page/PageCursor.h
index 4dfde338a24..eb66608ac9b 100644
--- a/Libraries/LibWeb/Page/PageCursor.h
+++ b/Libraries/LibWeb/Page/PageCursor.h
@@ -17,7 +17,7 @@
namespace Web {
// The cursor a page asks its client to show. The main thread asks for one as it handles the pointer, and so does a hover
-// of the render clock while a task runs, on the StyleLayout thread. Each asks under one lock, so the client is left
+// of the render clock while a task runs, on the Render thread. Each asks under one lock, so the client is left
// showing the cursor asked for last.
class WEB_API PageCursor final : public AtomicRefCounted<PageCursor> {
public:
diff --git a/Libraries/LibWeb/Painting/ScrollSnap.cpp b/Libraries/LibWeb/Painting/ScrollSnap.cpp
index f738c9c8fa9..b23e444ea3d 100644
--- a/Libraries/LibWeb/Painting/ScrollSnap.cpp
+++ b/Libraries/LibWeb/Painting/ScrollSnap.cpp
@@ -88,10 +88,17 @@ bool is_scroll_snap_container(Layout::Node const& node)
auto const* node_with_style = as_if<Layout::NodeWithStyle>(node);
if (!node_with_style || !node_with_style->is_scroll_container())
return false;
- // OPTIMIZATION: Only the viewport takes its snap type from another box's style, so any other box without one snaps
- // nothing.
- if (!node.is_viewport() && node_with_style->style_group<CSS::ComputedValues::MiscResetValues>().scroll_snap_strictness_value() == CSS::ScrollSnapStrictness::None)
+ // OPTIMIZATION: Only the viewport takes its snap type from another box's style, the document element's, so any
+ // other box without one snaps nothing, and nor does the viewport where the document element has
+ // none. Asking the render state what the box snaps measures its overflow.
+ if (!node.is_viewport() && node_with_style->style_group<CSS::ComputedValues::MiscInteractionValues>().scroll_snap_strictness_value() == CSS::ScrollSnapStrictness::None)
return false;
+ if (node.is_viewport()) {
+ auto const* document_element = node.document().document_element();
+ auto const* misc_interaction_values = document_element ? document_element->style_group<CSS::ComputedValues::MiscInteractionValues>() : nullptr;
+ if (!misc_interaction_values || misc_interaction_values->scroll_snap_strictness_value() == CSS::ScrollSnapStrictness::None)
+ return false;
+ }
return !snap_axes_of_scroll_container(node).is_empty();
}
diff --git a/Libraries/LibWeb/Rust/src/css/style/animations.rs b/Libraries/LibWeb/Rust/src/css/style/animations.rs
index 5b3c4aae351..0604f20d444 100644
--- a/Libraries/LibWeb/Rust/src/css/style/animations.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/animations.rs
@@ -102,12 +102,43 @@ impl FfiAppliedAnimationDefinition {
}
}
+/// A definition the host published as applied, holding the values it names, so that it can read them whenever the
+/// animation it describes has moved on.
+#[derive(Clone)]
+pub(crate) struct HeldAppliedAnimationDefinition {
+ definition: FfiAppliedAnimationDefinition,
+ _values: [crate::css::style_value::RetainedStyleValueData; 3],
+}
+
+impl HeldAppliedAnimationDefinition {
+ /// # Safety
+ /// The values `definition` names must be null or live style values.
+ pub(crate) unsafe fn retained(definition: FfiAppliedAnimationDefinition) -> Self {
+ use crate::css::style_value::{RetainedStyleValueData, StyleValueData, retain_style_value};
+ let hold = |value: *const std::ffi::c_void| {
+ if value.is_null() {
+ return RetainedStyleValueData::none();
+ }
+ // SAFETY: Guaranteed by the caller; the handle takes the reference this retains.
+ unsafe { RetainedStyleValueData::from_retained_pointer(retain_style_value(value.cast::<StyleValueData>())) }
+ };
+ Self {
+ definition,
+ _values: [
+ hold(definition.timing_function),
+ hold(definition.range_start_calculated),
+ hold(definition.range_end_calculated),
+ ],
+ }
+ }
+}
+
/// One of the CSS animations the host holds: its name, and the definition the last plan applied
/// to it.
#[derive(Clone)]
pub(crate) struct CssDefinedAnimation {
pub(crate) name: CssString,
- applied_definition: FfiAppliedAnimationDefinition,
+ applied_definition: HeldAppliedAnimationDefinition,
}
/// The CSS animations the host holds in one of an element's lists, in its order.
@@ -123,6 +154,23 @@ pub(crate) struct CssDefinedAnimations {
}
impl CssDefinedAnimations {
+ /// The bytes the rows hold on the heap, with each name the first time `sizer` reaches it.
+ pub(crate) fn heap_size(&self, sizer: &mut crate::heap_size::HeapSizer) -> usize {
+ use crate::heap_size::{map_bytes, vec_bytes};
+ let mut bytes = map_bytes(&self.rows);
+ for lists in self.rows.values() {
+ bytes += vec_bytes(lists);
+ for (_, animations) in lists {
+ bytes += size_of_val::<[CssDefinedAnimation]>(animations);
+ bytes += animations
+ .iter()
+ .map(|animation| animation.name.heap_size(sizer))
+ .sum::<usize>();
+ }
+ }
+ bytes
+ }
+
/// Replace one list from the names and applied definitions the host publishes, a definition per
/// animation. An empty list drops it, so an element that stops animating stops costing anything.
pub(crate) fn set(
@@ -130,7 +178,7 @@ impl CssDefinedAnimations {
node: StyleNodeID,
slot: AnimationSlot,
names: Box<[CssString]>,
- definitions: &[FfiAppliedAnimationDefinition],
+ definitions: Box<[HeldAppliedAnimationDefinition]>,
) {
debug_assert_eq!(
definitions.len(),
@@ -140,7 +188,7 @@ impl CssDefinedAnimations {
let animations: Box<[CssDefinedAnimation]> = names
.into_iter()
.zip(definitions)
- .map(|(name, &applied_definition)| CssDefinedAnimation {
+ .map(|(name, applied_definition)| CssDefinedAnimation {
name,
applied_definition,
})
@@ -234,13 +282,14 @@ pub(crate) fn plan_changes_nothing(
.enumerate()
.all(|(index, (definition, animation))| {
usize::try_from(definition.matched_existing_index) == Ok(index)
- && FfiAppliedAnimationDefinition::of(definition).would_change_nothing(&animation.applied_definition)
+ && FfiAppliedAnimationDefinition::of(definition)
+ .would_change_nothing(&animation.applied_definition.definition)
})
}
/// The tree scope an `animation-name` declaration was written in, where the `@keyframes` it names
/// are looked for first.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub(crate) enum DeclarationScope {
/// A declaration of the document, of another origin or of the element itself, or none at all:
/// none of these has a scope of its own.
@@ -256,7 +305,7 @@ pub(crate) type KeyframesRow = HashMap<Box<[u16]>, usize>;
/// them, with the host's keyframe set for each name.
///
/// A scope publishes its row whenever its rule cache is built, and the host builds every scope's
-/// cache before a style transaction, so resolving an animation's keyframes is a lookup here rather
+/// cache before a style update, so resolving an animation's keyframes is a lookup here rather
/// than building a rule cache in the middle of a style computation. A keyframe set is the host's
/// refcounted object, borrowed: the scope keeps a reference to every set its row names until it
/// publishes the row again or gives it up, which the engine takes in ahead of anything that
@@ -264,10 +313,6 @@ pub(crate) type KeyframesRow = HashMap<Box<[u16]>, usize>;
#[derive(Clone, Default)]
pub(crate) struct AnimationKeyframes {
scopes: HashMap<TreeScopeID, KeyframesRow>,
- /// Which scope a shadow root's pointer identity names. The cascade attributes the winning
- /// `animation-name` declaration to a shadow root by that identity, and the scope it names is
- /// where the declaration's `@keyframes` are looked for first.
- scope_by_shadow_root: HashMap<usize, TreeScopeID>,
}
impl AnimationKeyframes {
@@ -288,20 +333,11 @@ impl AnimationKeyframes {
}
/// Replaces one scope's row. An empty row gives the scope's row up.
- pub(crate) fn set(&mut self, tree_scope: TreeScopeID, shadow_root_identity: usize, row: KeyframesRow) {
+ pub(crate) fn set(&mut self, tree_scope: TreeScopeID, row: KeyframesRow) {
if row.is_empty() {
self.scopes.remove(&tree_scope);
- // A scope with no row answers like one that defines nothing, so its identity stops
- // naming it, unless another shadow root has since been allocated at that address and
- // published under it.
- if self.scope_by_shadow_root.get(&shadow_root_identity) == Some(&tree_scope) {
- self.scope_by_shadow_root.remove(&shadow_root_identity);
- }
return;
}
- if shadow_root_identity != 0 {
- self.scope_by_shadow_root.insert(shadow_root_identity, tree_scope);
- }
self.scopes.insert(tree_scope, row);
}
@@ -671,7 +707,14 @@ mod tests {
range_start_calculated: std::ptr::null(),
range_end_calculated: std::ptr::null(),
};
- animations.set(node, slot, self::names(names), &vec![undescribed; names.len()]);
+ // SAFETY: The definition names no values.
+ let undescribed = unsafe { HeldAppliedAnimationDefinition::retained(undescribed) };
+ animations.set(
+ node,
+ slot,
+ self::names(names),
+ vec![undescribed; names.len()].into_boxed_slice(),
+ );
}
fn list_names(animations: &CssDefinedAnimations, node: StyleNodeID, slot: AnimationSlot) -> Vec<CssString> {
@@ -934,25 +977,20 @@ mod tests {
assert!(animations.rows.is_empty());
}
- fn publish(keyframes: &mut AnimationKeyframes, scope: u32, identity: usize, rows: &[(&str, usize)]) {
+ fn publish(keyframes: &mut AnimationKeyframes, scope: u32, rows: &[(&str, usize)]) {
let lengths: Vec<u32> = rows
.iter()
.map(|(name, _)| name.encode_utf16().count() as u32)
.collect();
let units: Vec<u16> = rows.iter().flat_map(|(name, _)| name.encode_utf16()).collect();
let sets: Vec<usize> = rows.iter().map(|&(_, set)| set).collect();
- keyframes.set(
- TreeScopeID(scope),
- identity,
- AnimationKeyframes::row(&lengths, &units, &sets),
- );
+ keyframes.set(TreeScopeID(scope), AnimationKeyframes::row(&lengths, &units, &sets));
}
- fn resolve(keyframes: &AnimationKeyframes, identity: usize, scope: u32, name: &str) -> Option<usize> {
- let declaration_scope = keyframes
- .scope_by_shadow_root
- .get(&identity)
- .map_or(DeclarationScope::Unscoped, |&scope| DeclarationScope::Shadow(scope));
+ fn resolve(keyframes: &AnimationKeyframes, declaration: Option<u32>, scope: u32, name: &str) -> Option<usize> {
+ let declaration_scope = declaration.map_or(DeclarationScope::Unscoped, |scope| {
+ DeclarationScope::Shadow(TreeScopeID(scope))
+ });
keyframes.resolve(
declaration_scope,
TreeScopeID(scope),
@@ -963,31 +1001,28 @@ mod tests {
#[test]
fn keyframes_resolve_in_the_declaration_scope_then_the_element_scope_then_the_document() {
let mut keyframes = AnimationKeyframes::default();
- publish(&mut keyframes, 0, 0, &[("a", 1), ("b", 2)]);
- publish(&mut keyframes, 1, 0x100, &[("a", 3)]);
- publish(&mut keyframes, 2, 0x200, &[("a", 4), ("b", 5)]);
+ publish(&mut keyframes, 0, &[("a", 1), ("b", 2)]);
+ publish(&mut keyframes, 1, &[("a", 3)]);
+ publish(&mut keyframes, 2, &[("a", 4), ("b", 5)]);
- assert_eq!(resolve(&keyframes, 0, 0, "a"), Some(1));
- assert_eq!(resolve(&keyframes, 0, 1, "a"), Some(3));
- assert_eq!(resolve(&keyframes, 0, 1, "b"), Some(2));
+ assert_eq!(resolve(&keyframes, None, 0, "a"), Some(1));
+ assert_eq!(resolve(&keyframes, None, 1, "a"), Some(3));
+ assert_eq!(resolve(&keyframes, None, 1, "b"), Some(2));
// A `:host` rule of scope 2 styling an element of scope 1.
- assert_eq!(resolve(&keyframes, 0x200, 1, "a"), Some(4));
- assert_eq!(resolve(&keyframes, 0x200, 1, "c"), None);
+ assert_eq!(resolve(&keyframes, Some(2), 1, "a"), Some(4));
+ assert_eq!(resolve(&keyframes, Some(2), 1, "c"), None);
}
#[test]
- fn a_departed_scope_gives_up_its_row_but_not_a_reused_identity() {
+ fn a_departed_scope_gives_up_its_row() {
let mut keyframes = AnimationKeyframes::default();
- publish(&mut keyframes, 1, 0x100, &[("a", 3)]);
- // Another shadow root allocated at the same address publishes before the first one's row
- // is given up.
- publish(&mut keyframes, 2, 0x100, &[("a", 4)]);
- publish(&mut keyframes, 1, 0x100, &[]);
+ publish(&mut keyframes, 1, &[("a", 3)]);
+ publish(&mut keyframes, 2, &[("a", 4)]);
+ publish(&mut keyframes, 1, &[]);
assert_eq!(keyframes.scopes.len(), 1);
- assert_eq!(resolve(&keyframes, 0x100, 0, "a"), Some(4));
+ assert_eq!(resolve(&keyframes, Some(2), 0, "a"), Some(4));
- publish(&mut keyframes, 2, 0x100, &[]);
+ publish(&mut keyframes, 2, &[]);
assert!(keyframes.scopes.is_empty());
- assert!(keyframes.scope_by_shadow_root.is_empty());
}
}
diff --git a/Libraries/LibWeb/Rust/src/css/style/bridge/animations.rs b/Libraries/LibWeb/Rust/src/css/style/bridge/animations.rs
new file mode 100644
index 00000000000..88ecc2e98f5
--- /dev/null
+++ b/Libraries/LibWeb/Rust/src/css/style/bridge/animations.rs
@@ -0,0 +1,447 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+use super::*;
+
+/// How one animation effect's description travels across the boundary: the ranges of the flat
+/// buffers that belong to it.
+#[repr(C)]
+pub struct FfiPublishedAnimationEffect {
+ pub identity: u64,
+ pub generation: u64,
+ /// The effect belongs to a CSS transition, which the interpolation treats differently.
+ pub is_transition: bool,
+ /// The effect's keyframes come from a style sheet, which their URLs resolve against: its base
+ /// URL is the range of the base URL buffer below.
+ pub has_resource_context: bool,
+ pub resource_context_is_origin_clean: bool,
+ pub first_keyframe: u32,
+ pub keyframe_count: u32,
+ pub base_url_offset: u32,
+ pub base_url_length: u32,
+ /// A transition's reversing-adjusted start value, or null for any other effect.
+ pub reversing_adjusted_start_value: *const c_void,
+ /// A transition's reversing shortening factor.
+ pub reversing_shortening_factor: f64,
+}
+
+/// The easing function a published keyframe spells out.
+#[repr(u8)]
+#[derive(Clone, Copy)]
+#[expect(dead_code, reason = "C++ constructs the variants")]
+pub enum FfiPublishedEasingKind {
+ Linear,
+ CubicBezier,
+ Steps,
+}
+
+/// One keyframe of a published effect: its offset on the scale the host keys keyframes by, its
+/// easing spelled out, its composite operation and the ranges of what it declares.
+#[repr(C)]
+pub struct FfiPublishedAnimationKeyframe {
+ pub key: i64,
+ pub easing_kind: FfiPublishedEasingKind,
+ pub step_position: u8,
+ pub interval_count: i32,
+ pub x1: f64,
+ pub y1: f64,
+ pub x2: f64,
+ pub y2: f64,
+ pub first_linear_point: u32,
+ pub linear_point_count: u32,
+ /// The keyframe's own easing where it still has to be substituted against the element being
+ /// sampled, or null.
+ pub easing_value: *const c_void,
+ /// The keyframe's composite operation, with `auto` already the effect's own.
+ pub composite: crate::css::animation::FfiCompositeOperation,
+ pub first_declaration: u32,
+ pub declaration_count: u32,
+ pub first_custom_declaration: u32,
+ pub custom_declaration_count: u32,
+}
+
+/// One control point of a published `linear()` easing.
+#[repr(C)]
+pub struct FfiPublishedLinearEasingPoint {
+ pub input: f64,
+ pub output: f64,
+}
+
+/// One longhand a published keyframe declares. A null value stands for the element's own value,
+/// which a keyframe the host synthesized holds and which is not known until the element is
+/// sampled.
+#[repr(C)]
+pub struct FfiPublishedAnimationDeclaration {
+ pub property_id: u16,
+ pub value: *const c_void,
+}
+
+/// One custom property a published keyframe declares, by the raw representation of its name. A
+/// null value stands for the element's own value of it.
+#[repr(C)]
+pub struct FfiPublishedAnimationCustomDeclaration {
+ pub name: usize,
+ pub value: *const c_void,
+}
+
+/// The version of one animation effect the host is about to sample.
+#[repr(C)]
+pub struct FfiAnimationEffectVersion {
+ pub identity: u64,
+ pub generation: u64,
+}
+
+/// Describe the effects one of an element's animation lists holds, in composite order, for the
+/// style engine to sample them from. The host retains every value the effects name and streams
+/// the description to the engine.
+///
+/// # Safety
+/// `host` must be a live document host, on its document's thread, every buffer must hold the count
+/// it is given, and every value and custom-property name the buffers name must be live for the
+/// duration of the call.
+#[unsafe(no_mangle)]
+#[allow(clippy::too_many_arguments)]
+pub unsafe extern "C" fn style_engine_set_element_animation_effect_descriptions(
+ host: &DocumentHost,
+ node: u32,
+ slot: u8,
+ effects: *const FfiPublishedAnimationEffect,
+ effect_count: usize,
+ keyframes: *const FfiPublishedAnimationKeyframe,
+ keyframe_count: usize,
+ declarations: *const FfiPublishedAnimationDeclaration,
+ declaration_count: usize,
+ custom_declarations: *const FfiPublishedAnimationCustomDeclaration,
+ custom_declaration_count: usize,
+ linear_points: *const FfiPublishedLinearEasingPoint,
+ linear_point_count: usize,
+ base_url_bytes: *const u8,
+ base_url_byte_count: usize,
+) {
+ let Some(node) = StyleNodeID::from_raw(node) else {
+ return;
+ };
+ // SAFETY: Guaranteed by the caller.
+ let effects = unsafe {
+ crate::css::style::effect_descriptions::PublishedEffectBuffers {
+ effects: ak::slice_from_raw_parts(effects, effect_count),
+ keyframes: ak::slice_from_raw_parts(keyframes, keyframe_count),
+ declarations: ak::slice_from_raw_parts(declarations, declaration_count),
+ custom_declarations: ak::slice_from_raw_parts(custom_declarations, custom_declaration_count),
+ linear_points: ak::slice_from_raw_parts(linear_points, linear_point_count),
+ base_url_bytes: ak::slice_from_raw_parts(base_url_bytes, base_url_byte_count),
+ }
+ .effects()
+ };
+ host.engine_memo().described.borrow_mut().follow(node, slot, &effects);
+ host.queue_change(crate::render_state::ArenaChange::Engine(
+ crate::css::style::engine_calls::EngineWrite::AnimationEffectDescriptions { node, slot, effects },
+ ));
+}
+
+/// Notes what the `attr()`s of the value `value`, which an animation effect's keyframes hold, can read, answering
+/// whether they can read a name none could before.
+///
+/// # Safety
+/// `value` must be a live style value.
+#[unsafe(no_mangle)]
+pub unsafe extern "C" fn style_engine_note_attr_names_read_by_value(host: &DocumentHost, value: *const c_void) -> bool {
+ // SAFETY: Guaranteed by the caller.
+ let value = unsafe { &*value.cast::<crate::css::style_value::StyleValueData>() };
+ let before = crate::css::style::host_atoms::attr_names_read_generation(host);
+ crate::css::style::host_atoms::note_attr_names_read_by(host, std::iter::once(value));
+ crate::css::style::host_atoms::attr_names_read_generation(host) != before
+}
+
+/// Whether the engine describes one of an element's animation lists as holding exactly these
+/// versions of its effects, in this order, so that the host need not describe them again. Only
+/// the host describes them, so it knows without asking.
+#[unsafe(no_mangle)]
+pub extern "C" fn style_engine_describes_animation_effects(
+ host: &DocumentHost,
+ node: u32,
+ slot: u8,
+ versions: ak::Span<'_, FfiAnimationEffectVersion>,
+) -> bool {
+ StyleNodeID::from_raw(node).is_some_and(|node| {
+ host.engine_memo()
+ .described
+ .borrow()
+ .describe(node, slot, versions.as_slice())
+ })
+}
+
+/// Publish already bound immutable selector inputs, after all host interning has finished.
+pub(crate) fn publish_style_rule(
+ engine: &mut StyleEngine,
+ sheet: u32,
+ before_rule: u32,
+ compiled: &SelectorListRef,
+ bound_scope: &BoundScopeChain,
+) -> u32 {
+ if sheet == 0 || compiled.is_empty() {
+ return 0;
+ }
+ let before = match before_rule {
+ 0 => None,
+ id => Some(RuleID(id - 1)),
+ };
+ let rule = engine.add_style_rule_in_scope(SheetID(sheet - 1), before, compiled, Some(bound_scope));
+ rule.0 + 1
+}
+
+/// Replace selectors using immutable compilation inputs, preserving rule identity.
+pub(crate) fn publish_style_rule_selectors(
+ engine: &mut StyleEngine,
+ rule: u32,
+ compiled: &SelectorListRef,
+ bound_scope: &BoundScopeChain,
+) {
+ if rule == 0 || compiled.is_empty() {
+ return;
+ }
+ engine.replace_style_rule_selectors(RuleID(rule - 1), compiled, Some(bound_scope));
+}
+/// Whether a candidate animation overlay changes any effective value of the record `installed` views, in place of the
+/// record's own overlay. The host reads it from the record it installed, as the engine would.
+///
+/// # Safety
+/// `installed` must view a record the host holds live, and `animated_overlay` must be null or live, for this call.
+#[unsafe(no_mangle)]
+pub unsafe extern "C" fn style_engine_animation_overlay_changed(
+ installed: &FfiStyleRecordView,
+ animated_overlay: *const c_void,
+) -> bool {
+ // SAFETY: Guaranteed by the caller.
+ let (longhands, old_overlay, new_overlay) = unsafe {
+ (
+ installed
+ .longhands()
+ .expect("the record of an element carries its longhands"),
+ installed.animated_overlay(),
+ animated_overlay.cast::<AnimatedOverlay>().as_ref(),
+ )
+ };
+ crate::css::style::style_invalidation::animation_overlay_changed(longhands, old_overlay, new_overlay)
+}
+
+/// What the host hands over to have an element's sampled animation overlay composed over the record it installed and
+/// published.
+#[repr(C)]
+pub struct FfiAnimationOverlayPublicationInput {
+ pub style_node: u32,
+ pub pseudo_kind: u8,
+ /// The record the element installed, which the overlay was sampled on and composes over.
+ pub style_record: u64,
+ /// The style record whose longhands the overlay was sampled over.
+ pub record: *const c_void,
+ pub animated_overlay: *const c_void,
+ /// The identity of the overlay, or 0 where it animates nothing, which releases the target's overlay record.
+ pub animation_overlay_identity: u64,
+ pub used_color_scheme: u8,
+ pub display_before_box_type_transformation_raw: u32,
+ pub is_document_element: bool,
+ /// What a target the engine holds no overlay slot for is published again whole with, beside the installed record's
+ /// base: the custom-property environment the target holds, with its store.
+ pub custom_property_environment: u64,
+ pub custom_property_store: *const c_void,
+ pub callback_context: *mut c_void,
+ /// Writes the animated style's platform font, a `ComputedValuesFFI::FfiFontGroupBuildInputs`;
+ /// asked only where the font group is rebuilt.
+ pub font_group_inputs: unsafe extern "C" fn(*mut c_void, *mut c_void),
+}
+
+/// What publishing an element's sampled animation overlay answers: what replacing the installed record with it damages,
+/// the record the target held and the one it holds now, with the view of the latter, which is missing where the engine
+/// holds no record the overlay was sampled on.
+#[repr(C)]
+pub struct FfiAnimationOverlayPublication {
+ pub invalidation: FfiAnimationInvalidation,
+ pub publication: FfiStyleRecordDelta,
+ /// The record the host holds for the record the target holds now, with a reference the host takes over: a later
+ /// publication of the same call can retire the record.
+ pub record: *const c_void,
+ /// Whether the overlay named a value the groups could not be told from, or nothing at all.
+ pub rebuilt_every_group: bool,
+}
+
+impl FfiAnimationOverlayPublication {
+ fn missing() -> Self {
+ Self {
+ invalidation: FfiAnimationInvalidation::default(),
+ publication: FfiStyleRecordDelta::default(),
+ record: std::ptr::null(),
+ rebuilt_every_group: false,
+ }
+ }
+}
+
+/// Composes each element's sampled animation overlay over the record it installed, rebuilding only the groups the
+/// overlay writes (see `RetainedState::build_animation_overlay_payloads`), compares it with that record, and publishes
+/// it as the target's record, writing what it answers to the same index of `out`: every element in one call of the
+/// engine. An element whose overlay rebuilds the font group is published again in a call of its own: resolving the
+/// animated font may read the engine, so the host resolves it between the two. The host keeps the view of each record
+/// it answers, which it installs next.
+///
+/// # Safety
+/// `host` must be a live document host, on its document's thread, `inputs` and `out` must point to `count` entries, and
+/// everything an input points to must be live for the call, its table non-null.
+#[unsafe(no_mangle)]
+pub unsafe extern "C" fn style_engine_publish_sampled_animation_overlays(
+ host: &DocumentHost,
+ read: &crate::render_state::BegunRead,
+ inputs: *const FfiAnimationOverlayPublicationInput,
+ count: usize,
+ out: *mut FfiAnimationOverlayPublication,
+) {
+ use crate::css::table_group_builder::FfiFontGroupBuildInputs;
+
+ // SAFETY: Guaranteed by the caller.
+ let (inputs, out) = unsafe {
+ (
+ ak::slice_from_raw_parts(inputs, count),
+ ak::slice_from_raw_parts_mut(out, count),
+ )
+ };
+ with_engine(read, host, |engine| {
+ for (input, out) in inputs.iter().zip(out.iter_mut()) {
+ // SAFETY: Guaranteed by the caller.
+ *out = unsafe { publish_sampled_animation_overlay(engine, input, None) }.unwrap_or_else(
+ |crate::css::style::engine_sample::NeedsHostFont| FfiAnimationOverlayPublication::missing(),
+ );
+ }
+ });
+ for (input, out) in inputs.iter().zip(out.iter_mut()) {
+ if out.record.is_null() {
+ // A publication the first call could not make, for want of the font or of a record, is tried again with
+ // the font.
+ let mut font = std::mem::MaybeUninit::<FfiFontGroupBuildInputs>::uninit();
+ // SAFETY: Guaranteed by the caller. The host writes the whole font.
+ let font = unsafe {
+ (input.font_group_inputs)(input.callback_context, font.as_mut_ptr().cast());
+ font.assume_init()
+ };
+ // SAFETY: Guaranteed by the caller.
+ *out = with_engine(read, host, |engine| unsafe {
+ publish_sampled_animation_overlay(engine, input, Some(&font))
+ })
+ .unwrap_or_else(|crate::css::style::engine_sample::NeedsHostFont| {
+ FfiAnimationOverlayPublication::missing()
+ });
+ }
+ if !out.record.is_null() {
+ host.engine_memo()
+ .views
+ .set(out.publication.new_style_record, out.record);
+ }
+ }
+}
+
+/// [`style_engine_publish_sampled_animation_overlays`]'s call of `engine` for one element, which answers `Err` where it
+/// needs the animated font, `font`, it was not given.
+///
+/// # Safety
+/// As for [`style_engine_publish_sampled_animation_overlays`], for one input.
+pub(in crate::css::style) unsafe fn publish_sampled_animation_overlay(
+ engine: &mut StyleEngine,
+ input: &FfiAnimationOverlayPublicationInput,
+ font: Option<&crate::css::table_group_builder::FfiFontGroupBuildInputs>,
+) -> Result<FfiAnimationOverlayPublication, crate::css::style::engine_sample::NeedsHostFont> {
+ use crate::css::table_group_builder::group_index;
+
+ let Some(node) = StyleNodeID::from_raw(input.style_node) else {
+ return Ok(FfiAnimationOverlayPublication::missing());
+ };
+ let Some(installed_style_record) = crate::css::style::computed::FinalStyleRecordID::from_raw(input.style_record)
+ else {
+ return Ok(FfiAnimationOverlayPublication::missing());
+ };
+ // NB: style styles an element-backed pseudo-element as the element of the shadow tree that
+ // backs it, so the animations of the pseudo-element compose over that element's record.
+ let (node, pseudo_kind) = match input.pseudo_kind {
+ kind @ FIRST_ELEMENT_REFERENCE_PSEUDO_ELEMENT_KIND..=LAST_ELEMENT_REFERENCE_PSEUDO_ELEMENT_KIND => {
+ let element = crate::css::cascaded_properties::NO_PSEUDO_ELEMENT;
+ let backing = engine
+ .backing_elements(node, 1 << kind)
+ .find(|&backing| {
+ engine.computed_group_sets.assigned_final_style_record(
+ crate::css::style::computed::ComputedStyleTarget::new(backing, element),
+ ) == Some(installed_style_record)
+ })
+ .expect(
+ "the engine assigns the record an element-backed pseudo-element installed to its backing element",
+ );
+ (backing, element)
+ }
+ kind => (node, kind),
+ };
+ // SAFETY: Guaranteed by the caller.
+ let (longhands, overlay) = unsafe {
+ (
+ crate::css::style::ViewLonghands::of_raw_record(input.record),
+ input.animated_overlay.cast::<AnimatedOverlay>().as_ref(),
+ )
+ };
+ let mut payloads = [std::ptr::null(); group_index::COUNT];
+ let Some(old_record) = engine.computed_group_sets.host_record(input.style_record).cloned() else {
+ return Ok(FfiAnimationOverlayPublication::missing());
+ };
+ let old_view = crate::css::style::StyleRecordView::of_host_record(&old_record);
+ let rebuilt = engine.build_animation_overlay_payloads(
+ node,
+ pseudo_kind,
+ old_view,
+ longhands,
+ overlay,
+ input.used_color_scheme,
+ input.display_before_box_type_transformation_raw,
+ font,
+ &mut payloads,
+ )?;
+ // SAFETY: The rebuild wrote a live payload of each group.
+ let groups = &unsafe { crate::css::computed_values::StyleGroups::retained(&payloads, rebuilt.bits) };
+ // Compared before the publication, which may release the installed record: nothing else keeps a pseudo-element's.
+ let invalidation = engine.compare_animation_overlay(
+ old_view,
+ input.animated_overlay.cast(),
+ groups,
+ input.is_document_element,
+ );
+ let (animated_overlay, overlay_payloads) = match input.animation_overlay_identity {
+ 0 => (std::ptr::null(), None),
+ _ => (input.animated_overlay, Some(groups)),
+ };
+ let publication = match engine.publish_animation_overlay_impl(
+ crate::css::style::computed::ComputedStyleTarget::new(node, pseudo_kind),
+ input.animation_overlay_identity,
+ HostShared::new(animated_overlay).cast(),
+ overlay_payloads,
+ ) {
+ Some(publication) => FfiStyleRecordDelta {
+ old_style_record: publication.previous_style_record.raw(),
+ new_style_record: publication.style_record.raw(),
+ },
+ // NB: The engine assigns every pseudo-element it styles the record it installed, so a target it holds no
+ // assignment for has no style to compose over.
+ None => {
+ crate::css::style::engine_sample::release_rebuilt_overlay_payloads(&payloads, rebuilt.groups);
+ return Ok(FfiAnimationOverlayPublication::missing());
+ }
+ };
+ crate::css::style::engine_sample::release_rebuilt_overlay_payloads(&payloads, rebuilt.groups);
+ engine.retained.live_counters.note_animated_sample(rebuilt.every_group);
+ Ok(FfiAnimationOverlayPublication {
+ invalidation,
+ publication,
+ record: engine
+ .computed_group_sets
+ .host_record(publication.new_style_record)
+ .map_or(std::ptr::null(), |record| {
+ std::sync::Arc::into_raw(record.clone()).cast()
+ }),
+ rebuilt_every_group: rebuilt.every_group,
+ })
+}
diff --git a/Libraries/LibWeb/Rust/src/css/style/effect_descriptions.rs b/Libraries/LibWeb/Rust/src/css/style/effect_descriptions.rs
index e7f6f191310..3998016f656 100644
--- a/Libraries/LibWeb/Rust/src/css/style/effect_descriptions.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/effect_descriptions.rs
@@ -19,11 +19,13 @@ use super::bridge::{
FfiPublishedAnimationEffect, FfiPublishedAnimationKeyframe, FfiPublishedEasingKind, FfiPublishedLinearEasingPoint,
};
use super::tree::StyleNodeID;
+use super::weak_pool::WeakPool;
use crate::css::animation::FfiCompositeOperation;
use crate::css::custom_properties::CustomPropertyRegistry;
use crate::css::easing::{Easing, FfiEasingDescriptor, FfiEasingKind, FfiLinearEasingPoint};
use crate::css::retained_fly_string::RetainedUtf16FlyString;
use crate::css::style_compute::FfiEffectTiming;
+use crate::css::style_value::EasingPayload;
use crate::css::style_value::{RetainedStyleValueData, StyleValueData};
use std::collections::HashMap;
use std::ffi::c_void;
@@ -40,6 +42,14 @@ pub(crate) enum PublishedValue {
}
impl PublishedValue {
+ /// The value's identity: zero for the element's own value.
+ fn identity(&self) -> usize {
+ match self {
+ Self::ElementValue => 0,
+ Self::Declared(value) => value.pointer() as usize,
+ }
+ }
+
/// Retains the value a host pointer names, or stands for the element's own value where it is
/// null.
///
@@ -53,6 +63,33 @@ impl PublishedValue {
}
}
+impl PublishedEffect {
+ /// The values the effect's keyframes declare, and those they run their easing by.
+ pub(crate) fn declared_values(&self) -> impl Iterator<Item = &StyleValueData> {
+ let keyframes = &self.keyframes;
+ let declared = keyframes
+ .declarations
+ .iter()
+ .map(|declaration| &declaration.value)
+ .chain(
+ keyframes
+ .custom_declarations
+ .iter()
+ .map(|declaration| &declaration.value),
+ )
+ .filter_map(|value| match value {
+ PublishedValue::ElementValue => None,
+ PublishedValue::Declared(value) => value.optional_data(),
+ });
+ let easings = keyframes
+ .keyframes
+ .iter()
+ .filter_map(|keyframe| keyframe.easing_value.as_ref())
+ .filter_map(RetainedStyleValueData::optional_data);
+ declared.chain(easings)
+ }
+}
+
/// # Safety
/// `value` must be a live style value.
unsafe fn retained(value: *const c_void) -> RetainedStyleValueData {
@@ -68,17 +105,7 @@ unsafe fn retained(value: *const c_void) -> RetainedStyleValueData {
pub(crate) fn easing_from_computed_timing_function(value: &StyleValueData) -> Option<Easing> {
use crate::css::css_enums::keyword;
let cubic_bezier = |x1, y1, x2, y2| Easing::CubicBezier { x1, y1, x2, y2 };
- let StyleValueData::Easing {
- kind,
- step_position,
- x1,
- y1,
- x2,
- y2,
- number_of_intervals,
- ..
- } = value
- else {
+ let StyleValueData::Easing(easing_payload) = value else {
let StyleValueData::Keyword { keyword } = value else {
return None;
};
@@ -91,6 +118,16 @@ pub(crate) fn easing_from_computed_timing_function(value: &StyleValueData) -> Op
_ => None,
};
};
+ let EasingPayload {
+ kind,
+ step_position,
+ x1,
+ y1,
+ x2,
+ y2,
+ number_of_intervals,
+ ..
+ } = &**easing_payload;
// Each argument reads the way the host's `numeric()` reads it, which resolves a calculation on
// the spot.
let numeric = |value: &RetainedStyleValueData| match value.data() {
@@ -108,9 +145,10 @@ pub(crate) fn easing_from_computed_timing_function(value: &StyleValueData) -> Op
// The stops are canonicalized first, which resolves each one's calculated values and
// interpolates the inputs it was not given.
let canonical = crate::css::absolutize::canonicalize_linear_easing(value);
- let StyleValueData::Easing { linear_stops, .. } = canonical.data() else {
+ let StyleValueData::Easing(easing_payload) = canonical.data() else {
return None;
};
+ let EasingPayload { linear_stops, .. } = &**easing_payload;
Some(Easing::Linear(
linear_stops
.as_slice()
@@ -150,8 +188,7 @@ pub(crate) struct PublishedCustomDeclaration {
pub(crate) value: PublishedValue,
}
-#[derive(Clone)]
-
+#[derive(Clone, PartialEq)]
pub(crate) struct PublishedKeyframe {
pub(crate) key: i64,
/// The easing the keyframe runs, which is the one its animation runs where the keyframe has
@@ -175,6 +212,99 @@ pub(crate) struct PublishedResourceContext {
/// Maps an interval's declaration indices to its substituted values.
type CustomPropertyIntervalValues = HashMap<[usize; 2], [RetainedStyleValueData; 2]>;
+/// What an effect's keyframes declare, which effects describing equal keyframes share: the elements running one
+/// `@keyframes` rule hold one of these between them.
+pub(crate) struct PublishedKeyframes {
+ /// The style sheet the keyframes come from, which their URLs resolve against.
+ resource_context: Option<PublishedResourceContext>,
+ target_properties: Box<[u16]>,
+ keyframes: Box<[PublishedKeyframe]>,
+ declarations: Box<[PublishedDeclaration]>,
+ custom_declarations: Box<[PublishedCustomDeclaration]>,
+}
+
+impl PublishedKeyframes {
+ /// The hash the document's pool finds equal keyframes under: what each declares, values by identity.
+ fn pool_hash(&self) -> u64 {
+ use std::hash::{Hash, Hasher};
+ let mut hasher = super::fast_hash::fast_hasher();
+ self.resource_context
+ .as_ref()
+ .map(|context| (&context.base_url, context.origin_clean))
+ .hash(&mut hasher);
+ self.target_properties.hash(&mut hasher);
+ for keyframe in &self.keyframes {
+ keyframe.key.hash(&mut hasher);
+ (keyframe.composite as u8).hash(&mut hasher);
+ }
+ for declaration in &self.declarations {
+ declaration.property_id.hash(&mut hasher);
+ declaration.value.identity().hash(&mut hasher);
+ }
+ for declaration in &self.custom_declarations {
+ declaration.name.raw().hash(&mut hasher);
+ declaration.value.identity().hash(&mut hasher);
+ }
+ hasher.finish()
+ }
+
+ /// Whether the two declare the same, values by identity.
+ fn declares_the_same_as(&self, other: &Self) -> bool {
+ self.resource_context
+ .as_ref()
+ .map(|context| (&context.base_url, context.origin_clean))
+ == other
+ .resource_context
+ .as_ref()
+ .map(|context| (&context.base_url, context.origin_clean))
+ && self.target_properties == other.target_properties
+ && self.keyframes.len() == other.keyframes.len()
+ && self.keyframes.iter().zip(&other.keyframes).all(|(first, second)| {
+ first.key == second.key
+ && first.easing == second.easing
+ && first.easing_value.as_ref().map(RetainedStyleValueData::pointer)
+ == second.easing_value.as_ref().map(RetainedStyleValueData::pointer)
+ && first.composite == second.composite
+ && first.declarations == second.declarations
+ && first.custom_declarations == second.custom_declarations
+ })
+ && self.declarations.len() == other.declarations.len()
+ && self
+ .declarations
+ .iter()
+ .zip(&other.declarations)
+ .all(|(first, second)| {
+ first.property_id == second.property_id && first.value.identity() == second.value.identity()
+ })
+ && self.custom_declarations.len() == other.custom_declarations.len()
+ && self
+ .custom_declarations
+ .iter()
+ .zip(&other.custom_declarations)
+ .all(|(first, second)| {
+ first.name.raw() == second.name.raw() && first.value.identity() == second.value.identity()
+ })
+ }
+
+ fn heap_size(&self) -> usize {
+ self.resource_context
+ .as_ref()
+ .map_or(0, |context| crate::heap_size::ARC_HEADER_BYTES + context.base_url.len())
+ + size_of_val::<[u16]>(&self.target_properties)
+ + size_of_val::<[PublishedKeyframe]>(&self.keyframes)
+ + self
+ .keyframes
+ .iter()
+ .map(|keyframe| match &keyframe.easing {
+ Easing::Linear(points) => crate::heap_size::vec_bytes(points),
+ _ => 0,
+ })
+ .sum::<usize>()
+ + size_of_val::<[PublishedDeclaration]>(&self.declarations)
+ + size_of_val::<[PublishedCustomDeclaration]>(&self.custom_declarations)
+ }
+}
+
/// One of an element's animation effects, described for the style engine.
#[derive(Clone)]
pub(crate) struct PublishedEffect {
@@ -182,19 +312,18 @@ pub(crate) struct PublishedEffect {
pub(crate) generation: u64,
/// The effect belongs to a CSS transition, which the interpolation treats differently.
pub(crate) is_transition: bool,
- pub(crate) resource_context: Option<PublishedResourceContext>,
- pub(crate) target_properties: Box<[u16]>,
- pub(crate) keyframes: Box<[PublishedKeyframe]>,
- declarations: Box<[PublishedDeclaration]>,
- custom_declarations: Box<[PublishedCustomDeclaration]>,
- /// Substituted interval values retained for this effect version.
- custom_property_interval_values: Arc<Mutex<CustomPropertyIntervalValues>>,
+ keyframes: Arc<PublishedKeyframes>,
+ /// Substituted interval values retained for this effect version, for an effect whose keyframes declare custom
+ /// properties.
+ custom_property_interval_values: Option<Arc<Mutex<CustomPropertyIntervalValues>>>,
/// The timing the host last sampled the effect with, which moves without the description.
pub(crate) timing: Option<EffectTiming>,
/// What a transition reverses to, and how much shorter a reversing transition runs, where the effect is one.
pub(crate) reversing: Option<TransitionReversing>,
}
+const _: () = assert!(size_of::<PublishedEffect>() == 224);
+
/// What a transition that reverses the one an effect belongs to starts from.
/// https://drafts.csswg.org/css-transitions/#reversing-adjusted-start-value
#[derive(Clone)]
@@ -242,34 +371,53 @@ impl PublishedEffect {
identity,
generation: 0,
is_transition: true,
- resource_context: None,
- target_properties: target_properties([property_id]),
- // `KeyframeEffect::AnimationKeyFrameKeyScaleFactor` keys the end at 100%.
- keyframes: Box::new([keyframe(0, 0), keyframe(100 * 1000, 1)]),
- declarations: Box::new([start, end].map(|value| PublishedDeclaration {
- property_id,
- value: PublishedValue::Declared(value),
- })),
- custom_declarations: Box::new([]),
- custom_property_interval_values: Default::default(),
+ keyframes: Arc::new(PublishedKeyframes {
+ resource_context: None,
+ target_properties: target_properties([property_id]),
+ // `KeyframeEffect::AnimationKeyFrameKeyScaleFactor` keys the end at 100%.
+ keyframes: Box::new([keyframe(0, 0), keyframe(100 * 1000, 1)]),
+ declarations: Box::new([start, end].map(|value| PublishedDeclaration {
+ property_id,
+ value: PublishedValue::Declared(value),
+ })),
+ custom_declarations: Box::new([]),
+ }),
+ custom_property_interval_values: None,
timing,
reversing: None,
}
}
+ /// The style sheet the effect's keyframes come from, which their URLs resolve against.
+ #[must_use]
+ pub(crate) fn resource_context(&self) -> Option<&PublishedResourceContext> {
+ self.keyframes.resource_context.as_ref()
+ }
+
+ /// The longhands the effect's keyframes animate, sorted.
+ #[must_use]
+ pub(crate) fn target_properties(&self) -> &[u16] {
+ &self.keyframes.target_properties
+ }
+
+ #[must_use]
+ pub(crate) fn keyframes(&self) -> &[PublishedKeyframe] {
+ &self.keyframes.keyframes
+ }
+
#[must_use]
pub(crate) fn declarations_of(&self, keyframe: &PublishedKeyframe) -> &[PublishedDeclaration] {
- &self.declarations[keyframe.declarations.clone()]
+ &self.keyframes.declarations[keyframe.declarations.clone()]
}
#[must_use]
pub(crate) fn custom_declarations_of(&self, keyframe: &PublishedKeyframe) -> &[PublishedCustomDeclaration] {
- &self.custom_declarations[keyframe.custom_declarations.clone()]
+ &self.keyframes.custom_declarations[keyframe.custom_declarations.clone()]
}
#[must_use]
pub(crate) fn custom_declaration_at(&self, index: usize) -> &PublishedCustomDeclaration {
- &self.custom_declarations[index]
+ &self.keyframes.custom_declarations[index]
}
/// Resolve interval values afresh for interpolable syntaxes or neutral keyframes; retain them otherwise.
@@ -282,7 +430,7 @@ impl PublishedEffect {
) -> ([RetainedStyleValueData; 2], bool) {
let has_neutral_endpoint = declaration_indices
.iter()
- .any(|&index| matches!(self.custom_declarations[index].value, PublishedValue::ElementValue));
+ .any(|&index| matches!(self.custom_declaration_at(index).value, PublishedValue::ElementValue));
if has_interpolable_syntax || has_neutral_endpoint {
return (resolve_values(), false);
@@ -293,6 +441,8 @@ impl PublishedEffect {
// properties via CSSDefaultInterpolationType; we currently limit it to custom properties.
let values = self
.custom_property_interval_values
+ .as_ref()
+ .expect("an effect interpolating custom properties keeps their interval values")
.lock()
.unwrap()
.entry(declaration_indices)
@@ -365,17 +515,19 @@ impl PublishedEffectBuffers<'_> {
identity: effect.identity,
generation: effect.generation,
is_transition: effect.is_transition,
- resource_context: effect.has_resource_context.then(|| PublishedResourceContext {
- base_url: self.base_url_bytes[range(effect.base_url_offset, effect.base_url_length)].into(),
- origin_clean: effect.resource_context_is_origin_clean,
+ custom_property_interval_values: (!custom_declarations.is_empty()).then(Default::default),
+ keyframes: Arc::new(PublishedKeyframes {
+ resource_context: effect.has_resource_context.then(|| PublishedResourceContext {
+ base_url: self.base_url_bytes[range(effect.base_url_offset, effect.base_url_length)].into(),
+ origin_clean: effect.resource_context_is_origin_clean,
+ }),
+ target_properties: target_properties(
+ declarations.iter().map(|declaration| declaration.property_id),
+ ),
+ keyframes,
+ declarations: declarations.into(),
+ custom_declarations: custom_declarations.into(),
}),
- target_properties: target_properties(
- declarations.iter().map(|declaration| declaration.property_id),
- ),
- keyframes,
- declarations: declarations.into(),
- custom_declarations: custom_declarations.into(),
- custom_property_interval_values: Default::default(),
timing: None,
reversing: (!effect.reversing_adjusted_start_value.is_null()).then(|| TransitionReversing {
adjusted_start_value: unsafe { retained(effect.reversing_adjusted_start_value) },
@@ -421,9 +573,42 @@ pub(crate) struct AnimationEffectDescriptions {
/// Holding an animation is rare, so only the elements that do have a row, and a row holds only
/// the lists that are not empty.
rows: HashMap<StyleNodeID, Vec<AnimationEffectList>>,
+ /// The keyframes the effects describe, by content, which an effect describing equal ones shares.
+ keyframes: WeakPool<PublishedKeyframes>,
}
impl AnimationEffectDescriptions {
+ /// The bytes of the descriptions: the rows, the effects, and the keyframes and interval caches they hold, each
+ /// shared one once. The values the keyframes declare are their rules'.
+ pub(super) fn heap_size(&self, sizer: &mut crate::heap_size::HeapSizer) -> usize {
+ use crate::heap_size::{map_bytes, vec_bytes};
+ let effect_bytes =
+ |effect: &PublishedEffect, sizer: &mut crate::heap_size::HeapSizer| {
+ let keyframes = match sizer.arc_shallow(&effect.keyframes) {
+ 0 => 0,
+ bytes => bytes + effect.keyframes.heap_size(),
+ };
+ let interval_values = effect.custom_property_interval_values.as_ref().map_or(0, |values| {
+ match sizer.arc_shallow(values) {
+ 0 => 0,
+ bytes => bytes + map_bytes(&values.lock().unwrap()),
+ }
+ });
+ keyframes + interval_values
+ };
+ let mut bytes = map_bytes(&self.rows);
+ for lists in self.rows.values() {
+ bytes += vec_bytes(lists);
+ for (_, effects) in lists {
+ bytes += size_of_val::<[PublishedEffect]>(effects);
+ for effect in effects {
+ bytes += effect_bytes(effect, sizer);
+ }
+ }
+ }
+ bytes
+ }
+
pub(super) fn registrations_changed(
&mut self,
previous: &CustomPropertyRegistry,
@@ -431,19 +616,45 @@ impl AnimationEffectDescriptions {
) {
for (_, effects) in self.rows.values_mut().flatten() {
for effect in effects {
- let mut retained_values = effect.custom_property_interval_values.lock().unwrap().clone();
+ let Some(interval_values) = &effect.custom_property_interval_values else {
+ continue;
+ };
+ let mut retained_values = interval_values.lock().unwrap().clone();
retained_values.retain(|declaration_indices, _| {
- let name = &effect.custom_declarations[declaration_indices[0]].name;
+ let name = &effect.custom_declaration_at(declaration_indices[0]).name;
registry.registration_matches(previous, &name.to_utf16())
});
// Leave values held by older style snapshots intact.
- effect.custom_property_interval_values = Arc::new(Mutex::new(retained_values));
+ effect.custom_property_interval_values = Some(Arc::new(Mutex::new(retained_values)));
}
}
}
+ /// Whether an animation of `node` interpolates a custom property whose name `moved` holds for.
+ pub(crate) fn animates_custom_property(&self, node: StyleNodeID, moved: impl Fn(&[u16]) -> bool) -> bool {
+ self.rows.get(&node).is_some_and(|lists| {
+ lists.iter().flat_map(|(_, effects)| effects.iter()).any(|effect| {
+ effect
+ .keyframes
+ .custom_declarations
+ .iter()
+ .any(|declaration| moved(&declaration.name.to_utf16()))
+ })
+ })
+ }
+
/// Replace one list. An empty list drops it.
pub(crate) fn set(&mut self, node: StyleNodeID, slot: AnimationSlot, mut effects: Box<[PublishedEffect]>) {
+ for effect in &mut effects {
+ let hash = effect.keyframes.pool_hash();
+ match self
+ .keyframes
+ .find(hash, |pooled| pooled.declares_the_same_as(&effect.keyframes))
+ {
+ Some(pooled) => effect.keyframes = pooled,
+ None => self.keyframes.insert(hash, &effect.keyframes),
+ }
+ }
let lists = self.rows.entry(node).or_default();
let existing = lists.iter().position(|(list_slot, _)| *list_slot == slot);
if let Some(index) = existing {
@@ -479,31 +690,6 @@ impl AnimationEffectDescriptions {
.map_or(&[], |(_, effects)| effects)
}
- pub(crate) fn keyframes_read_any_of_custom_properties(&self, node: StyleNodeID, names: &[Arc<[u16]>]) -> bool {
- let Some(lists) = self.rows.get(&node) else {
- return false;
- };
- let reads_any = |value: &RetainedStyleValueData| {
- super::custom_property_cascade::value_reads_any_of_custom_properties(value.data(), names)
- };
- lists.iter().flat_map(|(_, effects)| effects.iter()).any(|effect| {
- effect.keyframes.iter().any(|keyframe| {
- keyframe.easing_value.as_ref().is_some_and(reads_any)
- || effect
- .declarations_of(keyframe)
- .iter()
- .map(|declaration| &declaration.value)
- .chain(
- effect
- .custom_declarations_of(keyframe)
- .iter()
- .map(|declaration| &declaration.value),
- )
- .any(|value| matches!(value, PublishedValue::Declared(value) if reads_any(value)))
- })
- })
- }
-
/// Whether one of an element's lists describes exactly these versions of the effects, in this
/// order. Every change that moves what a description says moves its effect's generation.
#[cfg(test)]
@@ -605,6 +791,23 @@ pub(crate) struct DescribedVersions {
type DescribedList = (AnimationSlot, Box<[(u64, u64)]>);
impl DescribedVersions {
+ /// The bytes the versions hold on the heap.
+ pub(crate) fn heap_size(&self) -> usize {
+ use crate::heap_size::{map_bytes, vec_bytes};
+ map_bytes(&self.rows)
+ + self
+ .rows
+ .values()
+ .map(|lists| {
+ vec_bytes(lists)
+ + lists
+ .iter()
+ .map(|(_, versions)| size_of_val::<[(u64, u64)]>(versions))
+ .sum::<usize>()
+ })
+ .sum::<usize>()
+ }
+
/// Follows the host describing `effects` as one of `node`'s lists.
pub(crate) fn follow(&mut self, node: StyleNodeID, slot: AnimationSlot, effects: &[PublishedEffect]) {
let lists = self.rows.entry(node).or_default();
diff --git a/Libraries/LibWeb/Rust/src/css/style/engine_sample.rs b/Libraries/LibWeb/Rust/src/css/style/engine_sample.rs
index c869cfd6b9f..7fc540f1495 100644
--- a/Libraries/LibWeb/Rust/src/css/style/engine_sample.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/engine_sample.rs
@@ -8,27 +8,23 @@
//! published inputs, rather than from the host's working set.
use super::bridge::element_adjustment_fact;
-use super::publication::drive_font_metric;
+use super::computed::{StyleRecordView, ViewLonghands};
+use super::pipeline::drive::drive_font_metric;
use super::tree::{StyleNodeID, TreeScopeID};
use super::{RetainedState, bridge};
use crate::css::animated_overlay::AnimatedOverlay;
use crate::css::color_resolution::{ColorResolutionInput, Rgba, to_color};
-use crate::css::computed_longhand_table::{ComputedLonghandTable, FONT_METRICS_DEPEND_ON_VIEWPORT_METRICS};
-use crate::css::computed_value_types::{
- FontValues, STYLE_GROUP_INDEX_ANCHOR, STYLE_GROUP_INDEX_FONT, STYLE_GROUP_INDEX_INHERITED_BOX,
- STYLE_GROUP_INDEX_SURROUND,
-};
-use crate::css::computed_values::InheritedBoxValues;
+use crate::css::computed_longhand_table::FONT_METRICS_DEPEND_ON_VIEWPORT_METRICS;
+use crate::css::computed_value_types::FontValues;
use crate::css::css_pixels::CssPixels;
-use crate::css::host_shared::{HostShared, SharedPayload};
use crate::css::property_metadata::property_id as prop;
use crate::css::style_compute::{
AnimationSampleInput, FfiAnimationLengthContexts, FfiEffectiveColorSchemeInput, FfiFontMetrics,
FfiLengthResolutionContext, FfiStyleComputationEnvironment, HostSampledEffects, keyword, px_length_unit,
working_set_current_color,
};
-use crate::css::style_value::StyleValueData;
-use crate::css::table_group_builder::{FfiFontGroupBuildInputs, TableGroupBuildInputs, group_index};
+use crate::css::style_value::{RetainedStyleValueData, StyleValueData};
+use crate::css::table_group_builder::{FfiFontGroupBuildInputs, group_index};
/// One record's font, as a length resolves against it.
struct RecordFont {
@@ -37,27 +33,30 @@ struct RecordFont {
inline_axis_is_horizontal: bool,
}
-impl RetainedState {
- fn record_font(&self, style_record: u64) -> Option<RecordFont> {
- let view = self.computed_group_sets.style_record_view(style_record)?;
- let font = unsafe { view.payloads[STYLE_GROUP_INDEX_FONT].cast::<FontValues>().deref() };
- let inherited_box = unsafe {
- view.payloads[STYLE_GROUP_INDEX_INHERITED_BOX]
- .cast::<InheritedBoxValues>()
- .deref()
- };
- Some(RecordFont {
+impl RecordFont {
+ fn of(view: &super::StyleRecordView<'_>) -> Self {
+ let font = unsafe { view.payloads[group_index::FONT].cast::<FontValues>().deref() };
+ let first_available = font.first_available_font_metrics();
+ Self {
metrics: FfiFontMetrics {
font_size: font.font_size.to_double(),
- x_height: drive_font_metric(font.font_x_height),
+ x_height: drive_font_metric(first_available.x_height),
// The host's metrics approximate the cap height with the ascent.
- cap_height: drive_font_metric(font.font_ascent),
- zero_advance: drive_font_metric(font.font_zero_advance),
- line_height: font.line_height_used.to_double(),
+ cap_height: drive_font_metric(first_available.ascent),
+ zero_advance: drive_font_metric(first_available.zero_advance),
+ line_height: font.line_height_used().to_double(),
},
depends_on_viewport_metrics: view.dependency_flags & FONT_METRICS_DEPEND_ON_VIEWPORT_METRICS != 0,
- inline_axis_is_horizontal: inherited_box.writing_mode == crate::css::css_enums::writing_mode::HORIZONTAL_TB,
- })
+ inline_axis_is_horizontal: view.payloads.inherited_bits().writing_mode()
+ == crate::css::css_enums::writing_mode::HORIZONTAL_TB,
+ }
+ }
+}
+
+impl RetainedState {
+ /// The record the host holds for the element `node`, as the engine notes it.
+ fn held_record(&self, node: StyleNodeID) -> Option<&std::sync::Arc<super::pipeline::Record>> {
+ self.held_style_records.get(node)
}
/// https://drafts.csswg.org/css-viewport/#effective-zoom
@@ -65,7 +64,7 @@ impl RetainedState {
fn root_effective_zoom(&self) -> f64 {
self.held_root_font_inputs
.unwrap_or_else(|| {
- super::publication::RootFontInputs::from_document(&self.document_style_computation_inputs)
+ super::pipeline::compute::RootFontInputs::from_document(&self.document_style_computation_inputs)
})
.effective_zoom()
}
@@ -76,38 +75,36 @@ impl RetainedState {
fn root_font_metrics(&self) -> (FfiFontMetrics, bool) {
self.held_root_font_inputs
.unwrap_or_else(|| {
- super::publication::RootFontInputs::from_document(&self.document_style_computation_inputs)
+ super::pipeline::compute::RootFontInputs::from_document(&self.document_style_computation_inputs)
})
.font_metrics()
}
/// The three length-resolution contexts a sample of an element's animations computes keyframe
- /// values in over `style_record`, the record the host holds for it: the font context, which
+ /// values in over `record`, the record the host holds for it: the font context, which
/// reads the record its inheritance parent holds; the line-height context, the element's own
/// font with the line height it inherits; and the one everything else resolves against, the
/// element's own font. A mirror of the host's `make_computation_context_for_property(FontFamily /
/// LineHeight / Color)` over the working set it reconstructs from that record, without the
/// container bases only the host resolves.
- ///
- /// `None` where the engine cannot read the record.
pub(crate) fn animation_sample_length_contexts(
&self,
node: StyleNodeID,
pseudo_kind: Option<u8>,
- style_record: u64,
- ) -> Option<FfiAnimationLengthContexts> {
+ record: &std::sync::Arc<super::pipeline::Record>,
+ ) -> FfiAnimationLengthContexts {
let inputs = &self.document_style_computation_inputs;
- let own = self.record_font(style_record)?;
+ let own = RecordFont::of(&super::StyleRecordView::of_host_record(record));
// A pseudo-element inherits from its originating element.
let parent = match pseudo_kind {
Some(_) => Some(node),
- None => self.tree.inheritance_parent(node),
+ None => self.projection.inheritance_parent(node),
};
let parent_font = parent
- .and_then(|parent| self.held_style_records.get(&parent).copied())
- .and_then(|record| self.record_font(record));
+ .and_then(|parent| self.held_record(parent))
+ .map(|record| RecordFont::of(&super::StyleRecordView::of_host_record(record)));
let is_document_element =
- self.computed_group_sets.adjustment_facts(node) & element_adjustment_fact::IS_DOCUMENT_ELEMENT != 0;
+ self.projection.adjustment_facts(node) & element_adjustment_fact::IS_DOCUMENT_ELEMENT != 0;
let document_root = self.root_font_metrics();
let own_font = (own.metrics, own.depends_on_viewport_metrics);
let length_context = |font, root| length_resolution_context(inputs, font, root, own.inline_axis_is_horizontal);
@@ -160,29 +157,26 @@ impl RetainedState {
document_root
},
);
- Some(FfiAnimationLengthContexts {
+ FfiAnimationLengthContexts {
font,
line_height,
remaining,
- })
+ }
}
- /// What a transition on an element resolves its lengths against: the font of the record the
- /// element has installed, a sampled animated font included, the root's font and the viewport.
- /// A mirror of the host's computation context for `color` over that record. `None` where the
- /// engine cannot read the record.
+ /// What a transition on an element resolves its lengths against: the font of `record`, the
+ /// record the element has installed, a sampled animated font included, the root's font and the
+ /// viewport. A mirror of the host's computation context for `color` over that record.
pub(crate) fn transition_length_resolution_context(
&self,
- style_record: u64,
- ) -> Option<crate::css::animation::FfiAnimationLengthResolutionContext> {
- let record = self.record_font(style_record)?;
- Some(crate::css::style_compute::animation_length_resolution_context(
- &length_resolution_context(
- &self.document_style_computation_inputs,
- (record.metrics, record.depends_on_viewport_metrics),
- self.root_font_metrics(),
- record.inline_axis_is_horizontal,
- ),
+ record: &std::sync::Arc<super::pipeline::Record>,
+ ) -> crate::css::animation::FfiAnimationLengthResolutionContext {
+ let record = RecordFont::of(&super::StyleRecordView::of_host_record(record));
+ crate::css::style_compute::animation_length_resolution_context(&length_resolution_context(
+ &self.document_style_computation_inputs,
+ (record.metrics, record.depends_on_viewport_metrics),
+ self.root_font_metrics(),
+ record.inline_axis_is_horizontal,
))
}
@@ -201,27 +195,31 @@ impl RetainedState {
&self,
node: StyleNodeID,
pseudo_kind: u8,
- style_record: u64,
- table: &ComputedLonghandTable,
+ view: StyleRecordView<'_>,
+ longhands: ViewLonghands<'_>,
overlay: Option<&AnimatedOverlay>,
used_color_scheme: u8,
display_before_box_type_transformation_raw: u32,
font: Option<&FfiFontGroupBuildInputs>,
payloads: &mut [*const std::ffi::c_void; group_index::COUNT],
- ) -> Option<Result<RebuiltOverlayGroups, NeedsHostFont>> {
- let view = self.computed_group_sets.style_record_view(style_record)?;
- payloads.copy_from_slice(SharedPayload::as_pointer_slice(view.base_payloads));
+ ) -> Result<RebuiltOverlayGroups, NeedsHostFont> {
+ payloads.copy_from_slice(&view.base_payloads.pointers());
// An overlay with no sampled values or additional properties to treat as included in will-change leaves the
// base as it is: publishing it releases the element's overlay record.
let Some(overlay) = overlay.filter(|overlay| !overlay.is_empty()) else {
- return Some(Ok(RebuiltOverlayGroups {
+ return Ok(RebuiltOverlayGroups {
groups: 0,
every_group: true,
- }));
+ bits: view.base_payloads.style_bits(),
+ });
};
// A value no group is known to hold, or an animated `color` whose readers the engine cannot
// name, rebuilds every group.
let named_groups = overlay.entries().iter().try_fold(0u32, |groups, entry| {
+ // NB: A value the inherited bits hold is in no group: the sample holds it beside them.
+ if crate::css::computed_values::StyleBitField::of(entry.property).is_some() {
+ return Some(groups);
+ }
let group = crate::css::property_metadata::property_style_group_index(entry.property)?;
let readers = match entry.property {
prop::COLOR => self.current_color_dependent_group_mask(node, pseudo_kind)?,
@@ -232,20 +230,20 @@ impl RetainedState {
let rebuilds_every_group = named_groups.is_none();
let mut groups = named_groups.unwrap_or((1 << group_index::COUNT) - 1);
if !overlay.implicit_will_change.is_empty() {
- groups |= 1 << group_index::MISC_RESET;
+ groups |= 1 << group_index::MISC_INTERACTION;
}
// The surround group duplicates `position-anchor` for layout, so rebuilding the anchor
// group refreshes it too.
- if groups & (1 << STYLE_GROUP_INDEX_ANCHOR) != 0 {
- groups |= 1 << STYLE_GROUP_INDEX_SURROUND;
+ if groups & (1 << group_index::ANCHOR) != 0 {
+ groups |= 1 << group_index::SURROUND;
}
// Colors resolve against the element's font as it stood when the overlay was last
// published, or against the animated font where the overlay rebuilds the font group.
- let record = self.record_font(style_record)?;
- let rebuilds_font = groups & (1 << STYLE_GROUP_INDEX_FONT) != 0;
+ let record = RecordFont::of(&view);
+ let rebuilds_font = groups & (1 << group_index::FONT) != 0;
if rebuilds_font && font.is_none() {
- return Some(Err(NeedsHostFont));
+ return Err(NeedsHostFont);
}
let font_inputs = font.filter(|_| rebuilds_font);
let own_font = match font_inputs {
@@ -266,10 +264,7 @@ impl RetainedState {
);
// The element's own color resolves first, since every other group resolves `currentcolor`
// against it.
- let color_data = table
- .effective_value_handle(Some(overlay), prop::COLOR, true)
- .0
- .optional_data();
+ let color_data = longhands.effective_value(Some(overlay), prop::COLOR).optional_data();
let color = color_data
.and_then(|color| {
to_color(
@@ -291,21 +286,20 @@ impl RetainedState {
length: Some(&length),
channels: None,
};
- let build_inputs = TableGroupBuildInputs {
+ let build_inputs = crate::css::table_group_builder::GroupBuildInputs {
color_input: &color_input,
used_color_scheme,
- animated_overlay: Some(overlay),
box_display_before_transformation_raw: display_before_box_type_transformation_raw,
font: font_inputs,
+ defaults: &self.process_style.default_groups,
};
let mut rebuilt = [std::ptr::null(); group_index::COUNT];
+ let source = crate::css::table_group_builder::LonghandSource::Longhands {
+ longhands,
+ animated_overlay: Some(overlay),
+ };
unsafe {
- crate::css::table_group_builder::build_group_payloads_from_table(
- table,
- groups,
- &build_inputs,
- &mut rebuilt,
- );
+ crate::css::table_group_builder::build_group_payloads(&source, groups, &build_inputs, &mut rebuilt);
}
let mut rebuilt_groups = 0;
for (group, payload) in rebuilt.into_iter().enumerate() {
@@ -314,10 +308,11 @@ impl RetainedState {
rebuilt_groups |= 1 << group;
}
}
- Some(Ok(RebuiltOverlayGroups {
+ Ok(RebuiltOverlayGroups {
groups: rebuilt_groups,
every_group: rebuilds_every_group,
- }))
+ bits: source.style_bits(),
+ })
}
}
@@ -387,12 +382,12 @@ impl super::StyleEngine {
let mut composed = crate::css::style_compute::SampledEffects::new();
let mut composed_properties = smallvec::SmallVec::<[u16; 8]>::new();
let mut ended_properties = smallvec::SmallVec::<[u16; 8]>::new();
- for effect in effects.iter().filter(|effect| effect.keyframes.len() >= 2) {
+ for effect in effects.iter().filter(|effect| effect.keyframes().len() >= 2) {
let Some(timing) = &effect.timing else {
continue;
};
let properties = effect
- .keyframes
+ .keyframes()
.iter()
.flat_map(|keyframe| effect.declarations_of(keyframe))
.map(|declaration| declaration.property_id);
@@ -411,8 +406,11 @@ impl super::StyleEngine {
}
}
- let view = self.computed_group_sets.style_record_view(record).ok_or(NeedsHost)?;
- let mut overlay = view.animated_overlay.cloned().unwrap_or_default();
+ let record = self.computed_group_sets.host_record(record).ok_or(NeedsHost)?.clone();
+ let mut overlay = super::StyleRecordView::of_host_record(&record)
+ .animated_overlay
+ .cloned()
+ .unwrap_or_default();
for &property in ended_properties
.iter()
.filter(|property| !composed_properties.contains(property))
@@ -421,7 +419,7 @@ impl super::StyleEngine {
}
self.sample_composed_over_record(
node,
- record,
+ &record,
overlay,
None,
composed,
@@ -445,7 +443,7 @@ impl super::StyleEngine {
let mut properties = smallvec::SmallVec::new();
for effect in self.element_animation_effects(node, 0) {
for declaration in effect
- .keyframes
+ .keyframes()
.iter()
.flat_map(|keyframe| effect.declarations_of(keyframe))
{
@@ -462,7 +460,7 @@ impl super::StyleEngine {
pub(crate) fn sample_composed_over_record(
&mut self,
node: StyleNodeID,
- record: u64,
+ record: &std::sync::Arc<super::pipeline::Record>,
mut overlay: AnimatedOverlay,
fresh: Option<&[super::effect_descriptions::PublishedEffect]>,
composed: crate::css::style_compute::SampledEffects,
@@ -484,59 +482,30 @@ impl super::StyleEngine {
if outcome == crate::css::style_compute::FfiHostAnimationSampleOutcome::Cleared {
overlay = AnimatedOverlay::default();
}
- let sample = self.compose_overlay_over_record(node, record, &overlay, bounds)?;
- Ok((sample, overlay))
- }
-
- /// Composes `overlay`, the values of animations of the element `node` names, or those it inherits from an
- /// ancestor's, over `record` into a record no element holds, pinned for a box, where the composition changes no more
- /// than `bounds` lets it.
- pub(crate) fn compose_overlay_over_record(
- &mut self,
- node: StyleNodeID,
- record: u64,
- overlay: &AnimatedOverlay,
- bounds: super::style_invalidation::SampleBounds,
- ) -> Result<super::layout_style::DerivedStyleRecord, NeedsHost> {
- self.compose_overlay_over_record_of(
+ let sample = self.compose_overlay_over_record(
node,
crate::css::cascaded_properties::NO_PSEUDO_ELEMENT,
record,
- overlay,
+ &overlay,
bounds,
- )
- }
-
- /// Composes `overlay`, the values a pseudo-element of the kind `pseudo_kind` of the element `node` names inherits of
- /// the element's animations, or of those the element inherits from an ancestor's, over `record`, the
- /// pseudo-element's, as [`Self::compose_overlay_over_record`] does for an element.
- pub(crate) fn compose_overlay_over_pseudo_element_record(
- &mut self,
- node: StyleNodeID,
- pseudo_kind: u8,
- record: u64,
- overlay: &AnimatedOverlay,
- bounds: super::style_invalidation::SampleBounds,
- ) -> Result<super::layout_style::DerivedStyleRecord, NeedsHost> {
- self.compose_overlay_over_record_of(node, pseudo_kind, record, overlay, bounds)
+ )?;
+ Ok((sample, overlay))
}
- fn compose_overlay_over_record_of(
+ /// Composes `overlay`, the values of animations of the element `node` names, or those it inherits from an
+ /// ancestor's, over `record` into a record no element holds, pinned for a box, where the composition changes no more
+ /// than `bounds` lets it. `record` is the element's, or, for a `pseudo_kind`, that pseudo-element's, and `overlay`
+ /// then holds the values the pseudo-element inherits of them.
+ pub(crate) fn compose_overlay_over_record(
&mut self,
node: StyleNodeID,
pseudo_kind: u8,
- record: u64,
+ record: &std::sync::Arc<super::pipeline::Record>,
overlay: &AnimatedOverlay,
bounds: super::style_invalidation::SampleBounds,
) -> Result<super::layout_style::DerivedStyleRecord, NeedsHost> {
- let table = HostShared::from_option(
- self.computed_group_sets
- .style_record_view(record)
- .ok_or(NeedsHost)?
- .longhand_table,
- );
// What the host adjusts after it samples, and an animated color scheme, are the host's to compose.
- let facts = self.computed_group_sets.adjustment_facts(node);
+ let facts = self.projection.adjustment_facts(node);
if overlay.entries().iter().any(|entry| {
entry.post_compute_adjustment
|| post_compute_adjusts(entry.property, facts)
@@ -544,63 +513,50 @@ impl super::StyleEngine {
}) {
return Err(NeedsHost);
}
- // SAFETY: As above.
- let table = unsafe { table.as_ref() }.ok_or(NeedsHost)?;
- let used_color_scheme = u8::try_from(table.effective_color_scheme()).map_err(|_| NeedsHost)?;
+ // NB: The base record is held, so that its longhands outlive the view while the engine
+ // resolves the animated font.
+ let view = StyleRecordView::of_host_record(record);
+ let base = view.retained_record();
+ let longhands = ViewLonghands::of_record(&base);
+ let used_color_scheme = u8::try_from(longhands.effective_color_scheme()).map_err(|_| NeedsHost)?;
let mut payloads = [std::ptr::null(); group_index::COUNT];
let mut build = |engine: &Self, font: Option<&FfiFontGroupBuildInputs>| {
- engine
- .build_animation_overlay_payloads(
- node,
- pseudo_kind,
- record,
- table,
- Some(overlay),
- used_color_scheme,
- table.display_before_box_type_transformation(),
- font,
- &mut payloads,
- )
- .ok_or(NeedsHost)
+ engine.build_animation_overlay_payloads(
+ node,
+ pseudo_kind,
+ view,
+ longhands,
+ Some(overlay),
+ used_color_scheme,
+ longhands.display_before_box_type_transformation(),
+ font,
+ &mut payloads,
+ )
};
// A sample that moves the font asks the document's font resolver for it, as the host's sample does.
- let rebuilt = match build(self, None)? {
+ let rebuilt = match build(self, None) {
Err(NeedsHostFont) => {
- let font = self.animated_font_group_inputs(node, table, overlay).ok_or(NeedsHost)?;
- build(self, Some(&font))?.map_err(|NeedsHostFont| NeedsHost)?
+ let font = self
+ .animated_font_group_inputs(node, longhands, overlay)
+ .ok_or(NeedsHost)?;
+ build(self, Some(&font)).map_err(|NeedsHostFont| NeedsHost)?
}
Ok(rebuilt) => rebuilt,
};
// What the sample changes beyond its box is the host's to show: the visual contexts above all, which the
// compositor has from the host's frames.
- if !self.animation_sample_stays_in_its_box(
- node,
- record,
- overlay,
- SharedPayload::from_pointer_slice(&payloads),
- bounds,
- ) {
+ // SAFETY: The rebuild wrote a live payload of each group.
+ let groups = &unsafe {
+ crate::css::computed_values::StyleGroups::retained_sharing(&payloads, rebuilt.bits, &[Some(&base.payloads)])
+ };
+ if !self.animation_sample_stays_in_its_box(node, view, overlay, groups, bounds) {
release_rebuilt_overlay_payloads(&payloads, rebuilt.groups);
return Err(NeedsHost);
}
- let sampled = super::bridge::publish_computed_groups_from_inputs(
- self,
- 0,
- u8::MAX,
- SharedPayload::from_pointer_slice(&payloads),
- super::computed::ENGINE_INHERITED_GROUP_COUNT,
- 0,
- false,
- 0,
- 0,
- std::ptr::null(),
- &[],
- Some(table),
- std::ptr::null(),
- )
- .new_style_record;
+ // The sample holds the longhands of the record it composes over, as the host's does.
+ let sampled = self.install_record_derived(&base, groups, None);
release_rebuilt_overlay_payloads(&payloads, rebuilt.groups);
- Ok(super::layout_style::DerivedStyleRecord::pin(self, sampled))
+ Ok(super::layout_style::DerivedStyleRecord::pin(self, sampled.raw()))
}
/// Samples `composed` onto `overlay` over `record`, a record the engine holds for the element `node`
@@ -610,23 +566,18 @@ impl super::StyleEngine {
pub(crate) fn sample_over_record(
&mut self,
node: StyleNodeID,
- record: u64,
+ record: &std::sync::Arc<super::pipeline::Record>,
overlay: &mut AnimatedOverlay,
fresh: Option<&[super::effect_descriptions::PublishedEffect]>,
composed: crate::css::style_compute::SampledEffects,
transform_reference_box: Option<crate::css::css_pixels::CssPixelRect>,
timeline_samples: super::animations::AnimationTimelineSamples<'_>,
) -> Result<crate::css::style_compute::FfiHostAnimationSampleResult, NeedsHost> {
- let table = HostShared::new(std::ptr::from_ref(
- self.computed_group_sets
- .style_record_view(record)
- .ok_or(NeedsHost)?
- .longhand_table
- .ok_or(NeedsHost)?,
- ));
+ let base = super::StyleRecordView::of_host_record(record).retained_record();
+ let longhands = ViewLonghands::of_record(&base);
// A keyframe substitutes against the custom properties of the element and of its parent, as the host's
// sample does, from the stores the engine holds for their environments throughout the sample.
- let inheritance_parent = self.tree.inheritance_parent(node);
+ let inheritance_parent = self.projection.inheritance_parent(node);
let custom_property_environments = [Some(node), inheritance_parent].map(|node| {
node.and_then(|node| self.computed_group_sets.custom_property_environment_identity(node))
.unwrap_or(0)
@@ -636,9 +587,7 @@ impl super::StyleEngine {
.store(identity)
.map_or(std::ptr::null(), |store| std::sync::Arc::as_ptr(store).cast())
});
- let inheritance_parent_style_record = inheritance_parent
- .and_then(|parent| self.held_style_records.get(&parent).copied())
- .unwrap_or(0);
+ let inheritance_parent_record = inheritance_parent.and_then(|parent| self.held_record(parent)).cloned();
let inputs = &self.document_style_computation_inputs;
let environment = FfiStyleComputationEnvironment {
// SAFETY: As the host's value-initialized input, which an animation sample does not read.
@@ -665,17 +614,14 @@ impl super::StyleEngine {
default_font_size_raw: inputs.default_font_size_raw,
root_effective_zoom: self.root_effective_zoom(),
};
- // SAFETY: The record's table is frozen, and the record the caller holds keeps it alive throughout the
- // sample, which writes only `overlay` and what the engine keeps of the element's animations.
- let table = unsafe { table.deref() };
let input = AnimationSampleInput {
style_node: node.raw(),
pseudo_kind: crate::css::cascaded_properties::NO_PSEUDO_ELEMENT,
effects: HostSampledEffects::none(),
- longhand_table: table,
+ longhands,
has_animated_overlay: true,
- current_color: working_set_current_color(table, Some(overlay)),
- style_record: record,
+ current_color: working_set_current_color(longhands, Some(overlay)),
+ style_record: Some(record.clone()),
stores: crate::css::animation::KeyframeStores {
substitution: store,
// A sample that animates a custom property is the host's, so none composes over the element's own.
@@ -684,7 +630,7 @@ impl super::StyleEngine {
element_declares_custom_properties: false,
},
custom_property_environments,
- inheritance_parent_style_record,
+ inheritance_parent_record,
environment: &environment,
custom_property_registration_generation: inputs.custom_property_registration_generation,
element_box_slot: crate::layout::node_data::NodeSlotId::INVALID.index,
@@ -714,8 +660,8 @@ impl super::StyleEngine {
return Some(node);
}
let mut target = node;
- for ancestor in std::iter::successors(self.tree.flat_tree_parent(node), |&ancestor| {
- self.tree.flat_tree_parent(ancestor)
+ for ancestor in std::iter::successors(self.projection.flat_tree_parent(node), |&ancestor| {
+ self.projection.flat_tree_parent(ancestor)
}) {
match self.tick_shown.get(ancestor).map(|shown| shown.boxes) {
Some(ShownBoxes::TakenAway) => return None,
@@ -743,7 +689,7 @@ impl super::StyleEngine {
if self.record_holds_an_animation_overlay(host_record) {
return Err(NeedsHost);
}
- let record = self.derive_record(node, bridge::FfiRecordDemand::ElementRead)?;
+ let record = self.derive_for_clock(node);
let restyled = super::computed::FinalStyleRecordID::from_raw(record.style_record).ok_or(NeedsHost)?;
// The box a clock frame built shows the records it was built from, whatever the host's say.
let built = self.tick_shown.get(node).map(|shown| shown.boxes) == Some(ShownBoxes::Built);
@@ -808,18 +754,6 @@ impl super::StyleEngine {
Ok(DependentRestyle::PseudoElementsMove(in_box))
}
- /// The record a read-only `demand` derives for `node`.
- fn derive_record(
- &mut self,
- node: StyleNodeID,
- demand: bridge::FfiRecordDemand,
- ) -> Result<super::publication::DemandedEngineRecord, NeedsHost> {
- match self.answer_record_demand(node, super::publication::RecordDemand::Element(demand)) {
- Ok(super::publication::RecordDemandAnswer::Record { record, .. }) => Ok(record),
- _ => Err(NeedsHost),
- }
- }
-
/// Shows the clock frame's build the records the boxes a hover's move of `node` builds again take: where the element
/// gains a box or its boxes move, its own and those of the elements below it, which compute against it, and where it
/// loses its box, its own, which generates none. The host builds what only it can.
@@ -833,10 +767,6 @@ impl super::StyleEngine {
let element = self.computed_group_sets.assigned_style_record(node).ok_or(NeedsHost)?;
let mut record = super::publication::DemandedEngineRecord {
style_record: element.raw(),
- explicitly_inherited_groups: 0,
- owes_an_animation_plan: false,
- owes_a_transition_step: false,
- composed_by_the_host: false,
pseudo_records_present: 0,
pseudo_records: [0; bridge::PSEUDO_RECORD_SLOTS],
};
@@ -892,40 +822,22 @@ impl super::StyleEngine {
pseudo: record.pseudo_records,
};
let moved = self.retained.show_for_tick(node, shown);
- if self.tree.first_element_child(node).is_none() || self.record_is_in_display_none_subtree(element.raw()) {
+ if self.projection.first_element_child(node).is_none() || self.record_is_in_display_none_subtree(element.raw())
+ {
return Ok(moved);
}
- // The elements below read their parent's record as the one assigned to it, which it is while they are read: in
- // place of the host's, which an element below one without a box may not have yet, or not at all when the flush
- // left it unstyled in a display:none subtree.
- let host = self
- .computed_group_sets
- .assigned_style_record(node)
- .unwrap_or(super::computed::FinalStyleRecordID::NONE);
- let replaced = if host == element {
- None
- } else {
- let replaced = self
- .computed_group_sets
- .assign_engine_computed_record(node, host, element);
- Some(replaced.ok_or(NeedsHost)?)
- };
- let below = self.show_built_children(node, transitions);
- if let Some(replaced) = replaced {
- self.computed_group_sets
- .revert_engine_computed_record(node, element, replaced);
- }
- Ok(below? || moved)
+ // NB: The engine computes the elements below over the record the clock frame shows for their parent.
+ Ok(self.show_built_children(node, transitions)? || moved)
}
/// Shows the records the element children of `parent` compute to against the one assigned to it, in the boxes a
/// clock frame builds for them. Answers whether any moved from what the clock showed.
fn show_built_children(&mut self, parent: StyleNodeID, transitions: Transitions) -> Result<bool, NeedsHost> {
let mut moved = false;
- let mut child = self.tree.first_element_child(parent);
+ let mut child = self.projection.first_element_child(parent);
while let Some(node) = child {
- child = self.tree.next_element_sibling(node);
- let record = self.derive_record(node, bridge::FfiRecordDemand::ElementReadAgainstParent)?;
+ child = self.projection.next_element_sibling(node);
+ let record = self.derive_for_clock(node);
let element = super::computed::FinalStyleRecordID::from_raw(record.style_record).ok_or(NeedsHost)?;
moved |= self.show_built_boxes(node, ShownBoxes::BuiltBelow, element, &record, transitions)?;
}
@@ -967,12 +879,11 @@ impl super::StyleEngine {
let Some(view) = self.computed_group_sets.style_record_view(element.raw()) else {
return Err(NeedsHost);
};
- let values =
- crate::css::computed_value_views::ComputedValuesView::new(SharedPayload::as_pointer_slice(view.payloads));
+ let values = crate::css::computed_value_views::ComputedValuesView::of(view.payloads);
let plain = self.element_box_kind(node) == bridge::ElementBoxKind::FromDisplay
- && self.computed_group_sets.adjustment_facts(node) & typed == 0
- && self.tree.shadow_root_of(node).is_none()
- && self.tree.assigned_slot_of(node).is_none()
+ && self.projection.adjustment_facts(node) & typed == 0
+ && self.projection.shadow_root_of(node).is_none()
+ && self.projection.assigned_slot_of(node).is_none()
&& !is_container(element)
&& !self
.computed_group_sets
@@ -1040,11 +951,11 @@ impl super::StyleEngine {
use element_adjustment_fact::{
IS_DOCUMENT_ELEMENT, IS_HTML_BODY_ELEMENT, IS_SVG_ELEMENT, RENDERED_IN_TOP_LAYER,
};
- let parent = self.tree.parent(node)?;
+ let parent = self.projection.parent(node)?;
let placed_otherwise = IS_DOCUMENT_ELEMENT | IS_HTML_BODY_ELEMENT | IS_SVG_ELEMENT | RENDERED_IN_TOP_LAYER;
- (self.computed_group_sets.adjustment_facts(node) & placed_otherwise == 0
- && self.tree.assigned_slot_of(node).is_none()
- && self.tree.shadow_root_of(parent).is_none()
+ (self.projection.adjustment_facts(node) & placed_otherwise == 0
+ && self.projection.assigned_slot_of(node).is_none()
+ && self.projection.shadow_root_of(parent).is_none()
&& self.computed_group_sets.assigned_style_record(parent).is_some())
.then_some(parent)
}
@@ -1068,10 +979,8 @@ impl super::StyleEngine {
self.computed_group_sets
.style_record_view(record.raw())
.is_none_or(|view| {
- crate::css::computed_value_views::ComputedValuesView::new(SharedPayload::as_pointer_slice(
- view.payloads,
- ))
- .affects_generated_content_state()
+ crate::css::computed_value_views::ComputedValuesView::of(view.payloads)
+ .affects_generated_content_state()
})
}
@@ -1081,9 +990,7 @@ impl super::StyleEngine {
let Some(view) = self.computed_group_sets.style_record_view(record.raw()) else {
return true;
};
- let display =
- crate::css::computed_value_views::ComputedValuesView::new(SharedPayload::as_pointer_slice(view.payloads))
- .display();
+ let display = crate::css::computed_value_views::ComputedValuesView::of(view.payloads).display();
view.dependency_flags & super::computed::IN_DISPLAY_NONE_SUBTREE == 0
&& !display.is_none()
&& !display.is_contents()
@@ -1099,9 +1006,7 @@ impl super::StyleEngine {
) -> bool {
let place = |record: super::computed::FinalStyleRecordID| {
self.computed_group_sets.style_record_view(record.raw()).map(|view| {
- let values = crate::css::computed_value_views::ComputedValuesView::new(
- SharedPayload::as_pointer_slice(view.payloads),
- );
+ let values = crate::css::computed_value_views::ComputedValuesView::of(view.payloads);
let display = values.display();
(
display.is_outside_and_inside(),
@@ -1123,10 +1028,11 @@ impl super::StyleEngine {
fn animated_font_group_inputs(
&mut self,
node: StyleNodeID,
- table: &ComputedLonghandTable,
+ longhands: ViewLonghands<'_>,
overlay: &AnimatedOverlay,
) -> Option<FfiFontGroupBuildInputs> {
- let request = font_resolution_request(table, Some(overlay), &self.document_style_computation_inputs, || {
+ let values = |property| Some(longhands.effective_value(Some(overlay), property));
+ let request = font_resolution_request(values, &self.document_style_computation_inputs, || {
self.font_feature_values_scope(node)
});
let lookup = |engine: &Self| engine.font_resolution.as_ref()?.lookup(request);
@@ -1140,14 +1046,8 @@ impl super::StyleEngine {
lookup(self)?
}
};
- let line_height_used = used_line_height(table, Some(overlay), &request, &resolved);
- Some(font_group_build_inputs(
- table,
- Some(overlay),
- &request,
- line_height_used,
- &resolved,
- ))
+ let line_height_used = used_line_height(values, &request, &resolved);
+ Some(font_group_build_inputs(values, &request, line_height_used, &resolved))
}
}
@@ -1311,6 +1211,8 @@ pub(crate) struct RebuiltOverlayGroups {
/// Whether the overlay named a value the groups could not be told from, or nothing at all, so
/// none of the base record's groups could be kept as they were.
pub(crate) every_group: bool,
+ /// What the sampled style's inherited set holds beside its groups.
+ pub(crate) bits: crate::css::computed_value_types::StyleBits,
}
/// Give back the references to the payloads `build_animation_overlay_payloads` rebuilt.
@@ -1349,29 +1251,20 @@ fn length_resolution_context(
}
}
-/// A longhand's computed value, over the overlay a sample composed where there is one.
-pub(super) fn effective_data<'a>(
- table: &'a ComputedLonghandTable,
- overlay: Option<&'a AnimatedOverlay>,
- property: u16,
-) -> Option<&'a StyleValueData> {
- table.effective_value_handle(overlay, property, true).0.optional_data()
-}
-
/// What resolving an element's font asks the document's resolver, as the C++ font computer would
-/// resolve it for the element's computed values over `overlay`. The font phase computes
-/// font-size, font-weight and font-width to the shapes read here. `feature_values_scope` names the
-/// tree scope whose `@font-feature-values` the element's `font-variant-alternates` reads, asked
-/// only when it has one.
-pub(super) fn font_resolution_request(
- table: &ComputedLonghandTable,
- overlay: Option<&AnimatedOverlay>,
+/// resolve it for the element's computed values `values`. The font phase computes font-size,
+/// font-weight and font-width to the shapes read here. `feature_values_scope` names the tree scope
+/// whose `@font-feature-values` the element's `font-variant-alternates` reads, asked only when it
+/// has one.
+pub(super) fn font_resolution_request<'a>(
+ values: impl Fn(u16) -> Option<&'a RetainedStyleValueData>,
inputs: &bridge::FfiDocumentStyleComputationInputs,
feature_values_scope: impl FnOnce() -> TreeScopeID,
) -> bridge::FfiFontResolutionRequest {
- let value_of = |property| effective_data(table, overlay, property);
- let handle_of =
- |property| bridge::FfiHostHandle::from_pointer(table.effective_value(overlay, property, true).value.cast());
+ let value_of = |property| values(property).and_then(RetainedStyleValueData::optional_data);
+ let handle_of = |property| {
+ bridge::FfiHostHandle::from_pointer(values(property).map_or(std::ptr::null(), |value| value.pointer().cast()))
+ };
// The resolver reads these beside the family, so the request names each one whose computed
// value is not the initial one and nothing for the rest. A non-initial value can also come
// from inheritance.
@@ -1533,16 +1426,15 @@ pub(super) fn normal_line_height(resolved: &bridge::FfiResolvedFont) -> f64 {
f64::from(resolved.ascent.round() as i32 + resolved.descent.round() as i32)
}
-/// The used line height, as the C++ working set reads it from the computed value over `overlay`
+/// The used line height, as the C++ working set reads it from the computed value in `values`
/// against the font it resolved. The line-height phase computes line-height to one of these
/// shapes.
-pub(super) fn used_line_height(
- table: &ComputedLonghandTable,
- overlay: Option<&AnimatedOverlay>,
+pub(super) fn used_line_height<'a>(
+ values: impl Fn(u16) -> Option<&'a RetainedStyleValueData>,
request: &bridge::FfiFontResolutionRequest,
resolved: &bridge::FfiResolvedFont,
) -> f64 {
- match effective_data(table, overlay, prop::LINE_HEIGHT) {
+ match values(prop::LINE_HEIGHT).and_then(RetainedStyleValueData::optional_data) {
Some(StyleValueData::Keyword { keyword }) if *keyword == keyword::NORMAL => normal_line_height(resolved),
Some(StyleValueData::Length { value, unit }) if *unit == px_length_unit() => {
CssPixels::nearest_value_for(*value).to_double()
@@ -1553,19 +1445,19 @@ pub(super) fn used_line_height(
}
/// What the font group of a record is built from, for an element whose font `request` resolved to
-/// `resolved`, with the computed values over `overlay`.
-pub(super) fn font_group_build_inputs(
- table: &ComputedLonghandTable,
- overlay: Option<&AnimatedOverlay>,
+/// `resolved`, with the computed values `values`.
+pub(super) fn font_group_build_inputs<'a>(
+ values: impl Fn(u16) -> Option<&'a RetainedStyleValueData>,
request: &bridge::FfiFontResolutionRequest,
line_height_used: f64,
resolved: &bridge::FfiResolvedFont,
) -> FfiFontGroupBuildInputs {
- let keyword_code = |property, map: fn(u16) -> Option<u8>| match effective_data(table, overlay, property) {
- Some(StyleValueData::Keyword { keyword }) => map(*keyword).unwrap_or(0),
- _ => 0,
- };
- let math_depth = match effective_data(table, overlay, prop::MATH_DEPTH) {
+ let keyword_code =
+ |property, map: fn(u16) -> Option<u8>| match values(property).and_then(RetainedStyleValueData::optional_data) {
+ Some(StyleValueData::Keyword { keyword }) => map(*keyword).unwrap_or(0),
+ _ => 0,
+ };
+ let math_depth = match values(prop::MATH_DEPTH).and_then(RetainedStyleValueData::optional_data) {
Some(StyleValueData::Integer { value }) => *value,
_ => 0,
};
diff --git a/Libraries/LibWeb/Rust/src/css/style/flight_style_rows.rs b/Libraries/LibWeb/Rust/src/css/style/flight_style_rows.rs
deleted file mode 100644
index 5bd48598588..00000000000
--- a/Libraries/LibWeb/Rust/src/css/style/flight_style_rows.rs
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-//! The rows of a style transaction a frame applies to the layout nodes of their elements itself, ahead of the host that
-//! installs the transaction on the elements once the frame has landed.
-//!
-//! A frame that goes on from its style transaction to a layout round lays out what the round reads of the
-//! transaction's rows: each row's record, bound to the box of the row's element, and the relayout the row's move asks
-//! for. It does so only for a transaction whose install leaves the host nothing the round reads: every row is an
-//! element's record the engine computed over the one the element holds, with its damage answered, which rebuilds
-//! nothing, reaches no descendant and no pseudo-element, moves no custom property environment, animates nothing and
-//! names no image or anchor. The host installs any other transaction before it lays out, as without the frame.
-
-use super::bridge::{FfiStyleDelta, FfiStyleDeltaGap, FfiStyleInvalidationField};
-use super::transaction::{
- STYLE_REACTION_ANCESTOR_BECAME_VISIBLE, STYLE_REACTION_INHERITED_CUSTOM_PROPERTIES,
- STYLE_REACTION_RECOMPUTE_DESCENDANT_STYLES,
-};
-use super::{StyleEngine, StyleNodeID};
-use crate::css::computed_value_views::ComputedValuesView;
-use crate::css::host_shared::SharedPayload;
-
-/// A row of a style transaction a frame applies to the box of its element.
-pub(crate) struct FlightStyleRow {
- pub(crate) style_node: StyleNodeID,
- pub(crate) old_style_record: u64,
- pub(crate) new_style_record: u64,
- /// Whether the move lays the element's box out again.
- pub(crate) relayout: bool,
-}
-
-/// Why a frame leaves a style transaction's rows to the host.
-#[derive(Clone, Copy, PartialEq, Eq, Debug)]
-pub(crate) enum Decline {
- /// A row is a pseudo-element's, or one the host settles in a way of its own.
- Row,
- /// A row is an element's first style.
- FirstStyle,
- /// A row's damage is the host's to compare.
- Damage,
- /// A row rebuilds the layout tree.
- Rebuild,
- /// A row's move reaches its element's descendants.
- Descendants,
- /// A row's element owes its animations or transitions something.
- Animation,
- /// A row moved a custom property environment.
- CustomProperties,
- /// A row's records hold images or name anchors.
- Resources,
- /// A row's box is one the frame does not style.
- LayoutNode,
-}
-
-/// The `InvalidationLevel` of a style move at which its box lays out again, and the one at which the layout tree is
-/// built again.
-pub(crate) const RELAYOUT_LEVEL: u32 = 2;
-pub(crate) const REBUILD_LEVEL: u32 = 3;
-
-impl StyleEngine {
- /// The rows of `answers`, a style transaction's, that a frame applies to the boxes of their elements itself, or why
- /// it leaves them to the host.
- pub(crate) fn rows_the_flight_applies(&self, answers: &[FfiStyleDelta]) -> Result<Vec<FlightStyleRow>, Decline> {
- let mut rows = Vec::with_capacity(answers.len());
- for answer in answers {
- // An element the engine answered as hidden needs no style until a read or its subtree's reveal asks.
- if answer.gap == FfiStyleDeltaGap::Hidden {
- continue;
- }
- if answer.pseudo_kind != u8::MAX || answer.gap != FfiStyleDeltaGap::Computed {
- return Err(Decline::Row);
- }
- let style_node = StyleNodeID::from_raw(answer.style_node).ok_or(Decline::Row)?;
- if answer.reaction
- & (STYLE_REACTION_ANCESTOR_BECAME_VISIBLE
- | STYLE_REACTION_INHERITED_CUSTOM_PROPERTIES
- | STYLE_REACTION_RECOMPUTE_DESCENDANT_STYLES)
- != 0
- {
- return Err(Decline::Descendants);
- }
- if answer.old_style_record == 0 || answer.new_style_record == 0 {
- return Err(Decline::FirstStyle);
- }
- if answer.owes_an_animation_plan || answer.owes_a_transition_step || answer.composed_by_the_host {
- return Err(Decline::Animation);
- }
- if answer.old_style_record == answer.new_style_record {
- continue;
- }
- let damage = answer.record_damage;
- if damage & FfiStyleInvalidationField::EngineComputed as u32 == 0 {
- return Err(Decline::Damage);
- }
- let level = damage & FfiStyleInvalidationField::LevelMask as u32;
- if level >= REBUILD_LEVEL {
- return Err(Decline::Rebuild);
- }
- let reaches_descendants = FfiStyleInvalidationField::RecomputeDescendants as u32
- | FfiStyleInvalidationField::ResnapScrollContainer as u32
- | FfiStyleInvalidationField::RepaintHighlights as u32
- | FfiStyleInvalidationField::NonInheritedInheritanceSource as u32
- | (FfiStyleInvalidationField::InheritedGroupsMask as u32)
- << FfiStyleInvalidationField::InheritedGroupsShift as u32;
- if damage & reaches_descendants != 0 {
- return Err(Decline::Descendants);
- }
- let sets = &self.computed_group_sets;
- if sets.style_record_custom_property_environment(answer.old_style_record)
- != sets.style_record_custom_property_environment(answer.new_style_record)
- {
- return Err(Decline::CustomProperties);
- }
- if self.record_holds_resources(answer.old_style_record)
- || self.record_holds_resources(answer.new_style_record)
- {
- return Err(Decline::Resources);
- }
- // A box that becomes a size container, or stops being one, has its queries evaluated after a full layout,
- // which the round was sealed without.
- if self.record_is_size_container(answer.old_style_record)
- != self.record_is_size_container(answer.new_style_record)
- {
- return Err(Decline::LayoutNode);
- }
- rows.push(FlightStyleRow {
- style_node,
- old_style_record: answer.old_style_record,
- new_style_record: answer.new_style_record,
- relayout: level >= RELAYOUT_LEVEL,
- });
- }
- Ok(rows)
- }
-
- /// Whether `record` makes its box a size query container.
- fn record_is_size_container(&self, record: u64) -> bool {
- self.style_record_payloads(record).is_some_and(|payloads| {
- let box_values = ComputedValuesView::new(SharedPayload::as_pointer_slice(payloads)).box_values();
- box_values.is_size_container || box_values.is_inline_size_container
- })
- }
-
- /// Whether `record` holds an image a box loads, or names an anchor the host registers, or is gone.
- fn record_holds_resources(&self, record: u64) -> bool {
- let holds_images = self
- .style_record_dependency_flags(record)
- .is_none_or(|flags| flags & super::computed::HOLDS_IMAGE_VALUES != 0);
- holds_images || self.record_names_anchors(record)
- }
-
- /// Whether `record` names an anchor the host registers, or is gone.
- pub(super) fn record_names_anchors(&self, record: u64) -> bool {
- self.style_record_payloads(record).is_none_or(|payloads| {
- !ComputedValuesView::new(SharedPayload::as_pointer_slice(payloads))
- .anchor()
- .anchor_names
- .as_slice()
- .is_empty()
- })
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use crate::css::style::bridge::FfiStyleDeltaDamage;
-
- fn row(style_node: u32) -> FfiStyleDelta {
- FfiStyleDelta {
- style_node,
- match_answer: 0,
- old_style_record: 1,
- new_style_record: 2,
- damage: FfiStyleDeltaDamage::Full,
- reaction: 0,
- inherited_style_groups: 0,
- pseudo_kind: u8::MAX,
- gap: FfiStyleDeltaGap::Computed,
- uses_substitution: false,
- record_reads: 0,
- explicitly_inherited_groups: 0,
- record_damage: FfiStyleInvalidationField::EngineComputed as u32,
- owes_an_animation_plan: false,
- owes_a_transition_step: false,
- composed_by_the_host: false,
- }
- }
-
- fn decline(answer: FfiStyleDelta) -> Option<Decline> {
- let host = crate::render_state::TestHost::new();
- // SAFETY: The engine lives as long as the test host, which nothing else reaches meanwhile.
- let engine = unsafe { host.engine().get() };
- engine.rows_the_flight_applies(&[answer]).err()
- }
-
- #[test]
- fn a_frame_leaves_the_host_every_row_it_cannot_apply_alone() {
- assert_eq!(
- decline(FfiStyleDelta {
- pseudo_kind: 0,
- ..row(1)
- }),
- Some(Decline::Row)
- );
- assert_eq!(
- decline(FfiStyleDelta {
- gap: FfiStyleDeltaGap::Materialize,
- ..row(1)
- }),
- Some(Decline::Row)
- );
- assert_eq!(
- decline(FfiStyleDelta {
- old_style_record: 0,
- ..row(1)
- }),
- Some(Decline::FirstStyle)
- );
- assert_eq!(
- decline(FfiStyleDelta {
- reaction: STYLE_REACTION_RECOMPUTE_DESCENDANT_STYLES,
- ..row(1)
- }),
- Some(Decline::Descendants)
- );
- assert_eq!(
- decline(FfiStyleDelta {
- owes_a_transition_step: true,
- ..row(1)
- }),
- Some(Decline::Animation)
- );
- assert_eq!(
- decline(FfiStyleDelta {
- record_damage: 0,
- ..row(1)
- }),
- Some(Decline::Damage)
- );
- assert_eq!(
- decline(FfiStyleDelta {
- record_damage: FfiStyleInvalidationField::EngineComputed as u32 | REBUILD_LEVEL,
- ..row(1)
- }),
- Some(Decline::Rebuild)
- );
- assert_eq!(
- decline(FfiStyleDelta {
- record_damage: FfiStyleInvalidationField::EngineComputed as u32
- | FfiStyleInvalidationField::RecomputeDescendants as u32,
- ..row(1)
- }),
- Some(Decline::Descendants)
- );
- }
-
- #[test]
- fn a_hidden_row_or_one_that_keeps_its_record_leaves_the_frame_nothing_to_apply() {
- let host = crate::render_state::TestHost::new();
- // SAFETY: As above.
- let engine = unsafe { host.engine().get() };
- let hidden = FfiStyleDelta {
- gap: FfiStyleDeltaGap::Hidden,
- ..row(1)
- };
- let kept = FfiStyleDelta {
- new_style_record: 1,
- ..row(2)
- };
- assert!(
- engine
- .rows_the_flight_applies(&[hidden, kept])
- .is_ok_and(|rows| rows.is_empty())
- );
- }
-}
diff --git a/Libraries/LibWeb/Rust/src/css/style/hover_lane.rs b/Libraries/LibWeb/Rust/src/css/style/hover_lane.rs
index 1ad38a4dd37..34e317bda6f 100644
--- a/Libraries/LibWeb/Rust/src/css/style/hover_lane.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/hover_lane.rs
@@ -10,16 +10,13 @@
use super::StyleEngine;
use super::bridge::{
- FfiDocumentStyleComputationInputs, FfiStyleDelta, FfiStyleDeltaGap, FfiStyleInvalidationField,
- element_adjustment_fact, style_reaction_applied_fact,
+ FfiDocumentStyleComputationInputs, FfiStyleDelta, FfiStyleInvalidationField, element_adjustment_fact,
};
use super::fast_hash::FastMap as HashMap;
+use super::input_types::{STYLE_REACTION_RECOMPUTE_STYLE, StateFact};
use super::layout_style::DerivedStyleRecord;
-use super::transaction::{
- STYLE_REACTION_INHERITED_CUSTOM_PROPERTIES, STYLE_REACTION_PSEUDO_INPUTS_MAY_HAVE_CHANGED,
- STYLE_REACTION_RECOMPUTE_STYLE, StateFact,
-};
use super::tree::StyleNodeID;
+use crate::css::computed_value_views::ComputedValuesView;
use crate::css::transition::HoverTransitions;
use smallvec::SmallVec;
@@ -42,14 +39,19 @@ pub(crate) enum HoverBoxRebuild {
PlaceMoves { parent: StyleNodeID },
}
-/// Cursor facts copied from the presented frame, including elements that have no layout box.
+/// The cursor facts of the presented frame, including elements that have no layout box, read from the generations of
+/// rows and installed records it shows: publishing them costs reference counts however many elements there are.
pub(crate) struct HoverCursorFacts {
- parents: Vec<Option<StyleNodeID>>,
- editable: super::fast_hash::FastSet<StyleNodeID>,
- user_select: Vec<Option<u8>>,
+ projection: super::pipeline::projection::ProjectionGeneration,
+ installed: super::computed::InstalledStyles,
+ editable: std::sync::Arc<super::fast_hash::FastSet<StyleNodeID>>,
}
impl HoverCursorFacts {
+ pub(super) fn editable(&self) -> std::sync::Arc<super::fast_hash::FastSet<StyleNodeID>> {
+ self.editable.clone()
+ }
+
pub(crate) fn is_editable(&self, element: StyleNodeID) -> bool {
self.editable.contains(&element)
}
@@ -60,11 +62,14 @@ impl HoverCursorFacts {
if self.is_editable(element) {
return None;
}
- let value = self.user_select.get(element.element_slot()).copied().flatten()?;
+ let installed = self.installed.element(element)?;
+ let value = ComputedValuesView::of(&installed.record.payloads)
+ .misc_interaction()
+ .user_select;
if value != user_select::AUTO {
return Some(value != user_select::NONE);
}
- match self.parents.get(element.element_slot()).copied().flatten() {
+ match self.projection.element_inheritance_parent(element) {
Some(parent) if parent.element_index().is_some() => element = parent,
_ => return Some(true),
}
@@ -73,65 +78,55 @@ impl HoverCursorFacts {
}
impl StyleEngine {
- pub(crate) fn hover_cursor_facts(&self) -> HoverCursorFacts {
- let (parents, editable) = self.tree().hover_cursor_relations();
- HoverCursorFacts {
- parents,
- editable: editable.into_iter().collect(),
- user_select: self.computed_group_sets.hover_user_select_values(),
+ /// Whether `record` names an anchor the host registers, or is gone.
+ fn record_names_anchors(&self, record: u64) -> bool {
+ self.style_record_payloads(record).is_none_or(|payloads| {
+ !ComputedValuesView::of(payloads)
+ .anchor()
+ .anchor_names
+ .as_slice()
+ .is_empty()
+ })
+ }
+
+ /// The cursor facts of the elements as they stand, published again only where what they read moved since they were
+ /// published last.
+ pub(crate) fn hover_cursor_facts(&mut self) -> std::sync::Arc<HoverCursorFacts> {
+ if let Some(facts) = self.memoized_hover_cursor_facts() {
+ return facts;
}
+ let facts = std::sync::Arc::new(HoverCursorFacts {
+ projection: self.retained.projection.generation(),
+ installed: self.computed_group_sets.publish_installed_styles(),
+ editable: self.hover_editable_nodes(),
+ });
+ self.memoize_hover_cursor_facts(facts.clone());
+ facts
}
/// Whether a hover needs the style engine to restyle an element or reject a disabled control.
- pub(crate) fn hover_needs_style_state(&self, root: StyleNodeID) -> bool {
- use super::index::FeatureKey;
- use super::partial_view::Lookup;
- if self.tree().live_nodes().any(|node| {
- self.facts.states_of_node(node).contains(StateFact::Disabled)
- && self.tree().is_in_shadow_including_subtree_of(node, root)
- }) {
- return true;
+ pub(crate) fn hover_needs_style_state(&mut self, root: StyleNodeID) -> bool {
+ if let Some(needs_style_state) = self.memoized_hover_seal(root) {
+ return needs_style_state;
}
- let may_have_elements = |key: FeatureKey| {
- if !key.has_selector_posting() || key == FeatureKey::State(StateFact::Hover) {
- return true;
- }
- match self.facts.postings().lookup(key) {
- Lookup::Known(posting) => posting
- .candidates()
- .any(|node| self.tree().is_in_shadow_including_subtree_of(node, root)),
- Lookup::KnownAbsent => false,
- Lookup::Missing(_) => true,
- }
- };
- self.routing
- .routes_for(FeatureKey::State(StateFact::Hover))
- .iter()
- .any(|&route| {
- let alternatives = self.routing.origin_dispatch_of(route);
- (alternatives.is_empty() || alternatives.iter().copied().any(may_have_elements))
- && self
- .routing
- .origin_required_of(route)
- .iter()
- .copied()
- .all(may_have_elements)
- })
+ let needs_style_state = self.hover_seal_needs_style_state(root);
+ self.memoize_hover_seal(root, needs_style_state);
+ needs_style_state
}
/// The element a mouse move aimed at `node`, an element, is dispatched to, as the host dispatches it: none where
/// the node is gone, or where the move would be aimed at a disabled form control or anything under one, which the
/// host dispatches no event to.
pub(crate) fn element_for_hover_dispatch(&self, node: StyleNodeID) -> Option<StyleNodeID> {
- if node.element_index().is_none() || !self.tree().is_live(node) {
+ if node.element_index().is_none() || !self.projection.is_live(node) {
return None;
}
- let disabled = std::iter::successors(Some(node), |&ancestor| self.tree().parent(ancestor)).any(|ancestor| {
- self.retained
- .facts
- .states_of_node(ancestor)
- .contains(StateFact::Disabled)
- });
+ let disabled =
+ std::iter::successors(Some(node), |&ancestor| self.projection.parent(ancestor)).any(|ancestor| {
+ self.projection
+ .written_facts(ancestor)
+ .is_some_and(|facts| facts.states().contains(StateFact::Disabled))
+ });
(!disabled).then_some(node)
}
@@ -148,7 +143,7 @@ impl StyleEngine {
/// be selected however its style says.
pub(crate) fn hover_text_may_be_selected(&self, element: StyleNodeID) -> Option<bool> {
use crate::css::css_enums::user_select;
- let tree = self.tree();
+ let tree = &self.projection;
let mut element = element;
loop {
if self.hover_target_is_editable(element) {
@@ -156,11 +151,9 @@ impl StyleEngine {
}
let record = self.computed_group_sets.assigned_style_record(element)?;
let view = self.computed_group_sets.style_record_view(record.raw())?;
- let computed = crate::css::computed_value_views::ComputedValuesView::new(
- crate::css::host_shared::SharedPayload::as_pointer_slice(view.payloads),
- )
- .misc_reset()
- .user_select;
+ let computed = crate::css::computed_value_views::ComputedValuesView::of(view.payloads)
+ .misc_interaction()
+ .user_select;
if computed != user_select::AUTO {
return Some(computed != user_select::NONE);
}
@@ -181,8 +174,13 @@ impl StyleEngine {
let mut chain = HoverChain::new();
// https://drafts.csswg.org/selectors-4/#useraction-pseudos
loop {
- let settled = tree.is_live(node).then(|| self.retained.settled_tree_relations(node));
- let Some(relations) = self.host.tree_staging.current_row(node, settled) else {
+ // NB: An element whose links were not written stands as the tree settled it. The relation-only Document
+ // identity has no relations in the projection, so the tree answers for it.
+ let relations = match self.retained.projection.relations_were_written(node) {
+ true => self.retained.projection.written_relations(node),
+ false => tree.is_live(node).then(|| self.retained.settled_tree_relations(node)),
+ };
+ let Some(relations) = relations else {
return HoverChain::new();
};
if tree.is_relation_only(node) {
@@ -192,13 +190,13 @@ impl StyleEngine {
HoverChain::new()
};
}
- let adjustment_facts = self.computed_group_sets.adjustment_facts(node);
+ let adjustment_facts = self.projection.adjustment_facts(node);
// NB: The document element has no style-tree parent. The Document identity roots only the DOM child sequence.
let is_document_element = relations.parent.is_none()
&& relations.tree_scope == super::tree::TreeScopeID::DOCUMENT
&& adjustment_facts & element_adjustment_fact::IS_DOCUMENT_ELEMENT != 0;
if node.element_index().is_some()
- && tree.host_of(node).is_none()
+ && self.retained.projection.host_of(node).is_none()
&& (relations.parent.is_some() || is_document_element)
{
chain.push(node);
@@ -213,9 +211,11 @@ impl StyleEngine {
let Some(parent) = relations.parent else {
return HoverChain::new();
};
- if let Some(host) = tree.host_of(parent) {
+ if let Some(host) = self.retained.projection.host_of(parent) {
node = host;
- } else if tree.shadow_root_of(parent).is_some() || !tree.assigned_nodes_of(parent).is_empty() {
+ } else if self.retained.projection.shadow_root_of(parent).is_some()
+ || !self.retained.projection.assigned_nodes_of(parent).is_empty()
+ {
return HoverChain::new();
} else {
node = parent;
@@ -275,15 +275,12 @@ impl StyleEngine {
/// Those of `properties` that a box with the style record `record` takes from its parent rather than declares, or
/// none where the engine holds no such record.
pub(crate) fn properties_inherited_by_record(&self, record: u64, properties: &[u16]) -> Option<SmallVec<[u16; 8]>> {
- let table = self
- .computed_group_sets
- .style_record_view(record)
- .and_then(|view| view.longhand_table)?;
+ let longhands = self.computed_group_sets.style_record_view(record)?.longhands();
Some(
properties
.iter()
.copied()
- .filter(|&property| table.is_inherited(property))
+ .filter(|&property| longhands.is_inherited(property))
.collect(),
)
}
@@ -309,47 +306,32 @@ impl StyleEngine {
let tree = self.tree();
node.element_index().is_some()
&& !tree.is_relation_only(node)
- && tree.host_of(node).is_none()
+ && self.retained.projection.host_of(node).is_none()
&& (tree.is_live(node) || self.node_arrival_is_pending(node))
});
- let new_chain = self.hover_chain(target);
- let old_chain = std::mem::take(&mut self.retained.hover.chain);
- for &node in old_chain.iter().filter(|node| !new_chain.contains(node)) {
- let arriving = self.node_arrival_is_pending(node);
- self.record_batched_state(node, StateFact::Hover, false, arriving);
- }
- for &node in new_chain.iter().filter(|node| !old_chain.contains(node)) {
- let arriving = self.node_arrival_is_pending(node);
- self.record_batched_state(node, StateFact::Hover, true, arriving);
- }
- self.settle_batched_inputs();
- self.retained.hover = Hover {
- target,
- chain: new_chain,
- };
+ let chain = self.hover_chain(target);
+ self.retained.projection.place_hover(&chain);
+ self.retained.hover = Hover { target };
}
}
-/// Where the hover is: the element it targets, and the elements that hold the hover fact for it, as
-/// [`StyleEngine::set_hover`] last placed them.
+/// The element the hover targets, as [`StyleEngine::set_hover`] last placed it. The chain of elements that hold the hover
+/// state for it is the projection's hover overlay.
#[derive(Clone, Default)]
pub(crate) struct Hover {
target: Option<StyleNodeID>,
- chain: HoverChain,
}
impl Hover {
- /// Lets go of the element `node` names, whose identity retires: an element that leaves the tree takes its hover
- /// fact along.
+ /// Lets go of the element `node` names, whose identity retires.
pub(super) fn retire(&mut self, node: StyleNodeID) {
if self.target == Some(node) {
self.target = None;
}
- self.chain.retain(|held| *held != node);
}
}
-/// A row of a hover's style transaction the render owner installed in the engine and in the boxes, which the host
+/// A row of a hover's style update the render owner installed in the engine and in the boxes, which the host
/// installs on its element in turn: the element's row, and the rows of its pseudo-elements beside it. The records the
/// rows move to stay pinned until [`StyleEngine::release_hover_install`].
#[derive(Clone)]
@@ -372,7 +354,7 @@ impl HoverInstall {
}
}
-/// The rows of a wave of a hover's style transaction, element rows each followed by the rows of its pseudo-elements,
+/// The rows of a wave of a hover's style update, element rows each followed by the rows of its pseudo-elements,
/// as the transaction answered them.
pub(crate) struct HoverWave {
pub(crate) rows: Vec<FfiStyleDelta>,
@@ -399,7 +381,7 @@ impl HoverWave {
.count();
let pseudo_rows = &rows[index + 1..index + 1 + pseudo_elements];
index += 1 + pseudo_elements;
- if row.pseudo_kind != u8::MAX || row.gap == FfiStyleDeltaGap::Hidden {
+ if row.pseudo_kind != u8::MAX {
continue;
}
return Some((row, pseudo_rows));
@@ -409,18 +391,13 @@ impl HoverWave {
}
}
-/// The reactions of a row that moves only its element's inherited custom-property environment, which the host answers
-/// by computing nothing for an element whose style, its pseudo-elements' included, reads none of it.
-const ENVIRONMENT_ONLY_REACTIONS: u8 =
- STYLE_REACTION_INHERITED_CUSTOM_PROPERTIES | STYLE_REACTION_PSEUDO_INPUTS_MAY_HAVE_CHANGED;
-
/// The pseudo-elements that style parts of the boxes of any element their rules match, as bits of a pseudo-style mask.
/// Rules for `::before` and `::after` generate boxes only where they give content, which the boxes answer, and every
/// element matches rules for `::marker` and `::backdrop`, which generate boxes only for a list item and a top layer
/// element.
-const BOX_PSEUDO_ELEMENTS: u64 = {
+const BOX_PSEUDO_ELEMENTS: [u8; 2] = {
use super::publication::pseudo_kind::{FIRST_LETTER, FIRST_LINE};
- (1 << FIRST_LETTER) | (1 << FIRST_LINE)
+ [FIRST_LETTER, FIRST_LINE]
};
/// Whether `row` keeps its element, whose record the host composes with its animations, on the record it holds, and
@@ -431,7 +408,6 @@ fn hover_row_keeps_a_composed_record(row: &FfiStyleDelta) -> bool {
&& !row.owes_an_animation_plan
&& !row.owes_a_transition_step
&& row.pseudo_kind == u8::MAX
- && row.gap == FfiStyleDeltaGap::Computed
&& row.old_style_record != 0
&& row.old_style_record == row.new_style_record
}
@@ -459,15 +435,13 @@ pub(crate) fn hover_row_generated_for(row: &FfiStyleDelta) -> Option<u8> {
}
impl StyleEngine {
- /// Whether a style transaction the render owner takes for a hover takes no input but the hover's: the host left
+ /// Whether a style update the render owner takes for a hover takes no input but the hover's: the host left
/// nothing pending and no transaction of its own unended.
pub(crate) fn takes_hover_transactions(&self) -> bool {
- !self.has_pending_transaction()
- && !self.has_deferred_element_style_inputs()
- && self.retained.engine_computed_records_pending.is_empty()
+ !self.has_pending_transaction() && !self.has_deferred_element_style_inputs()
}
- /// Takes the next wave of the style transaction of a hover, under `root`, with the document computation inputs the
+ /// Takes the next wave of the style update of a hover, under `root`, with the document computation inputs the
/// host sealed last, and answers its rows, and whether the render owner can install all of them as the host would.
/// The wave leaves the atoms it would sweep to a later transaction, which the host takes.
///
@@ -494,7 +468,7 @@ impl StyleEngine {
) -> HoverWave {
self.defer_atom_sweep(true);
// SAFETY: Guaranteed by the caller.
- let output = unsafe { super::bridge::take_style_transaction(self, root, inputs, None) };
+ let output = unsafe { super::bridge::run_style_update(self, root, inputs) };
self.defer_atom_sweep(false);
let mut rows = output.answers().to_vec();
self.answer_hover_row_damage(&mut rows);
@@ -517,7 +491,7 @@ impl StyleEngine {
}
}
let mut installable =
- output.reclaimed_style_atoms().is_empty() && rows.iter().all(|row| self.hover_row_is_installable(row));
+ output.reclaimed_style_atoms().is_empty() && rows.iter().all(|row| self.hover_row_refusal(row).is_none());
let mut refusal = None;
// A scroll container that snaps snaps again as the content the host lays out moves, which the render owner
// leaves to the host.
@@ -526,16 +500,6 @@ impl StyleEngine {
installable = false;
refusal = Some("a move a snapping scroll container snaps to");
}
- // A child that inherits a group its parent's transitions animate explicitly reads the composition.
- if rows.iter().any(|row| {
- StyleNodeID::from_raw(row.style_node)
- .and_then(|node| self.tree.inheritance_parent(node))
- .and_then(|parent| composed_beside.get(&parent))
- .is_some_and(|&groups| row.explicitly_inherited_groups & groups != 0)
- }) {
- installable = false;
- refusal = Some("a child that inherits what its parent's transitions animate");
- }
// A row that owes its element the transition step starts the transitions the step decides, which the render
// owner samples itself where nothing but the engine decides them.
let mut transitions = Vec::new();
@@ -581,6 +545,26 @@ impl StyleEngine {
}
}
}
+ // A child that inherits a group its parent's transitions animate explicitly reads the composition, whether an
+ // earlier wave started them or this one, which styles the children of an element with it under the engine.
+ if installable
+ && rows.iter().any(|row| {
+ StyleNodeID::from_raw(row.style_node)
+ .and_then(|node| self.projection.inheritance_parent(node))
+ .and_then(|parent| {
+ composed_beside.get(&parent).copied().or_else(|| {
+ composed
+ .iter()
+ .find(|&&(node, _)| node == parent)
+ .map(|&(_, groups)| groups)
+ })
+ })
+ .is_some_and(|groups| row.explicitly_inherited_groups & groups != 0)
+ })
+ {
+ installable = false;
+ refusal = Some("a child that inherits what its parent's transitions animate");
+ }
let mut wave = HoverWave {
rows,
installable,
@@ -592,10 +576,8 @@ impl StyleEngine {
return wave;
}
// The host composes the record of an element whose transitions the render owner composes as it installs the
- // row, which moves nothing its children inherit, as no transition animates an inherited property: the next
- // wave settles them over the record the element holds.
+ // row, which moves nothing its children inherit, as no transition animates an inherited property.
for (node, groups) in composed {
- self.settle_children_beside_composition_of(node);
composed_beside.insert(node, groups);
}
wave
@@ -620,11 +602,7 @@ impl StyleEngine {
if row.pseudo_kind == u8::MAX {
element_record = row.new_style_record;
}
- if row.record_damage & engine_computed != 0
- || row.old_style_record == 0
- || row.new_style_record == 0
- || !matches!(row.gap, FfiStyleDeltaGap::Computed | FfiStyleDeltaGap::None)
- {
+ if row.record_damage & engine_computed != 0 || row.old_style_record == 0 || row.new_style_record == 0 {
continue;
}
let damage = if row.pseudo_kind == u8::MAX {
@@ -644,21 +622,13 @@ impl StyleEngine {
}
}
- /// Whether the render owner can install `row`, of a hover's transaction, as the host would: a record the engine
- /// settled itself, which owes the host no animation plan or composition, and no transition step of a
- /// pseudo-element.
- fn hover_row_is_installable(&self, row: &FfiStyleDelta) -> bool {
- self.hover_row_refusal(row).is_none()
- }
-
/// Whether `row`, of a hover's transaction, moves its element to the record the host holds for it, or to the one
/// the composition the host holds is laid over.
pub(crate) fn hover_row_returns_to_held_record(&self, row: &FfiStyleDelta) -> bool {
if row.pseudo_kind != u8::MAX || row.new_style_record == 0 {
return false;
}
- let Some(held) =
- StyleNodeID::from_raw(row.style_node).and_then(|node| self.retained.held_style_records.get(&node).copied())
+ let Some(held) = StyleNodeID::from_raw(row.style_node).and_then(|node| self.retained.held_style_record(node))
else {
return false;
};
@@ -684,10 +654,11 @@ impl StyleEngine {
};
if row.owes_a_transition_step
&& (row.pseudo_kind != u8::MAX
- || self.published_pseudo_style_mask(node) & BOX_PSEUDO_ELEMENTS != 0
+ || BOX_PSEUDO_ELEMENTS
+ .iter()
+ .any(|&kind| self.computed_group_sets.pseudo_style_record(node, kind).is_some())
|| self.record_displays_a_list_item(row.new_style_record)
- || self.computed_group_sets.adjustment_facts(node) & element_adjustment_fact::RENDERED_IN_TOP_LAYER
- != 0)
+ || self.projection.adjustment_facts(node) & element_adjustment_fact::RENDERED_IN_TOP_LAYER != 0)
{
return Some("a transition step of an element with pseudo-elements");
}
@@ -696,29 +667,27 @@ impl StyleEngine {
if hover_row_generated_for(row).is_none() {
return Some("a pseudo-element other than ::before, ::after and ::marker");
}
- return (row.gap != FfiStyleDeltaGap::Computed || !engine_damage)
- .then_some("a pseudo-element the host settles");
- }
- if self.hover_row_moves_only_an_environment(row) {
- return None;
- }
- match row.gap {
- FfiStyleDeltaGap::Hidden => return None,
- FfiStyleDeltaGap::Materialize => return Some("a record the host materializes"),
- FfiStyleDeltaGap::Computed | FfiStyleDeltaGap::None => {
- if !engine_damage {
- return Some("damage the host compares");
- }
- if row.old_style_record == 0 || row.new_style_record == 0 {
- return Some("a first style");
- }
+ return (!engine_damage).then_some("a pseudo-element the host settles");
+ }
+ // A first record the engine computed for an element the host holds no style for, below one it did not display,
+ // is the record the boxes the hover reveals are built from.
+ let reveals_boxes =
+ row.old_style_record == 0 && row.new_style_record != 0 && !self.retained.held_style_records.contains(node);
+ if !reveals_boxes {
+ if !engine_damage {
+ return Some("damage the host compares");
+ }
+ if row.old_style_record == 0 || row.new_style_record == 0 {
+ return Some("a first style");
}
}
// The host keeps the root's font metrics beside its record, which only it moves.
- if self.computed_group_sets.adjustment_facts(node) & element_adjustment_fact::IS_DOCUMENT_ELEMENT != 0 {
+ if self.projection.adjustment_facts(node) & element_adjustment_fact::IS_DOCUMENT_ELEMENT != 0 {
return Some("the document element");
}
- if self.record_names_anchors(row.old_style_record) || self.record_names_anchors(row.new_style_record) {
+ if (row.old_style_record != 0 && self.record_names_anchors(row.old_style_record))
+ || self.record_names_anchors(row.new_style_record)
+ {
return Some("anchors the host registers");
}
if self.hover_row_moves_images(row) {
@@ -735,16 +704,24 @@ impl StyleEngine {
fn hover_row_moves_svg_references(&self, row: &FfiStyleDelta) -> bool {
use crate::css::computed_value_types::SVG_PAINT_URL;
use crate::css::computed_value_views::ComputedValuesView;
- use crate::css::host_shared::SharedPayload;
- let view = |record: u64| {
- self.style_record_payloads(record)
- .map(|payloads| ComputedValuesView::new(SharedPayload::as_pointer_slice(payloads)))
+ let view = |record: u64| self.style_record_payloads(record).map(ComputedValuesView::of);
+ let paints_a_server = |values: ComputedValuesView<'_>| {
+ values.inherited_svg().fill.kind == SVG_PAINT_URL || values.inherited_svg().stroke.kind == SVG_PAINT_URL
};
- let (Some(old), Some(new)) = (view(row.old_style_record), view(row.new_style_record)) else {
+ let Some(new) = view(row.new_style_record) else {
return true;
};
- let paints_a_server = |values: ComputedValuesView<'_>| {
- values.inherited_svg().fill.kind == SVG_PAINT_URL || values.inherited_svg().stroke.kind == SVG_PAINT_URL
+ // A first style, below an element the host did not display, publishes what the new record names alone.
+ if row.old_style_record == 0 {
+ use crate::css::computed_values::GroupPayloadRef;
+ use crate::css::table_group_builder::group_index;
+ // SAFETY: The mask payload is the record's, which stays live while the row is read.
+ let masks = unsafe { GroupPayloadRef::new(group_index::MASK, std::ptr::from_ref(new.mask()).cast()) }
+ .is_none_or(|mask| !mask.holds_the_defaults());
+ return paints_a_server(new) || masks;
+ }
+ let Some(old) = view(row.old_style_record) else {
+ return true;
};
paints_a_server(old) || paints_a_server(new) || !std::ptr::eq(old.mask(), new.mask())
}
@@ -752,7 +729,6 @@ impl StyleEngine {
/// Whether `row` moves its element to a record that holds other images than the one it held, which the host loads
/// for the box. A box keeps the images of a move between records that hold the same ones.
fn hover_row_moves_images(&self, row: &FfiStyleDelta) -> bool {
- use crate::css::host_shared::SharedPayload;
if !self.style_record_holds_image_values(row.old_style_record)
&& !self.style_record_holds_image_values(row.new_style_record)
{
@@ -765,39 +741,14 @@ impl StyleEngine {
return true;
};
// SAFETY: Published style-group payloads stay live while their records do.
- unsafe {
- crate::css::computed_values::style_group_payloads_move_image_values(
- SharedPayload::as_pointer_slice(old),
- SharedPayload::as_pointer_slice(new),
- )
- }
- }
-
- /// Whether `row` owes its element no more than a moved inherited custom-property environment, which its style reads
- /// none of: the engine moved the element's environment, and the record over it, as its parent's moved. The host
- /// installs nothing for such a row, and only carries the reaction on to the children. The engine asks the host to
- /// compute the style again of an element it leaves such a reaction to that reads the environment.
- pub(crate) fn hover_row_moves_only_an_environment(&self, row: &FfiStyleDelta) -> bool {
- row.gap == FfiStyleDeltaGap::Materialize
- && row.pseudo_kind == u8::MAX
- && row.reaction & STYLE_REACTION_INHERITED_CUSTOM_PROPERTIES != 0
- && row.reaction & !ENVIRONMENT_ONLY_REACTIONS == 0
- && row.old_style_record != 0
- && StyleNodeID::from_raw(row.style_node).is_some_and(|node| {
- self.deferred_element_style_reaction(node)
- .is_none_or(|pending| pending & !ENVIRONMENT_ONLY_REACTIONS == 0)
- })
+ unsafe { crate::css::computed_values::style_group_payloads_move_image_values(&old.pointers(), &new.pointers()) }
}
/// Whether `record` makes its element a list item, which generates a marker.
fn record_displays_a_list_item(&self, record: u64) -> bool {
use crate::css::computed_value_views::ComputedValuesView;
- use crate::css::host_shared::SharedPayload;
- self.style_record_payloads(record).is_none_or(|payloads| {
- ComputedValuesView::new(SharedPayload::as_pointer_slice(payloads))
- .display()
- .is_list_item()
- })
+ self.style_record_payloads(record)
+ .is_none_or(|payloads| ComputedValuesView::of(payloads).display().is_list_item())
}
/// The flat-tree element descendants of the element `node` names that inherit one of `properties` from it, each with
@@ -813,8 +764,7 @@ impl StyleEngine {
let mut covers_subtree = true;
let mut parents: Vec<(StyleNodeID, SmallVec<[u16; 2]>)> = vec![(node, properties.iter().copied().collect())];
while let Some((parent, inherited)) = parents.pop() {
- let children: SmallVec<[StyleNodeID; 8]> = self.tree.flat_tree_children(parent).collect();
- for child in children {
+ for child in self.projection.flat_tree_children(parent) {
let Some(view) = self
.computed_group_sets
.assigned_style_record(child)
@@ -822,13 +772,11 @@ impl StyleEngine {
else {
continue;
};
- let Some(table) = view.longhand_table else {
- continue;
- };
+ let longhands = view.longhands();
let inherits: SmallVec<[u16; 2]> = inherited
.iter()
.copied()
- .filter(|&property| table.is_inherited(property))
+ .filter(|&property| longhands.is_inherited(property))
.collect();
if inherits.is_empty() {
covers_subtree = false;
@@ -846,19 +794,12 @@ impl StyleEngine {
/// Whether an element the element `node` inherits from runs animations, which move what it inherits.
pub(crate) fn inheritance_ancestors_animate(&self, node: StyleNodeID) -> bool {
- std::iter::successors(self.tree.inheritance_parent(node), |&ancestor| {
- self.tree.inheritance_parent(ancestor)
+ std::iter::successors(self.projection.inheritance_parent(node), |&ancestor| {
+ self.projection.inheritance_parent(ancestor)
})
.any(|ancestor| self.element_adjustment_facts(ancestor) & element_adjustment_fact::HAS_ANIMATIONS != 0)
}
- /// Whether `row` moves its element's custom-property environment, which the elements below it inherit.
- fn hover_row_moves_custom_properties(&self, row: &FfiStyleDelta) -> bool {
- let sets = &self.computed_group_sets;
- sets.style_record_custom_property_environment(row.old_style_record)
- != sets.style_record_custom_property_environment(row.new_style_record)
- }
-
/// Installs the rows of `wave`, which the render owner applies to the boxes, on the engine's side as the host's
/// application of them does: what each element owes is answered, the engine's record becomes its own, and what the
/// element's move derives for its children joins the next wave. Answers the installs for the host, whose records
@@ -867,89 +808,21 @@ impl StyleEngine {
let mut installs = Vec::new();
for (row, pseudo_rows) in wave.element_rows() {
let node = StyleNodeID::from_raw(row.style_node).expect("an installable row names a style node");
- if self.hover_row_moves_only_an_environment(&row) {
- // As the host applies such a row: the reaction it owes joins the element's own, and the children take
- // it on from an element whose style did not move.
- let absorbed = self.absorb_element_style_input(node, row.reaction, row.inherited_style_groups, true);
- let (reaction, inherited_style_groups) = match absorbed {
- 0 => (row.reaction, row.inherited_style_groups),
- absorbed => (absorbed as u8, (absorbed >> 8) as u8),
- };
- // A reaction an earlier row derived for the element that asks for more is the host's to answer.
- if reaction & !ENVIRONMENT_ONLY_REACTIONS != 0 {
- self.record_derived_element_style_input(
- node,
- reaction | STYLE_REACTION_RECOMPUTE_STYLE,
- inherited_style_groups,
- );
- continue;
- }
- let (_, _, facts) =
- self.engine_row_child_reaction_facts(node, row.old_style_record, row.old_style_record, []);
- self.note_style_reaction_applied(
- node,
- reaction,
- 0,
- 0,
- facts | style_reaction_applied_fact::INVALIDATION_IS_NONE,
- );
- // The host's element holds the environment, and the record, the engine held before it moved them, which
- // the host takes in its turn, as its own move of the environment hands them down.
- let install = HoverInstall {
- element: FfiStyleDelta { reaction, ..row },
- pseudo_elements: SmallVec::new(),
- };
- for record in install.records() {
- self.pin_style_record(record);
- }
- installs.push(install);
- continue;
- }
if hover_row_keeps_a_composed_record(&row) && pseudo_rows.is_empty() {
- // As the host installs such a row: the record answers what the element owes, and the children take the
- // reaction on from an element whose style did not move. The composition stands as the host made it.
- let absorbed = self.absorb_element_style_input(node, row.reaction, row.inherited_style_groups, false);
- let reaction = if absorbed != 0 { absorbed as u8 } else { row.reaction };
+ // As the host installs such a row: the record answers what the element owes. The composition stands as
+ // the host made it.
+ self.absorb_element_style_input(node, row.reaction, row.inherited_style_groups);
self.consume_element_style_input(node);
- self.retained.acknowledge_engine_computed_record(node);
- let (_, _, facts) =
- self.engine_row_child_reaction_facts(node, row.old_style_record, row.old_style_record, []);
- self.note_style_reaction_applied(
- node,
- reaction,
- 0,
- 0,
- facts | style_reaction_applied_fact::INVALIDATION_IS_NONE,
- );
continue;
}
let (mut reaction, mut inherited_style_groups) = (row.reaction, row.inherited_style_groups);
// A reaction a row before this one derived for the element joins the element's own, as it covers it.
- let absorbed = self.absorb_element_style_input(node, reaction, inherited_style_groups, false);
+ let absorbed = self.absorb_element_style_input(node, reaction, inherited_style_groups);
if absorbed != 0 {
reaction = absorbed as u8;
inherited_style_groups = (absorbed >> 8) as u8;
}
self.consume_element_style_input(node);
- if row.gap == FfiStyleDeltaGap::Computed {
- self.retained.acknowledge_engine_computed_record(node);
- }
- let damages =
- std::iter::once(row.record_damage).chain(pseudo_rows.iter().map(|pseudo| pseudo.record_damage));
- let (inherited_style_groups_changed, changed_non_inherited_style_groups, mut facts) =
- self.engine_row_child_reaction_facts(node, row.old_style_record, row.new_style_record, damages);
- // The host moves the environments below an element whose own moved as it installs the row. Here, the
- // elements below compute again over the environment the engine now assigns their parent, in the next wave.
- if self.hover_row_moves_custom_properties(&row) {
- facts |= style_reaction_applied_fact::DID_CHANGE_CUSTOM_PROPERTIES;
- }
- self.note_style_reaction_applied(
- node,
- reaction,
- inherited_style_groups_changed,
- changed_non_inherited_style_groups,
- facts,
- );
let install = HoverInstall {
element: FfiStyleDelta {
reaction,
@@ -972,7 +845,7 @@ impl StyleEngine {
pub(crate) fn abandon_hover_wave(&mut self, wave: &mut HoverWave) {
self.release_hover_transition_samples(wave);
// NB: The engine is a lane's fork, whose released identities no host mints again.
- let _ = self.discard_style_transaction_outputs();
+ let _ = self.discard_style_update_outputs();
for (row, _) in wave.element_rows() {
if let Some(node) = StyleNodeID::from_raw(row.style_node) {
self.record_derived_element_style_input(
@@ -984,10 +857,10 @@ impl StyleEngine {
}
}
- /// Ends the style transaction of a hover once its waves are installed, as the host ends one.
+ /// Ends the style update of a hover once its waves are installed, as the host ends one.
pub(crate) fn end_hover_transaction(&mut self) {
// NB: The engine is a lane's fork, whose released identities no host mints again.
- let _ = self.discard_style_transaction_outputs();
+ let _ = self.discard_style_update_outputs();
}
/// Lets go of the records of `install`, which the host installed, or which a later install replaced.
@@ -999,14 +872,18 @@ impl StyleEngine {
}
/// Takes the element the style node `target` names, or none for 0, as the element the hover of `host`'s document
-/// targets, as the events of a mouse move hover it, and stages the move of the engine's hover to it for the input the
-/// host submits next, where it moves. Answers whether it does.
+/// targets, as the events of a mouse move hover it, and moves the engine's hover to it behind what the host wrote
+/// before, where it moves. Answers whether it does.
#[unsafe(no_mangle)]
pub extern "C" fn style_engine_request_hover(host: &crate::render_state::DocumentHost, target: u32) -> bool {
let target = StyleNodeID::from_raw(target);
let moves = host.request_hover(target);
if moves {
- host.engine_memo().staged_input.borrow_mut().stage_hover(target);
+ // NB: The hover's chain reads the tree as the host wrote it.
+ host.publish_element_writes();
+ host.queue_change(crate::render_state::ArenaChange::Engine(
+ super::engine_calls::EngineWrite::MoveHover(target),
+ ));
}
moves
}
diff --git a/Libraries/LibWeb/Rust/src/css/style/transition_baselines.rs b/Libraries/LibWeb/Rust/src/css/style/transition_baselines.rs
index 3fdacd72859..ce12a5347fe 100644
--- a/Libraries/LibWeb/Rust/src/css/style/transition_baselines.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/transition_baselines.rs
@@ -7,58 +7,60 @@
//! The before-change styles a style stabilization epoch decides CSS transitions against.
use super::boundary::StyleChange;
+use super::pipeline::Record;
use super::tree::StyleNodeID;
-use super::{HashMap, RetainedState};
+use super::{HashMap, RetainedState, ViewLonghands};
use crate::css::animated_overlay::FfiAnimatedOverlayEntry;
-use crate::css::computed_longhand_table::ComputedLonghandTable;
use crate::css::style_value::StyleValueData;
use smallvec::SmallVec;
+use std::sync::Arc;
/// https://drafts.csswg.org/css-transitions-2/#defining-before-change-style
/// Per transition target, by element and then pseudo-element kind, the before-change style its transitions are decided
-/// against for the rest of the style stabilization epoch: the first record named for the target. The engine keeps them
-/// pinned until the epoch commits, and the host follows every baseline it records for the engine, the commit that
-/// releases them, and every identity a transaction releases, as the engine drops a retired node's baselines, so it
-/// knows each without asking.
+/// against for the rest of the style stabilization epoch: the first record named for the target, which the baseline
+/// holds until the epoch commits. The host follows every baseline it records for the engine, the commit that releases
+/// them, and every identity a transaction releases, as the engine drops a retired node's baselines, so it knows each
+/// without asking.
#[derive(Clone, Default)]
pub(crate) struct TransitionBaselines {
- baselines: HashMap<StyleNodeID, SmallVec<[(u8, u64); 1]>>,
+ /// Shared with a fork until either side writes it.
+ baselines: crate::fork::ForkShared<HashMap<StyleNodeID, SmallVec<[TargetBaseline; 1]>>>,
}
+/// The baseline of a transition target, by its pseudo-element kind.
+type TargetBaseline = (u8, Arc<Record>);
+
impl TransitionBaselines {
- /// Keeps `style_record` as the target's baseline where it has none, answering whether it did.
- fn insert(&mut self, node: StyleNodeID, pseudo_kind: u8, style_record: u64) -> bool {
- let baselines = self.baselines.entry(node).or_default();
- if baselines.iter().any(|&(kind, _)| kind == pseudo_kind) {
- return false;
- }
- baselines.push((pseudo_kind, style_record));
- true
+ /// The bytes the baselines hold on the heap.
+ pub(crate) fn heap_size(&self) -> usize {
+ use crate::heap_size::{map_bytes, small_vec_bytes};
+ map_bytes(&self.baselines) + self.baselines.values().map(small_vec_bytes).sum::<usize>()
}
- /// The baseline of the target, or 0 before a pass has recorded one.
- pub(crate) fn get(&self, node: StyleNodeID, pseudo_kind: u8) -> u64 {
+ /// Keeps `record` as the target's baseline where it has none.
+ fn insert(&mut self, node: StyleNodeID, pseudo_kind: u8, record: &Arc<Record>) {
+ if self.get(node, pseudo_kind).is_some() {
+ return;
+ }
self.baselines
- .get(&node)
- .and_then(|baselines| baselines.iter().find(|&&(kind, _)| kind == pseudo_kind))
- .map_or(0, |&(_, style_record)| style_record)
+ .entry(node)
+ .or_default()
+ .push((pseudo_kind, record.clone()));
}
- /// Lets go of the baselines of `node`'s element and pseudo-elements, answering their records.
- pub(crate) fn remove(&mut self, node: StyleNodeID) -> impl Iterator<Item = u64> {
+ /// The baseline of the target, or none before a pass has recorded one.
+ pub(crate) fn get(&self, node: StyleNodeID, pseudo_kind: u8) -> Option<&Arc<Record>> {
self.baselines
- .remove(&node)
- .into_iter()
- .flatten()
- .map(|(_, style_record)| style_record)
+ .get(&node)
+ .and_then(|baselines| baselines.iter().find(|(kind, _)| *kind == pseudo_kind))
+ .map(|(_, record)| record)
}
- /// Lets go of every baseline, answering their records.
- fn take(&mut self) -> impl Iterator<Item = u64> {
- std::mem::take(&mut self.baselines)
- .into_values()
- .flatten()
- .map(|(_, style_record)| style_record)
+ /// Lets go of the baselines of `node`'s element and pseudo-elements.
+ pub(crate) fn remove(&mut self, node: StyleNodeID) {
+ if self.baselines.contains_key(&node) {
+ self.baselines.remove(&node);
+ }
}
/// Follows `change`, a write the host queued for the engine, as the engine applies it.
@@ -67,11 +69,11 @@ impl TransitionBaselines {
StyleChange::RecordTransitionBaseline {
node: Some(node),
pseudo_kind,
- style_record,
- } if style_record != 0 => {
- self.insert(node, pseudo_kind, style_record);
+ style_record: Some(ref record),
+ } => self.insert(node, pseudo_kind, record),
+ StyleChange::ReleaseTransitionBaselines if !self.baselines.is_empty() => {
+ self.baselines = Default::default();
}
- StyleChange::ReleaseTransitionBaselines => self.baselines.clear(),
_ => {}
}
}
@@ -79,7 +81,7 @@ impl TransitionBaselines {
/// Forgets the baselines of the nodes a transaction retired, whose identities it `released`.
pub(crate) fn forget(&mut self, released: &[u32]) {
for node in released.iter().filter_map(|&raw| StyleNodeID::from_raw(raw)) {
- self.baselines.remove(&node);
+ self.remove(node);
}
}
}
@@ -96,22 +98,21 @@ pub(crate) enum InheritedAnimatedValue<'a> {
impl RetainedState {
/// Style, layout or animation feedback can give a target a transition in any later pass of
/// the epoch, and that transition starts from the style the target held before the epoch's
- /// first pass. The first record named for a target is that style: it is kept, pinned, until
- /// the epoch commits.
- pub(crate) fn record_transition_baseline(&mut self, node: StyleNodeID, pseudo_kind: u8, style_record: u64) {
- if style_record != 0 && self.transition_baselines.insert(node, pseudo_kind, style_record) {
- self.computed_group_sets.pin_style_record(style_record);
- }
+ /// first pass. The first record named for a target is that style: it is kept until the epoch
+ /// commits.
+ pub(crate) fn record_transition_baseline(&mut self, node: StyleNodeID, pseudo_kind: u8, record: Arc<Record>) {
+ self.transition_baselines.insert(node, pseudo_kind, &record);
}
- /// The baseline of `node`'s element or pseudo-element of kind `pseudo_kind`, or 0 before a pass has recorded one.
- pub(crate) fn transition_baseline(&self, node: StyleNodeID, pseudo_kind: u8) -> u64 {
+ /// The baseline of `node`'s element or pseudo-element of kind `pseudo_kind`, or none before a pass has recorded
+ /// one.
+ pub(crate) fn transition_baseline(&self, node: StyleNodeID, pseudo_kind: u8) -> Option<&Arc<Record>> {
self.transition_baselines.get(node, pseudo_kind)
}
/// Whether an ancestor `node` inherits from holds animated values, which is the only way it inherits one.
pub(crate) fn ancestors_hold_animated_values(&self, node: StyleNodeID) -> bool {
- let mut ancestor = self.tree.inheritance_parent(node);
+ let mut ancestor = self.projection.inheritance_parent(node);
while let Some(current) = ancestor {
if let Some(record) = self.computed_group_sets.assigned_style_record(current)
&& self
@@ -121,12 +122,12 @@ impl RetainedState {
{
return true;
}
- ancestor = self.tree.inheritance_parent(current);
+ ancestor = self.projection.inheritance_parent(current);
}
false
}
- /// Where an inherited value of `property` in `table`, a record of `node`'s, comes from when an
+ /// Where an inherited value of `property` in `longhands`, a record of `node`'s, comes from when an
/// ancestor animates it. A record the engine derives holds the animated value its parent passed
/// on in its table, where a transition decides against the value beneath the animations: an
/// animation's value, where an ancestor's animation other than a transition sets it, or else the
@@ -135,39 +136,37 @@ impl RetainedState {
pub(crate) fn inherited_animated_value(
&self,
node: StyleNodeID,
- table: &ComputedLonghandTable,
+ longhands: ViewLonghands<'_>,
property: u16,
) -> Option<InheritedAnimatedValue<'_>> {
- if !table.is_inherited(property) {
+ if !longhands.is_inherited(property) {
return None;
}
let mut transition_entry = None;
- let mut ancestor = self.tree.inheritance_parent(node);
+ let mut ancestor = self.projection.inheritance_parent(node);
while let Some(current) = ancestor {
let record = self.computed_group_sets.assigned_style_record(current)?;
let view = self.computed_group_sets.style_record_view(record.raw())?;
- let ancestor_table = view.longhand_table?;
+ let ancestor_longhands = view.longhands();
if let Some(entry) = view.animated_overlay.and_then(|overlay| overlay.get(property)) {
if !entry.result_of_transition {
return Some(InheritedAnimatedValue::Animation(entry));
}
transition_entry = Some(entry);
}
- if !ancestor_table.is_inherited(property) {
+ if !ancestor_longhands.is_inherited(property) {
transition_entry?;
return Some(InheritedAnimatedValue::BeneathTransitions(
- ancestor_table.get(property)?.data(),
+ ancestor_longhands.value(property)?,
));
}
- ancestor = self.tree.inheritance_parent(current);
+ ancestor = self.projection.inheritance_parent(current);
}
None
}
/// The epoch committed: no later pass decides against these styles.
pub(crate) fn release_transition_baselines(&mut self) {
- for style_record in self.transition_baselines.take() {
- self.computed_group_sets.unpin_style_record(style_record);
- }
+ self.transition_baselines.baselines.clear();
}
}
diff --git a/Libraries/LibWeb/Rust/src/fork.rs b/Libraries/LibWeb/Rust/src/fork.rs
index 0a658d54fd3..523c7cc41fd 100644
--- a/Libraries/LibWeb/Rust/src/fork.rs
+++ b/Libraries/LibWeb/Rust/src/fork.rs
@@ -16,12 +16,6 @@ use std::ops::{Deref, DerefMut};
#[derive(Default)]
pub(crate) struct ForkReset<T: Default>(T);
-impl<T: Default> ForkReset<T> {
- pub(crate) fn new(value: T) -> Self {
- Self(value)
- }
-}
-
impl<T: Default> Clone for ForkReset<T> {
fn clone(&self) -> Self {
Self(T::default())
@@ -42,81 +36,24 @@ impl<T: Default> DerefMut for ForkReset<T> {
}
}
-/// An atomic that a fork copies with the value it holds.
-#[derive(Default, Debug)]
-pub(crate) struct ForkCopied<T>(T);
-
-impl<T> ForkCopied<T> {
- pub(crate) const fn new(value: T) -> Self {
- Self(value)
- }
-}
-
-impl<T> Deref for ForkCopied<T> {
- type Target = T;
-
- fn deref(&self) -> &T {
- &self.0
- }
-}
-
-impl<T> DerefMut for ForkCopied<T> {
- fn deref_mut(&mut self) -> &mut T {
- &mut self.0
- }
-}
-
-macro_rules! fork_copied_atomic {
- ($($atomic:ty),+) => {
- $(
- impl Clone for ForkCopied<$atomic> {
- fn clone(&self) -> Self {
- Self(<$atomic>::new(self.0.load(std::sync::atomic::Ordering::Relaxed)))
- }
- }
- )+
- };
-}
-
-fork_copied_atomic!(
- std::sync::atomic::AtomicBool,
- std::sync::atomic::AtomicU8,
- std::sync::atomic::AtomicU32,
- std::sync::atomic::AtomicU64
-);
-
-/// A mutex that a fork copies with what it holds.
-#[derive(Default, Debug)]
-pub(crate) struct ForkLocked<T>(std::sync::Mutex<T>);
+/// The mark of the render state the host writes, which a fork of it, starting the mark anew as
+/// [`ForkReset`], does not carry: `ForkReset<IsOriginal>` tells the state from its forks.
+#[derive(Default, Clone, Copy, PartialEq, Eq, Debug)]
+pub(crate) struct IsOriginal(bool);
-impl<T> ForkLocked<T> {
- pub(crate) const fn new(value: T) -> Self {
- Self(std::sync::Mutex::new(value))
- }
+impl IsOriginal {
+ pub(crate) const ORIGINAL: Self = Self(true);
}
-impl<T: Clone> Clone for ForkLocked<T> {
- fn clone(&self) -> Self {
- Self(std::sync::Mutex::new(
- self.0
- .lock()
- .expect("a forked lock is never held across a panic")
- .clone(),
- ))
+impl ForkReset<IsOriginal> {
+ /// The mark of the render state the host writes.
+ pub(crate) fn original() -> Self {
+ Self(IsOriginal::ORIGINAL)
}
-}
-
-impl<T> Deref for ForkLocked<T> {
- type Target = std::sync::Mutex<T>;
- fn deref(&self) -> &std::sync::Mutex<T> {
- &self.0
- }
-}
-
-impl<T> DerefMut for ForkLocked<T> {
- fn deref_mut(&mut self) -> &mut std::sync::Mutex<T> {
- &mut self.0
+ /// Whether this is the render state the host writes, and not a fork of it.
+ pub(crate) fn is_original(&self) -> bool {
+ self.0 == IsOriginal::ORIGINAL
}
}
@@ -129,6 +66,23 @@ impl<T: Clone> ForkShared<T> {
pub(crate) fn new(value: T) -> Self {
Self(std::sync::Arc::new(value))
}
+
+ /// Replaces the part, in place where no fork shares it.
+ pub(crate) fn assign(&mut self, value: T) {
+ match std::sync::Arc::get_mut(&mut self.0) {
+ Some(part) => *part = value,
+ None => self.0 = std::sync::Arc::new(value),
+ }
+ }
+
+ /// Takes the part, leaving its default: the part moves out as it is where no fork shares it, and is copied where
+ /// one does.
+ pub(crate) fn take(&mut self) -> T
+ where
+ T: Default,
+ {
+ std::sync::Arc::unwrap_or_clone(std::mem::take(&mut self.0))
+ }
}
impl<T: Clone> Clone for ForkShared<T> {
diff --git a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
index fd4aa94f7d1..dff3b5e1289 100644
--- a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
+++ b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
@@ -8,6 +8,7 @@ use super::*;
use crate::css::style::layout_style::LayoutStyle;
use crate::css::style::position_try::PositionOptionStyle;
use crate::css::style::tree::StyleNodeID;
+use crate::css::style_value::{AnchorPayload, AnchorSizePayload};
use crate::painting::paint_read::{GeometryRead, PaintRead};
pub(super) fn axis_modes(style: StyleValues) -> (abspos_inputs::AbsposAxisMode, abspos_inputs::AbsposAxisMode) {
@@ -498,8 +499,9 @@ impl AbsposEngine<'_> {
let arena = self.callbacks.arena();
let mut candidate = Some(element);
while let Some(current) = candidate {
- if let Some(payloads) = arena.style_node_style_payloads(current) {
- let anchor = ComputedValuesView::new(&payloads.groups).anchor();
+ if let Some(style) = arena.style_node_style(current) {
+ // SAFETY: The record the element published is retained for the pass.
+ let anchor = unsafe { style.view() }.anchor();
// The <anchor-name> represents a strictly matched tree-scoped name, i.e. it can only match against
// anchor names in the same shadow tree.
if (anchor.anchor_scope_all || anchor.anchor_scope_names.raws().contains(&anchor_name))
@@ -1559,21 +1561,12 @@ unsafe extern "C" fn resolve_anchor_non_math_function(context: *mut c_void, shel
let engine = unsafe { &*context.engine };
// SAFETY: `shell` is the live Rust style-value data retained by the CSS
// calc core's non-math-function node for this synchronous resolution.
- let (has_anchor_name, explicit_anchor_name, fallback_value) = match unsafe { &*shell.cast::<StyleValueData>() } {
- StyleValueData::Anchor {
- has_anchor_name,
- anchor_name,
- fallback_value,
- ..
- }
- | StyleValueData::AnchorSize {
- has_anchor_name,
- anchor_name,
- fallback_value,
- ..
- } => (*has_anchor_name, anchor_name, fallback_value),
- _ => return std::ptr::null(),
+ let Some((has_anchor_name, explicit_anchor_name, fallback_value)) =
+ unsafe { &*shell.cast::<StyleValueData>() }.anchor_name_and_fallback()
+ else {
+ return std::ptr::null();
};
+
let style = engine.style(context.positioned_box);
let bound_anchor_name = has_anchor_name.then(|| explicit_anchor_name.to_fly_string());
let anchor_name = if let Some(name) = &bound_anchor_name {
@@ -1594,37 +1587,43 @@ unsafe extern "C" fn resolve_anchor_non_math_function(context: *mut c_void, shel
);
// SAFETY: As above.
let resolved = match unsafe { &*shell.cast::<StyleValueData>() } {
- StyleValueData::Anchor { anchor_side, .. } => engine
- .anchor_side(
- anchor_side_from_style_value(anchor_side.data()),
+ StyleValueData::Anchor(anchor_payload) => {
+ let AnchorPayload { anchor_side, .. } = &**anchor_payload;
+ engine
+ .anchor_side(
+ anchor_side_from_style_value(anchor_side.data()),
+ rect,
+ context.positioned_box,
+ context.containing_block,
+ context.is_from_end,
+ context.is_horizontal_axis,
+ )
+ .map(|side| {
+ // SAFETY: The state pointer is live and uniquely used by this
+ // synchronous resolver.
+ let resolution_state = unsafe { &mut *context.resolution_state };
+ engine.note_resolved_anchor_function(anchor_box, context.is_horizontal_axis, resolution_state);
+ if context.is_from_end {
+ context.containing_block_extent - side
+ } else {
+ side
+ }
+ })
+ }
+ StyleValueData::AnchorSize(anchor_size_payload) => {
+ let AnchorSizePayload {
+ has_anchor_size,
+ anchor_size,
+ ..
+ } = &**anchor_size_payload;
+ Some(engine.anchor_size(
+ has_anchor_size.then_some(*anchor_size),
rect,
context.positioned_box,
context.containing_block,
- context.is_from_end,
context.is_horizontal_axis,
- )
- .map(|side| {
- // SAFETY: The state pointer is live and uniquely used by this
- // synchronous resolver.
- let resolution_state = unsafe { &mut *context.resolution_state };
- engine.note_resolved_anchor_function(anchor_box, context.is_horizontal_axis, resolution_state);
- if context.is_from_end {
- context.containing_block_extent - side
- } else {
- side
- }
- }),
- StyleValueData::AnchorSize {
- has_anchor_size,
- anchor_size,
- ..
- } => Some(engine.anchor_size(
- has_anchor_size.then_some(*anchor_size),
- rect,
- context.positioned_box,
- context.containing_block,
- context.is_horizontal_axis,
- )),
+ ))
+ }
_ => unreachable!("the shell was matched as an anchor function above"),
};
if let Some(resolved) = resolved {
@@ -3475,12 +3474,12 @@ impl<'pass> AbsposEngine<'pass> {
// OPTIMIZATION: The styles of an option are made the first time it is tried, so that a box that fits with
// its current styles makes no other.
- let made_styles: std::cell::RefCell<Vec<(u32, Option<Option<node_data::StylePayloadsRef>>)>> =
+ let made_styles: std::cell::RefCell<Vec<(u32, Option<Option<node_data::LayoutStyleRef>>)>> =
std::cell::RefCell::new(Vec::new());
let option_styles = std::cell::RefCell::new(Vec::new());
// The styles the option applies: none where the entry makes no option, and no styles of its own for the base
// styles or an option that changes none of them.
- let option_style = |option: u32| -> Option<Option<node_data::StylePayloadsRef>> {
+ let option_style = |option: u32| -> Option<Option<node_data::LayoutStyleRef>> {
let Some((index, _)) = entry_of(option) else {
return Some(None);
};
@@ -3556,7 +3555,11 @@ impl<'pass> AbsposEngine<'pass> {
.last_successful_position_option(node)
.filter(|choice| {
choice.base_style_record == base_style_record
- && entry_of(choice.option).map_or(0, |(_, rule)| rule) == choice.rule
+ && entry_of(choice.option)
+ .map_or(crate::css::style::position_try::PositionTryRuleID::NONE, |(_, rule)| {
+ rule
+ })
+ == choice.rule
})
.map_or(0, |choice| choice.option);
let current = options
@@ -3567,7 +3570,9 @@ impl<'pass> AbsposEngine<'pass> {
let choice_of = |option: u32| abspos_inputs::PositionOptionChoice {
option,
base_style_record,
- rule: entry_of(option).map_or(0, |(_, rule)| rule),
+ rule: entry_of(option).map_or(crate::css::style::position_try::PositionTryRuleID::NONE, |(_, rule)| {
+ rule
+ }),
};
let fits = |index: usize| {
let option = options[index];
@@ -3608,7 +3613,7 @@ impl<'pass> AbsposEngine<'pass> {
fn with_position_option_style<T>(
&self,
node: Node,
- style: Option<node_data::StylePayloadsRef>,
+ style: Option<node_data::LayoutStyleRef>,
callback: impl for<'option> FnOnce(&AbsposEngine<'option>) -> T,
) -> T {
let Some(style) = style else {
@@ -4062,7 +4067,7 @@ pub(crate) fn compute_inset_native(
/// options, which the style reads of the box address while this lives.
struct PositionOptionStyles {
choice: Option<abspos_inputs::PositionOptionChoice>,
- style: Option<node_data::StylePayloadsRef>,
+ style: Option<node_data::LayoutStyleRef>,
/// Boxed so that the payloads the style reads address stay in place as the list grows.
#[expect(clippy::vec_box)]
option_styles: Vec<Box<LayoutStyle>>,
diff --git a/Libraries/LibWeb/Rust/src/layout/abspos_inputs.rs b/Libraries/LibWeb/Rust/src/layout/abspos_inputs.rs
index 1b68f8e81a5..db4a86713a2 100644
--- a/Libraries/LibWeb/Rust/src/layout/abspos_inputs.rs
+++ b/Libraries/LibWeb/Rust/src/layout/abspos_inputs.rs
@@ -173,9 +173,9 @@ pub(crate) struct PositionOptionChoice {
/// 0 for the base styles, or one more than the index of the position-try-fallbacks entry that made the option.
pub(crate) option: u32,
pub(crate) base_style_record: u64,
- /// The identity of the @position-try rule the entry names, or 0 where it names none.
+ /// The @position-try rule the entry names.
/// NB: A choice whose rule was replaced since is no longer the box's last successful position option.
- pub(crate) rule: usize,
+ pub(crate) rule: crate::css::style::position_try::PositionTryRuleID,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
diff --git a/Libraries/LibWeb/Rust/src/layout/box_removal.rs b/Libraries/LibWeb/Rust/src/layout/box_removal.rs
index fd86f5984e5..6c52c6b7496 100644
--- a/Libraries/LibWeb/Rust/src/layout/box_removal.rs
+++ b/Libraries/LibWeb/Rust/src/layout/box_removal.rs
@@ -146,7 +146,7 @@ impl LayoutNodeArena {
node_kind_is_node_with_style(self.data(row).kind.get())
&& self
.node_style_if_live(row)
- .is_some_and(|style| style.box_values().position == positioning::ABSOLUTE)
+ .is_some_and(|style| style.position() == positioning::ABSOLUTE)
}
/// Whether the box `child` of the node `child_node` can leave the box `parent` of its DOM parent `parent_node`
@@ -285,8 +285,8 @@ impl LayoutNodeArena {
};
FfiDetachedBoxFacts {
parent_is_body: engine.element_adjustment_facts(parent) & IS_HTML_BODY_ELEMENT != 0,
- previous_sibling: sibling(engine.tree().previous_sibling_in_dom_order(node)),
- next_sibling: sibling(engine.tree().next_sibling_in_dom_order(node)),
+ previous_sibling: sibling(engine.previous_sibling_in_dom_order(node)),
+ next_sibling: sibling(engine.next_sibling_in_dom_order(node)),
level: match box_is_block_level {
true => FfiDetachedBoxLevel::Block,
false => FfiDetachedBoxLevel::AtomicInline,
diff --git a/Libraries/LibWeb/Rust/src/layout/commit.rs b/Libraries/LibWeb/Rust/src/layout/commit.rs
index f5b370fe68f..6790ad33a2c 100644
--- a/Libraries/LibWeb/Rust/src/layout/commit.rs
+++ b/Libraries/LibWeb/Rust/src/layout/commit.rs
@@ -701,7 +701,7 @@ impl<'tree> Commit<'_, 'tree> {
}
}
-fn content_size_change_affects_container_queries(
+pub(crate) fn content_size_change_affects_container_queries(
style: crate::css::computed_value_views::ComputedValuesView<'_>,
old_size: FfiCssPixelSize,
new_size: FfiCssPixelSize,
diff --git a/Libraries/LibWeb/Rust/src/layout/counters.rs b/Libraries/LibWeb/Rust/src/layout/counters.rs
index 6964cf669a7..e51d6ac56eb 100644
--- a/Libraries/LibWeb/Rust/src/layout/counters.rs
+++ b/Libraries/LibWeb/Rust/src/layout/counters.rs
@@ -200,9 +200,7 @@ pub(crate) fn style_of<'a>(
if row.is_invalid() {
return None;
}
- arena
- .style_payloads(row)
- .map(|payloads| ComputedValuesView::new(&payloads.groups))
+ arena.style_view(row)
}
generated_for => engine.published_style_view(owner.element, Some(pseudo_kind_of(generated_for))),
}
@@ -213,10 +211,9 @@ fn parent_element(engine: &RetainedState, owner: CounterOwner) -> Option<StyleNo
if owner.generated_for != 0 {
return Some(owner.element);
}
- let tree = engine.tree();
- let parent = tree.parent(owner.element)?;
+ let parent = engine.dom_parent(owner.element)?;
// A shadow root and the document stand in the style tree, but neither is an element.
- if tree.host_of(parent).is_some() || tree.is_relation_only(parent) {
+ if engine.host_of(parent).is_some() || engine.is_relation_only(parent) {
return None;
}
Some(parent)
@@ -454,10 +451,9 @@ fn walk_reversed_counter_sibling_run(
state: &mut ReversedScopeWalkState<'_>,
first: Option<StyleNodeID>,
) -> ReversedScopeWalkDecision {
- let tree = engine.tree();
let mut element = first;
while let Some(current) = element {
- element = tree.next_element_sibling(current);
+ element = engine.next_element_sibling(current);
let Some(style) = engine.published_style_view(current, None) else {
continue;
};
@@ -470,7 +466,7 @@ fn walk_reversed_counter_sibling_run(
if apply_reversed_counter_contribution(state, style) == ReversedScopeWalkDecision::Stop {
return ReversedScopeWalkDecision::Stop;
}
- if walk_reversed_counter_sibling_run(engine, state, tree.first_element_child(current))
+ if walk_reversed_counter_sibling_run(engine, state, engine.first_element_child(current))
== ReversedScopeWalkDecision::Stop
{
return ReversedScopeWalkDecision::Stop;
@@ -507,11 +503,10 @@ fn reversed_counter_start_value(
// FIXME: Counters reset on pseudo-elements don't walk a scope yet; only the pseudo-element's own
// contribution is taken into account.
if decision == ReversedScopeWalkDecision::Continue && originating_element.generated_for == 0 {
- let tree = engine.tree();
let element = originating_element.element;
- decision = walk_reversed_counter_sibling_run(engine, &mut state, tree.first_element_child(element));
+ decision = walk_reversed_counter_sibling_run(engine, &mut state, engine.first_element_child(element));
if decision == ReversedScopeWalkDecision::Continue {
- walk_reversed_counter_sibling_run(engine, &mut state, tree.next_element_sibling(element));
+ walk_reversed_counter_sibling_run(engine, &mut state, engine.next_element_sibling(element));
}
}
(state.num + state.last_nonzero_increment_negated).clamp(i64::from(CounterValue::MIN), i64::from(CounterValue::MAX))
diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
index a3692f2e117..fd4132c85ae 100644
--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
@@ -406,6 +406,9 @@ const EARLIER_ENTRIES_PER_BOX: usize = 3;
const LAYOUT_COMMITS_AN_UNCOMMITTED_ENTRY_SURVIVES_UNUSED: u64 = 2;
+/// How many boxes' entries a chunk of [`FcRunCacheStore::slots`] holds: a write after a fork copies this many.
+const FC_RUN_CACHE_SLOTS_PER_CHUNK: usize = 128;
+
#[derive(Clone, Copy, Default)]
struct StoredEntrySummary {
fragment_cache_epoch: u32,
@@ -456,7 +459,8 @@ type EarlierEntriesOfBox = smallvec::SmallVec<[std::sync::Arc<FcRunCacheEntry>;
/// ones.
#[derive(Clone, Default)]
pub(crate) struct FcRunCacheStore {
- slots: RefCell<Vec<FcRunCacheSlot>>,
+ /// In chunks a fork of the arena shares until either side writes one, so forking does not copy every box's entries.
+ slots: RefCell<crate::cow_column::CowVec<FcRunCacheSlot, FC_RUN_CACHE_SLOTS_PER_CHUNK>>,
earlier_entries: RefCell<HashMap<u32, EarlierEntriesOfBox>>,
inline_layout_damage: RefCell<Vec<InlineLayoutDamage>>,
pending_sweep_slots: RefCell<Vec<u32>>,
@@ -532,8 +536,8 @@ impl FcRunCacheStore {
}
pub(crate) fn remove_entry(&self, slot: u32) {
- if let Some(entries) = self.slots.borrow_mut().get_mut(slot as usize) {
- *entries = FcRunCacheSlot::default();
+ if self.slot_holds_entries(slot) {
+ self.slots.borrow_mut()[slot as usize] = FcRunCacheSlot::default();
}
self.earlier_entries.borrow_mut().remove(&slot);
self.forget_inline_layout_damage(slot);
@@ -631,7 +635,7 @@ impl FcRunCacheStore {
entry.structural_epoch_bumps_when_stored = self.structural_epoch_bumps_of(box_);
let mut slots = self.slots.borrow_mut();
if slots.len() <= slot as usize {
- slots.resize_with(slot as usize + 1, FcRunCacheSlot::default);
+ slots.resize_with_default(slot as usize + 1);
}
let entries = &mut slots[slot as usize];
let mut earlier_entries = self.earlier_entries.borrow_mut();
diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
index 4ee6af4edc4..0349256e068 100644
--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
@@ -4540,10 +4540,9 @@ fn abs(value: CssPixels) -> CssPixels {
#[cfg(test)]
mod stretch_cross_limit_tests {
use super::*;
- use crate::css::computed_values::{GroupPayloadRef, clone_group_payload, release_group_payload};
+ use crate::css::style::layout_style::LayoutScratchStyle;
use crate::css::style_value::{RetainedStyleValueData, StyleValueData};
- use crate::css::table_group_builder::group_index;
- use crate::layout::node_data::{NodeConstructionFacts, StylePayloadsRef};
+ use crate::layout::node_data::NodeConstructionFacts;
use crate::layout::run_state::LayoutScratch;
fn length(value: i32) -> ComputedSize {
@@ -4627,38 +4626,15 @@ mod stretch_cross_limit_tests {
let max_constrained = cross_space == CrossSpace::MaxConstrained;
let mut arena = LayoutNodeArena::new();
let scratch = LayoutScratch::default();
- let defaults = FfiStylePayloads {
- groups: std::array::from_fn(|index| GroupPayloadRef::default_payload(index).as_ptr()),
- };
- let mut styles = [defaults; 3];
- let mut clones = Vec::new();
- for style in &mut styles {
- for group in [
- group_index::BOX,
- group_index::SIZING,
- group_index::ALIGNMENT,
- group_index::SURROUND,
- group_index::BORDER,
- ] {
- // SAFETY: The source is the immortal default payload for this group.
- let payload = unsafe { clone_group_payload(group, style.groups[group]) };
- style.groups[group] = payload;
- clones.push((group, payload));
- }
- }
- for (index, style) in styles.iter().enumerate() {
- // SAFETY: These private clones have the selected group's layout and no readers yet.
- unsafe {
- let box_values = &mut *style.groups[group_index::BOX].cast_mut().cast::<BoxValues>();
- box_values.display = if index == 0 {
+ let styles: [LayoutScratchStyle; 3] = std::array::from_fn(|index| {
+ LayoutScratchStyle::over_defaults(|style| {
+ style.box_mut().display = if index == 0 {
FfiDisplay::from_single_keyword(keyword::FLEX).unwrap()
} else {
FfiDisplay::block()
};
- let alignment = &mut *style.groups[group_index::ALIGNMENT]
- .cast_mut()
- .cast::<AlignmentValues>();
if index == 0 {
+ let alignment = style.alignment_mut();
alignment.flex_direction = if column {
flex_direction::COLUMN
} else {
@@ -4677,27 +4653,8 @@ mod stretch_cross_limit_tests {
align_items::FLEX_START
};
}
- let sizing = &mut *style.groups[group_index::SIZING].cast_mut().cast::<SizingValues>();
- let cross = if index == 0 {
- 100
- } else if index == 1 {
- preferred
- } else {
- 200
- };
- let main = if index == 0 { 100 } else { 50 };
- sizing.width = length(if column { cross } else { main });
- sizing.height = length(if column { main } else { cross });
- if index == 0 && !definite_cross_basis {
- let cross_size = if column { &mut sizing.width } else { &mut sizing.height };
- *cross_size = ComputedSize::keyword(ComputedSizeKind::Auto);
- if max_constrained {
- assert!(!column);
- sizing.max_height = length(100);
- }
- }
if index == 1 && max_constrained {
- let surround = &mut *style.groups[group_index::SURROUND].cast_mut().cast::<SurroundValues>();
+ let surround = style.surround_mut();
for side in [&mut surround.margin.top, &mut surround.margin.bottom] {
*side = ComputedLengthPercentageOrAuto {
is_auto: false,
@@ -4710,7 +4667,7 @@ mod stretch_cross_limit_tests {
value: crate::css::computed_values::ComputedStyleValueHandle::length(2.0),
};
}
- let border = &mut *style.groups[group_index::BORDER].cast_mut().cast::<BorderValues>();
+ let border = style.border_mut();
for side in [&mut border.border_top, &mut border.border_bottom] {
side.line_style = line_style::SOLID;
side.width = CssPixels::from_integer(3);
@@ -4718,6 +4675,25 @@ mod stretch_cross_limit_tests {
border.border_top_computed_width = CssPixels::from_integer(3);
border.border_bottom_computed_width = CssPixels::from_integer(3);
}
+ let sizing = style.sizing_mut();
+ let cross = if index == 0 {
+ 100
+ } else if index == 1 {
+ preferred
+ } else {
+ 200
+ };
+ let main = if index == 0 { 100 } else { 50 };
+ sizing.width = length(if column { cross } else { main });
+ sizing.height = length(if column { main } else { cross });
+ if index == 0 && !definite_cross_basis {
+ let cross_size = if column { &mut sizing.width } else { &mut sizing.height };
+ *cross_size = ComputedSize::keyword(ComputedSizeKind::Auto);
+ if max_constrained {
+ assert!(!column);
+ sizing.max_height = length(100);
+ }
+ }
if index == 1 {
if auto {
let preferred_size = if column { &mut sizing.width } else { &mut sizing.height };
@@ -4736,8 +4712,8 @@ mod stretch_cross_limit_tests {
};
*limit = ComputedSize::keyword(ComputedSizeKind::Stretch);
}
- }
- }
+ })
+ });
let facts = NodeConstructionFacts {
kind: NodeKind::BlockContainer,
is_anonymous: false,
@@ -4755,7 +4731,7 @@ mod stretch_cross_limit_tests {
let target = arena.allocate(facts);
let peer = arena.allocate(facts);
for (node, style) in [container, target, peer].into_iter().zip(&styles) {
- arena.set_node_style(node, 0, StylePayloadsRef::new(style));
+ arena.set_node_style(node, 0, Some(style.style()));
}
for child in [target, peer] {
arena.set_node_flag(child, NodeFlag::IsFlexItem, true);
@@ -4850,8 +4826,5 @@ mod stretch_cross_limit_tests {
arena
.free_subtree(container)
.destroy_shells_and_invoke_callbacks(&crate::stage::MainThread::for_test());
- for (group, payload) in clones {
- release_group_payload(group, payload);
- }
}
}
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index ef2bb2a18a7..9a0f51d32a5 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -3824,12 +3824,11 @@ fn layout_subtree_with_frozen_root_geometry(run: &FormattingContextRun<'_>) {
#[cfg(test)]
mod baseline_tests {
use super::*;
- use crate::css::computed_values::{BoxValues, GroupPayloadRef, clone_group_payload, release_group_payload};
use crate::css::css_enums::keyword;
use crate::css::display::FfiDisplay;
- use crate::css::table_group_builder::group_index;
+ use crate::css::style::layout_style::LayoutScratchStyle;
use crate::layout::layout_node_arena::LayoutNodeArena;
- use crate::layout::node_data::{NodeConstructionFacts, NodeKind, StylePayloadsRef};
+ use crate::layout::node_data::{NodeConstructionFacts, NodeKind};
use crate::layout::run_state::LayoutScratch;
#[test]
@@ -3845,20 +3844,10 @@ mod baseline_tests {
fn check_block_derivation(display: u16) {
let mut arena = LayoutNodeArena::new();
let scratch = LayoutScratch::default();
- let mut child_style = FfiStylePayloads {
- groups: std::array::from_fn(|index| GroupPayloadRef::default_payload(index).as_ptr()),
- };
- let mut parent_style = child_style;
- // SAFETY: The source is the immortal default box payload. The clone is private until installed below.
- let parent_box = unsafe { clone_group_payload(group_index::BOX, parent_style.groups[group_index::BOX]) };
- // SAFETY: The clone has the BoxValues layout and no readers yet.
- unsafe { (*parent_box.cast::<BoxValues>()).display = FfiDisplay::block() };
- parent_style.groups[group_index::BOX] = parent_box;
- // SAFETY: The source is the immortal default box payload. The clone is private until installed below.
- let child_box = unsafe { clone_group_payload(group_index::BOX, child_style.groups[group_index::BOX]) };
- // SAFETY: The clone has the BoxValues layout and no readers yet.
- unsafe { (*child_box.cast::<BoxValues>()).display = FfiDisplay::from_single_keyword(display).unwrap() };
- child_style.groups[group_index::BOX] = child_box;
+ let parent_style = LayoutScratchStyle::over_defaults(|style| style.box_mut().display = FfiDisplay::block());
+ let child_style = LayoutScratchStyle::over_defaults(|style| {
+ style.box_mut().display = FfiDisplay::from_single_keyword(display).unwrap();
+ });
let facts = NodeConstructionFacts {
kind: NodeKind::BlockContainer,
is_anonymous: false,
@@ -3874,8 +3863,8 @@ mod baseline_tests {
};
let parent = arena.allocate(facts);
let child = arena.allocate(facts);
- arena.set_node_style(parent, 0, StylePayloadsRef::new(&parent_style));
- arena.set_node_style(child, 0, StylePayloadsRef::new(&child_style));
+ arena.set_node_style(parent, 0, Some(parent_style.style()));
+ arena.set_node_style(child, 0, Some(child_style.style()));
arena.insert_child(parent, child, Node::INVALID);
let callbacks = LayoutPass::new(
&arena,
@@ -3910,7 +3899,5 @@ mod baseline_tests {
arena
.free_subtree(parent)
.destroy_shells_and_invoke_callbacks(&crate::stage::MainThread::for_test());
- release_group_payload(group_index::BOX, child_box);
- release_group_payload(group_index::BOX, parent_box);
}
}
diff --git a/Libraries/LibWeb/Rust/src/layout/fragment_overflow.rs b/Libraries/LibWeb/Rust/src/layout/fragment_overflow.rs
index 20c7be65585..5abe92dbf13 100644
--- a/Libraries/LibWeb/Rust/src/layout/fragment_overflow.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fragment_overflow.rs
@@ -857,13 +857,9 @@ impl LayoutNodeArena {
#[cfg(test)]
mod tests {
use super::*;
- use crate::css::computed_values::{
- BoxValues, ComputedLengthPercentageOrAuto, ComputedStyleValueHandle, GroupPayloadRef, InheritedBoxValues,
- SurroundValues, clone_group_payload, release_group_payload,
- };
+ use crate::css::computed_values::{ComputedLengthPercentageOrAuto, ComputedStyleValueHandle};
use crate::css::css_enums::overflow;
- use crate::css::table_group_builder::group_index;
- use crate::layout::node_data::{FfiStylePayloads, StylePayloadsRef};
+ use crate::css::style::layout_style::LayoutScratchStyle;
#[test]
fn overflow_percentage_margins_use_the_containing_blocks_inline_size() {
@@ -873,42 +869,24 @@ mod tests {
(writing_mode::VERTICAL_RL, 310),
] {
let mut arena = LayoutNodeArena::new();
- let mut container_style = FfiStylePayloads {
- groups: std::array::from_fn(|index| GroupPayloadRef::default_payload(index).as_ptr()),
- };
- let mut child_style = container_style;
- // SAFETY: These are private clones of the corresponding default payloads.
- let (box_payload, inherited, surround) = unsafe {
- (
- clone_group_payload(group_index::BOX, container_style.groups[group_index::BOX]),
- clone_group_payload(
- group_index::INHERITED_BOX,
- container_style.groups[group_index::INHERITED_BOX],
- ),
- clone_group_payload(group_index::SURROUND, child_style.groups[group_index::SURROUND]),
- )
- };
- // SAFETY: Each private clone has its group's payload layout and no readers yet.
- unsafe {
- (*box_payload.cast::<BoxValues>()).display = FfiDisplay::block();
- (*box_payload.cast::<BoxValues>()).overflow_x = overflow::AUTO;
- (*box_payload.cast::<BoxValues>()).overflow_y = overflow::AUTO;
- (*inherited.cast::<InheritedBoxValues>()).writing_mode = mode;
- (*surround.cast::<SurroundValues>()).margin.bottom = ComputedLengthPercentageOrAuto {
+ let container_style = LayoutScratchStyle::over_defaults(|style| {
+ let box_values = style.box_mut();
+ box_values.display = FfiDisplay::block();
+ style.set_writing_mode(mode);
+ style.set_overflow(overflow::AUTO, overflow::AUTO);
+ });
+ // SAFETY: The container's style outlives the child's.
+ let child_style = LayoutScratchStyle::over(unsafe { container_style.style().view() }, |style| {
+ style.surround_mut().margin.bottom = ComputedLengthPercentageOrAuto {
is_auto: false,
value: ComputedStyleValueHandle::percentage(50.0),
};
- }
- container_style.groups[group_index::BOX] = box_payload;
- container_style.groups[group_index::INHERITED_BOX] = inherited;
- child_style.groups[group_index::BOX] = box_payload;
- child_style.groups[group_index::INHERITED_BOX] = inherited;
- child_style.groups[group_index::SURROUND] = surround;
+ });
let container = arena.allocate_for_test().slot;
let child = arena.allocate_for_test().slot;
for (node, style) in [(container, &container_style), (child, &child_style)] {
arena.write_shape(node).set_kind(NodeKind::BlockContainer);
- arena.set_node_style(node, 0, StylePayloadsRef::new(style));
+ arena.set_node_style(node, 0, Some(style.style()));
}
arena.insert_child(container, child, NodeSlotId::INVALID);
let mut container_link = FragmentLink::for_test(container);
@@ -936,9 +914,6 @@ mod tests {
arena
.free_subtree(container)
.destroy_shells_and_invoke_callbacks(&crate::stage::MainThread::for_test());
- release_group_payload(group_index::BOX, box_payload);
- release_group_payload(group_index::INHERITED_BOX, inherited);
- release_group_payload(group_index::SURROUND, surround);
}
}
}
diff --git a/Libraries/LibWeb/Rust/src/layout/generated_content.rs b/Libraries/LibWeb/Rust/src/layout/generated_content.rs
index 078bd814f68..dc4d5a54f9e 100644
--- a/Libraries/LibWeb/Rust/src/layout/generated_content.rs
+++ b/Libraries/LibWeb/Rust/src/layout/generated_content.rs
@@ -10,7 +10,7 @@
use super::counters::{CounterName, CounterOwner, CountersSets, LIST_ITEM_COUNTER_NAME, style_of};
use super::layout_node_arena::{CounterTables, LayoutNodeArena};
-use super::node_data::{GENERATED_FOR_MARKER, NodeSlotId};
+use super::node_data::NodeSlotId;
use crate::css::computed_value_views::ComputedValuesView;
use crate::css::counter_representation::{
CounterStyle, decimal, generate_a_counter_representation, resolve_counter_style_value,
@@ -20,6 +20,7 @@ use crate::css::css_string::CssString;
use crate::css::style::fast_hash::FastMap as HashMap;
use crate::css::style::tree::StyleNodeID;
use crate::css::style_value::{COUNTER_FUNCTION_COUNTER, StyleValueData};
+use crate::css::style_value::{ContentPayload, CounterPayload};
use std::sync::Arc;
/// What a list marker whose `content` is `normal` shows, resolved from the published records of the
@@ -124,8 +125,7 @@ fn resolve_marker_content(
) -> MarkerContent<'_> {
let style_of_row = |row: NodeSlotId| {
arena
- .style_payloads(row)
- .map(|payloads| ComputedValuesView::new(&payloads.groups))
+ .style_view(row)
.expect("a list marker and its list item box both carry a style")
};
let list_item_style = style_of_row(list_box);
@@ -309,18 +309,19 @@ fn content_counter_styles(
content: Option<&StyleValueData>,
tree_scope: u32,
) -> Vec<Option<Arc<CounterStyle>>> {
- let Some(StyleValueData::Content {
- content: content_list,
- alt_text,
- }) = content
- else {
+ let Some(StyleValueData::Content(content_payload)) = content else {
return Vec::new();
};
+ let ContentPayload {
+ content: content_list,
+ alt_text,
+ } = &**content_payload;
let mut styles = Vec::new();
arena.with_counter_style_registry(|registry| {
for list in [content_list.optional_data(), alt_text.optional_data()] {
for item in value_list(list) {
- if let Some(StyleValueData::Counter { counter_style, .. }) = item.optional_data() {
+ if let Some(StyleValueData::Counter(counter_payload)) = item.optional_data() {
+ let CounterPayload { counter_style, .. } = &**counter_payload;
styles.push(resolve_counter_style_value(
registry,
tree_scope,
@@ -353,36 +354,6 @@ fn note_content_counter_styles_in_use(
generated_content.content_counter_styles_in_use.insert(owner, styles);
}
-/// Whether the counter styles the pseudo-element's record names now differ from the ones its box
-/// was built with. False while no box of the pseudo-element has recorded any.
-pub(crate) fn content_counter_styles_changed(arena: &LayoutNodeArena, owner: CounterOwner) -> bool {
- let generated_content = arena.generated_content();
- let Some(in_use) = generated_content.content_counter_styles_in_use.get(&owner) else {
- return false;
- };
- let styles = arena.with_style_store(|engine| {
- let tree_scope = engine.counter_style_tree_scope(owner.element);
- let style = style_of(arena, engine, owner)?;
- let content = style.content_value();
- // A list marker whose `content` is `normal` shows its marker string, and the marker
- // string is what the build recorded for it. Re-deriving from `content` would answer
- // about a value that names no counter at all, so the two sets could never agree and
- // every recomputation of the marker's style would read as a counter-style change.
- // Answer the same question the build did instead.
- if owner.generated_for == GENERATED_FOR_MARKER && content_is_normal(content) {
- let list_item_style = style_of(arena, engine, CounterOwner::element(owner.element))?;
- return Some(marker_counter_styles_in_use(&marker_content(
- arena,
- tree_scope,
- style,
- list_item_style,
- )));
- }
- Some(content_counter_styles(arena, content, tree_scope))
- });
- styles.is_some_and(|styles| *in_use != styles)
-}
-
/// Resolves the content of the pseudo-element `element` names, whose box the host has just built. A
/// list marker box whose `content` is `normal` shows its marker string instead.
pub(crate) fn resolve_content(
@@ -427,11 +398,7 @@ fn resolve_content_with(
}
let styles = content_counter_styles(arena, content, tree_scope);
- let Some(StyleValueData::Content {
- content: content_list,
- alt_text,
- }) = content
- else {
+ let Some(StyleValueData::Content(content_payload)) = content else {
note_content_counter_styles_in_use(&mut tables.generated_content, element, styles);
tables.generated_content.accessible_texts.remove(&element);
return ResolvedContent {
@@ -441,6 +408,10 @@ fn resolve_content_with(
renders_list_item_counter_value: false,
};
};
+ let ContentPayload {
+ content: content_list,
+ alt_text,
+ } = &**content_payload;
let mut counters = CounterItemResolver {
arena,
@@ -492,12 +463,13 @@ fn resolve_content_with(
}
_ => {}
},
- Some(StyleValueData::Counter {
- function,
- counter_name,
- join_string,
- ..
- }) => {
+ Some(StyleValueData::Counter(counter_payload)) => {
+ let CounterPayload {
+ function,
+ counter_name,
+ join_string,
+ ..
+ } = &**counter_payload;
flush_pending_text(&mut items, &mut pending_text);
items.push(ContentItem::Text(counters.resolve(
*function,
@@ -523,12 +495,15 @@ fn resolve_content_with(
for item in value_list(Some(alt_text)) {
match item.optional_data() {
Some(StyleValueData::String { string, .. }) => accessible_text.extend_from_slice(string.units()),
- Some(StyleValueData::Counter {
- function,
- counter_name,
- join_string,
- ..
- }) => accessible_text.extend(counters.resolve(*function, counter_name, join_string)),
+ Some(StyleValueData::Counter(counter_payload)) => {
+ let CounterPayload {
+ function,
+ counter_name,
+ join_string,
+ ..
+ } = &**counter_payload;
+ accessible_text.extend(counters.resolve(*function, counter_name, join_string));
+ }
_ => {}
}
}
diff --git a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
index a1507b301cd..434b1d42839 100644
--- a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
@@ -5,6 +5,8 @@
*/
use super::*;
+use crate::css::style_value::GridTrackSizeListPayload;
+use crate::css::style_value::StyleValueBox;
use std::ops::Range;
mod grid_lanes;
@@ -382,11 +384,11 @@ impl OwnedUsedGridTrackList {
}));
}
}
- StyleValueData::GridTrackSizeList {
+ StyleValueData::GridTrackSizeList(StyleValueBox::new(GridTrackSizeListPayload {
is_subgrid: self.is_subgrid,
preserve_line_name_sets: self.is_subgrid,
entries: RetainedGridTrackEntryList::from_retained_entries(entries),
- }
+ }))
}
}
@@ -1433,7 +1435,7 @@ impl<'pass> ParentGridData<'pass> {
/// (the fc-run-cache probe): a declared subgrid axis counts regardless of the
/// parent-grid placement check only a run in progress can make.
pub(super) fn grid_template_declares_a_subgrid_axis(callbacks: &LayoutPass<'_>, box_: Node) -> bool {
- let grid_style = ComputedValuesView::new(&callbacks.style_payloads(box_).groups).grid_values();
+ let grid_style = callbacks.style_view(box_).grid_values();
grid_style.template_columns.is_subgrid || grid_style.template_rows.is_subgrid
}
@@ -1614,7 +1616,7 @@ impl<'pass> GridFormattingContext<'pass> {
/// outlives the pass because the node's ComputedValues keep it alive and
/// style containers are only replaced between passes.
fn grid_style(&self, node: Node) -> &'pass GridValues {
- ComputedValuesView::new(&self.run.callbacks.style_payloads(node).groups).grid_values()
+ self.run.callbacks.style_view(node).grid_values()
}
/// Picks whichever of the per-grid-axis values (as in grid-template-columns and grid-template-rows) belongs to the
diff --git a/Libraries/LibWeb/Rust/src/layout/host_tables.rs b/Libraries/LibWeb/Rust/src/layout/host_tables.rs
index 3ab7b61dbc7..5678a171c62 100644
--- a/Libraries/LibWeb/Rust/src/layout/host_tables.rs
+++ b/Libraries/LibWeb/Rust/src/layout/host_tables.rs
@@ -85,7 +85,7 @@ impl HostTables {
return std::ptr::null_mut();
};
assert!(
- !crate::stage_thread::style_layout_thread().is_current(),
+ !crate::stage_thread::render_thread().is_current(),
"a layout node is made on the main thread, whose heap it is allocated from"
);
// SAFETY: Registration and unregistration keep the factory context live. The factory's
diff --git a/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs b/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs
index 69b5dbf1b3c..6fbfd318bcb 100644
--- a/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs
+++ b/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs
@@ -88,9 +88,13 @@ struct InFlowBlockSlot {
/// Per-document store of in-flow block layouts, surviving across layout passes in the layout stage's scratch.
#[derive(Clone, Default)]
pub(crate) struct InFlowBlockCacheStore {
- entries: RefCell<Vec<InFlowBlockSlot>>,
+ /// In chunks a fork of the arena shares until either side writes one, so forking does not copy every box's entries.
+ entries: RefCell<crate::cow_column::CowVec<InFlowBlockSlot, IN_FLOW_BLOCK_SLOTS_PER_CHUNK>>,
}
+/// How many boxes' entries a chunk of [`InFlowBlockCacheStore::entries`] holds: a write after a fork copies this many.
+const IN_FLOW_BLOCK_SLOTS_PER_CHUNK: usize = 128;
+
impl InFlowBlockCacheStore {
/// The stored layout of the box in `slot` for `key` that placed the fragment the box committed, `committed_identity`.
pub(super) fn matching(
@@ -115,7 +119,7 @@ impl InFlowBlockCacheStore {
pub(super) fn store(&self, slot: u32, entry: InFlowBlockEntry, committed_identity: Option<u64>) {
let mut entries = self.entries.borrow_mut();
if entries.len() <= slot as usize {
- entries.resize_with(slot as usize + 1, InFlowBlockSlot::default);
+ entries.resize_with_default(slot as usize + 1);
}
let slot = &mut entries[slot as usize];
let places_committed_fragment = |entry: &Option<std::sync::Arc<InFlowBlockEntry>>| {
@@ -137,8 +141,12 @@ impl InFlowBlockCacheStore {
}
pub(crate) fn remove_entry(&self, slot: u32) {
- if let Some(slot) = self.entries.borrow_mut().get_mut(slot as usize) {
- *slot = InFlowBlockSlot::default();
+ let mut entries = self.entries.borrow_mut();
+ if entries
+ .get(slot as usize)
+ .is_some_and(|entries| entries.latest.is_some() || entries.committed.is_some())
+ {
+ entries[slot as usize] = InFlowBlockSlot::default();
}
}
}
diff --git a/Libraries/LibWeb/Rust/src/layout/layout_changes.rs b/Libraries/LibWeb/Rust/src/layout/layout_changes.rs
index 25b46d32e08..028ff5d63df 100644
--- a/Libraries/LibWeb/Rust/src/layout/layout_changes.rs
+++ b/Libraries/LibWeb/Rust/src/layout/layout_changes.rs
@@ -29,6 +29,11 @@ pub(crate) enum LayoutChange {
},
/// The whole layout tree is built again.
SetNeedsFullLayoutTreeUpdate,
+ /// Loads filled faces into the font cascades of these addresses in place, so the styles naming them stay as they
+ /// are: the boxes whose text renders in one of them lay out again.
+ RelayoutUsersOfFontLists {
+ font_lists: Box<[u64]>,
+ },
/// The box takes `marks`.
MarkBox {
target: super::tree_update_marks::MarkedBox,
@@ -127,7 +132,7 @@ pub(crate) enum LayoutChange {
SetNodeStyle {
node: NodeSlotId,
record: u64,
- payloads: super::node_data::StylePayloadsRef,
+ payloads: Option<super::node_data::LayoutStyleRef>,
},
/// The style record of the box the node `style_node` is bound to, or of the box of its pseudo-element
/// `generated_for`, stays readable once the node has left the document.
@@ -170,6 +175,7 @@ impl LayoutChange {
Self::SetNodeStyle { .. } => RowWrite::NamedStyles,
Self::SetNeedsLayoutUpdate { .. }
| Self::SetNeedsFullLayoutTreeUpdate
+ | Self::RelayoutUsersOfFontLists { .. }
| Self::MarkBox { .. }
| Self::ApplyLayoutTreeUpdateMark { .. }
| Self::RecordPartialRelayoutEscape
@@ -237,6 +243,7 @@ impl LayoutChange {
}
}
Self::SetNeedsFullLayoutTreeUpdate => arena.set_needs_full_layout_tree_update(true),
+ Self::RelayoutUsersOfFontLists { font_lists } => arena.relayout_users_of_font_lists(&font_lists),
Self::MarkBox { target, marks } => marks.apply(arena, target),
Self::ApplyLayoutTreeUpdateMark { node, mark } => arena.apply_layout_tree_update_mark(node, mark),
Self::RecordPartialRelayoutEscape => arena.record_partial_relayout_escape(),
@@ -482,6 +489,18 @@ pub extern "C" fn render_state_detach_remaining_rows_for_removal(host: &Document
host.queue_change(ArenaChange::DetachForRemoval(style_nodes.into()));
}
+/// Marks for layout every box whose text renders in one of the font cascades of `font_lists`, which loads filled faces
+/// into in place.
+#[unsafe(no_mangle)]
+pub extern "C" fn render_state_relayout_users_of_font_lists(host: &DocumentHost, font_lists: ak::Span<'_, u64>) {
+ queue(
+ host,
+ LayoutChange::RelayoutUsersOfFontLists {
+ font_lists: font_lists.as_slice().into(),
+ },
+ );
+}
+
#[unsafe(no_mangle)]
pub extern "C" fn render_state_set_needs_full_layout_tree_update(host: &DocumentHost) {
queue(host, LayoutChange::SetNeedsFullLayoutTreeUpdate);
diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
index 22531c024f2..95afb091c84 100644
--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
@@ -11,11 +11,11 @@ use super::shell_reads::read_arena;
use super::tree_builder::FfiLayoutTreeBuildOutcome;
use super::tree_shape::{Chunk, PUBLISHED_ROWS_PER_CHUNK, ShapeWriter, ShapeWrites, TreeShape};
use super::update_layout::FfiLayoutTreeBuildStats;
-use crate::cow_column::{ColumnSnapshot, CowColumn};
+use crate::cow_column::{ColumnSnapshot, CowColumn, CowVec};
use crate::css::css_pixels::{CssPixelPoint, FfiCssPixelPoint};
use crate::css::style::bridge::ElementBoxKind;
+use crate::css::style::bridge::{REBUILD_LEVEL, RELAYOUT_LEVEL};
use crate::css::style::fast_hash::{FastMap as HashMap, FastSet as HashSet};
-use crate::css::style::flight_style_rows::{Decline, FlightStyleRow, REBUILD_LEVEL, RELAYOUT_LEVEL};
use crate::css::style::tree::{StyleNodeID, TableSpans};
use crate::css::style::{
PublishedBoxFacts, PublishedTextSource, StyleEngine, TextStyleParentFacts,
@@ -25,9 +25,9 @@ use crate::css::style::{
use crate::layout::ComputedValuesView;
use crate::layout::CssPixels;
use crate::layout::node_data::{
- AncestorFact, DomPaintFact, FfiStylePayloads, GENERATED_FOR_AFTER, GENERATED_FOR_BEFORE,
- GENERATED_FOR_FIRST_LETTER, GENERATED_FOR_LAST_SYNTHETIC, GENERATED_FOR_MARKER, MAX_NODE_SLOT_COUNT, NodeData,
- NodeFlag, NodeKind, NodeSlotId, StylePayloadsRef, pseudo_kind_of,
+ AncestorFact, DomPaintFact, GENERATED_FOR_AFTER, GENERATED_FOR_BEFORE, GENERATED_FOR_FIRST_LETTER,
+ GENERATED_FOR_LAST_SYNTHETIC, GENERATED_FOR_MARKER, LayoutStyleRef, MAX_NODE_SLOT_COUNT, NodeData, NodeFlag,
+ NodeKind, NodeSlotId, pseudo_kind_of,
};
use crate::layout::node_facts::ReplacedContentFacts;
use crate::layout::tree_mutation::HostCalls;
@@ -42,8 +42,11 @@ use std::sync::Arc;
crate::render_state::held_node_entries!();
+mod installed_styles;
mod main_thread_entries;
+pub(crate) use installed_styles::{ElementInstall, StyledRows};
+
pub(crate) use main_thread_entries::MainThreadFfiEntry;
pub(crate) const SLOTS_PER_CHUNK: usize = 256;
@@ -337,11 +340,12 @@ impl Default for TextNodeSlot {
/// Each text row's state, and what it publishes for the paint side. A slot is written only through
/// a [`TextStateMut`], which republishes the slot when it drops, or by [`TextSlots::reset`], so
/// the published column cannot fall behind the slots. The states live side by side rather than
-/// each in an allocation of its own, which keeps a copy of the slots to one allocation.
+/// each in an allocation of its own, in chunks a fork of the arena shares until either side writes
+/// one, so forking the arena does not copy every text row's state.
#[derive(Clone, Default)]
struct TextSlots {
slots: Vec<TextNodeSlot>,
- states: Vec<TextNodeState>,
+ states: CowVec<TextNodeState, TEXT_STATES_PER_CHUNK>,
/// The places in `states` no slot uses.
vacant_states: Vec<u32>,
published: CowColumn<PublishedTextSlot, SLOTS_PER_CHUNK>,
@@ -450,6 +454,9 @@ impl Drop for TextStateMut<'_> {
}
}
+/// How many text states a chunk of [`TextSlots::states`] holds: a write after a fork copies this many.
+const TEXT_STATES_PER_CHUNK: usize = 64;
+
#[derive(Clone, Default)]
struct TextNodeState {
source_range: Option<FfiTextSourceRange>,
@@ -473,9 +480,11 @@ pub(crate) struct RowsVersion {
style: u64,
/// The part of `writes` that populated or reset a paintable row.
population: u64,
- /// Where the paint fact tables, the image maps and the visual context tree are, which moves
- /// when a write copies one a publication shares or replaces the tree.
- tables: [usize; 5],
+ /// The writes to the paint fact tables and the image maps.
+ table_writes: u64,
+ /// Which copy of the visual context tree the rows are at, which moves when a write copies one a
+ /// publication shares or replaces the tree.
+ visual_context_tree: u64,
}
impl RowsVersion {
@@ -502,6 +511,9 @@ impl RowsVersion {
}
}
+/// How many slots a chunk of [`LayoutNodeArena::replaced_content_facts`] holds: a write after a fork copies this many.
+const REPLACED_CONTENT_FACTS_PER_CHUNK: usize = 128;
+
#[derive(Clone, Default)]
struct ReplacedContentFactsSlot {
generation: u8,
@@ -599,31 +611,26 @@ pub struct FfiStyleRecordHostCallbacks {
}
/// Whether `a` and `b` hold equal payloads in the inherited groups, which are all an anonymous box inherits.
-fn style_payloads_equal_in_inherited_groups(a: StylePayloadsRef, b: StylePayloadsRef) -> bool {
+fn style_payloads_equal_in_inherited_groups(a: Option<LayoutStyleRef>, b: Option<LayoutStyleRef>) -> bool {
style_payloads_equal_in_groups(a, b, |group_index| {
group_index < crate::css::style::ENGINE_INHERITED_GROUP_COUNT
})
}
-fn style_payloads_equal_in_groups(a: StylePayloadsRef, b: StylePayloadsRef, compares: impl Fn(usize) -> bool) -> bool {
+fn style_payloads_equal_in_groups(
+ a: Option<LayoutStyleRef>,
+ b: Option<LayoutStyleRef>,
+ compares: impl Fn(usize) -> bool,
+) -> bool {
if a == b {
return true;
}
- if a.is_null() || b.is_null() {
+ let (Some(a), Some(b)) = (a, b) else {
return false;
- }
- // SAFETY: A row's non-null style addresses the payload array of the record pinned for it.
- let (a, b) = unsafe { (a.deref(), b.deref()) };
- (0..a.groups.len()).all(|group_index| {
- !compares(group_index)
- || a.groups[group_index] == b.groups[group_index]
- // SAFETY: Published style-group payloads stay live while their records do.
- || unsafe { crate::css::computed_values::style_group_payloads_equal(
- group_index,
- a.groups[group_index],
- b.groups[group_index],
- ) }
- })
+ };
+ // SAFETY: A row's style is that of the record pinned for it.
+ let (a, b) = unsafe { (a.view(), b.view()) };
+ crate::css::computed_values::style_groups_equal_in(a, b, compares)
}
/// The image resources a tree build owes the host for a row it stamped, which the host attaches
@@ -1124,12 +1131,14 @@ pub(crate) struct LayoutNodeArena {
any_default_scroll_shift_anchor_ever_stored: bool,
text_slots: TextSlots,
pub(super) searchable_text: Option<Vec<super::text_queries::MappedText>>,
- replaced_content_facts: Vec<ReplacedContentFactsSlot>,
+ replaced_content_facts: CowVec<ReplacedContentFactsSlot, REPLACED_CONTENT_FACTS_PER_CHUNK>,
/// The layout kind of each row built for a MathML element, from its tag name.
math_layout_kinds: HashMap<NodeSlotId, super::math_formatting_context::MathLayoutKind>,
replaced_paint_facts: Arc<crate::painting::replaced_paint_facts::ReplacedPaintFactsTable>,
layer_image_paint_facts: Arc<crate::painting::layer_image_paint_facts::LayerImagePaintFactsTable>,
svg_paint_resources: crate::painting::svg_paint_resources::SvgPaintResources,
+ /// The writes to `replaced_paint_facts` and `layer_image_paint_facts`.
+ paint_fact_writes: u64,
/// The rows built for one DOM node, chained into a ring through the rows themselves; a row that
/// is the only one built for its node links to nothing. The chain lives on the rows rather than
/// under a key so that it survives the node's identity being retired and re-issued.
@@ -1208,6 +1217,15 @@ pub(crate) struct LayoutNodeArena {
}
impl LayoutNodeArena {
+ /// The bytes of the columns that name the style record each row is built from.
+ pub(crate) fn style_column_heap_size(&self) -> usize {
+ use crate::heap_size::vec_bytes;
+ vec_bytes(&self.style_records)
+ + vec_bytes(&self.image_resources_owed_records)
+ + vec_bytes(&self.style_record_pins)
+ + vec_bytes(&self.style_records_pinned_by_host)
+ }
+
pub(crate) fn new() -> Self {
Self {
chunks: Vec::new(),
@@ -1250,11 +1268,12 @@ impl LayoutNodeArena {
any_default_scroll_shift_anchor_ever_stored: false,
text_slots: TextSlots::default(),
searchable_text: None,
- replaced_content_facts: Vec::new(),
+ replaced_content_facts: CowVec::default(),
math_layout_kinds: Default::default(),
replaced_paint_facts: Default::default(),
layer_image_paint_facts: Default::default(),
svg_paint_resources: crate::painting::svg_paint_resources::SvgPaintResources::default(),
+ paint_fact_writes: 0,
next_rows_built_for_same_node: Vec::new(),
memo_invalidations: Default::default(),
layout_trace: super::trace::TraceRecord::default(),
@@ -1366,8 +1385,8 @@ impl LayoutNodeArena {
);
}
- /// Checks that the calling thread may reach the arena: the StyleLayout thread, which the arena's render state lives
- /// on, or the host's, while the StyleLayout thread waits for its next message.
+ /// Checks that the calling thread may reach the arena: the Render thread, which the arena's render state lives
+ /// on, or the host's, while the Render thread waits for its next message.
// Freshly created chunks are default-initialized and free() resets slots on release, so
// allocate() always hands out clean NodeData without writing it again.
#[cfg(test)]
@@ -1605,8 +1624,12 @@ impl LayoutNodeArena {
self.paintable_rows.reset_committed_fragment_link_slot(index);
self.text_slots.reset(index as usize);
self.text_nodes_enrolled_for_content_sync.remove(&id);
- if let Some(slot) = self.replaced_content_facts.get_mut(index as usize) {
- *slot = ReplacedContentFactsSlot::default();
+ if self
+ .replaced_content_facts
+ .get(index as usize)
+ .is_some_and(|slot| slot.facts.is_some())
+ {
+ self.replaced_content_facts[index as usize] = ReplacedContentFactsSlot::default();
}
self.owned_image_natural_sizes.remove(&id);
self.owned_image_providers.remove(&id);
@@ -1616,9 +1639,11 @@ impl LayoutNodeArena {
self.math_layout_kinds.remove(&id);
if self.replaced_paint_facts.contains_key(&id) {
Arc::make_mut(&mut self.replaced_paint_facts).remove(&id);
+ self.paint_fact_writes += 1;
}
if self.layer_image_paint_facts.contains_key(&id) {
Arc::make_mut(&mut self.layer_image_paint_facts).remove(&id);
+ self.paint_fact_writes += 1;
}
self.svg_paint_resources.forget_slot(id);
for highlight in crate::painting::selection::HighlightPseudoElement::ALL {
@@ -1759,7 +1784,7 @@ impl LayoutNodeArena {
pub(crate) fn retire_layout_tree_update_marks_of_cleared_node(&mut self, node: StyleNodeID) {
let mut current = node;
while self.layout_tree_update_marks.merge(current, false, 0) {
- let Some(host) = self.with_style_store(|engine| engine.tree().host_of(current)) else {
+ let Some(host) = self.with_style_store(|engine| engine.host_of(current)) else {
break;
};
current = host;
@@ -2037,13 +2062,13 @@ impl LayoutNodeArena {
/// The parent element of `element` in the style tree, if any.
pub(crate) fn style_node_parent(&self, element: StyleNodeID) -> Option<StyleNodeID> {
- self.with_style_store(|engine| engine.tree().parent(element))
+ self.with_style_store(|engine| engine.dom_parent(element))
}
/// The shadow host of the shadow tree `element` is in, or none in the document tree. A shadow
/// root has no layout row, so the tree scope is named by its host.
pub(crate) fn tree_scope_host(&self, element: StyleNodeID) -> Option<StyleNodeID> {
- self.with_style_store(|engine| engine.tree().shadow_host_of(element))
+ self.with_style_store(|engine| engine.shadow_host_of(element))
}
/// What the row is scrolled to: the viewport's row holds the navigable's offset, a
@@ -2245,7 +2270,12 @@ impl LayoutNodeArena {
}
}
- pub(crate) fn set_node_style(&mut self, id: NodeSlotId, style_record: u64, payloads: StylePayloadsRef) -> bool {
+ pub(crate) fn set_node_style(
+ &mut self,
+ id: NodeSlotId,
+ style_record: u64,
+ payloads: Option<LayoutStyleRef>,
+ ) -> bool {
self.write_shape(id).set_style(payloads);
self.note_row_style(id);
self.set_node_flag(id, NodeFlag::FollowsPrincipalStyle, false);
@@ -2272,8 +2302,8 @@ impl LayoutNodeArena {
&mut self,
slot: NodeSlotId,
style_record: u64,
- payloads: StylePayloadsRef,
- previous_payloads: Option<StylePayloadsRef>,
+ payloads: Option<LayoutStyleRef>,
+ previous_payloads: Option<Option<LayoutStyleRef>>,
) {
if self.set_node_style(slot, style_record, payloads) {
self.refresh_style_flags(slot);
@@ -2290,78 +2320,40 @@ impl LayoutNodeArena {
pub(crate) fn style_move_keeps_layout_inputs(
&self,
slot: NodeSlotId,
- previous: StylePayloadsRef,
- new: StylePayloadsRef,
+ previous: Option<LayoutStyleRef>,
+ new: Option<LayoutStyleRef>,
) -> bool {
if previous == new {
return true;
}
- if previous.is_null() || new.is_null() {
+ let (Some(previous), Some(new)) = (previous, new) else {
return false;
- }
- // SAFETY: A row's non-null style addresses the payload array of the record pinned for it.
- let (previous, new) = unsafe { (previous.deref(), new.deref()) };
+ };
+ // SAFETY: A row's style is that of the record pinned for it.
+ let (previous, new) = unsafe { (previous.view(), new.view()) };
let is_svg_box = super::node_facts::kind_is_svg_box(self.data(slot).kind.get());
- // SAFETY: Published style-group payloads stay live while their records do.
- unsafe {
- crate::css::computed_values::style_payloads_layout_inputs_equal(&previous.groups, &new.groups, is_svg_box)
- }
+ crate::css::computed_values::style_payloads_layout_inputs_equal(previous, new, is_svg_box)
}
- /// Applies `rows`, the rows of a style transaction a frame applies ahead of the host, to the boxes of their elements,
+ /// Applies `rows`, the rows of a style update a frame applies ahead of the host, to the boxes of their elements,
/// as the host's install of each row does: the row's record, the styles the box's anonymous descendants inherit, and
/// the relayout the move asks for. Answers the rows it applied, by element, or why it applied none: a row's box is
/// one the host styles in a way of its own. The host installs the rows on the elements once the frame has landed.
- pub(crate) fn apply_flight_style_rows(
- &mut self,
- host_calls: HostCalls<'_>,
- rows: Vec<FlightStyleRow>,
- ) -> Result<Vec<FlightStyleRow>, Decline> {
- let mut applied = Vec::with_capacity(rows.len());
- for row in rows {
- let slot = self.bound_row(row.style_node);
- if slot.is_invalid() {
- continue;
- }
- // Replaced content, form controls, list items, tables and SVG take facts from their element the host
- // publishes as it styles them, and a box that holds a style of the arena's or one the host pins is styled
- // in a way of its own. So is a table box, whose wrapper may take properties of it and so give it a style of
- // the arena's, which its layout node hears of only as the host pays the frame, after the host installs the
- // row.
- let parent = self.data(slot).parent.get();
- if !matches!(
- self.data(slot).kind.get(),
- NodeKind::Box | NodeKind::BlockContainer | NodeKind::InlineNode
- ) || self.style_records[slot.slot_index() as usize] != row.old_style_record
- || self.node_style_record_is_derived(slot)
- || self.node_style_record_pinned_by_host(slot) != 0
- || (!parent.is_invalid() && self.data(parent).kind.get() == NodeKind::TableWrapper)
- {
- return Err(Decline::LayoutNode);
- }
- applied.push(row);
- }
- for row in &applied {
- let slot = self.bound_row(row.style_node);
- let previous_payloads = self.data(slot).style.get();
- let payloads = self.with_style_engine(|engine| {
- engine
- .style_record_payloads(row.new_style_record)
- .map_or(std::ptr::null(), <[_]>::as_ptr)
- });
- let payloads = StylePayloadsRef::new(payloads.cast());
- self.install_style_record(slot, row.new_style_record, payloads, Some(previous_payloads));
- self.set_node_flag(slot, NodeFlag::HasAnimatedOpacityOrTransform, false);
- self.reinherit_anonymous_descendants(HostCalls(host_calls.0), slot);
- if row.relayout {
- self.mark_row_for_relayout_after_style_change(row.style_node, slot);
- }
- }
- applied.sort_unstable_by_key(|row| row.style_node);
- Ok(applied)
+ /// Whether the box `slot` is one only the host styles. Replaced content, form controls, list items, tables and SVG
+ /// take facts from their element the host publishes as it styles them, and a box that holds a style of the arena's
+ /// or one the host pins is styled in a way of its own. So is a table box, whose wrapper may take properties of it
+ /// and so give it a style of the arena's, which its layout node hears of only as the host installs its record.
+ pub(crate) fn box_is_styled_by_host(&self, slot: NodeSlotId) -> bool {
+ let parent = self.data(slot).parent.get();
+ !matches!(
+ self.data(slot).kind.get(),
+ NodeKind::Box | NodeKind::BlockContainer | NodeKind::InlineNode
+ ) || self.node_style_record_is_derived(slot)
+ || self.node_style_record_pinned_by_host(slot) != 0
+ || (!parent.is_invalid() && self.data(parent).kind.get() == NodeKind::TableWrapper)
}
- /// The box of the element or pseudo-element `row` of a hover's style transaction styles, `generated_for` naming the
+ /// The box of the element or pseudo-element `row` of a hover's style update styles, `generated_for` naming the
/// pseudo-element, or 0 for the element.
fn hover_row_box(&self, row: &crate::css::style::bridge::FfiStyleDelta, generated_for: u8) -> NodeSlotId {
let Some(node) = StyleNodeID::from_raw(row.style_node) else {
@@ -2373,7 +2365,7 @@ impl LayoutNodeArena {
}
}
- /// Whether the box of the element or pseudo-element `row` of a hover's style transaction moves takes the row's
+ /// Whether the box of the element or pseudo-element `row` of a hover's style update moves takes the row's
/// record as the host's install of it would, without the host: the move rebuilds no box, and a box it styles is a
/// plain one that shows the record the row moves from. List items, images and SVG boxes, which take facts from their
/// element as the host styles them, take a move that only repaints them.
@@ -2386,7 +2378,7 @@ impl LayoutNodeArena {
self.hover_row_box_refusal(row, generated_for).is_none()
}
- /// Why the box of the element or pseudo-element `row` of a hover's style transaction moves cannot take the row's
+ /// Why the box of the element or pseudo-element `row` of a hover's style update moves cannot take the row's
/// record without the host, or none where it can (see [`Self::takes_hover_row`]).
pub(crate) fn hover_row_box_refusal(
&self,
@@ -2436,7 +2428,7 @@ impl LayoutNodeArena {
(!parent.is_invalid() && self.data(parent).kind.get() == NodeKind::TableWrapper).then(|| "a table box".into())
}
- /// Whether the box of the element or pseudo-element `row` of a hover's style transaction styles shows the record the
+ /// Whether the box of the element or pseudo-element `row` of a hover's style update styles shows the record the
/// row moves to already, or there is no box.
pub(crate) fn hover_row_box_shows_its_record(
&self,
@@ -2447,7 +2439,7 @@ impl LayoutNodeArena {
slot.is_invalid() || self.style_records[slot.slot_index() as usize] == row.new_style_record
}
- /// Installs the record `row` of a hover's style transaction moves to in the box of its element or pseudo-element,
+ /// Installs the record `row` of a hover's style update moves to in the box of its element or pseudo-element,
/// which [`Self::takes_hover_row`] took, as the host's install of the row does: the style, the styles the box's
/// anonymous descendants inherit, and the relayout, the visual contexts and the repaint the move asks for.
pub(crate) fn install_hover_row(
@@ -2465,9 +2457,8 @@ impl LayoutNodeArena {
let payloads = self.with_style_engine(|engine| {
engine
.style_record_payloads(row.new_style_record)
- .map_or(std::ptr::null(), <[_]>::as_ptr)
+ .map(LayoutStyleRef::of_groups)
});
- let payloads = StylePayloadsRef::new(payloads.cast());
self.install_style_record(slot, row.new_style_record, payloads, Some(previous_payloads));
self.reinherit_anonymous_descendants(HostCalls(host_calls.0), slot);
let level = row.record_damage & FfiStyleInvalidationField::LevelMask as u32;
@@ -2506,7 +2497,7 @@ impl LayoutNodeArena {
/// whose sample moves the style of an anonymous box: its layout node would have to hear of a style no host reads.
pub(crate) fn takes_sample(&self, row: NodeSlotId, sample: &DerivedStyleRecord, kind: SampleKind) -> bool {
self.takes_sample_beside_anonymous_boxes(row, kind)
- && !self.sample_moves_anonymous_box_style(row, sample.payloads)
+ && !self.sample_moves_anonymous_box_style(row, Some(sample.payloads))
}
/// Whether the box `row` shows a sample of `kind` of the effects of its element where the anonymous boxes below it
@@ -2647,7 +2638,7 @@ impl LayoutNodeArena {
/// Whether showing a style with `payloads` in `row` moves the style of an anonymous box: the table wrapper's, which
/// takes properties of its table box of its own, or an anonymous child's, which inherits the inherited groups.
- fn sample_moves_anonymous_box_style(&self, row: NodeSlotId, payloads: StylePayloadsRef) -> bool {
+ fn sample_moves_anonymous_box_style(&self, row: NodeSlotId, payloads: Option<LayoutStyleRef>) -> bool {
let parent = self.data(row).parent.get();
if !parent.is_invalid() && self.data(parent).kind.get() == NodeKind::TableWrapper {
return true;
@@ -2666,14 +2657,12 @@ impl LayoutNodeArena {
/// Whether the style the box `row` shows differs from the record `host_record`, which the host installed for it, in
/// what its children inherit.
pub(crate) fn shows_other_inherited_style_than(&self, row: NodeSlotId, host_record: u64) -> bool {
- let Some(host_payloads) = self.with_style_store(|engine| {
- engine
- .style_record_payloads(host_record)
- .map(|payloads| StylePayloadsRef::new(payloads.as_ptr().cast()))
- }) else {
+ let Some(host_payloads) =
+ self.with_style_store(|engine| engine.style_record_payloads(host_record).map(LayoutStyleRef::of_groups))
+ else {
return true;
};
- !style_payloads_equal_in_inherited_groups(self.data(row).style.get(), host_payloads)
+ !style_payloads_equal_in_inherited_groups(self.data(row).style.get(), Some(host_payloads))
}
/// Gives `row` back the style the host installed for it, which a clock tick took to show a sample in its place. The
@@ -2688,19 +2677,17 @@ impl LayoutNodeArena {
self.with_style_engine(|engine| engine.unpin_layout_style_record(sample));
let HostStyle { record, pin } = host_style;
let payloads = self.with_style_store(|engine| {
- engine
- .style_record_payloads(record)
- .expect("the host's style record is live while a box shows a sample")
- .as_ptr()
+ LayoutStyleRef::of_groups(
+ engine
+ .style_record_payloads(record)
+ .expect("the host's style record is live while a box shows a sample"),
+ )
});
self.style_record_pins[index] = pin;
self.show_style(
row,
self.node_style_node(row),
- DerivedStyleRecord {
- record,
- payloads: StylePayloadsRef::new(payloads.cast()),
- },
+ DerivedStyleRecord { record, payloads },
relayout,
);
}
@@ -2718,14 +2705,14 @@ impl LayoutNodeArena {
let previous_payloads = self.data(row).style.get();
self.replace_style_record(row.slot_index() as usize, style.record);
let mut shape = self.write_shape(row);
- shape.set_style(style.payloads);
+ shape.set_style(Some(style.payloads));
shape.mark();
self.note_row_style(row);
self.refresh_style_flags(row);
self.invalidate_overflow_after_style_change(row);
self.enroll_text_children_for_content_sync(row);
self.enroll_node_for_svg_paint_resources_sync(row);
- if self.style_move_keeps_layout_inputs(row, previous_payloads, style.payloads) {
+ if self.style_move_keeps_layout_inputs(row, previous_payloads, Some(style.payloads)) {
return;
}
if let StyleRelayout::ByDamage(damage) = relayout
@@ -2753,8 +2740,8 @@ impl LayoutNodeArena {
}
let confined = !viewport_propagation_source
&& self
- .style_payloads(slot)
- .is_some_and(|payloads| ComputedValuesView::new(&payloads.groups).is_absolutely_positioned())
+ .style_view(slot)
+ .is_some_and(|payloads| payloads.is_absolutely_positioned())
&& self.node_is_partial_relayout_boundary(slot)
&& self
.bound_pseudo_element_row(style_node, super::node_data::GENERATED_FOR_BACKDROP)
@@ -3176,7 +3163,7 @@ impl LayoutNodeArena {
return None;
}
self.with_style_store(|engine| {
- let scope = engine.tree().tree_scope(referrer);
+ let scope = engine.element_tree_scope(referrer);
engine
.element_by_id(crate::css::style::tree::TreeScopeID::DOCUMENT, name)
.or_else(|| {
@@ -3192,12 +3179,11 @@ impl LayoutNodeArena {
///
/// The group pointers are copied out rather than borrowed, since the style store's borrow ends
/// with the query while the record they address is retained for the pass.
- pub(crate) fn style_node_style_payloads(&self, style_node: StyleNodeID) -> Option<FfiStylePayloads> {
+ pub(crate) fn style_node_style(&self, style_node: StyleNodeID) -> Option<LayoutStyleRef> {
self.with_style_store(|engine| {
- let groups = engine.element_published_style_payloads(style_node)?;
- let mut payloads = FfiStylePayloads::default();
- payloads.groups.copy_from_slice(groups);
- Some(payloads)
+ engine
+ .element_published_style(style_node)
+ .map(|style| LayoutStyleRef::of(style.record_groups()))
})
}
@@ -3257,7 +3243,7 @@ impl LayoutNodeArena {
/// Whether the element has an element child, which is what `childElementCount` counts.
pub(crate) fn has_dom_element_children(&self, style_node: StyleNodeID) -> bool {
style_node.element_index().is_some()
- && self.with_style_store(|engine| engine.tree().first_element_child(style_node).is_some())
+ && self.with_style_store(|engine| engine.first_element_child(style_node).is_some())
}
/// The names a publication holds a sweep retention on: the one an `href` names, and the four
@@ -3320,22 +3306,21 @@ impl LayoutNodeArena {
/// none. Nodes that can never have a box (a comment, a doctype, a processing instruction) hold
/// no place in it.
pub(crate) fn first_dom_child(&self, style_node: StyleNodeID) -> Option<StyleNodeID> {
- self.with_style_store(|engine| engine.tree().dom_children(style_node).next())
+ self.with_style_store(|engine| engine.dom_children(style_node).next())
}
/// Everything one step of the stale-subtree walk reads out of the style mirror, in one borrow.
pub(crate) fn stale_walk_facts(&self, style_node: StyleNodeID) -> StaleWalkFacts {
self.with_style_store(|engine| {
- let tree = engine.tree();
let owns_children = style_node.text_index().is_none();
StaleWalkFacts {
rendered_in_top_layer: owns_children
&& engine.element_adjustment_facts(style_node)
& crate::css::style::bridge::element_adjustment_fact::RENDERED_IN_TOP_LAYER
!= 0,
- shadow_root: owns_children.then(|| tree.shadow_root_of(style_node)).flatten(),
- first_dom_child: owns_children.then(|| tree.dom_children(style_node).next()).flatten(),
- next_dom_sibling: tree.next_sibling_in_dom_order(style_node),
+ shadow_root: owns_children.then(|| engine.shadow_root_of(style_node)).flatten(),
+ first_dom_child: owns_children.then(|| engine.dom_children(style_node).next()).flatten(),
+ next_dom_sibling: engine.next_sibling_in_dom_order(style_node),
}
})
}
@@ -3343,12 +3328,12 @@ impl LayoutNodeArena {
/// The shadow root the element `host` hosts, if any. The style mirror names a root the moment it
/// is attached to a host in the document.
pub(crate) fn shadow_root_of(&self, host: StyleNodeID) -> Option<StyleNodeID> {
- self.with_style_store(|engine| engine.tree().shadow_root_of(host))
+ self.with_style_store(|engine| engine.shadow_root_of(host))
}
/// The node after `style_node` in its parent's DOM child sequence.
pub(crate) fn next_dom_sibling(&self, style_node: StyleNodeID) -> Option<StyleNodeID> {
- self.with_style_store(|engine| engine.tree().next_sibling_in_dom_order(style_node))
+ self.with_style_store(|engine| engine.next_sibling_in_dom_order(style_node))
}
/// The element facts the style mirror holds for `style_node`, as
@@ -3417,12 +3402,10 @@ impl LayoutNodeArena {
/// in the element relations, so the document element has none.
pub(crate) fn flat_tree_parent(&self, style_node: StyleNodeID) -> Option<StyleNodeID> {
self.with_style_store(|engine| {
- let tree = engine.tree();
- if let Some(slot) = tree.assigned_slot_of(style_node) {
+ if let Some(slot) = engine.assigned_slot_of(style_node) {
return Some(slot);
}
- let parent = tree.parent(style_node)?;
- Some(tree.host_of(parent).unwrap_or(parent))
+ engine.parent_element_or_host(style_node)
})
}
@@ -3443,19 +3426,19 @@ impl LayoutNodeArena {
/// is not a slot with assigned nodes answers zero.
pub(crate) fn assigned_node_count(&self, style_node: Option<StyleNodeID>) -> usize {
style_node.map_or(0, |style_node| {
- self.with_style_store(|engine| engine.tree().assigned_nodes_of(style_node).len())
+ self.with_style_store(|engine| engine.assigned_node_count(style_node))
})
}
/// The node assigned to the slot `style_node` names at `index`, in flat-tree order.
pub(crate) fn assigned_node_at(&self, style_node: StyleNodeID, index: usize) -> StyleNodeID {
- self.with_style_store(|engine| engine.tree().assigned_nodes_of(style_node)[index])
+ self.with_style_store(|engine| engine.assigned_node(style_node, index))
}
/// The document's top layer member at `index`, in the order the members were added, or nothing
/// past the last one.
pub(crate) fn top_layer_element(&self, index: usize) -> Option<StyleNodeID> {
- self.with_style_store(|engine| engine.tree().top_layer().get(index).copied())
+ self.with_style_store(|engine| engine.top_layer_element(index))
}
/// Whether a style engine hosts this arena's records; a layout test's arena has none.
@@ -3599,14 +3582,7 @@ impl LayoutNodeArena {
parent: u64,
column_source: Option<u64>,
) -> DerivedStyleRecord {
- self.with_style_engine(|engine| {
- let mut style = LayoutStyle::from_record(engine, record);
- style.inherit_from(engine, parent);
- if let Some(column_source) = column_source {
- style.copy_column_properties(&LayoutStyle::from_record(engine, column_source));
- }
- style.intern(engine)
- })
+ self.with_style_engine(|engine| engine.reinherited_anonymous_style_record(record, parent, column_source))
}
fn anonymous_box_column_source(&self, node: NodeSlotId) -> Option<NodeSlotId> {
@@ -3632,12 +3608,12 @@ impl LayoutNodeArena {
&mut self,
host_calls: HostCalls<'_>,
node: NodeSlotId,
- update: impl FnOnce(&mut LayoutStyle),
+ update: impl FnOnce(&mut LayoutStyle, &crate::css::computed_values::DefaultGroups),
) {
let record = self.node_style_record(node);
let derived = self.with_style_engine(|engine| {
let mut style = LayoutStyle::from_record(engine, record);
- update(&mut style);
+ update(&mut style, engine.default_groups());
if style.is_unchanged() {
return None;
}
@@ -3658,7 +3634,7 @@ impl LayoutNodeArena {
host_calls: HostCalls<'_>,
node: NodeSlotId,
) {
- self.update_layout_style(host_calls, node, |style| {
+ self.update_layout_style(host_calls, node, |style, _| {
style.set_display(crate::layout::FfiDisplay::outside_and_inside(
crate::css::css_enums::display_outside::INLINE,
crate::css::css_enums::display_inside::FLOW,
@@ -3672,8 +3648,8 @@ impl LayoutNodeArena {
data.kind.get() == NodeKind::InlineNode
&& super::node_facts::has_flag(data, NodeFlag::IsPseudoElementPrincipalBox)
&& self
- .style_payloads(node)
- .is_some_and(|payloads| ComputedValuesView::new(&payloads.groups).display().is_contents())
+ .style_view(node)
+ .is_some_and(|payloads| payloads.display().is_contents())
}
pub(crate) fn reinherit_anonymous_descendants(&mut self, host_calls: HostCalls<'_>, node: NodeSlotId) {
@@ -3688,8 +3664,8 @@ impl LayoutNodeArena {
let parent_is_table_wrapper_of_this_table_box = !parent.is_invalid()
&& self.data(parent).kind.get() == NodeKind::TableWrapper
&& self
- .style_payloads(node)
- .is_some_and(|payloads| ComputedValuesView::new(&payloads.groups).display().is_table_inside());
+ .style_view(node)
+ .is_some_and(|payloads| payloads.display().is_table_inside());
if parent_is_table_wrapper_of_this_table_box {
let derived = self.derive_anonymous_style_record(
self.node_style_record(node),
@@ -3774,7 +3750,7 @@ impl LayoutNodeArena {
) -> bool {
let previous_payloads = self.data(slot).style.get();
let changes_layout_affecting_style =
- !self.style_move_keeps_layout_inputs(slot, previous_payloads, derived.payloads);
+ !self.style_move_keeps_layout_inputs(slot, previous_payloads, Some(derived.payloads));
self.replace_arena_pinned_style_record(slot, derived);
if changes_layout_affecting_style {
self.invalidate_fragments_and_intrinsic_sizes_of_self_and_ancestors(slot);
@@ -4075,7 +4051,7 @@ impl LayoutNodeArena {
/// is made when first asked for and reads the row's style as it is made, so the record must
/// outlive a publication that replaces it before then.
fn stamp_published_style_record(&mut self, slot: NodeSlotId, published: DerivedStyleRecord) {
- if self.set_node_style(slot, published.record, published.payloads) {
+ if self.set_node_style(slot, published.record, Some(published.payloads)) {
self.refresh_style_flags(slot);
}
self.style_record_pins[slot.slot_index() as usize] = ArenaStylePin::Published;
@@ -4178,22 +4154,22 @@ impl LayoutNodeArena {
NodeKind::Unset,
"stamped an anonymous box onto a bound slot"
);
- assert!(derived.record != 0 && !derived.payloads.is_null());
+ assert!(derived.record != 0);
data.set_kind(kind);
data.set_flags(super::node_facts::construction_flags(kind, true, 0));
self.replace_style_record(slot.slot_index() as usize, derived.record);
self.style_record_pins[slot.slot_index() as usize] = ArenaStylePin::Derived;
let mut data = self.write_shape(slot);
- data.set_style(derived.payloads);
+ data.set_style(Some(derived.payloads));
data.mark();
self.note_row_style(slot);
self.enroll_node_for_replaced_content_facts_sync_if_eligible(slot);
}
pub(crate) fn refresh_insets_use_anchor_functions_flag(&mut self, slot: NodeSlotId) {
- let insets_use_anchor_functions = self.style_payloads(slot).is_some_and(|payloads| {
- super::node_facts::style_insets_use_anchor_functions(ComputedValuesView::new(&payloads.groups))
- });
+ let insets_use_anchor_functions = self
+ .style_view(slot)
+ .is_some_and(|payloads| super::node_facts::style_insets_use_anchor_functions(payloads));
self.set_node_flag(slot, NodeFlag::InsetsUseAnchorFunctions, insets_use_anchor_functions);
}
@@ -4275,11 +4251,11 @@ impl LayoutNodeArena {
&mut self.style_record_pins[slot.slot_index() as usize],
ArenaStylePin::Derived,
) != ArenaStylePin::None;
- assert!(derived.record != 0 && !derived.payloads.is_null());
+ assert!(derived.record != 0);
let previous_style_record = self.replace_style_record(slot.slot_index() as usize, derived.record);
self.shape_writes.note_style();
let mut shape = self.write_shape(slot);
- shape.set_style(derived.payloads);
+ shape.set_style(Some(derived.payloads));
shape.mark();
self.note_row_style(slot);
self.refresh_style_flags(slot);
@@ -4334,6 +4310,7 @@ impl LayoutNodeArena {
true
};
if changed {
+ self.paint_fact_writes += 1;
use crate::painting::record::damage::PaintDamage;
self.push_paint_damage_for_repaint(
id,
@@ -4381,6 +4358,7 @@ impl LayoutNodeArena {
continue;
}
Arc::make_mut(&mut self.replaced_paint_facts).insert(row, facts.clone());
+ self.paint_fact_writes += 1;
self.push_paint_damage_for_repaint(row, damage);
}
}
@@ -4397,17 +4375,13 @@ impl LayoutNodeArena {
identity: self.rows_identity_version(),
style: self.shape_writes.style(),
population: self.paintable_population_version(),
- tables: [
- Arc::as_ptr(&self.replaced_paint_facts).addr(),
- Arc::as_ptr(&self.layer_image_paint_facts).addr(),
- self.svg_paint_resources.address(),
- self.image_map_areas().address(),
- self.paint_state
- .visual_context
- .tree
- .as_ref()
- .map_or(0, |tree| Arc::as_ptr(tree).addr()),
- ],
+ table_writes: self.paint_fact_writes + self.svg_paint_resources.writes() + self.image_map_areas().writes(),
+ visual_context_tree: self
+ .paint_state
+ .visual_context
+ .tree
+ .as_ref()
+ .map_or(0, |tree| tree.copy.number()),
}
}
@@ -5398,15 +5372,16 @@ impl LayoutNodeArena {
self.data(id);
let index = id.slot_index() as usize;
if self.replaced_content_facts.len() <= index {
- self.replaced_content_facts
- .resize_with(index + 1, ReplacedContentFactsSlot::default);
+ self.replaced_content_facts.resize_with_default(index + 1);
}
let previous = &self.replaced_content_facts[index];
let changed = previous.generation != id.generation() || previous.facts != Some(facts);
- self.replaced_content_facts[index] = ReplacedContentFactsSlot {
- generation: id.generation(),
- facts: Some(facts),
- };
+ if changed {
+ self.replaced_content_facts[index] = ReplacedContentFactsSlot {
+ generation: id.generation(),
+ facts: Some(facts),
+ };
+ }
changed
}
@@ -5518,7 +5493,7 @@ impl LayoutNodeArena {
.map(|index| self.assigned_node_at(element, index))
.collect()
} else {
- self.with_style_store(|engine| engine.tree().dom_children(element).collect())
+ self.with_style_store(|engine| engine.dom_children(element).collect())
};
for child in children {
let row = self.bound_row(child);
@@ -5625,13 +5600,12 @@ impl LayoutNodeArena {
if self.may_have_auto_content_visibility && self.may_have_scroll_snap_areas {
return;
}
- let Some(payloads) = self.style_payloads(slot) else {
+ let Some(style) = self.style_view(slot) else {
return;
};
- let style = ComputedValuesView::new(&payloads.groups);
let has_auto_content_visibility = style.content_visibility() == crate::css::css_enums::content_visibility::AUTO;
let has_scroll_snap_area =
- style.misc_reset().scroll_snap_strictness != crate::css::css_enums::scroll_snap_strictness::NONE;
+ style.misc_interaction().scroll_snap_strictness != crate::css::css_enums::scroll_snap_strictness::NONE;
self.may_have_auto_content_visibility |= has_auto_content_visibility;
self.may_have_scroll_snap_areas |= has_scroll_snap_area;
}
@@ -5647,14 +5621,14 @@ impl LayoutNodeArena {
}
#[inline]
- pub(crate) fn style_payloads(&self, id: NodeSlotId) -> Option<&FfiStylePayloads> {
- Self::row_style_payloads(self.data(id))
+ pub(crate) fn style_view(&self, id: NodeSlotId) -> Option<ComputedValuesView<'_>> {
+ Self::row_style_view(self.data(id))
}
#[inline]
- fn row_style_payloads(data: &NodeData) -> Option<&FfiStylePayloads> {
+ fn row_style_view(data: &NodeData) -> Option<ComputedValuesView<'_>> {
// SAFETY: The arena pins the style record of each of its rows while the row holds it.
- unsafe { super::node_data::style_payloads(data.style.get()) }
+ data.style.get().map(|style| unsafe { style.view() })
}
/// The row of the node `id` names, or `None` once the node is gone.
@@ -6149,7 +6123,7 @@ impl<'a> crate::painting::paint_read::PaintRow<'a> for LiveRow<'a> {
}
fn style(self) -> Option<ComputedValuesView<'a>> {
- LayoutNodeArena::row_style_payloads(self.data).map(|payloads| ComputedValuesView::new(&payloads.groups))
+ LayoutNodeArena::row_style_view(self.data)
}
fn style_node(self) -> Option<StyleNodeID> {
@@ -6163,40 +6137,19 @@ pub(crate) struct NodeAllocation {
pub(crate) slot: NodeSlotId,
}
-/// Whether the counter styles the generated content of the element `style_node` names, or of its
-/// pseudo-element `generated_for`, names now differ from the ones its box was built with.
-#[unsafe(no_mangle)]
-pub extern "C" fn render_state_content_counter_styles_changed(
- host: &DocumentHost,
- read: &crate::render_state::BegunRead,
- style_node: u32,
- generated_for: u8,
-) -> bool {
- let Some(owner) = counter_owner(style_node, generated_for) else {
- return false;
- };
- read_arena(host, read, owner, |arena, owner| {
- super::generated_content::content_counter_styles_changed(arena, owner)
- })
-}
-
-fn counter_owner(style_node: u32, generated_for: u8) -> Option<super::counters::CounterOwner> {
- StyleNodeID::from_raw(style_node).map(|element| super::counters::CounterOwner { element, generated_for })
-}
-
-/// Whether an element whose installed style has the `count` group payloads `payloads` has an innermost `list-item`
-/// counter of its own that counts forward, as the counters a layout tree build resolves for it from that style have:
-/// appending a last list item to such an element leaves the items before it as they are numbered.
+/// Whether an element whose installed style is `style` has an innermost `list-item` counter of its own that counts
+/// forward, as the counters a layout tree build resolves for it from that style have: appending a last list item to
+/// such an element leaves the items before it as they are numbered.
///
/// # Safety
///
-/// `payloads` must point at `count` live group payloads.
+/// `style` must point at the groups of a live style record.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn style_resets_forward_list_item_counter(payloads: *const *const c_void, count: usize) -> bool {
- assert!(!payloads.is_null(), "style group payload array is null");
+pub unsafe extern "C" fn style_resets_forward_list_item_counter(style: *const c_void) -> bool {
// SAFETY: Guaranteed by the caller.
- let groups = unsafe { ak::slice_from_raw_parts(payloads, count) };
- super::counters::style_resets_forward_list_item_counter(ComputedValuesView::new(groups))
+ let style = unsafe { LayoutStyleRef::from_raw(style) }.expect("an element's style record is not null");
+ // SAFETY: Guaranteed by the caller.
+ super::counters::style_resets_forward_list_item_counter(unsafe { style.view() })
}
#[unsafe(no_mangle)]
@@ -6232,7 +6185,8 @@ pub unsafe extern "C" fn render_state_set_node_style(
let change = LayoutChange::SetNodeStyle {
node: id,
record: style_record,
- payloads: StylePayloadsRef::new(payloads.cast()),
+ // SAFETY: The host keeps the record it names alive while the row holds it.
+ payloads: unsafe { LayoutStyleRef::from_raw(payloads) },
};
queue(host, change);
}
@@ -6889,14 +6843,13 @@ mod tests {
// The rows' styles hold no group, so the arena is told up front what it would read from them.
arena.may_have_auto_content_visibility = true;
arena.may_have_scroll_snap_areas = true;
- let payloads = [std::ptr::null::<c_void>(); 1];
let slot = arena.allocate_unbound();
arena.stamp_anonymous_box(
slot,
NodeKind::InlineNode,
DerivedStyleRecord {
record: 7,
- payloads: crate::layout::node_data::StylePayloadsRef::new(payloads.as_ptr().cast()),
+ payloads: crate::layout::node_data::LayoutStyleRef::dangling(),
},
);
assert_eq!(arena.data(slot).kind.get(), NodeKind::InlineNode);
@@ -6906,11 +6859,7 @@ mod tests {
assert!(arena.node_style_record_is_derived(slot));
let element = arena.allocate(test_construction_facts_with_kind(NodeKind::InlineNode));
- arena.set_node_style(
- element,
- 9,
- crate::layout::node_data::StylePayloadsRef::new(payloads.as_ptr().cast()),
- );
+ arena.set_node_style(element, 9, Some(crate::layout::node_data::LayoutStyleRef::dangling()));
assert_eq!(arena.node_style_record(element), 9);
assert!(!arena.node_style_record_is_derived(element));
diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena/installed_styles.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena/installed_styles.rs
new file mode 100644
index 00000000000..8e8483c59d8
--- /dev/null
+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena/installed_styles.rs
@@ -0,0 +1,383 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+//! The style records the render side installs in the boxes of their elements itself, as the host's install of each
+//! row would, ahead of the host that installs the records on the elements.
+
+use super::{ArenaStylePin, LayoutNodeArena, LayoutStyleRef, NodeKind, NodeSlotId};
+use crate::css::style::bridge::{
+ FfiStyleDelta, FfiStyleInvalidationField, LayoutTreeRebuildRoot, element_adjustment_fact,
+};
+use crate::css::style::bridge::{REBUILD_LEVEL, RELAYOUT_LEVEL, REPAINT_LEVEL};
+use crate::css::style::hover_lane::hover_row_generated_for;
+use crate::css::style::tree::StyleNodeID;
+use crate::layout::node_data::NodeFlag;
+use crate::layout::tree_mutation::HostCalls;
+use crate::layout::tree_update_marks::{FfiLayoutTreeUpdateMark, layout_tree_update_reuse_reason};
+use smallvec::SmallVec;
+
+/// A box the render side styled with a style record, which the host adopts without publishing it again.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub(crate) struct StyledBox {
+ pub(crate) slot: NodeSlotId,
+ pub(crate) style_record: u64,
+}
+
+/// An element whose rows the render side installed in all the boxes they style, with the record it installed for the
+/// element itself: the host marks no relayout and no repaint for its install.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub(crate) struct StyledElement {
+ pub(crate) node: StyleNodeID,
+ pub(crate) style_record: u64,
+}
+
+/// What the render side installed of a style update's style rows: the elements, by element, and the boxes, by
+/// box, with the records it pinned for the host, those the boxes moved from and those they moved to, which the host
+/// reads until it ends the transaction, and the elements whose layout tree rebuild it marked, by element.
+#[derive(Default)]
+pub(crate) struct StyledRows {
+ pub(crate) elements: Vec<StyledElement>,
+ pub(crate) boxes: Vec<StyledBox>,
+ pub(crate) pinned_records: Vec<u64>,
+ pub(crate) rebuilt: Vec<StyleNodeID>,
+}
+
+/// How the boxes of an element whose style record a transaction installed take it.
+#[derive(Clone, Copy)]
+pub(crate) enum ElementInstall {
+ /// The render side installs the records of the element and its pseudo-elements in their boxes, where it can install
+ /// all of them.
+ Boxes,
+ /// The layout tree is built again from the root the record move names, which the render side marks where it can.
+ Rebuild(LayoutTreeRebuildRoot),
+ /// Only the host installs the element's records: its boxes take the composition of its animations, or appear or go.
+ Host,
+}
+
+/// What installing one row asks of the render side.
+enum RowInstall {
+ /// The row moves no box: its element keeps its record.
+ Nothing,
+ /// The row moves the record of the box `slot`.
+ Box(NodeSlotId),
+}
+
+impl LayoutNodeArena {
+ /// The box `row`, a style row, moves, where the render side installs it as the host would, or none where only
+ /// the host installs it. The render side installs a record in a plain box that shows the record the row moves from:
+ /// replaced content, form controls, list items, tables and SVG take facts from their element as the host styles
+ /// them, and a box that shows a style of the arena's, or an animation sample, is styled in a way of its own.
+ fn style_row_install(&self, row: &FfiStyleDelta, node: StyleNodeID, generated_for: u8) -> Option<RowInstall> {
+ if row.composed_by_the_host {
+ return None;
+ }
+ if row.old_style_record == row.new_style_record && generated_for == 0 {
+ return Some(RowInstall::Nothing);
+ }
+ if row.old_style_record == 0 || row.new_style_record == 0 {
+ return None;
+ }
+ if row.record_damage & FfiStyleInvalidationField::LevelMask as u32 >= REBUILD_LEVEL {
+ return None;
+ }
+ let slot = match generated_for {
+ 0 => self.bound_row(node),
+ generated_for => self.bound_pseudo_element_row(node, generated_for),
+ };
+ if slot.is_invalid() {
+ return None;
+ }
+ let parent = self.data(slot).parent.get();
+ let plain = matches!(
+ self.data(slot).kind.get(),
+ NodeKind::Box | NodeKind::BlockContainer | NodeKind::InlineNode
+ ) && (parent.is_invalid() || self.data(parent).kind.get() != NodeKind::TableWrapper);
+ let shows_old_record = self.style_records[slot.slot_index() as usize] == row.old_style_record
+ && !matches!(
+ self.style_record_pins[slot.slot_index() as usize],
+ ArenaStylePin::Derived | ArenaStylePin::Sampled
+ );
+ (plain && shows_old_record).then_some(RowInstall::Box(slot))
+ }
+
+ /// Installs the style records `rows`, a style update's, in the boxes of their elements and pseudo-elements,
+ /// as the host's install of each row does: the record, the styles the box's anonymous descendants inherit, the
+ /// relayout, the visual contexts and the repaint the move asks for, and the styles viewport propagation gives the
+ /// viewport. It installs an element's rows where it installs all of them, marks the layout tree rebuild of an element
+ /// whose boxes are built again where it marks it as the host would, and leaves the host the other elements, and
+ /// those `element_install` leaves to it. Answers what it installed.
+ pub(crate) fn install_styles(
+ &mut self,
+ host_calls: HostCalls<'_>,
+ rows: &[FfiStyleDelta],
+ element_install: impl Fn(StyleNodeID) -> ElementInstall,
+ ) -> StyledRows {
+ let mut styled = StyledRows::default();
+ let mut propagates_to_viewport = false;
+ // An element's row is followed by the rows of its pseudo-elements.
+ let mut rest = rows;
+ while let Some((first, after)) = rest.split_first() {
+ let group_length = 1 + after
+ .iter()
+ .take_while(|row| row.style_node == first.style_node && row.pseudo_kind != u8::MAX)
+ .count();
+ let (group, next) = rest.split_at(group_length);
+ rest = next;
+ let Some(node) = StyleNodeID::from_raw(first.style_node) else {
+ continue;
+ };
+ if first.pseudo_kind != u8::MAX {
+ continue;
+ }
+ match element_install(node) {
+ ElementInstall::Boxes => {}
+ ElementInstall::Rebuild(root) => {
+ // NB: As the host's install of a row that rebuilds, the boxes built again take the records, and a
+ // box kept in place takes them as the build reaches it.
+ if self.mark_layout_tree_rebuild(node, root) {
+ styled.rebuilt.push(node);
+ styled.elements.push(StyledElement {
+ node,
+ style_record: first.new_style_record,
+ });
+ }
+ continue;
+ }
+ ElementInstall::Host => continue,
+ }
+ let installs: Option<Vec<_>> = group
+ .iter()
+ .map(|row| {
+ let generated_for = hover_row_generated_for(row)?;
+ Some((row, generated_for, self.style_row_install(row, node, generated_for)?))
+ })
+ .collect();
+ let Some(installs) = installs else {
+ continue;
+ };
+ let repaint = group_repaint(group);
+ for (row, generated_for, install) in installs {
+ let RowInstall::Box(slot) = install else {
+ continue;
+ };
+ self.install_style_row(host_calls, row, node, slot, repaint);
+ self.with_style_engine(|engine| {
+ engine.pin_layout_style_record(row.old_style_record);
+ engine.pin_layout_style_record(row.new_style_record);
+ });
+ styled
+ .pinned_records
+ .extend([row.old_style_record, row.new_style_record]);
+ propagates_to_viewport |= generated_for == 0
+ && self.data(slot).flags.get() & (NodeFlag::IsDocumentElement as u32 | NodeFlag::IsBody as u32)
+ != 0;
+ styled.boxes.push(StyledBox {
+ slot,
+ style_record: row.new_style_record,
+ });
+ }
+ styled.elements.push(StyledElement {
+ node,
+ style_record: first.new_style_record,
+ });
+ }
+ if propagates_to_viewport {
+ let viewport = self.bound_viewport_row();
+ if !viewport.is_invalid() {
+ crate::layout::viewport_propagation::propagate_root_styles_to_viewport(
+ host_calls,
+ self,
+ viewport,
+ &crate::layout::viewport_propagation::viewport_propagation_facts(self),
+ );
+ }
+ }
+ styled.elements.sort_unstable_by_key(|element| element.node);
+ styled.rebuilt.sort_unstable();
+ styled.boxes.sort_unstable_by_key(|styled| styled.slot.slot_index());
+ styled
+ }
+
+ /// Marks the layout tree rebuild from `root` a record move of `node` asks for, as the host marks it for a style
+ /// change, where the element has a box that is not placed in the top layer, nor the viewport's, and none of the
+ /// elements it marks is an SVG element or a child of one, which lends its resources to the elements that reference
+ /// it. Answers whether it marked it; the host marks the others.
+ fn mark_layout_tree_rebuild(&mut self, node: StyleNodeID, root: LayoutTreeRebuildRoot) -> bool {
+ let row = self.bound_row(node);
+ if row.is_invalid()
+ || self.element_adjustment_facts(Some(node)) & element_adjustment_fact::RENDERED_IN_TOP_LAYER != 0
+ || self.data(row).flags.get() & (NodeFlag::IsDocumentElement as u32 | NodeFlag::IsBody as u32) != 0
+ {
+ return false;
+ }
+ // The box of an element is placed in the top layer, or is the viewport's child, where the anonymous boxes
+ // around it are.
+ let mut placed = row;
+ loop {
+ let parent = self.data(placed).parent.get();
+ if parent.is_invalid() || self.data(parent).kind.get() == NodeKind::Viewport {
+ return false;
+ }
+ if self.data(parent).flags.get() & NodeFlag::Anonymous as u32 == 0 {
+ break;
+ }
+ placed = parent;
+ }
+ let parent_or_shadow_host =
+ |element: StyleNodeID| self.with_style_store(|engine| engine.parent_element_or_host(element));
+ let (target, reuse_reason) = match root {
+ LayoutTreeRebuildRoot::PSEUDO_ELEMENTS => (node, layout_tree_update_reuse_reason::PSEUDO_ELEMENT_CHANGE),
+ LayoutTreeRebuildRoot::SELF | LayoutTreeRebuildRoot::SELF_UNLESS_DOCUMENT_ELEMENT_OR_BODY => (node, 0),
+ LayoutTreeRebuildRoot::PARENT => (parent_or_shadow_host(node).unwrap_or(node), 0),
+ _ => return false,
+ };
+ // A display: contents element has its parent built again with it.
+ let mut marked: SmallVec<[StyleNodeID; 2]> = SmallVec::new();
+ let mut current = Some(target);
+ while let Some(element) = current {
+ marked.push(element);
+ let displays_contents = self.with_style_store(|engine| {
+ engine
+ .element_published_box_facts(element)
+ .is_some_and(|facts| facts.display.is_contents())
+ });
+ current = if displays_contents {
+ parent_or_shadow_host(element)
+ } else {
+ None
+ };
+ }
+ let is_svg = |element: StyleNodeID| {
+ self.element_adjustment_facts(Some(element)) & element_adjustment_fact::IS_SVG_ELEMENT != 0
+ };
+ if marked.iter().any(|&element| {
+ is_svg(element)
+ || self
+ .with_style_store(|engine| engine.dom_parent(element))
+ .is_some_and(is_svg)
+ }) {
+ return false;
+ }
+ for element in marked {
+ self.mark_layout_tree_update(Some(element), FfiLayoutTreeUpdateMark::style_change(reuse_reason));
+ }
+ true
+ }
+
+ /// Installs the record `row` moves to in `slot`, the box of `node` or of its pseudo-element it styles, and repaints
+ /// the box as `repaint` says.
+ fn install_style_row(
+ &mut self,
+ host_calls: HostCalls<'_>,
+ row: &FfiStyleDelta,
+ node: StyleNodeID,
+ slot: NodeSlotId,
+ repaint: Repaint,
+ ) {
+ let previous_payloads = self.data(slot).style.get();
+ let payloads = self.with_style_engine(|engine| {
+ engine
+ .style_record_payloads(row.new_style_record)
+ .map(LayoutStyleRef::of_groups)
+ });
+ self.install_style_record(slot, row.new_style_record, payloads, Some(previous_payloads));
+ self.set_node_flag(slot, NodeFlag::HasAnimatedOpacityOrTransform, false);
+ self.reinherit_anonymous_descendants(HostCalls(host_calls.0), slot);
+ if row.record_damage & FfiStyleInvalidationField::LevelMask as u32 >= RELAYOUT_LEVEL {
+ self.mark_row_for_relayout_after_style_change(node, slot);
+ }
+ self.note_style_visual_context_moves(slot, row.record_damage);
+ if row.record_damage & FfiStyleInvalidationField::RepaintTextDecorations as u32 != 0
+ && crate::painting::paint_read::GeometryRead::paintable_row_is_populated(self, slot)
+ {
+ self.push_propagated_text_decoration_damage(slot);
+ }
+ match repaint {
+ Repaint::None => {}
+ Repaint::Draw => crate::layout::tree_update_marks::repaint(self, slot, false),
+ Repaint::DrawAndHitTest => crate::layout::tree_update_marks::repaint(self, slot, true),
+ }
+ }
+}
+
+/// How the render side repaints the boxes of an element whose rows it installs.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+enum Repaint {
+ None,
+ Draw,
+ DrawAndHitTest,
+}
+
+/// How the moves of `group`, an element's row and those of its pseudo-elements, repaint the boxes they style. As the
+/// host's install of the rows, it reads their damages as one: a move that only updates the values of the element's
+/// visual contexts, as an opacity or transform change under `will-change` does, patches the visual context node and
+/// repaints no box.
+fn group_repaint(group: &[FfiStyleDelta]) -> Repaint {
+ use crate::css::style::pipeline::main_effects::record_damage_hit_tests_again;
+ if !group
+ .iter()
+ .any(|row| row.record_damage & FfiStyleInvalidationField::LevelMask as u32 >= REPAINT_LEVEL)
+ {
+ return Repaint::None;
+ }
+ if group.iter().any(|row| record_damage_hit_tests_again(row.record_damage)) {
+ Repaint::DrawAndHitTest
+ } else {
+ Repaint::Draw
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::{Repaint, group_repaint};
+ use crate::css::style::bridge::{FfiStyleDelta, FfiStyleInvalidationField};
+
+ fn row(pseudo_kind: u8, record_damage: u32) -> FfiStyleDelta {
+ FfiStyleDelta {
+ style_node: 1,
+ old_style_record: 1,
+ new_style_record: 2,
+ reaction: 0,
+ inherited_style_groups: 0,
+ pseudo_kind,
+ explicitly_inherited_groups: 0,
+ record_damage: record_damage | FfiStyleInvalidationField::EngineComputed as u32,
+ owes_an_animation_plan: false,
+ owes_a_transition_step: false,
+ composed_by_the_host: false,
+ }
+ }
+
+ #[test]
+ fn only_moves_that_repaint_repaint_the_boxes_of_their_element() {
+ let repaint = 1;
+ let relayout = 2;
+ let visual_contexts = |level: u32| level << FfiStyleInvalidationField::VisualContextShift as u32;
+ let element = u8::MAX;
+ let before = 0;
+ assert_eq!(group_repaint(&[row(element, 0)]), Repaint::None);
+ // An opacity or transform change under will-change only updates the values of the element's visual contexts.
+ assert_eq!(group_repaint(&[row(element, visual_contexts(1))]), Repaint::None);
+ assert_eq!(group_repaint(&[row(element, repaint)]), Repaint::Draw);
+ assert_eq!(
+ group_repaint(&[row(element, repaint | visual_contexts(2))]),
+ Repaint::DrawAndHitTest
+ );
+ assert_eq!(group_repaint(&[row(element, relayout)]), Repaint::DrawAndHitTest);
+ // The damages of an element's moves and those of its pseudo-elements repaint all of their boxes.
+ assert_eq!(
+ group_repaint(&[row(element, visual_contexts(1)), row(before, repaint)]),
+ Repaint::Draw
+ );
+ assert_eq!(
+ group_repaint(&[
+ row(element, repaint),
+ row(before, FfiStyleInvalidationField::AffectsHitTesting as u32)
+ ]),
+ Repaint::DrawAndHitTest
+ );
+ }
+}
diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena/main_thread_entries.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena/main_thread_entries.rs
index 1970141fcd2..94ab88682ad 100644
--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena/main_thread_entries.rs
+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena/main_thread_entries.rs
@@ -115,6 +115,13 @@ pub unsafe extern "C" fn render_state_adopt_derived_node_style(host: &DocumentHo
unsafe { write_and_pay(host, node_read(), LayoutWrite::AdoptDerivedNodeStyle { node, record }) };
}
+/// The style record the render side installed in the box `node` ahead of the host with the style update the host
+/// took last, which the box's layout node adopts without publishing it again, or 0 where it installed none.
+#[unsafe(no_mangle)]
+pub extern "C" fn render_state_installed_style_record(host: &DocumentHost, node: NodeSlotId) -> u64 {
+ host.render_state_installed_box_record(node).unwrap_or(0)
+}
+
/// The anonymous rows below the row inherit its style again, which their layout nodes hear of once the host has its next
/// job back. A table box, which `is_table_box` says the row's style makes it, may itself take a record the arena derives
/// as its wrapper inherits its style again, which its layout node hears of before it reads its style again.
diff --git a/Libraries/LibWeb/Rust/src/layout/layout_pass.rs b/Libraries/LibWeb/Rust/src/layout/layout_pass.rs
index 9c7d24e880f..85cf150b46e 100644
--- a/Libraries/LibWeb/Rust/src/layout/layout_pass.rs
+++ b/Libraries/LibWeb/Rust/src/layout/layout_pass.rs
@@ -49,7 +49,7 @@ pub(crate) struct LayoutPass<'arena> {
/// https://drafts.csswg.org/css-anchor-position-1/#apply-a-position-option
struct PositionOptionStyle<'pass> {
node: Node,
- style: super::node_data::StylePayloadsRef,
+ style: super::node_data::LayoutStyleRef,
enclosing: Option<&'pass PositionOptionStyle<'pass>>,
}
@@ -142,7 +142,7 @@ impl<'arena> LayoutPass<'arena> {
pub(crate) fn with_position_option_style<R>(
self,
node: Node,
- style: super::node_data::StylePayloadsRef,
+ style: super::node_data::LayoutStyleRef,
run: impl for<'option> FnOnce(LayoutPass<'option>) -> R,
) -> R {
let position_option_style = PositionOptionStyle {
@@ -159,7 +159,7 @@ impl<'arena> LayoutPass<'arena> {
/// The style the style reads of `node` see in place of the style of its row, if any.
#[inline]
- fn position_option_style(&self, node: Node) -> Option<super::node_data::StylePayloadsRef> {
+ fn position_option_style(&self, node: Node) -> Option<super::node_data::LayoutStyleRef> {
let mut position_option_style = self.position_option_styles;
while let Some(option) = position_option_style {
if option.node == node {
@@ -264,21 +264,11 @@ impl<'arena> LayoutPass<'arena> {
}
#[inline]
- pub(crate) fn style_payloads(&self, node: Node) -> &'arena FfiStylePayloads {
- self.style_payloads_if_styled(node)
+ pub(crate) fn style_view(&self, node: Node) -> ComputedValuesView<'arena> {
+ self.computed_values_view_if_styled(node)
.expect("styled node must publish its style container before layout")
}
- /// The style of `node`: that of its row, or the position option it is being laid out with.
- #[inline]
- pub(crate) fn style_payloads_if_styled(&self, node: Node) -> Option<&'arena FfiStylePayloads> {
- if let Some(style) = self.position_option_style(node) {
- // SAFETY: A position option's style stays alive while a box is laid out with it.
- return unsafe { super::node_data::style_payloads(style) };
- }
- self.arena.style_payloads(node)
- }
-
pub(crate) fn replaced_content_facts(&self, node: Node) -> Option<ReplacedContentFacts> {
self.arena.replaced_content_facts(node)
}
@@ -288,9 +278,14 @@ impl<'arena> LayoutPass<'arena> {
self.arena.has_replaced_content_facts(node)
}
+ /// The style of `node`: that of its row, or the position option it is being laid out with.
+ #[inline]
pub(crate) fn computed_values_view_if_styled(&self, node: Node) -> Option<ComputedValuesView<'arena>> {
- self.style_payloads_if_styled(node)
- .map(|payloads| ComputedValuesView::new(&payloads.groups))
+ if let Some(style) = self.position_option_style(node) {
+ // SAFETY: A position option's style stays alive while a box is laid out with it.
+ return Some(unsafe { style.view() });
+ }
+ self.arena.style_view(node)
}
pub(crate) fn can_skip_is_anonymous_text_run(&self, node: Node) -> bool {
diff --git a/Libraries/LibWeb/Rust/src/layout/line_builder.rs b/Libraries/LibWeb/Rust/src/layout/line_builder.rs
index 2f5eafad1e8..a1b2230561d 100644
--- a/Libraries/LibWeb/Rust/src/layout/line_builder.rs
+++ b/Libraries/LibWeb/Rust/src/layout/line_builder.rs
@@ -87,7 +87,7 @@ pub(crate) struct LineBuilder<'builder, 'context> {
style_cache: Cell<Option<(Node, StyleValues<'context>)>>,
/// The lookups behind the facts last asked for. Keeping the facts themselves copied the pass they
/// hold into the cell and back, and the copy of the pass's padded tail stalled the loads after it.
- facts_cache: Cell<Option<(Node, &'builder NodeData, Option<&'builder FfiStylePayloads>)>>,
+ facts_cache: Cell<Option<(Node, &'builder NodeData, Option<ComputedValuesView<'builder>>)>>,
}
impl<'builder, 'context> LineBuilder<'builder, 'context> {
@@ -226,7 +226,7 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {
return NodeFacts::from_lookups(&self.context.callbacks, node, data, style_payloads);
}
let facts = NodeFacts::new(&self.context.callbacks, node);
- self.facts_cache.set(Some((node, facts.data(), facts.style_payloads())));
+ self.facts_cache.set(Some((node, facts.data(), facts.style_view())));
facts
}
@@ -1443,7 +1443,10 @@ impl TextLayoutBounds {
// NB: The bounds above already enclose the glyphs of the first available font.
if let Some(font) = font
&& style.line_height_is_normal()
- && font.as_raw() != style.font().first_available_font
+ && style
+ .font()
+ .first_available_font()
+ .is_none_or(|first_available| font.as_raw() != first_available.as_raw())
{
bounds.ascent = bounds.ascent.max(CssPixels::nearest_value_for_f32(font.facts().ascent));
bounds.descent = bounds
diff --git a/Libraries/LibWeb/Rust/src/layout/mod.rs b/Libraries/LibWeb/Rust/src/layout/mod.rs
index c22b5d94734..81cd73db533 100644
--- a/Libraries/LibWeb/Rust/src/layout/mod.rs
+++ b/Libraries/LibWeb/Rust/src/layout/mod.rs
@@ -82,7 +82,6 @@ pub(crate) use crate::layout::layout_node_arena::{
HostStyle, LayoutNodeArena, LiveRow, PublishedBoundRows, RowsVersion, SLOTS_PER_CHUNK, SampleKind, StyleRelayout,
};
use crate::layout::node_data::AncestorFact;
-pub use crate::layout::node_data::FfiStylePayloads;
use crate::layout::node_data::NodeData;
use crate::layout::node_data::NodeFlag;
use crate::layout::node_data::NodeKind;
@@ -99,6 +98,7 @@ pub(crate) use geometry::{
};
pub(crate) use host_tables::{ArenaHandle, HostTables};
pub(crate) use layout_node_arena::HeldNode as ArenaHeldNode;
+pub(crate) use layout_node_arena::{ElementInstall, StyledRows};
pub(crate) use layout_pass::LayoutPass;
pub(crate) use node_facts::NodeFacts;
pub(crate) use partial_relayout::HeldNode as PartialRelayoutHeldNode;
diff --git a/Libraries/LibWeb/Rust/src/layout/node_data.rs b/Libraries/LibWeb/Rust/src/layout/node_data.rs
index bf599bfc421..4704e82a694 100644
--- a/Libraries/LibWeb/Rust/src/layout/node_data.rs
+++ b/Libraries/LibWeb/Rust/src/layout/node_data.rs
@@ -35,25 +35,56 @@ pub(crate) const fn pseudo_kind_of(generated_for: u8) -> u8 {
generated_for - 1
}
-// The full C++ StyleGroupIndex space; LayoutRustBridge.cpp static-asserts the
-// count so the style container array and the registered group indices line up.
-pub const STYLE_GROUP_COUNT: usize = 23;
-
-/// Where a row's computed style is: the group payload array of the style record pinned for the
-/// row, or null for a row with no style. The array and the groups it names are immutable, so the
-/// row shares it as a `HostShared` rather than as a raw pointer.
-pub(crate) type StylePayloadsRef = crate::css::host_shared::HostShared<FfiStylePayloads>;
-
-/// The group payload array a row's style addresses, or `None` for a row with no style.
-///
-/// # Safety
-///
-/// The style record pinned for the row must outlive `'a`.
-#[inline]
-pub(crate) unsafe fn style_payloads<'a>(style: StylePayloadsRef) -> Option<&'a FfiStylePayloads> {
- // SAFETY: A non-null style pointer addresses the group pointer array of the style record, which
- // FfiStylePayloads mirrors exactly, and the caller keeps the record alive for 'a.
- (!style.is_null()).then(|| unsafe { style.deref() })
+/// The style a row is laid out by: the groups at the front of the style record the row pins, of an
+/// anonymous box's style or of an animation overlay. A copy counts no reference: whoever made the
+/// row's style keeps it alive while the row holds it.
+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
+#[repr(transparent)]
+pub(crate) struct LayoutStyleRef(std::ptr::NonNull<crate::css::computed_value_views::StyleRecordGroups>);
+
+const _: () = assert!(size_of::<LayoutStyleRef>() == 8 && size_of::<Option<LayoutStyleRef>>() == 8);
+
+// SAFETY: A style's groups are immutable while a row holds them, and the handle touches no
+// reference count, so sharing one shares only reads.
+unsafe impl Send for LayoutStyleRef {}
+unsafe impl Sync for LayoutStyleRef {}
+
+impl LayoutStyleRef {
+ pub(crate) fn of(groups: &crate::css::computed_value_views::StyleRecordGroups) -> Self {
+ Self(std::ptr::NonNull::from(groups))
+ }
+
+ pub(crate) fn of_groups(groups: &crate::css::computed_values::StyleGroups) -> Self {
+ Self::of(crate::css::computed_value_views::StyleRecordGroups::of(groups))
+ }
+
+ /// The style `pointer` names, as the host passes one, or `None` for null.
+ ///
+ /// # Safety
+ /// A non-null `pointer` must point at the groups of a style that outlives every row holding it.
+ pub(crate) unsafe fn from_raw(pointer: *const c_void) -> Option<Self> {
+ std::ptr::NonNull::new(pointer.cast_mut()).map(|pointer| Self(pointer.cast()))
+ }
+
+ pub(crate) fn as_ptr(self) -> *const c_void {
+ self.0.as_ptr().cast_const().cast()
+ }
+
+ /// A style no read reaches, for a row a test lays out without reading its style.
+ #[cfg(test)]
+ pub(crate) fn dangling() -> Self {
+ Self(std::ptr::NonNull::dangling())
+ }
+
+ /// The style's computed values.
+ ///
+ /// # Safety
+ /// The style must stay alive and unchanged for `'a`.
+ #[inline]
+ pub(crate) unsafe fn view<'a>(self) -> crate::css::computed_value_views::ComputedValuesView<'a> {
+ // SAFETY: As the caller guarantees.
+ crate::css::computed_value_views::ComputedValuesView::of_record_groups(unsafe { self.0.as_ref() })
+ }
}
impl From<crate::painting::host::FfiNaturalSize> for crate::css::style::NaturalSize {
@@ -82,25 +113,6 @@ impl From<crate::css::style::NaturalSize> for crate::painting::host::FfiNaturalS
}
}
-#[derive(Clone, Copy)]
-#[repr(C)]
-pub struct FfiStylePayloads {
- pub groups: [*const c_void; STYLE_GROUP_COUNT],
-}
-
-// SAFETY: A style record's payload array is written once, as the record is interned, and never
-// through a shared reference, and the groups it points at are immutable while the record is pinned.
-// Sharing one shares only reads.
-unsafe impl Sync for FfiStylePayloads {}
-
-impl Default for FfiStylePayloads {
- fn default() -> Self {
- Self {
- groups: [std::ptr::null(); STYLE_GROUP_COUNT],
- }
- }
-}
-
pub use super::node_slot_id::{MAX_NODE_SLOT_COUNT, NodeSlotId};
/// A DOM node, named the way the host names one without pointing at it: the document, by itself,
@@ -293,7 +305,7 @@ pub(crate) struct NodeData {
pub table_row_span: u16,
pub dom_paint_facts: ShapeCell<u8>,
pub ancestor_facts: u8,
- pub style: ShapeCell<StylePayloadsRef>,
+ pub style: ShapeCell<Option<LayoutStyleRef>>,
}
impl Default for NodeData {
@@ -314,7 +326,7 @@ impl Default for NodeData {
dom_paint_facts: ShapeCell::new(0),
ancestor_facts: 0,
fragment_cache_epoch: 0,
- style: ShapeCell::new(StylePayloadsRef::null()),
+ style: ShapeCell::new(None),
}
}
}
@@ -353,7 +365,7 @@ pub(crate) struct PaintNode {
pub(crate) last_child: NodeSlotId,
pub(crate) previous_sibling: NodeSlotId,
pub(crate) next_sibling: NodeSlotId,
- pub(crate) style: StylePayloadsRef,
+ pub(crate) style: Option<LayoutStyleRef>,
/// The style record the row is built from, or 0.
pub(crate) style_record: u64,
/// The node whose style the row carries.
@@ -376,7 +388,7 @@ impl Default for PaintNode {
last_child: NodeSlotId::INVALID,
previous_sibling: NodeSlotId::INVALID,
next_sibling: NodeSlotId::INVALID,
- style: StylePayloadsRef::null(),
+ style: None,
style_record: 0,
style_node: None,
style_is_derived: false,
@@ -415,10 +427,7 @@ impl PaintNode {
/// The node's computed style, or `None` for a node without one.
pub(crate) fn style(&self) -> Option<crate::css::computed_value_views::ComputedValuesView<'_>> {
// SAFETY: No style record is released while a recording reads the rows published for it.
- let payloads = unsafe { style_payloads(self.style) }?;
- Some(crate::css::computed_value_views::ComputedValuesView::new(
- &payloads.groups,
- ))
+ self.style.map(|style| unsafe { style.view() })
}
}
diff --git a/Libraries/LibWeb/Rust/src/layout/node_facts.rs b/Libraries/LibWeb/Rust/src/layout/node_facts.rs
index ac9ea9aa0c9..6e554342566 100644
--- a/Libraries/LibWeb/Rust/src/layout/node_facts.rs
+++ b/Libraries/LibWeb/Rust/src/layout/node_facts.rs
@@ -345,13 +345,8 @@ fn auto_content_size(
/// The node's own computed style, read off the style container the node data points at. Callers inside a layout pass go
/// through the pass callbacks instead; this is for the node-data entry points the C++ side calls directly.
pub(crate) fn node_style_view(data: &NodeData) -> Option<ComputedValuesView<'_>> {
- if data.style.get().is_null() {
- return None;
- }
- // SAFETY: A non-null style pointer addresses the container's group
- // pointer array, which FfiStylePayloads mirrors exactly.
- let payloads = unsafe { data.style.get().deref() };
- Some(ComputedValuesView::new(&payloads.groups))
+ // SAFETY: The arena pins the style of each of its rows while the row holds it.
+ data.style.get().map(|style| unsafe { style.view() })
}
pub(crate) fn style_insets_use_anchor_functions(style: ComputedValuesView<'_>) -> bool {
@@ -400,14 +395,11 @@ pub(crate) fn node_is_positioned(data: &impl NodeShape, style: Option<ComputedVa
};
let box_values = style.box_values();
let is_flex_or_grid_item = has_flag(data, NodeFlag::IsFlexItem) || has_flag(data, NodeFlag::IsGridItem);
- box_values.position != crate::css::css_enums::positioning::STATIC
- || (is_flex_or_grid_item && box_values.has_z_index)
+ style.position() != crate::css::css_enums::positioning::STATIC || (is_flex_or_grid_item && box_values.has_z_index)
}
pub(crate) fn node_position(style: Option<ComputedValuesView<'_>>) -> u8 {
- style.map_or(crate::css::css_enums::positioning::STATIC, |style| {
- style.box_values().position
- })
+ style.map_or(crate::css::css_enums::positioning::STATIC, |style| style.position())
}
/// Flex items never float, whatever their computed float value says.
@@ -819,19 +811,19 @@ pub(crate) struct NodeFacts<'pass> {
callbacks: LayoutPass<'pass>,
node: Node,
data: &'pass NodeData,
- style_payloads: Option<&'pass FfiStylePayloads>,
+ style: Option<ComputedValuesView<'pass>>,
}
impl<'pass> NodeFacts<'pass> {
#[inline]
pub(crate) fn new(callbacks: &LayoutPass<'pass>, node: Node) -> Self {
let data = callbacks.node_data(node);
- let style_payloads = callbacks.style_payloads_if_styled(node);
+ let style = callbacks.computed_values_view_if_styled(node);
Self {
callbacks: *callbacks,
node,
data,
- style_payloads,
+ style,
}
}
@@ -841,13 +833,13 @@ impl<'pass> NodeFacts<'pass> {
callbacks: &LayoutPass<'pass>,
node: Node,
data: &'pass NodeData,
- style_payloads: Option<&'pass FfiStylePayloads>,
+ style: Option<ComputedValuesView<'pass>>,
) -> Self {
Self {
callbacks: *callbacks,
node,
data,
- style_payloads,
+ style,
}
}
@@ -855,8 +847,8 @@ impl<'pass> NodeFacts<'pass> {
self.data
}
- pub(super) fn style_payloads(&self) -> Option<&'pass FfiStylePayloads> {
- self.style_payloads
+ pub(super) fn style_view(&self) -> Option<ComputedValuesView<'pass>> {
+ self.style
}
/// The writing mode of the box's parent box, which it lays out its contents in if it has another one.
@@ -873,7 +865,7 @@ impl<'pass> NodeFacts<'pass> {
pub(super) fn style(&self) -> StyleValues<'pass> {
StyleValues::new(
- self.style_payloads
+ self.style
.expect("styled node must publish its style container before layout"),
)
.for_kind(self.data().kind.get())
@@ -881,8 +873,7 @@ impl<'pass> NodeFacts<'pass> {
}
pub(super) fn computed_values_view_if_styled(&self) -> Option<ComputedValuesView<'pass>> {
- self.style_payloads
- .map(|payloads| ComputedValuesView::new(&payloads.groups))
+ self.style
}
pub(super) fn parent_computed_values_view_if_styled(&self) -> Option<ComputedValuesView<'pass>> {
@@ -1430,7 +1421,7 @@ impl<'pass> NodeFacts<'pass> {
}
pub(crate) fn display(&self) -> crate::layout::FfiDisplay {
- if self.data().style.get().is_null() {
+ if self.data().style.get().is_none() {
return crate::layout::FfiDisplay::block();
}
self.style().display()
diff --git a/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs b/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs
index 447726011cd..dbc56f6eebb 100644
--- a/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs
+++ b/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs
@@ -189,9 +189,8 @@ impl LayoutNodeArena {
// boundary triggers ancestor scrollable overflow recomputation after commit.
let parent_style = (!data.parent.get().is_invalid())
- .then(|| self.style_payloads(data.parent.get()))
- .flatten()
- .map(|payloads| crate::css::computed_value_views::ComputedValuesView::new(&payloads.groups));
+ .then(|| self.style_view(data.parent.get()))
+ .flatten();
matches!(
formatting_context_type_created_by_node_data(
data,
@@ -556,7 +555,7 @@ impl LayoutNodeArena {
}
let style = node_facts::node_style_view(data)?;
let anchor = style.anchor();
- if style.box_values().position != positioning::ABSOLUTE
+ if style.position() != positioning::ABSOLUTE
|| style.has_position_anchor()
|| anchor.position_area.length != 0
|| anchor.position_try_fallbacks.length != 0
@@ -608,9 +607,8 @@ impl LayoutNodeArena {
let parent_style = node_facts::node_style_view(parent_data);
let grandparent = parent_data.parent.get();
let grandparent_style = (!grandparent.is_invalid())
- .then(|| self.style_payloads(grandparent))
- .flatten()
- .map(|payloads| crate::css::computed_value_views::ComputedValuesView::new(&payloads.groups));
+ .then(|| self.style_view(grandparent))
+ .flatten();
if !matches!(
formatting_context_type_created_by_node_data(
parent_data,
@@ -693,6 +691,41 @@ impl LayoutNodeArena {
self.push_paint_damage(parent, damage);
}
+ /// Marks for layout every box whose style renders in one of the font cascades of `font_lists`, which loads filled
+ /// faces into in place: as with a font fallback list resolving a loaded face, the styles stay, and only what lays
+ /// their text out runs again.
+ pub(crate) fn relayout_users_of_font_lists(&mut self, font_lists: &[u64]) {
+ let mut users = Vec::new();
+ let mut node = self.bound_viewport_row();
+ while !node.is_invalid() {
+ if self
+ .node_style_if_live(node)
+ .is_some_and(|style| font_lists.contains(&(style.font().font_cascade_list.as_raw() as u64)))
+ {
+ users.push(node);
+ }
+ let data = self.data(node);
+ node = data.first_child.get();
+ if node.is_invalid() {
+ let mut current = data;
+ loop {
+ node = current.next_sibling.get();
+ if !node.is_invalid() {
+ break;
+ }
+ let parent = current.parent.get();
+ if parent.is_invalid() {
+ break;
+ }
+ current = self.data(parent);
+ }
+ }
+ }
+ for user in users {
+ self.set_needs_layout_update(user, true);
+ }
+ }
+
pub(crate) fn set_needs_layout_update(&mut self, node: NodeSlotId, propagate_through_ancestors: bool) {
self.invalidate_one(node, AncestorInvalidation::ContentChange);
diff --git a/Libraries/LibWeb/Rust/src/layout/rendered_text.rs b/Libraries/LibWeb/Rust/src/layout/rendered_text.rs
index ac886e7e325..e643b40b6d6 100644
--- a/Libraries/LibWeb/Rust/src/layout/rendered_text.rs
+++ b/Libraries/LibWeb/Rust/src/layout/rendered_text.rs
@@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+use super::LayoutNodeArena;
use super::node_data::NodeSlotId;
use super::text_transform::{TextRenderingOptions, may_require_bidi_processing, render_text};
-use super::{ComputedValuesView, LayoutNodeArena};
use crate::css::css_enums::text_transform;
use std::cell::RefCell;
use std::sync::Arc;
@@ -120,8 +120,7 @@ pub(crate) fn enroll_text_after_language_change(arena: &mut LayoutNodeArena, roo
}
let parent = arena.data(node).parent.get();
!parent.is_invalid()
- && arena.style_payloads(parent).is_some_and(|style| {
- let values = ComputedValuesView::new(&style.groups);
+ && arena.style_view(parent).is_some_and(|values| {
transform_uses_locale(values.inherited_text().text_transform)
|| values.line_break() == crate::css::css_enums::line_break::LOOSE
})
@@ -163,6 +162,9 @@ pub(crate) struct TextChunkCacheKey {
pub(crate) line_break_language: super::text_chunker::LineBreakLanguage,
pub(crate) font_variant_emoji: u8,
pub(crate) frozen_font_list: std::sync::Arc<libgfx_rust::font::FrozenFontList>,
+ /// How many times loads had filled faces of the frozen cascade in, each of which can move the
+ /// font of a chunk.
+ pub(crate) frozen_font_list_fill_generation: u32,
pub(crate) splits_at_orientation_changes: bool,
}
@@ -177,8 +179,9 @@ impl PartialEq for TextChunkCacheKey {
&& self.line_break_language == other.line_break_language
&& self.font_variant_emoji == other.font_variant_emoji
&& self.splits_at_orientation_changes == other.splits_at_orientation_changes
- // A frozen cascade is immutable, so naming the same one is the whole of equality.
+ // A frozen cascade only moves when a load fills one of its faces in.
&& std::sync::Arc::ptr_eq(&self.frozen_font_list, &other.frozen_font_list)
+ && self.frozen_font_list_fill_generation == other.frozen_font_list_fill_generation
}
}
@@ -227,10 +230,14 @@ impl TextContent {
/// text is still that text.
#[derive(Default)]
pub(crate) struct TextMemos {
- chunks: RefCell<Vec<Option<ChunksOfText>>>,
+ /// In chunks a fork of the arena shares until either side writes one, so forking does not copy every row's memo.
+ chunks: RefCell<crate::cow_column::CowVec<Option<ChunksOfText>, CHUNK_MEMOS_PER_CHUNK>>,
grapheme_segmenters: RefCell<Vec<Option<GraphemeSegmenterOfText>>>,
}
+/// How many rows' chunk memos a chunk of [`TextMemos::chunks`] holds: a write after a fork copies this many.
+const CHUNK_MEMOS_PER_CHUNK: usize = 128;
+
/// The chunks a run made of a row's rendered text, and that text.
#[derive(Clone)]
struct ChunksOfText {
@@ -279,7 +286,7 @@ impl TextMemos {
});
let mut chunks = self.chunks.borrow_mut();
if chunks.len() <= index {
- chunks.resize_with(index + 1, || None);
+ chunks.resize_with_default(index + 1);
}
chunks[index] = Some(ChunksOfText {
rendered: rendered.clone(),
@@ -312,8 +319,9 @@ impl TextMemos {
/// Lets go of what the memos keep for the row in `slot`, which the arena freed.
pub(crate) fn forget(&self, slot: u32) {
- if let Some(chunks) = self.chunks.borrow_mut().get_mut(slot as usize) {
- *chunks = None;
+ let mut chunks = self.chunks.borrow_mut();
+ if chunks.get(slot as usize).is_some_and(Option::is_some) {
+ chunks[slot as usize] = None;
}
if let Some(segmenter) = self.grapheme_segmenters.borrow_mut().get_mut(slot as usize) {
*segmenter = None;
@@ -445,20 +453,15 @@ pub(super) fn ensure_text_content(arena: &mut LayoutNodeArena, id: NodeSlotId) {
fn sync_text_content(arena: &mut LayoutNodeArena, id: NodeSlotId) {
let parent = arena.data(id).parent.get();
- let inherited = ComputedValuesView::new(
- &arena
- .style_payloads(parent)
- .expect("text parent must have style")
- .groups,
- )
- .inherited_text();
+ let parent_style = arena.style_view(parent).expect("text parent must have style");
+ let inherited = parent_style.inherited_text();
let uses_locale = transform_uses_locale(inherited.text_transform);
let input = arena.published_text_source(id, uses_locale);
let source_length = length_in_code_units(&input.data);
let source_range = arena.text_source_range(id, source_length);
let options = TextRenderingOptions {
text_transform: inherited.text_transform,
- white_space_collapse: inherited.white_space_collapse,
+ white_space_collapse: parent_style.white_space_collapse(),
is_password_input: input.is_password_input,
dom_start_offset: source_range.start,
dom_length_in_code_units: source_range.length,
@@ -529,6 +532,7 @@ mod tests {
line_break_language: LineBreakLanguage::Japanese,
font_variant_emoji: 0,
frozen_font_list: std::sync::Arc::new(libgfx_rust::font::FrozenFontList::empty()),
+ frozen_font_list_fill_generation: 0,
splits_at_orientation_changes: false,
};
let memos = TextMemos::default();
@@ -576,6 +580,7 @@ mod tests {
line_break_language: crate::layout::text_chunker::LineBreakLanguage::Other,
font_variant_emoji: 0,
frozen_font_list: std::sync::Arc::new(libgfx_rust::font::FrozenFontList::empty()),
+ frozen_font_list_fill_generation: 0,
splits_at_orientation_changes: false,
};
let chunk = TextChunk {
@@ -845,7 +850,7 @@ mod tests {
arena.set_text_content(node, text);
assert!(!arena.text_content_needs_sync(node));
- arena.set_node_style(parent, 1, crate::layout::node_data::StylePayloadsRef::null());
+ arena.set_node_style(parent, 1, None);
let pending = arena.pending_text_nodes_for_content_sync();
assert_eq!(pending, [node]);
assert!(arena.text_content_needs_sync(node));
diff --git a/Libraries/LibWeb/Rust/src/layout/row_reads.rs b/Libraries/LibWeb/Rust/src/layout/row_reads.rs
index e6561d30891..5be48bdab3e 100644
--- a/Libraries/LibWeb/Rust/src/layout/row_reads.rs
+++ b/Libraries/LibWeb/Rust/src/layout/row_reads.rs
@@ -14,7 +14,7 @@ use super::RowsVersion;
use super::host_tables::ShellFacts;
use super::layout_node_arena::PublishedBoundRows;
use super::node_data::{
- CompositorAnimationFrameKind, FfiNodeLink, NodeFlag, NodeKind, NodeSlotId, PaintNode, StylePayloadsRef,
+ CompositorAnimationFrameKind, FfiNodeLink, LayoutStyleRef, NodeFlag, NodeKind, NodeSlotId, PaintNode,
};
use super::node_facts;
use crate::css::style::tree::StyleNodeID;
@@ -131,7 +131,7 @@ impl RowSnapshot {
self.live_node(id).style_record
}
- pub(crate) fn style_payloads(&self, id: NodeSlotId) -> StylePayloadsRef {
+ pub(crate) fn style(&self, id: NodeSlotId) -> Option<LayoutStyleRef> {
self.live_node(id).style
}
@@ -231,8 +231,8 @@ impl RowStyles {
self.0.style_record(id)
}
- pub(crate) fn style_payloads(&self, id: NodeSlotId) -> StylePayloadsRef {
- self.0.style_payloads(id)
+ pub(crate) fn style(&self, id: NodeSlotId) -> Option<LayoutStyleRef> {
+ self.0.style(id)
}
pub(crate) fn style_is_derived(&self, id: NodeSlotId) -> bool {
diff --git a/Libraries/LibWeb/Rust/src/layout/shell_reads.rs b/Libraries/LibWeb/Rust/src/layout/shell_reads.rs
index 90daa9fe060..9c526032104 100644
--- a/Libraries/LibWeb/Rust/src/layout/shell_reads.rs
+++ b/Libraries/LibWeb/Rust/src/layout/shell_reads.rs
@@ -106,8 +106,10 @@ pub extern "C" fn layout_row_style_is_derived(host: &DocumentHost, id: NodeSlotI
}
#[unsafe(no_mangle)]
-pub extern "C" fn layout_row_style_payloads(host: &DocumentHost, id: NodeSlotId) -> *const c_void {
- styles(host, id, node_read()).style_payloads(id).as_ptr().cast()
+pub extern "C" fn layout_row_style(host: &DocumentHost, id: NodeSlotId) -> *const c_void {
+ styles(host, id, node_read())
+ .style(id)
+ .map_or(std::ptr::null(), |style| style.as_ptr())
}
#[unsafe(no_mangle)]
diff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
index a9f757b55f3..efcbe98cb77 100644
--- a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
@@ -227,7 +227,7 @@ impl<'cells> SizedCells<'cells> {
pub(crate) struct SizingContext<'pass, 'container> {
state: &'pass RunState,
callbacks: LayoutPass<'pass>,
- style_cache: Cell<Option<(Node, &'pass FfiStylePayloads)>>,
+ style_cache: Cell<Option<(Node, ComputedValuesView<'pass>)>>,
child_run_shapes: Option<&'container dyn formatting_context::ChildRunShapes>,
}
@@ -312,7 +312,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
let payloads = match self.style_cache.get() {
Some((cached_node, payloads)) if cached_node == node => payloads,
_ => {
- let payloads = self.callbacks.style_payloads(node);
+ let payloads = self.callbacks.style_view(node);
self.style_cache.set(Some((node, payloads)));
payloads
}
@@ -4382,14 +4382,11 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
#[cfg(test)]
mod replaced_ratio_tests {
use super::*;
- use crate::css::computed_values::{
- BoxValues, GroupPayloadRef, SizingValues, clone_group_payload, release_group_payload,
- };
+ use crate::css::style::layout_style::LayoutScratchStyle;
use crate::css::style_value::{RetainedStyleValueData, StyleValueData};
- use crate::css::table_group_builder::group_index;
use crate::layout::formatting_context::LayoutStageFacts;
use crate::layout::layout_node_arena::LayoutNodeArena;
- use crate::layout::node_data::{NodeConstructionFacts, NodeKind, StylePayloadsRef};
+ use crate::layout::node_data::{NodeConstructionFacts, NodeKind};
use crate::layout::run_state::LayoutScratch;
fn size(
@@ -4401,15 +4398,8 @@ mod replaced_ratio_tests {
) -> (i32, i32) {
let mut arena = LayoutNodeArena::new();
let scratch = LayoutScratch::default();
- let mut style = FfiStylePayloads {
- groups: std::array::from_fn(|index| GroupPayloadRef::default_payload(index).as_ptr()),
- };
- // SAFETY: Each cloned immortal default payload is private until installed in this test's arena.
- let box_payload = unsafe { clone_group_payload(group_index::BOX, style.groups[group_index::BOX]) };
- let sizing_payload = unsafe { clone_group_payload(group_index::SIZING, style.groups[group_index::SIZING]) };
- // SAFETY: These clones have the corresponding payload layouts and no readers yet.
- unsafe {
- let box_values = &mut *box_payload.cast::<BoxValues>();
+ let style = LayoutScratchStyle::over_defaults(|style| {
+ let box_values = style.box_mut();
box_values.display = crate::css::display::FfiDisplay::block();
box_values.aspect_ratio.has_preferred_ratio = fallback;
box_values.aspect_ratio.preferred_ratio_numerator = 2.0;
@@ -4419,10 +4409,8 @@ mod replaced_ratio_tests {
value: 40.0,
unit: crate::css::style_compute::px_length_unit(),
});
- (*sizing_payload.cast::<SizingValues>()).max_height = ComputedSize::from_data(&length);
- }
- style.groups[group_index::BOX] = box_payload;
- style.groups[group_index::SIZING] = sizing_payload;
+ style.sizing_mut().max_height = ComputedSize::from_data(&length);
+ });
let node = arena.allocate(NodeConstructionFacts {
kind: NodeKind::ImageBox,
is_anonymous: false,
@@ -4436,7 +4424,7 @@ mod replaced_ratio_tests {
dom_paint_facts: 0,
style_node: 0,
});
- arena.set_node_style(node, 0, StylePayloadsRef::new(&raw const style));
+ arena.set_node_style(node, 0, Some(style.style()));
arena.set_replaced_content_facts(
node,
node_facts::ReplacedContentFacts {
@@ -4479,8 +4467,6 @@ mod replaced_ratio_tests {
arena
.free_subtree(node)
.destroy_shells_and_invoke_callbacks(&crate::stage::MainThread::for_test());
- release_group_payload(group_index::SIZING, sizing_payload);
- release_group_payload(group_index::BOX, box_payload);
result
}
diff --git a/Libraries/LibWeb/Rust/src/layout/style_values.rs b/Libraries/LibWeb/Rust/src/layout/style_values.rs
index dd5167e2c03..f856ea6982a 100644
--- a/Libraries/LibWeb/Rust/src/layout/style_values.rs
+++ b/Libraries/LibWeb/Rust/src/layout/style_values.rs
@@ -212,9 +212,9 @@ impl<'a> std::ops::Deref for StyleValues<'a> {
impl<'a> StyleValues<'a> {
#[inline]
- pub(crate) fn new(payloads: &'a FfiStylePayloads) -> Self {
+ pub(crate) fn new(payloads: ComputedValuesView<'a>) -> Self {
Self {
- style: ComputedValuesView::new(&payloads.groups),
+ style: payloads,
resolved_anchor_insets: None,
anchor_resolved_values: None,
vertical_align_override: None,
@@ -225,7 +225,7 @@ impl<'a> StyleValues<'a> {
#[inline]
pub(crate) fn for_node(callbacks: &LayoutPass<'a>, node: Node) -> Self {
- StyleValues::new(callbacks.style_payloads(node))
+ StyleValues::new(callbacks.style_view(node))
.for_kind(callbacks.node_data(node).kind.get())
.in_frame(callbacks.frame)
}
@@ -767,8 +767,8 @@ unsafe extern "C" fn resolve_unresolvable_anchor_function(context: *mut c_void,
// SAFETY: The context is the percentage basis resolve_calc_with_unresolvable_anchor_functions passes.
let percentage_basis = unsafe { *context.cast::<CssPixels>() };
// SAFETY: `shell` is the live style value the calc core's non-math-function node retains.
- match unsafe { &*shell.cast::<StyleValueData>() } {
- StyleValueData::Anchor { fallback_value, .. } | StyleValueData::AnchorSize { fallback_value, .. } => unsafe {
+ match unsafe { &*shell.cast::<StyleValueData>() }.anchor_name_and_fallback() {
+ Some((_, _, fallback_value)) => unsafe {
anchor_function_fallback_node(
fallback_value,
percentage_basis,
@@ -776,7 +776,7 @@ unsafe extern "C" fn resolve_unresolvable_anchor_function(context: *mut c_void,
resolve_unresolvable_anchor_function,
)
},
- _ => std::ptr::null(),
+ None => std::ptr::null(),
}
}
diff --git a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs
index 53aac474fa0..49504bacf74 100644
--- a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs
@@ -1031,8 +1031,7 @@ impl SvgShapeGeometry {
#[repr(C)]
pub struct FfiSvgGeometryElementShape {
pub geometry: FfiSvgAttributeFacts,
- pub payloads: *const *const c_void,
- pub payload_count: usize,
+ pub style: *const c_void,
pub points: *const FfiFloatPoint,
pub point_count: usize,
pub viewport_size: FfiCssPixelSize,
@@ -1043,21 +1042,19 @@ impl FfiSvgGeometryElementShape {
/// shape builders layout uses, and of the element's style.
///
/// # Safety
- /// `payloads` must point to `payload_count` live style group payloads, and `points` to `point_count` points.
+ /// `style` must point at the groups of a live style record, and `points` to `point_count` points.
unsafe fn measure<R>(&self, measure: impl FnOnce(&libgfx_rust::path::Path, StyleValues<'_>) -> R) -> R {
- assert!(!self.payloads.is_null(), "style group payload array is null");
- let mut style_payloads = FfiStylePayloads::default();
// SAFETY: Guaranteed by the caller.
- style_payloads
- .groups
- .copy_from_slice(unsafe { ak::slice_from_raw_parts(self.payloads, self.payload_count) });
+ let style = unsafe { crate::layout::node_data::LayoutStyleRef::from_raw(self.style) }
+ .expect("an SVG geometry element's style record is not null");
// SAFETY: Guaranteed by the caller.
let points = unsafe { ak::slice_from_raw_parts(self.points, self.point_count) };
let shape_geometry = SvgShapeGeometry {
viewport_width: self.viewport_size.width,
viewport_height: self.viewport_size.height,
};
- let style = StyleValues::new(&style_payloads);
+ // SAFETY: Guaranteed by the caller.
+ let style = StyleValues::new(unsafe { style.view() });
measure(&shape_geometry.path(self.geometry, style, Some(points)), style)
}
}
@@ -1363,16 +1360,16 @@ impl<'pass> SvgFormattingContext<'pass> {
// NB: The dominant-baseline offset is resolved against the metrics of the first available
// font - while each glyph is rendered with the first font in the cascade that contains
// its code point.
- let font = style.font();
+ let font = style.font().first_available_font_metrics();
match metric {
- baseline_metric::CENTRAL => (font.font_ascent - font.font_descent) / 2.0,
- baseline_metric::MIDDLE => font.font_x_height / 2.0,
+ baseline_metric::CENTRAL => (font.ascent - font.descent) / 2.0,
+ baseline_metric::MIDDLE => font.x_height / 2.0,
// FIXME: Read the hanging baseline from the font's BASE table.
- baseline_metric::HANGING => font.font_ascent * 0.8,
+ baseline_metric::HANGING => font.ascent * 0.8,
// FIXME: Read the ideographic baseline from the font's BASE table.
- baseline_metric::IDEOGRAPHIC => -font.font_descent,
+ baseline_metric::IDEOGRAPHIC => -font.descent,
// FIXME: Read the math baseline from the font's BASE table.
- baseline_metric::MATHEMATICAL => font.font_ascent * 0.5,
+ baseline_metric::MATHEMATICAL => font.ascent * 0.5,
// FIXME: Support text-top and text-bottom.
_ => 0.0,
}
@@ -1666,11 +1663,12 @@ impl<'pass> SvgFormattingContext<'pass> {
if attributes.geometry_kind == SVG_GEOMETRY_KIND_NONE {
return None;
}
- let payloads = arena.style_node_style_payloads(shape)?;
+ let style = arena.style_node_style(shape)?;
let points = arena.style_node_svg_points(shape);
Some(
self.shape_geometry()
- .path(attributes, StyleValues::new(&payloads), points.as_deref()),
+ // SAFETY: The record the element published is retained for the pass.
+ .path(attributes, StyleValues::new(unsafe { style.view() }), points.as_deref()),
)
}
@@ -1810,7 +1808,8 @@ impl<'pass> SvgFormattingContext<'pass> {
let style = self.style(node);
let svg = style.inherited_svg();
let stroke_is_visible =
- crate::painting::record::paint::svg::svg_paint_color(&svg.stroke).is_some_and(|color| color >> 24 != 0);
+ crate::painting::record::paint::svg::svg_paint_color(&svg.stroke, style.current_color())
+ .is_some_and(|color| color >> 24 != 0);
if !stroke_is_visible {
return 0.0;
}
@@ -2513,13 +2512,13 @@ impl<'pass> SvgFormattingContext<'pass> {
}
fn font_metrics_for_length_resolution(style: StyleValues<'_>) -> crate::css::style_compute::FfiFontMetrics {
- let font = style.font();
+ let font = style.font().first_available_font_metrics();
crate::css::style_compute::FfiFontMetrics {
font_size: style.font_size().to_double(),
- x_height: CssPixels::nearest_value_for_f32(font.font_x_height).to_double(),
+ x_height: CssPixels::nearest_value_for_f32(font.x_height).to_double(),
// FIXME: This is only approximately the cap height, exactly as Length::FontMetrics has it.
- cap_height: CssPixels::nearest_value_for_f32(font.font_ascent).to_double(),
- zero_advance: CssPixels::nearest_value_for_f32(font.font_zero_advance).to_double(),
+ cap_height: CssPixels::nearest_value_for_f32(font.ascent).to_double(),
+ zero_advance: CssPixels::nearest_value_for_f32(font.zero_advance).to_double(),
line_height: style.line_height().to_double(),
}
}
@@ -2579,7 +2578,7 @@ fn document_element_style<'pass>(callbacks: &LayoutPass<'pass>, node: Node) -> O
while !ancestor.is_invalid() {
let data = callbacks.node_data(ancestor);
if node_facts::has_flag(data, NodeFlag::IsDocumentElement) {
- return callbacks.arena().style_payloads(ancestor).map(StyleValues::new);
+ return callbacks.arena().style_view(ancestor).map(StyleValues::new);
}
ancestor = data.parent.get();
}
diff --git a/Libraries/LibWeb/Rust/src/layout/text_chunker.rs b/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
index 2d2bd542f8b..380220f10eb 100644
--- a/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
+++ b/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
@@ -1308,6 +1308,7 @@ pub(crate) fn text_chunks(
unidirectional_ltr: bool,
) -> std::sync::Arc<super::rendered_text::CachedTextChunks> {
let parent_style = StyleValues::for_node(callbacks, callbacks.parent(node));
+ let frozen_font_list = parent_style.frozen_font_list_ref();
let key = super::rendered_text::TextChunkCacheKey {
should_wrap_lines,
should_respect_linebreaks,
@@ -1321,7 +1322,8 @@ pub(crate) fn text_chunks(
LineBreakLanguage::Other
},
font_variant_emoji: parent_style.font_variant_emoji(),
- frozen_font_list: parent_style.frozen_font_list_ref(),
+ frozen_font_list_fill_generation: frozen_font_list.fill_generation(),
+ frozen_font_list,
splits_at_orientation_changes: matches!(
parent_style.writing_mode(),
writing_mode::VERTICAL_RL | writing_mode::VERTICAL_LR
diff --git a/Libraries/LibWeb/Rust/src/layout/text_queries.rs b/Libraries/LibWeb/Rust/src/layout/text_queries.rs
index 11edd405078..ec6a64597d1 100644
--- a/Libraries/LibWeb/Rust/src/layout/text_queries.rs
+++ b/Libraries/LibWeb/Rust/src/layout/text_queries.rs
@@ -128,8 +128,7 @@ fn collapses_whitespace(rows: &impl PaintRead, node: NodeSlotId) -> bool {
parent
.and_then(|parent| rows.node_style_if_live(parent))
.expect("text parent has style")
- .inherited_text()
- .white_space_collapse,
+ .white_space_collapse(),
white_space_collapse::COLLAPSE | white_space_collapse::PRESERVE_BREAKS
)
}
diff --git a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs
index e1162c9c5f7..963e87f5de9 100644
--- a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs
+++ b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs
@@ -27,12 +27,6 @@ use crate::layout::tree_update_marks::layout_tree_update_reuse_reason;
use crate::layout::{ComputedValuesView, FfiDisplay};
use crate::painting::paint_read::PaintRead;
-mod whitespace_text_boxes;
-
-use whitespace_text_boxes::{
- predicted_whitespace_text_needs_box, starts_with_whitespace_text, whitespace_text_needs_box,
-};
-
type LayoutNode = NodeSlotId;
pub(crate) struct TreeBuilderState {
@@ -51,9 +45,6 @@ pub(crate) struct TreeBuilderState {
/// The elements a finished build asks the document to rebuild. `None` asks for the whole tree:
/// the container the box escaped into stands for no element.
layout_tree_rebuild_requests: Vec<Option<StyleNodeID>>,
- /// The elements whose kept child lists hold a white space text whose box the build could not add or take away in
- /// place, for the document to have their child lists built again. `None` names the document.
- whitespace_text_box_rebuild_requests: Vec<Option<StyleNodeID>>,
/// Whether the build reached an element no style update settled, which it built no box for.
reached_unstyled_element: bool,
/// What the build found out that the document has to be told, in the order it found it out.
@@ -82,7 +73,6 @@ impl Default for TreeBuilderState {
layout_tree_update_escaped_rebuild_roots: false,
new_subtree_root: NodeSlotId::INVALID,
layout_tree_rebuild_requests: Vec::new(),
- whitespace_text_box_rebuild_requests: Vec::new(),
reached_unstyled_element: false,
reports: Vec::new(),
pinned_style_records: Vec::new(),
@@ -173,7 +163,7 @@ fn apply_replaced_display_adjustment(
FfiReplacedElementDisplayAdjustment::Inline => display_outside::INLINE,
FfiReplacedElementDisplayAdjustment::None => return,
};
- arena.update_layout_style(host_calls, node, |style| {
+ arena.update_layout_style(host_calls, node, |style, _| {
style.set_display(FfiDisplay::outside_and_inside(outside, display_inside::FLOW, false));
});
}
@@ -392,9 +382,8 @@ fn svg_resource_box_survives(
return true;
};
arena.with_style_store(|engine| {
- let tree = engine.tree();
// The document holds every node a row stands for.
- let root_is_document = tree.is_relation_only(cleared_subtree_root);
+ let root_is_document = engine.is_relation_only(cleared_subtree_root);
let mut ancestor = arena.data(layout_node).parent.get();
while !ancestor.is_invalid() {
let data = arena.data(ancestor);
@@ -403,7 +392,7 @@ fn svg_resource_box_survives(
root_is_document
} else {
arena.node_style_node(ancestor).is_some_and(|style_node| {
- root_is_document || tree.is_in_shadow_including_subtree_of(style_node, cleared_subtree_root)
+ root_is_document || engine.is_in_shadow_including_subtree_of(style_node, cleared_subtree_root)
})
};
if inside {
@@ -512,6 +501,13 @@ pub(crate) fn principal_box_placement_decision(
}
}
+/// Which way a sibling walk runs.
+#[derive(Clone, Copy, PartialEq, Eq)]
+enum SiblingDirection {
+ Previous,
+ Next,
+}
+
/// Whether the box an element already has can take the children that were just inserted under it,
/// rather than being rebuilt around them.
///
@@ -526,6 +522,9 @@ struct ChildListInsertionReuse<'a, 'host> {
/// Whether a `::first-letter` owner styles the first letter of this subtree, whose source
/// range only a full build can find again.
has_first_letter_owner: bool,
+ /// The last layout child, when it is an anonymous inline run that an inserted text node would
+ /// have to join.
+ trailing_inline_wrapper: LayoutNode,
}
/// Which narrower rebuilds the build settled on for one node.
@@ -616,7 +615,7 @@ fn may_update_pseudo_elements_in_place(
if !kind.is_element()
|| layout_node.is_invalid()
|| layout.data(layout_node).kind.get() != NodeKind::BlockContainer
- || engine.tree().shadow_root_of(element).is_some()
+ || engine.shadow_root_of(element).is_some()
|| engine.element_adjustment_facts(element) & element_adjustment_fact::RENDERED_IN_TOP_LAYER != 0
{
return false;
@@ -644,9 +643,7 @@ fn may_update_pseudo_elements_in_place(
child = layout.next_sibling(child);
}
- if first_letter_owner_covers_subtree(layout, engine, element, layout_node)
- || starts_with_whitespace_text(engine, element)
- {
+ if first_letter_owner_covers_subtree(layout, engine, element, layout_node) {
return false;
}
@@ -709,10 +706,7 @@ fn first_letter_owner_covers_subtree(
}
// The node's parent, or the host of the shadow root it is a child of: the ancestry a
// `::first-letter` owner is looked for along.
- ancestor = engine
- .tree()
- .parent(current)
- .map(|parent| engine.tree().host_of(parent).unwrap_or(parent));
+ ancestor = engine.parent_element_or_host(current);
}
false
}
@@ -727,19 +721,31 @@ fn may_reuse_layout_node_for_child_list_insertion(
let layout_node = arena.bound_row(element);
if !kind.is_element()
|| layout_node.is_invalid()
- || engine.tree().shadow_root_of(element).is_some()
+ || engine.shadow_root_of(element).is_some()
|| engine.element_is_slot(element)
|| engine.element_counter_reset_has_reversed_counter(element)
{
return false;
}
+ let last_layout_child = layout.last_child(layout_node);
+ let trailing_inline_wrapper = if !last_layout_child.is_invalid()
+ && node_facts::has_flag(layout.data(last_layout_child), NodeFlag::Anonymous)
+ && node_facts::has_flag(layout.data(last_layout_child), NodeFlag::ChildrenAreInline)
+ && !node_is_generated_for_pseudo_element(layout.data(last_layout_child))
+ {
+ last_layout_child
+ } else {
+ NodeSlotId::INVALID
+ };
+
let mut test = ChildListInsertionReuse {
layout,
engine,
element,
layout_node,
has_first_letter_owner: false,
+ trailing_inline_wrapper,
};
test.has_first_letter_owner = first_letter_owner_covers_subtree(layout, engine, element, layout_node);
test.run()
@@ -770,7 +776,7 @@ fn may_rebuild_child_list(
if !kind.is_element()
|| layout_node.is_invalid()
|| layout.parent(layout_node).is_invalid()
- || engine.tree().shadow_root_of(element).is_some()
+ || engine.shadow_root_of(element).is_some()
|| engine.element_is_slot(element)
|| engine.element_counter_reset_has_reversed_counter(element)
|| engine.element_box_kind(element) != ElementBoxKind::FromDisplay
@@ -791,6 +797,7 @@ fn may_rebuild_child_list(
element,
layout_node,
has_first_letter_owner: false,
+ trailing_inline_wrapper: NodeSlotId::INVALID,
};
test.child_list_can_be_rebuilt()
}
@@ -812,62 +819,155 @@ impl ChildListInsertionReuse<'_, '_> {
self.arena().needs_layout_tree_update(node)
}
- /// Whether the white space text `text` has a box once the inserted children are built, or `None` where an inserted
- /// child's box is not certain before it is built.
- fn whitespace_text_needs_box_after_insertion(&self, text: StyleNodeID) -> Option<bool> {
- predicted_whitespace_text_needs_box(self.layout, self.engine, self.layout_node, text)
+ fn is_out_of_flow(&self, node: LayoutNode) -> bool {
+ let data = self.layout.data(node);
+ node_kind_is_node_with_style(data.kind.get()) && node_is_out_of_flow(self.layout, node)
+ }
+
+ fn parent_collapses_whitespace(&self) -> bool {
+ self.layout
+ .style(self.layout_node)
+ .is_some_and(|style| style.white_space_collapse() == white_space_collapse::COLLAPSE)
+ }
+
+ /// Whether a text node holding only collapsing whitespace can be spliced in where it sits,
+ /// which needs the boxes on both sides of it to be children of this box.
+ fn collapsing_whitespace_can_be_inserted(&self, text: StyleNodeID) -> bool {
+ let mut will_join_trailing_inline_wrapper = false;
+ if !self.can_place_next_to_sibling(
+ self.engine.previous_sibling_in_dom_order(text),
+ SiblingDirection::Previous,
+ &mut will_join_trailing_inline_wrapper,
+ ) || !self.can_place_next_to_sibling(
+ self.engine.next_sibling_in_dom_order(text),
+ SiblingDirection::Next,
+ &mut will_join_trailing_inline_wrapper,
+ ) {
+ return false;
+ }
+
+ // Incremental inline insertion always reuses a trailing anonymous inline wrapper. If the
+ // whitespace belongs to a different run, only a full rebuild can place it correctly.
+ self.trailing_inline_wrapper.is_invalid() || will_join_trailing_inline_wrapper
}
- /// Whether every white space text child that is not being inserted keeps having a box, or keeps having none, once
- /// the inserted children are built. A text that has to gain or lose its box changes the anonymous wrappers around
- /// it, which only a build of the child list places right.
- fn whitespace_text_boxes_stay(&self) -> bool {
- self.dom_children().all(|child| {
- if child.text_index().is_none() || !self.engine.tree().text_is_ascii_whitespace(child) {
- return true;
+ fn can_place_next_to_layout_node(
+ &self,
+ sibling_layout_node: LayoutNode,
+ direction: SiblingDirection,
+ pseudo_element: Option<u8>,
+ will_join_trailing_inline_wrapper: &mut bool,
+ ) -> bool {
+ if sibling_layout_node.is_invalid() {
+ return true;
+ }
+ if self.is_out_of_flow(sibling_layout_node) && (pseudo_element.is_some() || direction == SiblingDirection::Next)
+ {
+ return false;
+ }
+
+ let mut sibling_layout_node = sibling_layout_node;
+ loop {
+ let parent = self.layout.parent(sibling_layout_node);
+ if parent.is_invalid() || parent == self.layout_node {
+ break;
}
- let has_box = !self.box_of(child).is_invalid();
- if !has_box && self.needs_layout_tree_update(child) {
- return true;
+ sibling_layout_node = parent;
+ }
+ if self.layout.parent(sibling_layout_node) != self.layout_node {
+ return false;
+ }
+ let children_are_inline = node_facts::has_flag(self.layout.data(self.layout_node), NodeFlag::ChildrenAreInline);
+ if let Some(generated_for) = pseudo_element {
+ // ::after cannot anchor a newly appended anonymous wrapper. In normal flow,
+ // inline ::before content also has to remain in its existing inline run, while
+ // blockified flex/grid pseudo-elements remain separate items.
+ if direction == SiblingDirection::Next {
+ return children_are_inline;
}
- self.whitespace_text_needs_box_after_insertion(child) == Some(has_box)
- })
- }
- /// Whether the box has an anonymous child other than one of its generated boxes, as table fixup makes around
- /// table-internal children.
- fn has_anonymous_child_box(&self) -> bool {
- let mut child = self.layout.first_child(self.layout_node);
- while !child.is_invalid() {
- let data = self.layout.data(child);
- if node_facts::has_flag(data, NodeFlag::Anonymous) && !node_is_generated_for_pseudo_element(data) {
- return true;
+ let pseudo_display = self
+ .engine
+ .pseudo_published_box_facts(self.element, pseudo_kind_of(generated_for))
+ .map(|facts| facts.display);
+ let parent_display = self.layout.display(self.layout_node);
+ let pseudo_belongs_to_inline_run = pseudo_display
+ .is_some_and(|display| display.is_inline_outside() || display.is_contents())
+ && !parent_display.is_flex_inside()
+ && !parent_display.is_grid_inside();
+ return children_are_inline || !pseudo_belongs_to_inline_run;
+ }
+ if node_facts::has_flag(self.layout.data(sibling_layout_node), NodeFlag::Anonymous) {
+ if sibling_layout_node != self.trailing_inline_wrapper {
+ return false;
}
- child = self.layout.next_sibling(child);
+ *will_join_trailing_inline_wrapper = true;
}
- false
+ true
}
- /// Whether the inserted text `text` renders nothing: white space that gets no box.
- fn inserted_text_gets_no_box(&self, text: StyleNodeID) -> bool {
- self.engine.tree().text_is_ascii_whitespace(text)
- && self.whitespace_text_needs_box_after_insertion(text) == Some(false)
+ fn can_place_next_to_sibling(
+ &self,
+ sibling: Option<StyleNodeID>,
+ direction: SiblingDirection,
+ will_join_trailing_inline_wrapper: &mut bool,
+ ) -> bool {
+ let mut sibling = sibling;
+ while let Some(current) = sibling {
+ if self
+ .published_display(current)
+ .is_some_and(|display| display.is_contents())
+ {
+ return false;
+ }
+ let sibling_layout_node = self.box_of(current);
+ if !sibling_layout_node.is_invalid() {
+ return self.can_place_next_to_layout_node(
+ sibling_layout_node,
+ direction,
+ None,
+ will_join_trailing_inline_wrapper,
+ );
+ }
+ sibling = match direction {
+ SiblingDirection::Next => self.engine.next_sibling_in_dom_order(current),
+ SiblingDirection::Previous => self.engine.previous_sibling_in_dom_order(current),
+ };
+ }
+
+ let generated_for = match direction {
+ SiblingDirection::Previous => GENERATED_FOR_BEFORE,
+ SiblingDirection::Next => GENERATED_FOR_AFTER,
+ };
+ self.can_place_next_to_layout_node(
+ self.arena().bound_pseudo_element_row(self.element, generated_for),
+ direction,
+ Some(generated_for),
+ will_join_trailing_inline_wrapper,
+ )
}
fn dom_children(&self) -> impl Iterator<Item = StyleNodeID> + '_ {
- let mut next = self.engine.tree().dom_children(self.element).next();
+ let mut next = self.engine.dom_children(self.element).next();
std::iter::from_fn(move || {
let current = next?;
- next = self.engine.tree().next_sibling_in_dom_order(current);
+ next = self.engine.next_sibling_in_dom_order(current);
Some(current)
})
}
/// Whether every child that has no box yet can be spliced in without the parent's own box
- /// being rebuilt: white space that gets no box, or an element with display: none.
+ /// being rebuilt: a collapsing whitespace text node, or an element that renders nothing.
fn pending_children_can_preserve_parent(&self) -> bool {
+ let collapses_whitespace = self.parent_collapses_whitespace();
+ let mut has_pending_collapsing_whitespace = false;
+ let mut inserted_whitespace_run_must_stay_last = false;
for child in self.dom_children() {
if !self.box_of(child).is_invalid() {
+ if inserted_whitespace_run_must_stay_last {
+ return false;
+ }
+ has_pending_collapsing_whitespace = false;
if self.needs_layout_tree_update(child) || self.arena().child_needs_layout_tree_update(Some(child)) {
return false;
}
@@ -876,10 +976,17 @@ impl ChildListInsertionReuse<'_, '_> {
if !self.needs_layout_tree_update(child) {
continue;
}
+ if child.text_index().is_some()
+ && self.engine.text_is_ascii_whitespace(child)
+ && collapses_whitespace
+ && !self.has_first_letter_owner
+ && self.collapsing_whitespace_can_be_inserted(child)
+ {
+ inserted_whitespace_run_must_stay_last |= has_pending_collapsing_whitespace;
+ has_pending_collapsing_whitespace = true;
+ continue;
+ }
if child.text_index().is_some() {
- if self.inserted_text_gets_no_box(child) {
- continue;
- }
return false;
}
if !self.published_display(child).is_some_and(|display| display.is_none()) {
@@ -889,6 +996,36 @@ impl ChildListInsertionReuse<'_, '_> {
true
}
+ /// Whether a row inserted between two existing rows would make the table fixup wrap whitespace
+ /// that sits at the edge of a row group today.
+ fn has_table_row_sibling(&self, sibling: Option<StyleNodeID>, direction: SiblingDirection) -> bool {
+ let mut sibling = sibling;
+ while let Some(current) = sibling {
+ let sibling_layout_node = self.box_of(current);
+ if !sibling_layout_node.is_invalid() {
+ return self.layout.parent(sibling_layout_node) == self.layout_node
+ && node_kind_is_node_with_style(self.layout.data(sibling_layout_node).kind.get())
+ && self.layout.display(sibling_layout_node).is_table_row();
+ }
+
+ if !current.text_index().is_some() {
+ let Some(sibling_display) = self.published_display(current) else {
+ return false;
+ };
+ if !sibling_display.is_none() {
+ return self.needs_layout_tree_update(current) && sibling_display.is_table_row();
+ }
+ } else if !self.engine.text_is_ascii_whitespace(current) {
+ return false;
+ }
+ sibling = match direction {
+ SiblingDirection::Next => self.engine.next_sibling_in_dom_order(current),
+ SiblingDirection::Previous => self.engine.previous_sibling_in_dom_order(current),
+ };
+ }
+ false
+ }
+
/// Whether a child before `inserted_child` resets a counter that counts down from its last item. The start value
/// of such a counter counts every increment in its scope, which includes the inserted child.
fn earlier_child_counts_a_counter_down(&self, inserted_child: StyleNodeID) -> bool {
@@ -972,7 +1109,7 @@ impl ChildListInsertionReuse<'_, '_> {
|| self
.arena()
.writing_suggestion()
- .is_some_and(|suggestion| self.engine.tree().text_parent(suggestion.text) == Some(self.element))
+ .is_some_and(|suggestion| self.engine.text_parent(suggestion.text) == Some(self.element))
{
return false;
}
@@ -1036,7 +1173,10 @@ impl ChildListInsertionReuse<'_, '_> {
continue;
}
if !self.needs_layout_tree_update(child) {
- // A text without a box is built again, which gives it one where it renders.
+ // A full build may give such a text node a box again.
+ if !is_element {
+ return false;
+ }
continue;
}
if !is_element || self.published_display(child).is_none_or(|display| display.is_none()) {
@@ -1063,9 +1203,6 @@ impl ChildListInsertionReuse<'_, '_> {
}
fn run(&self) -> bool {
- if !self.whitespace_text_boxes_stay() {
- return false;
- }
if self.pending_children_can_preserve_parent() {
// An empty set means every insertion was canceled before layout. Moves are marked dirty
// at their destination, so they still enter one of the rejection paths above.
@@ -1083,11 +1220,6 @@ impl ChildListInsertionReuse<'_, '_> {
let parent_lays_out_inline_children =
parent_lays_out_flow && (parent_children_are_inline || !parent_has_children);
let parent_lays_out_block_children = parent_lays_out_flow && !parent_children_are_inline;
- // An inline box, and a block container of nothing but inline-level boxes, lay out their inline content as their
- // own children, so inserted text lands among them where it sits in the DOM.
- let parent_holds_its_inline_content = (parent_lays_out_inline_children
- || (parent_display.is_inline_outside() && parent_display.is_flow_inside()))
- && !self.has_anonymous_child_box();
let parent_lays_out_table_rows = parent_display.is_table_row_group()
|| parent_display.is_table_header_group()
|| parent_display.is_table_footer_group();
@@ -1102,6 +1234,28 @@ impl ChildListInsertionReuse<'_, '_> {
return false;
}
+ if parent_lays_out_table_rows {
+ // NB: Table fixup discards whitespace at the edge of a row group. Inserting a row outside
+ // that whitespace makes it interior, so only a rebuild can create its anonymous table-row box.
+ for child in self.dom_children() {
+ if !child.text_index().is_some()
+ || !self.box_of(child).is_invalid()
+ || self.needs_layout_tree_update(child)
+ || !self.engine.text_is_ascii_whitespace(child)
+ {
+ continue;
+ }
+ if self.has_table_row_sibling(
+ self.engine.previous_sibling_in_dom_order(child),
+ SiblingDirection::Previous,
+ ) && self.has_table_row_sibling(self.engine.next_sibling_in_dom_order(child), SiblingDirection::Next)
+ {
+ return false;
+ }
+ }
+ }
+
+ let collapses_whitespace = self.parent_collapses_whitespace();
let mut will_insert_inline_child = false;
let mut will_insert_block_child = false;
let mut all_inserted_block_children_are_in_flow = true;
@@ -1113,6 +1267,11 @@ impl ChildListInsertionReuse<'_, '_> {
// A fieldset keeps its content in a structural anonymous content box that appended children must also enter.
let mut all_indirect_existing_children_are_in_text_run_wrappers =
self.layout.data(self.layout_node).kind.get() != NodeKind::FieldSetBox;
+ let mut has_pending_collapsing_whitespace = false;
+ // In a full build, an out-of-flow block or more whitespace after inserted whitespace joins the anonymous wrapper
+ // that whitespace starts. The incremental insertion finds that wrapper only while it stays the parent's last
+ // child.
+ let mut inserted_whitespace_run_must_stay_last = false;
// Counters are resolved from the boxes before a box, so an inserted subtree that touches one changes only what
// comes after it.
let mut first_inserted_child_touching_counters = None;
@@ -1120,9 +1279,10 @@ impl ChildListInsertionReuse<'_, '_> {
for child in self.dom_children() {
let child_layout_node = self.box_of(child);
if !child_layout_node.is_invalid() {
- if first_inserted_child_touching_counters.is_some() {
+ if inserted_whitespace_run_must_stay_last || first_inserted_child_touching_counters.is_some() {
return false;
}
+ has_pending_collapsing_whitespace = false;
has_existing_child_after_insertion |= has_inserted_child;
if self.layout.parent(child_layout_node) != self.layout_node {
let wrapper = self.layout.parent(child_layout_node);
@@ -1144,27 +1304,23 @@ impl ChildListInsertionReuse<'_, '_> {
if child.text_index().is_some() {
if !self.needs_layout_tree_update(child) {
- // White space without a box keeps having none, as whitespace_text_boxes_stay() found.
- has_unboxed_existing_text |= !self.engine.tree().text_is_ascii_whitespace(child);
+ has_unboxed_existing_text = true;
continue;
}
- if self.inserted_text_gets_no_box(child) {
- continue;
- }
- if parent_holds_its_inline_content && self.engine.tree().text_is_ascii_whitespace(child) {
- if will_insert_block_child {
+ if !self.engine.text_is_ascii_whitespace(child) || !collapses_whitespace {
+ // Text that renders is inline-level content, which is appended as an inline element is.
+ if !parent_lays_out_block_children || will_insert_block_child {
return false;
}
will_insert_inline_child = true;
has_inserted_child = true;
continue;
}
- // Text that renders is inline-level content, which is appended as an inline element is.
- if !parent_lays_out_block_children || will_insert_block_child {
+ if self.has_first_letter_owner || !self.collapsing_whitespace_can_be_inserted(child) {
return false;
}
- will_insert_inline_child = true;
- has_inserted_child = true;
+ inserted_whitespace_run_must_stay_last |= has_pending_collapsing_whitespace;
+ has_pending_collapsing_whitespace = true;
continue;
}
@@ -1206,6 +1362,10 @@ impl ChildListInsertionReuse<'_, '_> {
&& child_facts.position != positioning::FIXED
&& child_facts.float_ == float::NONE;
if parent_lays_out_flex_or_grid_children {
+ if has_pending_collapsing_whitespace && !child_is_in_flow {
+ return false;
+ }
+ has_pending_collapsing_whitespace = false;
has_inserted_child = true;
continue;
}
@@ -1213,6 +1373,10 @@ impl ChildListInsertionReuse<'_, '_> {
continue;
}
if parent_lays_out_block_children && child_display.is_block_outside() {
+ if has_pending_collapsing_whitespace && !child_is_in_flow {
+ inserted_whitespace_run_must_stay_last = true;
+ }
+ has_pending_collapsing_whitespace = false;
has_inserted_child = true;
will_insert_block_child = true;
if !child_is_in_flow {
@@ -1251,6 +1415,9 @@ impl ChildListInsertionReuse<'_, '_> {
&& !will_insert_block_child
&& (child_facts.position == positioning::ABSOLUTE || child_facts.position == positioning::FIXED)
{
+ if has_pending_collapsing_whitespace {
+ return false;
+ }
will_insert_inline_child = true;
has_inserted_child = true;
continue;
@@ -1289,7 +1456,8 @@ impl ChildListInsertionReuse<'_, '_> {
&& all_indirect_existing_children_are_in_text_run_wrappers);
let can_append_after_indirect_existing_children =
appends_independent_children && !has_indirect_existing_child_after_insertion;
- !has_indirect_existing_child || can_append_after_indirect_existing_children
+ (!has_indirect_existing_child || can_append_after_indirect_existing_children)
+ && !has_pending_collapsing_whitespace
}
}
@@ -1340,30 +1508,6 @@ pub(crate) fn principal_node_entry_decision(
}
}
-/// Whether an empty text produces a line box fragment: a child of an editing host, or text in a text control, which
-/// the caret anchors in and the control takes its baseline from.
-fn text_produces_line_box_fragment_when_empty(
- engine: &RetainedState,
- text: StyleNodeID,
- is_in_user_agent_shadow_tree: bool,
-) -> bool {
- use crate::css::style::bridge::element_construction_fact::{IS_EDITING_HOST, IS_HTML_INPUT_ELEMENT};
- let tree = engine.tree();
- let parent = tree.text_parent(text);
- let parent_is_editing_host = parent
- .filter(|parent| parent.element_index().is_some())
- .is_some_and(|parent| engine.element_construction_facts(parent) & IS_EDITING_HOST != 0);
- // NB: Tree relations are keyed by element identity, so the walk to the host starts at the text's parent.
- let is_in_text_control = is_in_user_agent_shadow_tree
- && parent
- .and_then(|parent| tree.shadow_host_of(parent))
- .is_some_and(|host| {
- engine.element_construction_facts(host) & IS_HTML_INPUT_ELEMENT != 0
- || engine.element_box_kind(host) == ElementBoxKind::TextArea
- });
- parent_is_editing_host || is_in_text_control
-}
-
impl TreeBuilderHost<'_> {
/// The first node in the DOM child sequence the style mirror holds for `parent`.
fn first_dom_child(&self, parent: StyleNodeID) -> Option<StyleNodeID> {
@@ -1543,41 +1687,26 @@ impl TreeBuildJob {
let scrollbar_width = host
.style(root_layout_node)
.expect("the document element's box publishes its style during the build")
- .misc_reset()
+ .misc_interaction()
.scrollbar_width;
let host_calls = host.host_calls();
host.arena_mut()
- .update_layout_style(host_calls, document_layout_node, |style| {
+ .update_layout_style(host_calls, document_layout_node, |style, _| {
style.set_scrollbar_width(scrollbar_width);
});
}
}
- let rebuild_requests = state
- .layout_tree_rebuild_requests
- .iter()
- .map(|&element| {
- (
- element,
- crate::layout::commit::FfiCommitMessageKind::LayoutTreeRebuildRequested,
- )
- })
- .chain(state.whitespace_text_box_rebuild_requests.iter().map(|&element| {
- (
- element,
- crate::layout::commit::FfiCommitMessageKind::WhitespaceTextBoxesStale,
- )
- }))
- .collect::<Vec<_>>();
- for (element, kind) in rebuild_requests {
+ for &element in &state.layout_tree_rebuild_requests {
// A request that names no element asks for the whole tree, which the arena answers itself.
let Some(element) = element else {
host.arena_mut().set_needs_full_layout_tree_update(true);
continue;
};
- state
- .reports
- .push(crate::layout::commit::FfiCommitMessage::new(element.raw(), kind));
+ state.reports.push(crate::layout::commit::FfiCommitMessage::new(
+ element.raw(),
+ crate::layout::commit::FfiCommitMessageKind::LayoutTreeRebuildRequested,
+ ));
}
let built_scroll_containers = host.arena_mut().take_built_scroll_containers();
@@ -1612,9 +1741,7 @@ impl TreeBuildJob {
viewport,
rebuilt_subtree_root_count,
layout_tree_update_escaped_rebuild_roots: state.layout_tree_update_escaped_rebuild_roots,
- needs_another_build_pass: !state.layout_tree_rebuild_requests.is_empty()
- || !state.whitespace_text_box_rebuild_requests.is_empty()
- || state.reached_unstyled_element,
+ needs_another_build_pass: !state.layout_tree_rebuild_requests.is_empty() || state.reached_unstyled_element,
};
TreeBuildAnswer {
outcome,
@@ -1633,13 +1760,8 @@ fn update_layout_tree_for_dom_children(
must_create_subtree: bool,
insertion_mode: FfiInsertionMode,
) {
- let keeps_layout_parent = !must_create_subtree && !context.document_needs_full_layout_tree_update;
let mut node = host.first_dom_child(parent);
while let Some(current) = node {
- if keeps_layout_parent && settle_whitespace_text_in_kept_child_list(host, state, current, insertion_mode) {
- node = host.next_dom_sibling(current);
- continue;
- }
if insertion_mode == FfiInsertionMode::InDomOrder && host.arena().bound_row(current).is_invalid() {
update_layout_tree_for_spliced_child(host, state, current, context, must_create_subtree, insertion_mode);
} else if !keeps_its_box_as_it_is(host, current, context, must_create_subtree) {
@@ -1649,47 +1771,6 @@ fn update_layout_tree_for_dom_children(
}
}
-/// A walk that keeps the box of a white space text's layout parent never gives the text a box or takes its box away
-/// where it sits: the anonymous wrappers around the text, and the boxes after it, would have to change with it, which
-/// only a build of the parent's child list gets right. Asks for that build when the text's box has to change, and
-/// answers whether the walk is done with the text.
-fn settle_whitespace_text_in_kept_child_list(
- host: &mut TreeBuilderHost<'_>,
- state: &mut TreeBuilderState,
- node: StyleNodeID,
- insertion_mode: FfiInsertionMode,
-) -> bool {
- if node.text_index().is_none() || !host.arena().text_is_ascii_whitespace(Some(node)) {
- return false;
- }
- let layout_parent = state.current_parent();
- let has_box = !host.arena().bound_row(node).is_invalid();
- let needs_box = whitespace_text_needs_box(host, layout_parent, node);
- let is_marked = host.arena().needs_layout_tree_update(node);
- if needs_box == has_box {
- // A text that renders nothing and holds no mark is done; any other takes the usual path.
- return !has_box && !is_marked;
- }
- // A child list insertion places an inserted text where it renders, as it places any inserted text.
- if needs_box && is_marked && insertion_mode == FfiInsertionMode::InDomOrder {
- return false;
- }
- let mut container = layout_parent;
- while node_facts::has_flag(host.data(container), NodeFlag::Anonymous) {
- container = host.parent(container);
- }
- let element = host
- .arena()
- .commit_message_style_node(container)
- .and_then(StyleNodeID::from_raw)
- .filter(|style_node| style_node.element_index().is_some());
- if !state.whitespace_text_box_rebuild_requests.contains(&element) {
- state.whitespace_text_box_rebuild_requests.push(element);
- }
- host.arena_mut().clear_layout_tree_update_marks(Some(node));
- true
-}
-
fn update_layout_tree_for_spliced_child(
host: &mut TreeBuilderHost<'_>,
state: &mut TreeBuilderState,
@@ -1770,13 +1851,8 @@ fn update_layout_tree_for_assigned_slottables(
) {
// The style mirror holds the assigned nodes in flat-tree order, and the list does not change while the build
// walks it.
- let keeps_layout_parent = !must_create_subtree && !context.document_needs_full_layout_tree_update;
for index in 0..host.arena().assigned_node_count(Some(slot)) {
let node = host.arena().assigned_node_at(slot, index);
- if keeps_layout_parent && settle_whitespace_text_in_kept_child_list(host, state, node, FfiInsertionMode::Append)
- {
- continue;
- }
update_layout_tree(
host,
state,
@@ -2617,14 +2693,7 @@ fn rebuild_child_list_from_dom_children(
kept_box = host.parent(kept_box);
}
if kept_box.is_invalid() {
- // A text without a box is built again, which gives it one where it renders.
- let is_text = child.text_index().is_some();
- update_layout_tree_for_spliced_child(host, state, child, context, is_text, FfiInsertionMode::Append);
- } else if host.arena().text_is_ascii_whitespace(Some(child))
- && !whitespace_text_needs_box(host, state.current_parent(), child)
- {
- // The kept box goes once nothing holds it.
- clear_stale_subtree(host, child, StaleSubtreeClearScope::Inclusive);
+ update_layout_tree_for_spliced_child(host, state, child, context, false, FfiInsertionMode::Append);
} else if host.arena().needs_layout_tree_update(child)
&& (host.arena().layout_tree_update_reuse_reasons(child) == 0
|| host.data(kept_box).kind.get() == NodeKind::TableWrapper)
@@ -2867,17 +2936,11 @@ fn construct_principal_layout_node(
layout_node = created;
created_box = Some(host.created(created));
} else if update.kind.is_text() {
- let text_is_ascii_whitespace = host.arena().text_is_ascii_whitespace(update.style_node);
- if text_is_ascii_whitespace
- && !whitespace_text_needs_box(host, update.state.current_parent(), update.identity)
- {
- return PrincipalBoxConstruction::none();
- }
let facts = host.arena().text_style_parent_facts(update.style_node);
let needs_style_wrapper = display_contents_text_needs_style_wrapper(
facts.has_style_parent,
facts.parent_display_is_contents,
- text_is_ascii_whitespace,
+ host.arena().text_is_ascii_whitespace(update.style_node),
facts.parent_collapses_whitespace,
);
let text_layout_node = host.create_text_box(update.identity);
@@ -4010,9 +4073,7 @@ impl<'a> TreeBuilderHost<'a> {
fn style(&self, node: LayoutNode) -> Option<ComputedValuesView<'_>> {
assert!(!node.is_invalid());
- self.arena
- .style_payloads(node)
- .map(|payloads| ComputedValuesView::new(&payloads.groups))
+ self.arena.style_view(node)
}
fn display(&self, node: LayoutNode) -> FfiDisplay {
@@ -4055,7 +4116,7 @@ impl<'a> TreeBuilderHost<'a> {
let display = self.style(slot).map(|style| style.display());
if let Some(display) = display.filter(FfiDisplay::is_flow_inside) {
let host_calls = self.host_calls();
- self.arena_mut().update_layout_style(host_calls, slot, |style| {
+ self.arena_mut().update_layout_style(host_calls, slot, |style, _| {
style.set_display(FfiDisplay::outside_and_inside(
display.outside,
crate::css::css_enums::display_inside::FLOW_ROOT,
@@ -4127,16 +4188,24 @@ impl<'a> TreeBuilderHost<'a> {
/// restamps it when editability changes. Under an element with a highlight pseudo-element style
/// and no box of its own, the row takes that style's paint facts itself.
fn stamp_text_row_facts(&mut self, slot: NodeSlotId, text: StyleNodeID) {
+ use crate::css::style::bridge::element_construction_fact::{IS_EDITING_HOST, IS_HTML_INPUT_ELEMENT};
let is_in_user_agent_shadow_tree =
self.arena().node_flags(slot) & NodeFlag::IsInUserAgentShadowTree as u32 != 0;
let (produces_line_box_fragment_when_empty, parent_element) = self.arena().with_style_store(|engine| {
- (
- text_produces_line_box_fragment_when_empty(engine, text, is_in_user_agent_shadow_tree),
- engine
- .tree()
- .text_parent(text)
- .filter(|parent| parent.element_index().is_some()),
- )
+ let parent = engine.text_parent(text);
+ let parent_element = parent.filter(|parent| parent.element_index().is_some());
+ let parent_is_editing_host =
+ parent_element.is_some_and(|parent| engine.element_construction_facts(parent) & IS_EDITING_HOST != 0);
+ // NB: Tree relations are keyed by element identity, so the walk to the host starts at the
+ // text's parent.
+ let is_in_text_control = is_in_user_agent_shadow_tree
+ && parent
+ .and_then(|parent| engine.shadow_host_of(parent))
+ .is_some_and(|host| {
+ engine.element_construction_facts(host) & IS_HTML_INPUT_ELEMENT != 0
+ || engine.element_box_kind(host) == ElementBoxKind::TextArea
+ });
+ (parent_is_editing_host || is_in_text_control, parent_element)
});
self.arena_mut().set_node_flag(
slot,
@@ -4753,29 +4822,6 @@ fn insert_child_in_dom_order(
host.attach_child(parent, child, NodeSlotId::INVALID);
}
-/// Whether `node` is an absolutely positioned box that would be inline-level in flow, laid out among the inline content
-/// of `parent`: its static position is where an inline box would sit in a line, after the floats and with the line's
-/// alignment, which only an inline formatting context gives it.
-/// https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width
-/// A flex, grid or MathML container positions its out-of-flow children itself, table fixup sees them as inline content
-/// already, SVG lays out its children without lines, and the viewport holds the top layer's members as boxes of their
-/// own.
-fn is_inline_level_absolutely_positioned_box_in_flow_layout(
- host: &TreeBuilderHost<'_>,
- parent: LayoutNode,
- node: LayoutNode,
-) -> bool {
- let parent_kind = host.data(parent).kind.get();
- node_kind_is_node_with_style(host.data(node).kind.get())
- && host.style(node).is_some_and(|style| {
- style.is_absolutely_positioned() && style.display_before_box_type_transformation().is_inline_outside()
- })
- && !lays_out_each_child_as_its_own_box(host, parent)
- && !is_tabular_container(host, parent)
- && !node_facts::kind_is_svg_box(parent_kind)
- && !matches!(parent_kind, NodeKind::SVGSVGBox | NodeKind::Viewport)
-}
-
fn insert_node_into_inline_or_block_ancestor(
host: &mut TreeBuilderHost<'_>,
state: &mut TreeBuilderState,
@@ -4787,8 +4833,6 @@ fn insert_node_into_inline_or_block_ancestor(
) {
assert!(!nearest_insertion_ancestor.is_invalid());
let node_slot = node.slot();
- let is_inline_outside = is_inline_outside
- || is_inline_level_absolutely_positioned_box_in_flow_layout(host, nearest_insertion_ancestor, node_slot);
let insertion_point = if is_inline_outside {
insertion_parent_for_inline_node(host, nearest_insertion_ancestor)
@@ -4944,8 +4988,7 @@ fn find_first_letter_in_layout_text(host: &TreeBuilderHost<'_>, node: LayoutNode
let preserves_segment_breaks = matches!(
host.style(host.parent(node))
.expect("text parent has style")
- .inherited_text()
- .white_space_collapse,
+ .white_space_collapse(),
white_space_collapse::PRESERVE | white_space_collapse::PRESERVE_BREAKS | white_space_collapse::BREAK_SPACES
);
let mut target = find_first_letter_in_text(
@@ -5070,7 +5113,7 @@ fn create_writing_suggestion_boxes(host: &mut TreeBuilderHost<'_>, element: Styl
return;
};
let is_child_text = host.arena().with_style_store(|engine| {
- if engine.tree().text_parent(suggestion.text) != Some(element) {
+ if engine.text_parent(suggestion.text) != Some(element) {
return false;
}
// Text that a `::first-letter` may already split is left alone, so the two splits never meet.
@@ -5079,10 +5122,7 @@ fn create_writing_suggestion_boxes(host: &mut TreeBuilderHost<'_>, element: Styl
if engine.has_published_first_letter_style(current) {
return false;
}
- ancestor = engine
- .tree()
- .parent(current)
- .map(|parent| engine.tree().host_of(parent).unwrap_or(parent));
+ ancestor = engine.parent_element_or_host(current);
}
true
});
@@ -5306,17 +5346,18 @@ fn wrap_fieldset_contents_if_needed(host: &mut TreeBuilderHost<'_>, layout_node:
let style = node_facts::node_style_view(host.data(layout_node)).expect("fieldset style");
let overrides = AnonymousStyleOverrides {
- overflow_x: style.box_values().overflow_x,
- overflow_y: style.box_values().overflow_y,
+ overflow_x: style.overflow_x(),
+ overflow_y: style.overflow_y(),
columns_from_parent: true,
};
let host_calls = host.host_calls();
- host.arena_mut().update_layout_style(host_calls, layout_node, |style| {
- style.set_overflow(
- crate::css::css_enums::overflow::VISIBLE,
- crate::css::css_enums::overflow::VISIBLE,
- );
- });
+ host.arena_mut()
+ .update_layout_style(host_calls, layout_node, |style, _| {
+ style.set_overflow(
+ crate::css::css_enums::overflow::VISIBLE,
+ crate::css::css_enums::overflow::VISIBLE,
+ );
+ });
let wrapper = host.create_anonymous_box(
layout_node,
AnonymousStyleKind::FieldsetContentWrapper,
@@ -6152,12 +6193,10 @@ mod tests {
#[test]
fn preserved_break_in_an_earlier_text_node_blocks_first_letter_search() {
- use crate::css::computed_value_types::InheritedTextValues;
- use crate::css::computed_values::{GroupPayloadRef, clone_group_payload, release_group_payload};
use crate::css::css_enums::white_space_collapse;
- use crate::css::table_group_builder::group_index;
+ use crate::css::style::layout_style::LayoutScratchStyle;
use crate::layout::layout_node_arena::LayoutNodeArena;
- use crate::layout::node_data::{FfiStylePayloads, NodeFlag, NodeKind, StylePayloadsRef};
+ use crate::layout::node_data::{NodeFlag, NodeKind};
use crate::layout::tree_mutation::OwedHostWork;
for (prefix, collapse, blocked) in [
@@ -6167,19 +6206,12 @@ mod tests {
(" ", white_space_collapse::PRESERVE, false),
("\n", white_space_collapse::COLLAPSE, false),
] {
- let mut style = FfiStylePayloads {
- groups: std::array::from_fn(|index| GroupPayloadRef::default_payload(index).as_ptr()),
- };
- // SAFETY: This private clone has the inherited text group layout, and has no readers yet.
- let text_group =
- unsafe { clone_group_payload(group_index::INHERITED_TEXT, style.groups[group_index::INHERITED_TEXT]) };
- unsafe { (*text_group.cast::<InheritedTextValues>()).white_space_collapse = collapse };
- style.groups[group_index::INHERITED_TEXT] = text_group;
+ let style = LayoutScratchStyle::over_defaults(|style| style.set_white_space_collapse(collapse));
let mut arena = LayoutNodeArena::new();
let block = arena.allocate_for_test().slot;
arena.write_shape(block).set_kind(NodeKind::BlockContainer);
arena.set_node_flag(block, NodeFlag::ChildrenAreInline, true);
- arena.set_node_style(block, 0, StylePayloadsRef::new(&style));
+ arena.set_node_style(block, 0, Some(style.style()));
let first = arena.allocate_unbound();
let second = arena.allocate_unbound();
arena.stamp_generated_text_row(
@@ -6209,7 +6241,6 @@ mod tests {
arena
.free_subtree(block)
.destroy_shells_and_invoke_callbacks(&crate::stage::MainThread::for_test());
- release_group_payload(group_index::INHERITED_TEXT, text_group);
}
}
diff --git a/Libraries/LibWeb/Rust/src/layout/tree_mutation.rs b/Libraries/LibWeb/Rust/src/layout/tree_mutation.rs
index f8adf5b116e..891ca73dfda 100644
--- a/Libraries/LibWeb/Rust/src/layout/tree_mutation.rs
+++ b/Libraries/LibWeb/Rust/src/layout/tree_mutation.rs
@@ -111,7 +111,7 @@ enum DueHostCall {
ShellStyleChanged {
facts: crate::layout::host_tables::ShellFacts,
record: u64,
- payloads: crate::layout::node_data::StylePayloadsRef,
+ payloads: Option<crate::layout::node_data::LayoutStyleRef>,
derived: bool,
attach_resources: bool,
},
@@ -167,7 +167,7 @@ fn tell_shell_of_style_change(
main_thread: &MainThread,
facts: crate::layout::host_tables::ShellFacts,
record: u64,
- payloads: crate::layout::node_data::StylePayloadsRef,
+ payloads: Option<crate::layout::node_data::LayoutStyleRef>,
derived: bool,
attach_resources: bool,
) {
@@ -197,7 +197,7 @@ fn tell_shell_of_style_change(
callbacks.context,
shell.as_ptr(),
record,
- payloads.as_ptr().cast(),
+ payloads.map_or(std::ptr::null(), |payloads| payloads.as_ptr()),
derived,
attach_resources,
);
diff --git a/Libraries/LibWeb/Rust/src/layout/tree_shape.rs b/Libraries/LibWeb/Rust/src/layout/tree_shape.rs
index 10fa56da0ea..1a67cc6748f 100644
--- a/Libraries/LibWeb/Rust/src/layout/tree_shape.rs
+++ b/Libraries/LibWeb/Rust/src/layout/tree_shape.rs
@@ -17,7 +17,7 @@
//! the chunk when a write changes it. A write the next publication would miss does not compile.
use super::layout_node_arena::SLOTS_PER_CHUNK;
-use super::node_data::{NodeData, NodeFlag, NodeKind, NodeSlotId, PaintNode, StylePayloadsRef};
+use super::node_data::{LayoutStyleRef, NodeData, NodeFlag, NodeKind, NodeSlotId, PaintNode};
use crate::cow_column::{ColumnSnapshot, CowColumn};
use crate::css::style::tree::StyleNodeID;
use std::ops::Deref;
@@ -220,7 +220,7 @@ impl ShapeWriter<'_> {
self.write(|data| &mut data.compositor_animation_frame_kinds, kinds);
}
- pub(crate) fn set_style(&mut self, style: StylePayloadsRef) {
+ pub(crate) fn set_style(&mut self, style: Option<LayoutStyleRef>) {
self.write(|data| &mut data.style, style);
}
}
@@ -400,7 +400,7 @@ mod tests {
writes.add_chunk(0);
let mut shape = chunk.write_shape(0, 3, &mut writes);
shape.set_parent(NodeSlotId::new(1, 1));
- shape.set_style(StylePayloadsRef::new(std::ptr::NonNull::dangling().as_ptr()));
+ shape.set_style(Some(LayoutStyleRef::dangling()));
shape.set_flags(NodeFlag::HasStyle as u32);
shape.mark();
assert_eq!((writes.all(), writes.identity()), (4, 0));
diff --git a/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs b/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs
index eae24e9c6ef..bdd93922bd0 100644
--- a/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs
+++ b/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs
@@ -404,10 +404,7 @@ impl LayoutNodeArena {
return Some(current);
}
}
- ancestor = engine
- .tree()
- .parent(current)
- .map(|parent| engine.tree().host_of(parent).unwrap_or(parent));
+ ancestor = engine.parent_element_or_host(current);
}
None
})
@@ -664,7 +661,7 @@ fn repaint_subtree(arena: &mut LayoutNodeArena, row: NodeSlotId) {
}
/// The row paints again, and the root's with it where the root paints the body's propagated background.
-fn repaint(arena: &mut LayoutNodeArena, row: NodeSlotId, includes_hit_testing: bool) {
+pub(crate) fn repaint(arena: &mut LayoutNodeArena, row: NodeSlotId, includes_hit_testing: bool) {
if !arena.paintable_row_is_populated(row) {
return;
}
diff --git a/Libraries/LibWeb/Rust/src/layout/update_layout.rs b/Libraries/LibWeb/Rust/src/layout/update_layout.rs
index d6565abd723..db62dda35fb 100644
--- a/Libraries/LibWeb/Rust/src/layout/update_layout.rs
+++ b/Libraries/LibWeb/Rust/src/layout/update_layout.rs
@@ -94,8 +94,7 @@ pub struct FfiLayoutUpdateHostCallbacks {
/// Records that a layout update ran out of its exact bound, and answers what the document still has pending, for
/// the panic that reports the failure, describing the elements the last unstyled-element report and the last
/// rebuild request named, or 0 for none.
- record_stabilization_bound_failure:
- extern "C" fn(*mut c_void, &BegunRead, u32, u32) -> FfiStabilizationBoundFailureHostFacts,
+ record_stabilization_bound_failure: extern "C" fn(*mut c_void, &BegunRead) -> FfiStabilizationBoundFailureHostFacts,
/// Attaches the image resources a box's style asks for. The flag says the box replaces its
/// element's contents with a single image, whose provider it owns.
attach_style_resources: extern "C" fn(*mut c_void, &BegunRead, NodeSlotId, bool, FfiStyleImageFacts),
@@ -143,25 +142,14 @@ pub struct FfiLayoutUpdateDocumentFacts {
pub struct FfiStabilizationBoundFailureHostFacts {
pub document_is_top_level: bool,
pub needs_animated_style_update: bool,
- pub has_pending_style_transaction: bool,
- pub has_flown_style_transaction: bool,
+ pub has_pending_style_update: bool,
+ pub has_flown_style_update: bool,
pub size_containers_await_evaluation: bool,
pub list_items_await_renumbering: bool,
pub top_layer_zone_rebuild_pending: bool,
pub top_layer_membership_changes_pending: bool,
pub document_needs_layout_tree_update: bool,
pub document_child_needs_layout_tree_update: bool,
- /// The element the last unstyled-element report of the update named, with its flat tree ancestors, as the host
- /// describes them: a NUL-terminated ASCII string.
- pub last_unstyled_element: [u8; 2048],
- /// As above, for the element the last rebuild request of the update named.
- pub last_rebuild_request: [u8; 640],
-}
-
-/// The text of a NUL-terminated string the host wrote into `bytes`.
-fn host_text(bytes: &[u8]) -> String {
- let end = bytes.iter().position(|&byte| byte == 0).unwrap_or(bytes.len());
- String::from_utf8_lossy(&bytes[..end]).into_owned()
}
/// What one layout update was asked for.
@@ -259,10 +247,8 @@ impl FfiLayoutUpdateHostCallbacks {
&self,
_: &MainThread,
read: &BegunRead,
- last_unstyled_element: u32,
- last_rebuild_request: u32,
) -> FfiStabilizationBoundFailureHostFacts {
- (self.record_stabilization_bound_failure)(self.context, read, last_unstyled_element, last_rebuild_request)
+ (self.record_stabilization_bound_failure)(self.context, read)
}
/// Hands the boxes the tree builds of the update stamped the image resources they are owed,
@@ -366,12 +352,10 @@ struct StabilizationTrace {
full_layouts_leaving_top_layer: u64,
/// Full layouts that left layout to do.
full_layouts_leaving_layout: u64,
- /// Elements the builds reached without a style, and the style node of the last of them.
+ /// Elements the builds reached without a style.
unstyled_elements_reached: u64,
- last_unstyled_element: u32,
- /// Rebuilds the builds requested for a box that escaped its rebuild root, and the style node of the last of them.
+ /// Rebuilds the builds requested for a box that escaped its rebuild root.
rebuild_requests: u64,
- last_rebuild_request: u32,
/// The builds' other reports.
other_build_reports: u64,
}
@@ -384,14 +368,8 @@ impl StabilizationTrace {
};
for report in &built.reports {
match report.kind {
- FfiCommitMessageKind::UnstyledElementReached => {
- self.unstyled_elements_reached += 1;
- self.last_unstyled_element = report.style_node;
- }
- FfiCommitMessageKind::LayoutTreeRebuildRequested => {
- self.rebuild_requests += 1;
- self.last_rebuild_request = report.style_node;
- }
+ FfiCommitMessageKind::UnstyledElementReached => self.unstyled_elements_reached += 1,
+ FfiCommitMessageKind::LayoutTreeRebuildRequested => self.rebuild_requests += 1,
_ => self.other_build_reports += 1,
}
}
@@ -432,8 +410,8 @@ impl StabilizationTrace {
(needs_full_tree_update, "full tree update"),
(updates_escaped, "updates escaped partial relayout"),
(host_facts.needs_animated_style_update, "animated style"),
- (host_facts.has_pending_style_transaction, "style transaction"),
- (host_facts.has_flown_style_transaction, "flown style transaction"),
+ (host_facts.has_pending_style_update, "style update"),
+ (host_facts.has_flown_style_update, "flown style update"),
(host_facts.size_containers_await_evaluation, "size containers"),
(host_facts.list_items_await_renumbering, "list item renumbering"),
(host_facts.top_layer_zone_rebuild_pending, "top layer zone rebuild"),
@@ -454,7 +432,7 @@ impl StabilizationTrace {
"{passes} passes for {connected_elements} connected elements of a {} document: {} flown, {} builds asking \
another pass, {} counter reconciles, partial layouts leaving style {}/layout {}, full layouts leaving \
style {}/top layer {}/layout {}; {} boundary roots, {} deferred insertions; facts: {}; build reports: {} \
- unstyled elements (last: {}), {} rebuild requests (last: {}), {} other",
+ unstyled elements, {} rebuild requests, {} other",
if host_facts.document_is_top_level {
"top-level"
} else {
@@ -476,9 +454,7 @@ impl StabilizationTrace {
facts_that_hold.join(", ")
},
self.unstyled_elements_reached,
- host_text(&host_facts.last_unstyled_element),
self.rebuild_requests,
- host_text(&host_facts.last_rebuild_request),
self.other_build_reports,
)
}
@@ -618,16 +594,16 @@ pub(crate) struct SealedRound {
}
impl SealedRound {
- /// Runs the round over `state` in the frame's flight, where the frame's style left its layout to do, owing the host
- /// `work` besides what the round owes it.
- pub(crate) fn run(self, state: &mut ArenaHandle, work: OwedHostWork) -> Option<FlownRound> {
+ /// Runs the round over `state` in the frame's flight, where its layout is not up to date. The flight reaches nothing
+ /// of the host, so a length only the host resolves leaves the layout for the host to lay out again.
+ pub(crate) fn run(self, state: &mut ArenaHandle) -> Option<FlownRound> {
if state
.arena()
.layout_is_up_to_date(self.job.facts.document_needs_layout_tree_build)
{
return None;
}
- let mut answer = self.job.run_owing(state, work);
+ let mut answer = self.job.run(state);
answer.prepare_committed_layout_for_rendering(state.arena_mut());
Some(FlownRound {
answer,
@@ -673,6 +649,7 @@ impl ClockRound {
build,
layout: RoundLayout::PartialIfPlanned,
container_query_evaluation_is_pending: false,
+ // NB: A clock round runs outside any layout update, which is what reports phase times.
}
.run(state);
// A box the build gave an image has none until the host attaches it.
@@ -785,11 +762,7 @@ fn seal_clock_round(main_thread: &MainThread, document_host: &DocumentHost, read
impl LayoutRoundJob {
/// Runs the round over `state`, and resolves what it owes the host as it ends.
pub(crate) fn run(self, state: &mut ArenaHandle) -> LayoutRoundAnswer {
- self.run_owing(state, OwedHostWork::default())
- }
-
- /// Runs the round over `state`, and resolves what it owes the host as it ends, `work` among it.
- fn run_owing(self, state: &mut ArenaHandle, work: OwedHostWork) -> LayoutRoundAnswer {
+ let work = OwedHostWork::default();
let mut answer = self.run_with(state, &work);
answer.work = work.resolve(state.arena_mut());
answer.owed_images = OwedImage::take_from(state.arena_mut());
@@ -1043,41 +1016,9 @@ fn layout_update_host(document_host: &DocumentHost) -> FfiLayoutUpdateHostCallba
.expect("the document has no layout update host")
}
-/// The first round of a rendering update's layout of `document_host`'s document, sealed for a frame to run beside the
-/// host, where the document is active and `needs_round` says the round has something to do as of its facts.
-fn sealed_first_round(
- main_thread: &MainThread,
- document_host: &DocumentHost,
- read: &BegunRead,
- inputs: &FfiLayoutUpdateInputs,
- needs_round: impl FnOnce(&FfiLayoutUpdateDocumentFacts) -> bool,
-) -> Option<SealedRound> {
- let host = layout_update_host(document_host);
- let facts = host.document_facts(main_thread, read);
- if !facts.document_is_active || inputs.is_template_contents_document || !needs_round(&facts) {
- return None;
- }
- Some(next_round(main_thread, document_host, read, &host, facts, false))
-}
-
-/// Seals the first round of a rendering update's layout of `document_host`'s document, which the frame the update lets
-/// fly next runs after its style.
-fn seal_first_round(
- main_thread: &MainThread,
- document_host: &DocumentHost,
- read: &BegunRead,
- inputs: &FfiLayoutUpdateInputs,
-) {
- // A round is sealed for a document whose layout is up to date as well: the frame's style may leave it layout to
- // do, which the round finds once the frame has applied the style.
- if let Some(round) = sealed_first_round(main_thread, document_host, read, inputs, |_| true) {
- document_host.seal_round(round);
- }
-}
-
/// Lets the first round of a rendering update's layout of `document_host`'s document fly beside the host, once the
-/// host's style is up to date, where the layout is not and no round that flew with the style waits to be taken in. The
-/// host's next layout update pays it first. Answers whether it flies.
+/// host's style is up to date, where the document is active, its layout is not up to date, and no round that flew
+/// before waits to be taken in. The host's next layout update pays it first. Answers whether it flies.
fn fly_first_round(
main_thread: &MainThread,
document_host: &DocumentHost,
@@ -1085,7 +1026,7 @@ fn fly_first_round(
inputs: &FfiLayoutUpdateInputs,
license: &FlightLicense,
) -> bool {
- // A round that flew with the style is the layout update's first: the update takes it in and goes on from it here.
+ // A round that flew before is the layout update's first: the update takes it in and goes on from it here.
if document_host.has_flown_round() {
return false;
}
@@ -1094,15 +1035,15 @@ fn fly_first_round(
let host = layout_update_host(document_host);
host.process_pending_list_item_renumbers(main_thread, read);
host.process_pending_top_layer_layout_changes(main_thread, read);
- let round = {
- sealed_first_round(main_thread, document_host, read, inputs, |facts| {
- !host_layout_is_up_to_date(document_host, read, facts)
- })
- };
- let Some(round) = round else {
+ let facts = host.document_facts(main_thread, read);
+ if !facts.document_is_active
+ || inputs.is_template_contents_document
+ || host_layout_is_up_to_date(document_host, read, &facts)
+ {
return false;
- };
- crate::render_state::fly(document_host, None, Some(round), license);
+ }
+ let round = next_round(main_thread, document_host, read, &host, facts, false);
+ crate::render_state::fly(document_host, crate::render_state::FrameJob::Round(round), license);
true
}
@@ -1298,12 +1239,7 @@ fn update_layout(
if host.needs_style_update_after_layout(main_thread, read)
|| !host_layout_is_up_to_date(document_host, read, &host.document_facts(main_thread, read))
{
- let host_facts = host.record_stabilization_bound_failure(
- main_thread,
- read,
- trace.last_unstyled_element,
- trace.last_rebuild_request,
- );
+ let host_facts = host.record_stabilization_bound_failure(main_thread, read);
unreachable!(
"the layout update did not stabilize within its exact bound: {}",
trace.describe(main_thread, document_host, read, &host, layout_pass, host_facts)
diff --git a/Libraries/LibWeb/Rust/src/layout/update_layout/main_thread_entries.rs b/Libraries/LibWeb/Rust/src/layout/update_layout/main_thread_entries.rs
index e38ee12fe3c..50bff196075 100644
--- a/Libraries/LibWeb/Rust/src/layout/update_layout/main_thread_entries.rs
+++ b/Libraries/LibWeb/Rust/src/layout/update_layout/main_thread_entries.rs
@@ -126,23 +126,6 @@ pub unsafe extern "C" fn render_state_seal_clock_plan(
});
}
-/// Seals the first round of the layout of a rendering update whose style is about to fly, as of the document's facts
-/// now, where the document needs one: the frame runs it after its style.
-///
-/// # Safety
-///
-/// As for [`render_state_update_layout`], with no layout update running.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn render_state_seal_first_layout_round(
- host: &DocumentHost,
- read: &BegunRead,
- inputs: &FfiLayoutUpdateInputs,
-) {
- // SAFETY: Guaranteed by the entry point's contract.
- let main_thread = unsafe { main_thread(host) };
- abort_on_panic(|| seal_first_round(&main_thread, host, read, inputs));
-}
-
/// Lets the first round of the layout of a rendering update whose style is up to date fly beside the host, in `read`,
/// where the document's layout is not up to date and `blocker` is none: the host's next layout update pays it first.
/// Answers whether the round flies.
diff --git a/Libraries/LibWeb/Rust/src/layout/viewport_propagation.rs b/Libraries/LibWeb/Rust/src/layout/viewport_propagation.rs
index 3b034610451..465dc77c1e6 100644
--- a/Libraries/LibWeb/Rust/src/layout/viewport_propagation.rs
+++ b/Libraries/LibWeb/Rust/src/layout/viewport_propagation.rs
@@ -46,9 +46,7 @@ pub(crate) struct ViewportPropagationFacts {
/// The published style record the style engine holds for an element.
fn published_style(engine: &RetainedState, node: StyleNodeID) -> Option<ComputedValuesView<'_>> {
- engine
- .element_published_style_payloads(node)
- .map(ComputedValuesView::new)
+ engine.element_published_style(node)
}
fn has_any_containment(style: ComputedValuesView<'_>) -> bool {
@@ -69,7 +67,6 @@ fn document_element(arena: &LayoutNodeArena) -> Option<StyleNodeID> {
/// The first child of the document element that is an HTML body element.
fn first_html_body_child(engine: &RetainedState, root_element: StyleNodeID) -> Option<StyleNodeID> {
engine
- .tree()
.dom_children(root_element)
.find(|&child| engine.element_adjustment_facts(child) & element_adjustment_fact::IS_HTML_BODY_ELEMENT != 0)
}
@@ -111,8 +108,8 @@ pub(crate) fn viewport_propagation_facts(arena: &LayoutNodeArena) -> ViewportPro
engine.element_construction_facts(root_element) & element_construction_fact::IS_HTML_HTML_ELEMENT != 0;
facts.root_overflow_x = root_style.overflow_x();
facts.root_overflow_y = root_style.overflow_y();
- facts.root_overscroll_behavior_x = root_style.misc_reset().overscroll_behavior_x;
- facts.root_overscroll_behavior_y = root_style.misc_reset().overscroll_behavior_y;
+ facts.root_overscroll_behavior_x = root_style.misc_interaction().overscroll_behavior_x;
+ facts.root_overscroll_behavior_y = root_style.misc_interaction().overscroll_behavior_y;
facts.root_writing_mode = root_style.writing_mode();
facts.root_direction = root_style.direction();
facts.root_has_containment = has_any_containment(root_style);
@@ -153,7 +150,6 @@ pub(crate) fn root_background_source(arena: &LayoutNodeArena) -> crate::painting
element_adjustment_fact::IS_HTML_BODY_ELEMENT | element_adjustment_fact::IS_HTML_FRAMESET_ELEMENT;
if root_is_html_html_element
&& let Some(body) = engine
- .tree()
.dom_children(root_element)
.find(|&child| engine.element_adjustment_facts(child) & body_or_frameset != 0)
{
@@ -183,7 +179,7 @@ pub(crate) fn root_background_source(arena: &LayoutNodeArena) -> crate::painting
}
source.use_body_background_properties =
!crate::painting::style_queries::background_layers_have_image(root_style)
- && root_style.background().background_color == 0;
+ && root_style.background_color() == 0;
});
source
}
@@ -309,17 +305,17 @@ pub(crate) fn propagate_root_styles_to_viewport(
) {
assert!(!viewport.is_invalid());
let apply_overflow = |arena: &mut LayoutNodeArena, node: NodeSlotId, (x, y): (u8, u8)| {
- arena.update_layout_style(host_calls, node, |style| style.set_overflow(x, y));
+ arena.update_layout_style(host_calls, node, |style, _| style.set_overflow(x, y));
};
let apply_writing_mode_and_direction =
|arena: &mut LayoutNodeArena, node: NodeSlotId, writing_mode: u8, direction: u8| {
- arena.update_layout_style(host_calls, node, |style| {
+ arena.update_layout_style(host_calls, node, |style, _| {
style.set_writing_mode_and_direction(writing_mode, direction);
});
};
let apply_viewport_overscroll_behavior = |arena: &mut LayoutNodeArena, (x, y): (u8, u8)| {
let mut changed = false;
- arena.update_layout_style(host_calls, viewport, |style| {
+ arena.update_layout_style(host_calls, viewport, |style, _| {
style.set_overscroll_behavior(x, y);
changed = !style.is_unchanged();
});
diff --git a/Libraries/LibWeb/Rust/src/painting/chrome_geometry.rs b/Libraries/LibWeb/Rust/src/painting/chrome_geometry.rs
index 05b91af94cd..514ebf0f320 100644
--- a/Libraries/LibWeb/Rust/src/painting/chrome_geometry.rs
+++ b/Libraries/LibWeb/Rust/src/painting/chrome_geometry.rs
@@ -104,12 +104,12 @@ pub(crate) fn physical_resize_axes(arena: &impl PaintRead, slot: NodeSlotId) ->
let overflow_allows_resize =
|overflow| overflow != css_enums::overflow::VISIBLE && overflow != css_enums::overflow::CLIP;
PhysicalAxes {
- horizontal: overflow_allows_resize(box_values.overflow_x)
+ horizontal: overflow_allows_resize(style.overflow_x())
&& (box_values.resize == css_enums::resize::BOTH
|| box_values.resize == css_enums::resize::HORIZONTAL
|| (box_values.resize == css_enums::resize::INLINE && horizontal_writing_mode)
|| (box_values.resize == css_enums::resize::BLOCK && !horizontal_writing_mode)),
- vertical: overflow_allows_resize(box_values.overflow_y)
+ vertical: overflow_allows_resize(style.overflow_y())
&& (box_values.resize == css_enums::resize::BOTH
|| box_values.resize == css_enums::resize::VERTICAL
|| (box_values.resize == css_enums::resize::INLINE && !horizontal_writing_mode)
@@ -163,7 +163,7 @@ pub(crate) fn scroll_boundary_behavior(arena: &impl PaintRead, slot: NodeSlotId)
};
use css_enums::overscroll_behavior::{AUTO, CHAIN, CONTAIN};
- let misc_reset = style.misc_reset();
+ let misc_interaction = style.misc_interaction();
// contain: The element must not perform non-local boundary default actions such as scroll chaining. This value
// must not modify the behavior of how local boundary default actions should behave, such as showing any
// overscroll affordances.
@@ -175,12 +175,12 @@ pub(crate) fn scroll_boundary_behavior(arena: &impl PaintRead, slot: NodeSlotId)
let shows_overscroll_effect = |value: u8| value == AUTO || value == CONTAIN;
ScrollBoundaryBehavior {
chains_to_ancestors: PhysicalAxes {
- horizontal: chains(misc_reset.overscroll_behavior_x),
- vertical: chains(misc_reset.overscroll_behavior_y),
+ horizontal: chains(misc_interaction.overscroll_behavior_x),
+ vertical: chains(misc_interaction.overscroll_behavior_y),
},
shows_overscroll_effect: PhysicalAxes {
- horizontal: shows_overscroll_effect(misc_reset.overscroll_behavior_x),
- vertical: shows_overscroll_effect(misc_reset.overscroll_behavior_y),
+ horizontal: shows_overscroll_effect(misc_interaction.overscroll_behavior_x),
+ vertical: shows_overscroll_effect(misc_interaction.overscroll_behavior_y),
},
}
}
@@ -197,12 +197,11 @@ pub(crate) fn wheel_scrollable_axes(arena: &impl PaintRead, slot: NodeSlotId) ->
let Some(style) = arena.node_style_if_live(slot) else {
return PhysicalAxes::default();
};
- let box_values = style.box_values();
let allows_wheel_scrolling =
|overflow| overflow == css_enums::overflow::AUTO || overflow == css_enums::overflow::SCROLL;
let mut axes = PhysicalAxes {
- horizontal: allows_wheel_scrolling(box_values.overflow_x),
- vertical: allows_wheel_scrolling(box_values.overflow_y),
+ horizontal: allows_wheel_scrolling(style.overflow_x()),
+ vertical: allows_wheel_scrolling(style.overflow_y()),
};
if !axes.horizontal && !axes.vertical {
return axes;
@@ -344,7 +343,7 @@ impl<'a, Arena: PaintRead> ChromeGeometry<'a, Arena> {
return None;
}
let style = self.arena.node_style_if_live(slot)?;
- if style.misc_reset().scrollbar_width == css_enums::scrollbar_width::NONE {
+ if style.misc_interaction().scrollbar_width == css_enums::scrollbar_width::NONE {
return None;
}
@@ -400,8 +399,8 @@ impl<'a, Arena: PaintRead> ChromeGeometry<'a, Arena> {
}
let style = arena.node_style_if_live(slot)?;
let overflow = match direction {
- ScrollDirection::Horizontal => style.box_values().overflow_x,
- ScrollDirection::Vertical => style.box_values().overflow_y,
+ ScrollDirection::Horizontal => style.overflow_x(),
+ ScrollDirection::Vertical => style.overflow_y(),
};
if overflow != css_enums::overflow::SCROLL && !self.wheel_scrollable_axes(slot).along(direction) {
return None;
@@ -498,7 +497,7 @@ pub(crate) fn scrollbar_colors_for_paint(
let Some(style) = arena.node_style_if_live(ancestor) else {
continue;
};
- let color = Color(style.background().background_color);
+ let color = Color(style.background_color());
if color.alpha() != 0 {
background_color = background_color.blend(color);
}
diff --git a/Libraries/LibWeb/Rust/src/painting/ffi.rs b/Libraries/LibWeb/Rust/src/painting/ffi.rs
index 67244546edb..0ce911fdec8 100644
--- a/Libraries/LibWeb/Rust/src/painting/ffi.rs
+++ b/Libraries/LibWeb/Rust/src/painting/ffi.rs
@@ -410,7 +410,7 @@ pub enum FfiRecordingStart {
Recorded,
}
-/// Why a rendering update's frame (its style transaction, or its recording) may not fly beside the
+/// Why a rendering update's frame (its style update, or its recording) may not fly beside the
/// event loop: something reads what it computes before the next task.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
@@ -1133,7 +1133,10 @@ pub extern "C" fn render_state_paintable_used_grid_tracks(
return std::ptr::null();
};
let list = if columns { &tracks.columns } else { &tracks.rows };
- std::sync::Arc::into_raw(std::sync::Arc::new(list.style_value())).cast()
+ crate::css::style_value_arc::StyleValueArc::into_raw(crate::css::style_value_arc::StyleValueArc::new(
+ list.style_value(),
+ ))
+ .cast()
},
)
}
diff --git a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
index 1fb5ead4a51..bbc16e22e9c 100644
--- a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
+++ b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
@@ -691,6 +691,13 @@ pub extern "C" fn render_state_hold_next_recording_for_testing() {
crate::painting::recording_slot::hold_next_recording_for_testing();
}
+/// Holds the next style update that flies before it reads anything, until the test releases it or the host waits
+/// for it.
+#[unsafe(no_mangle)]
+pub extern "C" fn render_state_hold_next_style_flight_for_testing() {
+ crate::painting::recording_slot::hold_next_style_flight_for_testing();
+}
+
/// Lets the recording held for the test go.
#[unsafe(no_mangle)]
pub extern "C" fn render_state_release_held_recording_for_testing() {
diff --git a/Libraries/LibWeb/Rust/src/painting/image_map_areas.rs b/Libraries/LibWeb/Rust/src/painting/image_map_areas.rs
index 3823275f11f..1b459e99b54 100644
--- a/Libraries/LibWeb/Rust/src/painting/image_map_areas.rs
+++ b/Libraries/LibWeb/Rust/src/painting/image_map_areas.rs
@@ -185,6 +185,7 @@ fn rectangle_path(left: f32, top: f32, right: f32, bottom: f32) -> Path {
pub struct ImageMapAreaColumn {
/// Shared with the rows published for the host, so a write copies the maps only while those hold them.
maps: Arc<ImageMaps>,
+ writes: u64,
}
/// The `<area>` elements of the image map of every image that has one, by the image's paintable row.
@@ -197,16 +198,16 @@ impl ImageMapAreaColumn {
return;
}
if areas.is_empty() {
- if self.maps.contains_key(&slot) {
- Arc::make_mut(&mut self.maps).remove(&slot);
- }
+ self.forget(slot);
} else {
+ self.writes += 1;
Arc::make_mut(&mut self.maps).insert(slot, areas.into());
}
}
pub fn forget(&mut self, slot: NodeSlotId) {
if self.maps.contains_key(&slot) {
+ self.writes += 1;
Arc::make_mut(&mut self.maps).remove(&slot);
}
}
@@ -221,9 +222,9 @@ impl ImageMapAreaColumn {
self.maps.clone()
}
- /// Where the maps are, which moves when a write copies the ones a snapshot shares.
- pub(crate) fn address(&self) -> usize {
- Arc::as_ptr(&self.maps).addr()
+ /// How many writes the maps took.
+ pub(crate) fn writes(&self) -> u64 {
+ self.writes
}
}
diff --git a/Libraries/LibWeb/Rust/src/painting/intersection_observer.rs b/Libraries/LibWeb/Rust/src/painting/intersection_observer.rs
index 88793cad37d..cd983d1add4 100644
--- a/Libraries/LibWeb/Rust/src/painting/intersection_observer.rs
+++ b/Libraries/LibWeb/Rust/src/painting/intersection_observer.rs
@@ -127,7 +127,7 @@ pub(crate) fn transform_subtree_is_clipped_outside(
ancestor = parent;
continue;
};
- if style.box_values().position == positioning::FIXED {
+ if style.position() == positioning::FIXED {
return false;
}
diff --git a/Libraries/LibWeb/Rust/src/painting/paint_passes.rs b/Libraries/LibWeb/Rust/src/painting/paint_passes.rs
index d370bb8dbb2..03e61c5c87a 100644
--- a/Libraries/LibWeb/Rust/src/painting/paint_passes.rs
+++ b/Libraries/LibWeb/Rust/src/painting/paint_passes.rs
@@ -406,10 +406,7 @@ pub(crate) fn update_accumulated_visual_contexts(
let viewport_overflow = arena
.paintable_rows()
.node_style_if_live(viewport)
- .map_or((0, 0), |style| {
- let box_values = style.box_values();
- (box_values.overflow_x, box_values.overflow_y)
- });
+ .map_or((0, 0), |style| (style.overflow_x(), style.overflow_y()));
let viewport_overflow_changed =
std::mem::replace(&mut state.last_viewport_overflow, viewport_overflow) != viewport_overflow;
if viewport_overflow_changed {
diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs
index 85bc978bfb1..47a7dd046b1 100644
--- a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs
+++ b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs
@@ -224,7 +224,8 @@ impl UniqueNodeIdColumn {
#[derive(Clone, Default)]
pub(crate) struct PaintableRowStore {
rows: CowColumn<PaintableData, PAINTABLE_SLOTS_PER_CHUNK>,
- side_data: Vec<PaintableSideData>,
+ /// In chunks a fork of the arena shares until either side writes one, so forking does not copy every row's.
+ side_data: crate::cow_column::CowVec<PaintableSideData, PAINTABLE_SLOTS_PER_CHUNK>,
committed_side_data: CowColumn<CommittedSideData, PAINTABLE_SLOTS_PER_CHUNK>,
pub(crate) row_paint_states: Vec<RowPaintState>,
pub(crate) damage: DamageSet,
diff --git a/Libraries/LibWeb/Rust/src/painting/record/async_scroll_metadata.rs b/Libraries/LibWeb/Rust/src/painting/record/async_scroll_metadata.rs
index 2beeb826ae6..b2022efdd17 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/async_scroll_metadata.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/async_scroll_metadata.rs
@@ -347,7 +347,7 @@ impl<O: Observer> PaintRecorder<'_, O> {
let records_viewport_scrollbars = self.source.node_kind_if_live(paintable) == Some(NodeKind::Viewport)
&& self.inputs.uncaptured.paint_viewport_scrollbars
&& self.source.node_style_if_live(paintable).is_some_and(|style| {
- style.misc_reset().scrollbar_width != crate::css::css_enums::scrollbar_width::NONE
+ style.misc_interaction().scrollbar_width != crate::css::css_enums::scrollbar_width::NONE
});
if !records_viewport_scrollbars {
return;
diff --git a/Libraries/LibWeb/Rust/src/painting/record/hit_test_items.rs b/Libraries/LibWeb/Rust/src/painting/record/hit_test_items.rs
index 13b4db95149..b25aad9cc78 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/hit_test_items.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/hit_test_items.rs
@@ -106,13 +106,13 @@ pub(crate) fn hit_test_facts(arena: &impl PaintRead, paintable: NodeSlotId) -> H
HitTestFacts {
visible_for_hit_testing: arena.paintable_row_is_populated(paintable)
&& row.dom_paint_facts() & DomPaintFact::Inert as u8 == 0
- && style.inherited_ui().pointer_events != css_enums::pointer_events::NONE,
+ && style.pointer_events() != css_enums::pointer_events::NONE,
has_resizer: crate::painting::chrome_geometry::has_resizer(arena, paintable),
could_be_scrolled_horizontally: wheel_axes.horizontal,
could_be_scrolled_vertically: wheel_axes.vertical,
svg_hit_areas: if svg_path {
let areas = svg_hit_areas(
- style.inherited_ui().pointer_events,
+ style.pointer_events(),
style.visibility() == css_enums::visibility::VISIBLE,
svg.fill.kind == SVG_PAINT_NONE,
svg.stroke.kind == SVG_PAINT_NONE,
@@ -131,7 +131,7 @@ pub(crate) fn hit_test_facts(arena: &impl PaintRead, paintable: NodeSlotId) -> H
// image is the determinant for whether the image receives the event).
// NB: The rectangular area for the image is also its bounding box.
if svg_hit_areas(
- style.inherited_ui().pointer_events,
+ style.pointer_events(),
style.visibility() == css_enums::visibility::VISIBLE,
false,
false,
@@ -142,7 +142,7 @@ pub(crate) fn hit_test_facts(arena: &impl PaintRead, paintable: NodeSlotId) -> H
0
}
} else if row.kind() == NodeKind::SVGGraphicsBox
- && style.inherited_ui().pointer_events == css_enums::pointer_events::BOUNDING_BOX
+ && style.pointer_events() == css_enums::pointer_events::BOUNDING_BOX
{
svg_hit_area::BOUNDING_BOX
} else {
@@ -568,7 +568,7 @@ impl<'a, O: Observer> PaintRecorder<'a, O> {
return false;
};
if style.visibility() != css_enums::visibility::VISIBLE
- || style.inherited_ui().pointer_events == css_enums::pointer_events::NONE
+ || style.pointer_events() == css_enums::pointer_events::NONE
{
return false;
}
@@ -587,7 +587,7 @@ impl<'a, O: Observer> PaintRecorder<'a, O> {
let parent_style = self.source.node_style_if_live(parent)?;
if parent_style.visibility() != css_enums::visibility::VISIBLE
|| parent_style.effects().opacity == 0.0
- || parent_style.inherited_ui().pointer_events == css_enums::pointer_events::NONE
+ || parent_style.pointer_events() == css_enums::pointer_events::NONE
|| row.dom_paint_facts() & DomPaintFact::Inert as u8 != 0
{
return None;
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/background.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/background.rs
index b60230a4b1c..e0ad500af43 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/background.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/background.rs
@@ -95,7 +95,7 @@ pub(crate) fn paint_background_within<O: Observer>(
paintable,
style,
paintable,
- libgfx_rust::Color(style.background().background_color),
+ libgfx_rust::Color(style.background_color()),
style.background().background_color_clip,
background_rect,
border_radii,
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/background_resolution.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/background_resolution.rs
index 4c2f65646be..6462fdeb24e 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/background_resolution.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/background_resolution.rs
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+use crate::css::style_value::{BackgroundSizePayload, ImageSetPayload, PositionPayload};
use crate::painting::record::trace::Observer;
use crate::css::computed_value_views::{ComputedValuesView, LengthPercentageRef};
@@ -238,7 +239,7 @@ pub(crate) fn background_paint_source_from_style_and_geometry(
}
let border_radii = border_radii_data(style, layout_arena, slot);
let background_color_clip = style.background().background_color_clip;
- let own_color = libgfx_rust::Color(style.background().background_color);
+ let own_color = libgfx_rust::Color(style.background_color());
// https://drafts.csswg.org/css-backgrounds/#root-background
if style_queries::node_is_root_element(layout_arena, slot) {
@@ -260,7 +261,7 @@ pub(crate) fn background_paint_source_from_style_and_geometry(
own_color
} else {
body_style.map_or(libgfx_rust::Color(0), |body_style| {
- libgfx_rust::Color(body_style.background().background_color)
+ libgfx_rust::Color(body_style.background_color())
})
};
// If the body's background was propagated to the root element, use the body's image-rendering value.
@@ -331,10 +332,13 @@ fn computed_layer_size(size_item: &StyleValueData) -> ComputedLayerSize<'_> {
match size_item {
StyleValueData::Keyword { keyword } if *keyword == CONTAIN => ComputedLayerSize::Contain,
StyleValueData::Keyword { keyword } if *keyword == COVER => ComputedLayerSize::Cover,
- StyleValueData::BackgroundSize { size_x, size_y } => ComputedLayerSize::LengthPercentage {
- x: length_percentage_or_auto(size_x.data()),
- y: length_percentage_or_auto(size_y.data()),
- },
+ StyleValueData::BackgroundSize(background_size_payload) => {
+ let BackgroundSizePayload { size_x, size_y } = &**background_size_payload;
+ ComputedLayerSize::LengthPercentage {
+ x: length_percentage_or_auto(size_x.data()),
+ y: length_percentage_or_auto(size_y.data()),
+ }
+ }
_ => unreachable!("computed background-size holds an unknown value"),
}
}
@@ -448,9 +452,10 @@ fn computed_mask_layers(style: ComputedValuesView<'_>, facts_owner: NodeSlotId)
let StyleValueData::RepeatStyle { repeat_x, repeat_y } = cycled(&repeat_items, index) else {
unreachable!("computed mask-repeat holds a repeat-style value");
};
- let StyleValueData::Position { edge_x, edge_y } = cycled(&position_items, index) else {
+ let StyleValueData::Position(position_payload) = cycled(&position_items, index) else {
unreachable!("computed mask-position holds a position value");
};
+ let PositionPayload { edge_x, edge_y } = &**position_payload;
let clip_keyword = keyword_of(cycled(&clip_items, index));
let clip = css_enums::keyword_to_background_box(clip_keyword).unwrap_or(css_enums::background_box::BORDER_BOX);
let origin = css_enums::keyword_to_background_box(keyword_of(cycled(&origin_items, index)))
@@ -772,10 +777,13 @@ fn layer_image_intrinsics<'a, O: Observer>(
_ => {
let facts = committed_layer_image_paint_facts(recorder, image);
let selected_image_value = match (image.value, facts.image_set_selected_option_index) {
- (StyleValueData::ImageSet { options }, Some(option_index)) => options
- .as_slice()
- .get(option_index as usize)
- .map(|option| option.values()[0].data()),
+ (StyleValueData::ImageSet(image_set_payload_1), Some(option_index)) => {
+ let ImageSetPayload { options } = &**image_set_payload_1;
+ options
+ .as_slice()
+ .get(option_index as usize)
+ .map(|option| option.values()[0].data())
+ }
_ => None,
};
LayerImageIntrinsics {
@@ -847,7 +855,7 @@ pub(crate) fn has_background_to_paint(
return true;
}
arena.node_style_if_live(paintable).is_some_and(|style| {
- libgfx_rust::Color(style.background().background_color).alpha() != 0
+ libgfx_rust::Color(style.background_color()).alpha() != 0
|| arena.node_has_compositor_animation_frame(
paintable,
crate::layout::node_data::CompositorAnimationFrameKind::BackgroundColor,
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/border_image.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/border_image.rs
index cd3efe27fdd..62539983861 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/border_image.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/border_image.rs
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+use crate::css::style_value::BorderImageSlicePayload;
use crate::painting::paint_read::PaintRead;
use crate::painting::record::trace::Observer;
@@ -418,13 +419,16 @@ pub(crate) fn paint_border_image<O: Observer>(
let slice_value = style_queries::handle_value(&border.border_image_slice)
.expect("computed border-image-slice lost its style value");
let (slice_values, fill) = match slice_value {
- StyleValueData::BorderImageSlice {
- top,
- right,
- bottom,
- left,
- fill,
- } => ([top.data(), right.data(), bottom.data(), left.data()], *fill),
+ StyleValueData::BorderImageSlice(border_image_slice_payload) => {
+ let BorderImageSlicePayload {
+ top,
+ right,
+ bottom,
+ left,
+ fill,
+ } = &**border_image_slice_payload;
+ ([top.data(), right.data(), bottom.data(), left.data()], *fill)
+ }
// NB: Typed OM can supply a single numeric slice directly, without the parser's four-sided wrapper.
StyleValueData::Number { .. }
| StyleValueData::Integer { .. }
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/form_controls.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/form_controls.rs
index d12c23cc221..73dd9d5f7a5 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/form_controls.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/form_controls.rs
@@ -60,7 +60,7 @@ fn form_control_system_colors<O: Observer>(
let ui = style.inherited_ui();
(
ui.color_scheme == PREFERRED_COLOR_SCHEME_DARK,
- (!ui.accent_color.is_auto).then_some(Color(ui.accent_color.used_color)),
+ (!ui.accent_color.is_auto).then_some(Color(ui.accent_color.color.resolve(style.current_color()))),
)
});
let system_color = |keyword_code: u16| {
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/gradient_resolution.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/gradient_resolution.rs
index 6fc749d57ab..fdfe00fbeee 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/gradient_resolution.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/gradient_resolution.rs
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+use crate::css::style_value::{ConicGradientPayload, LinearGradientPayload, RadialGradientPayload};
use crate::painting::record::trace::Observer;
use crate::css::color_resolution::{ColorResolutionInput, to_color};
@@ -836,34 +837,38 @@ pub(crate) fn resolve_gradient_paint_with_input(
) -> ResolvedGradientPaint {
let gradient_box = CssPixelRect::from_location_and_size(CssPixelPoint::default(), tile_size);
match gradient_value {
- StyleValueData::LinearGradient {
- has_direction_value,
- direction_value,
- side_or_corner,
- color_stop_list,
- gradient_type,
- repeating,
- color_interpolation_method,
- color_syntax,
- } => ResolvedGradientPaint::Linear(resolve_linear_gradient_paint(
- color_stop_list.as_slice(),
- has_direction_value.then(|| direction_value.data()),
- *side_or_corner,
- *gradient_type,
- *repeating,
- color_interpolation_method,
- *color_syntax,
- tile_size,
- color_input,
- )),
- StyleValueData::ConicGradient {
- from_angle,
- position,
- color_stop_list,
- repeating,
- color_interpolation_method,
- color_syntax,
- } => {
+ StyleValueData::LinearGradient(linear_gradient_payload) => {
+ let LinearGradientPayload {
+ has_direction_value,
+ direction_value,
+ side_or_corner,
+ color_stop_list,
+ gradient_type,
+ repeating,
+ color_interpolation_method,
+ color_syntax,
+ } = &**linear_gradient_payload;
+ ResolvedGradientPaint::Linear(resolve_linear_gradient_paint(
+ color_stop_list.as_slice(),
+ has_direction_value.then(|| direction_value.data()),
+ *side_or_corner,
+ *gradient_type,
+ *repeating,
+ color_interpolation_method,
+ *color_syntax,
+ tile_size,
+ color_input,
+ ))
+ }
+ StyleValueData::ConicGradient(conic_gradient_payload) => {
+ let ConicGradientPayload {
+ from_angle,
+ position,
+ color_stop_list,
+ repeating,
+ color_interpolation_method,
+ color_syntax,
+ } = &**conic_gradient_payload;
let (data, resolved_position) = resolve_conic_gradient_paint(
color_stop_list.as_slice(),
from_angle,
@@ -879,15 +884,16 @@ pub(crate) fn resolve_gradient_paint_with_input(
position: resolved_position,
}
}
- StyleValueData::RadialGradient {
- ending_shape,
- size,
- position,
- color_stop_list,
- repeating,
- color_interpolation_method,
- color_syntax,
- } => {
+ StyleValueData::RadialGradient(radial_gradient_payload) => {
+ let RadialGradientPayload {
+ ending_shape,
+ size,
+ position,
+ color_stop_list,
+ repeating,
+ color_interpolation_method,
+ color_syntax,
+ } = &**radial_gradient_payload;
let (data, center, gradient_size) = resolve_radial_gradient_paint(
color_stop_list.as_slice(),
*ending_shape,
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs
index 3587702f87a..f2b5b53176b 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs
@@ -355,7 +355,7 @@ fn set_own_background_as_contrast_backdrop<O: Observer>(
let backdrop = recorder
.source
.node_style_if_live(paintable)
- .map(|style| libgfx_rust::Color(style.background().background_color));
+ .map(|style| libgfx_rust::Color(style.background_color()));
recorder.recorder.set_contrast_backdrop(backdrop)
}
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/overlay.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/overlay.rs
index 431965f2b78..dbcdd845053 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/overlay.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/overlay.rs
@@ -30,7 +30,7 @@ pub(crate) fn paint_overlay<O: Observer>(recorder: &mut PaintRecorder<'_, O>, pa
let chrome_geometry = ChromeGeometry::for_recording(recorder.source, recorder.inputs);
let style = recorder.source.node_style_if_live(paintable);
let paints_scrollbars = style.is_some_and(|style| {
- !is_viewport && style.misc_reset().scrollbar_width != crate::css::css_enums::scrollbar_width::NONE
+ !is_viewport && style.misc_interaction().scrollbar_width != crate::css::css_enums::scrollbar_width::NONE
});
if paints_scrollbars {
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs
index 9fb5c65181d..1fb8ecba212 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs
@@ -232,7 +232,7 @@ pub(crate) fn get_replaced_box_painting_area<O: Observer>(
let zero = crate::css::css_pixels::CssPixels::from_raw(0);
match style {
Some(style) => {
- let misc = style.misc_reset();
+ let misc = style.misc_layout();
(
misc.object_position_x
.length_percentage()
@@ -278,7 +278,7 @@ fn replaced_style<O: Observer>(recorder: &PaintRecorder<'_, O>, paintable: NodeS
.source
.node_style_if_live(paintable)
.map_or((object_fit::FILL, image_rendering::AUTO), |style| {
- (style.misc_reset().object_fit, style.image_rendering())
+ (style.misc_layout().object_fit, style.image_rendering())
})
}
@@ -318,7 +318,7 @@ pub(crate) fn paint_image_foreground<O: Observer>(recorder: &mut PaintRecorder<'
let backdrop = recorder
.source
.node_style_if_live(paintable)
- .map(|style| libgfx_rust::Color(style.background().background_color));
+ .map(|style| libgfx_rust::Color(style.background_color()));
let previous = recorder.recorder.set_contrast_backdrop(backdrop);
recorder
.recorder
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/shadow.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/shadow.rs
index 82e433730f3..8cec63ccee0 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/shadow.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/shadow.rs
@@ -58,6 +58,7 @@ pub(crate) fn paint_box_shadow<O: Observer>(
if layers.is_empty() {
return;
}
+ let current_color = style.current_color();
paint_box_shadow_layers(
recorder,
paintable,
@@ -65,6 +66,7 @@ pub(crate) fn paint_box_shadow<O: Observer>(
borderless_content_rect,
border_radii,
layers,
+ current_color,
);
}
@@ -75,6 +77,7 @@ fn paint_box_shadow_layers<O: Observer>(
borderless_content_rect: CssPixelRect,
border_radii: BorderRadii,
layers: &[crate::css::computed_value_types::ComputedShadow],
+ current_color: u32,
) {
let converter = recorder.converter;
let corner_radii = border_radii.as_corners(&converter);
@@ -98,7 +101,7 @@ fn paint_box_shadow_layers<O: Observer>(
if let Some(shadow_shapes) = &shadow_shapes {
recorder.recorder.paint_path_box_shadow(
- Color(layer.color),
+ Color(layer.color.resolve(current_color)),
blur_radius,
spread_distance as f32,
FloatPoint {
@@ -147,7 +150,7 @@ fn paint_box_shadow_layers<O: Observer>(
recorder.recorder.paint_inner_box_shadow(
PaintInnerBoxShadow {
- color: Color(layer.color),
+ color: Color(layer.color.resolve(current_color)),
blur_radius,
device_content_rect,
content_corner_radii: corner_radii,
@@ -168,7 +171,7 @@ fn paint_box_shadow_layers<O: Observer>(
recorder.recorder.paint_outer_box_shadow(
PaintOuterBoxShadow {
- color: Color(layer.color),
+ color: Color(layer.color.resolve(current_color)),
blur_radius,
device_content_rect,
content_corner_radii: corner_radii,
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/svg.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/svg.rs
index 512f666d6a3..ab5f20ad841 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/svg.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/svg.rs
@@ -49,11 +49,12 @@ struct SvgPaintFacts {
references_paint_server: bool,
}
-pub(crate) fn svg_paint_color(paint: &ComputedSvgPaint) -> Option<u32> {
+/// The color `paint` paints with, with `currentcolor` resolved to `current_color`.
+pub(crate) fn svg_paint_color(paint: &ComputedSvgPaint, current_color: u32) -> Option<u32> {
match paint.kind {
SVG_PAINT_NONE => None,
- SVG_PAINT_COLOR => Some(paint.color),
- _ => paint.has_color.then_some(paint.color),
+ SVG_PAINT_COLOR => Some(paint.color.resolve(current_color)),
+ _ => paint.has_color.then(|| paint.color.resolve(current_color)),
}
}
@@ -96,8 +97,8 @@ fn svg_paint_facts<O: Observer>(
facts.fill_winding = to_winding(svg.fill_rule);
facts.fill_opacity = svg.fill_opacity;
facts.stroke_opacity = svg.stroke_opacity;
- facts.fill_color = svg_paint_color(&svg.fill);
- facts.stroke_color = svg_paint_color(&svg.stroke);
+ facts.fill_color = svg_paint_color(&svg.fill, style.current_color());
+ facts.stroke_color = svg_paint_color(&svg.stroke, style.current_color());
facts.references_paint_server = svg.fill.kind == SVG_PAINT_URL || svg.stroke.kind == SVG_PAINT_URL;
let stroke = svg_stroke_style(layout_arena, paintable, &style);
facts.cap_style = stroke.cap_style;
@@ -659,8 +660,7 @@ pub(crate) fn paint_image_element<O: Observer>(
.map_or((false, 0), |style| {
use crate::css::css_enums::overflow;
(
- style.box_values().overflow_x == overflow::VISIBLE
- && style.box_values().overflow_y == overflow::VISIBLE,
+ style.overflow_x() == overflow::VISIBLE && style.overflow_y() == overflow::VISIBLE,
style.image_rendering(),
)
});
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/table_backgrounds.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/table_backgrounds.rs
index 47c2b830c03..ac22490eb32 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/table_backgrounds.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/table_backgrounds.rs
@@ -51,7 +51,7 @@ pub(crate) fn paint_table_part_background<O: Observer>(recorder: &mut PaintRecor
paintable,
style,
paintable,
- libgfx_rust::Color(style.background().background_color),
+ libgfx_rust::Color(style.background_color()),
style.background().background_color_clip,
part_rect,
BorderRadii::default(),
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/text.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/text.rs
index 42e775e13c7..3f6975096b5 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/text.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/text.rs
@@ -234,7 +234,7 @@ fn compute_render_spans<O: Observer>(
.as_slice()
.iter()
.map(|shadow| ShadowLayer {
- color: shadow.color,
+ color: shadow.color.resolve(parent_style.current_color()),
offset_x: CssPixels::from_raw(shadow.offset_x),
offset_y: CssPixels::from_raw(shadow.offset_y),
blur_radius: CssPixels::from_raw(shadow.blur_radius),
@@ -460,7 +460,7 @@ pub(crate) fn paint_fragments<O: Observer>(recorder: &mut PaintRecorder<'_, O>,
let highlight_backdrop = recorder
.source
.node_style_if_live(block)
- .map(|style| Color(style.background().background_color));
+ .map(|style| Color(style.background_color()));
for highlight in HIGHLIGHT_OVERLAY_ORDER {
let overlays = || {
spans.iter().flat_map(move |span| {
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/text_decoration.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/text_decoration.rs
index 168f2f9a95b..e263e7f5c97 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/text_decoration.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/text_decoration.rs
@@ -194,7 +194,7 @@ pub(crate) fn decoration_sets_for_span<O: Observer>(
current,
lines,
text_reset.text_decoration_style,
- span.decoration_color.unwrap_or(text_reset.text_decoration_color),
+ span.decoration_color.unwrap_or(style.text_decoration_color()),
thickness,
);
}
@@ -230,7 +230,7 @@ pub(crate) fn decoration_sets_for_span<O: Observer>(
block_node,
lines,
text_reset.text_decoration_style,
- span.decoration_color.unwrap_or(text_reset.text_decoration_color),
+ span.decoration_color.unwrap_or(style.text_decoration_color()),
thickness,
);
}
diff --git a/Libraries/LibWeb/Rust/src/painting/recording_slot.rs b/Libraries/LibWeb/Rust/src/painting/recording_slot.rs
index aa7157eb17b..48370155aef 100644
--- a/Libraries/LibWeb/Rust/src/painting/recording_slot.rs
+++ b/Libraries/LibWeb/Rust/src/painting/recording_slot.rs
@@ -327,12 +327,13 @@ enum RecordingHold {
Idle,
Armed,
Holding,
- // A layout held is never handed to the StyleLayout thread until it goes, so that the thread runs the jobs of other
+ // A layout held is never handed to the Render thread until it goes, so that the thread runs the jobs of other
// documents meanwhile, as one the collector finalizes asks of it.
#[cfg(not(test))]
HoldingLayout {
_parked: ParkedJob,
},
+ ArmedForStyle,
}
static RECORDING_HOLD: Mutex<RecordingHold> = Mutex::new(RecordingHold::Idle);
@@ -357,22 +358,36 @@ pub(crate) fn take_recording_hold_for_testing() -> bool {
true
}
-/// Submits `job`, the layout of a frame, to the StyleLayout thread, or parks it where the test hold is armed for it.
-/// Answers the flight and whether the hold took it.
+/// Submits `job`, the layout of a frame, to the Render thread, which claims it inside `claim_under`, so that the
+/// host may take it back until then, or parks it where the test hold is armed for it. Answers the flight and whether
+/// the hold took it.
#[cfg(not(test))]
pub(crate) fn submit_layout<R: Send + 'static>(
job: impl FnOnce(&StopWord) -> R + Send + 'static,
+ claim_under: fn(&mut dyn FnMut()),
) -> (InFlight<R>, bool) {
- let thread = crate::stage_thread::style_layout_thread();
+ let thread = crate::stage_thread::render_thread();
let mut hold = recording_hold();
if !matches!(*hold, RecordingHold::Armed) {
- return (thread.submit(job), false);
+ return (thread.submit_reclaimable(job, claim_under), false);
}
let (flight, parked) = thread.park(job);
*hold = RecordingHold::HoldingLayout { _parked: parked };
(flight, true)
}
+/// Whether the style update about to fly is the one the test hold is armed for, which then parks as a frame's
+/// layout does.
+#[cfg(not(test))]
+pub(crate) fn take_style_flight_hold_for_testing() -> bool {
+ let mut hold = recording_hold();
+ if !matches!(*hold, RecordingHold::ArmedForStyle) {
+ return false;
+ }
+ *hold = RecordingHold::Armed;
+ true
+}
+
pub(crate) fn wait_while_recording_is_held_for_testing() {
let _released = RECORDING_HOLD_RELEASED
.wait_while(recording_hold(), |hold| matches!(hold, RecordingHold::Holding))
@@ -385,6 +400,13 @@ pub(crate) fn hold_next_recording_for_testing() {
*recording_hold() = RecordingHold::Armed;
}
+/// Holds the next style update that flies before it reads anything, until
+/// [`release_held_recording_for_testing`] or a wait for it, so that a test orders what it does beside the flight ahead
+/// of everything the transaction computes.
+pub(crate) fn hold_next_style_flight_for_testing() {
+ *recording_hold() = RecordingHold::ArmedForStyle;
+}
+
/// Lets the recording held for the test go, or disarms the hold no recording has taken yet.
pub(crate) fn release_held_recording_for_testing() {
*recording_hold() = RecordingHold::Idle;
diff --git a/Libraries/LibWeb/Rust/src/painting/scroll_snap.rs b/Libraries/LibWeb/Rust/src/painting/scroll_snap.rs
index 976953e1eda..9d08517020a 100644
--- a/Libraries/LibWeb/Rust/src/painting/scroll_snap.rs
+++ b/Libraries/LibWeb/Rust/src/painting/scroll_snap.rs
@@ -45,7 +45,7 @@ pub(crate) fn snap_axes_of_scroll_container(arena: &impl PaintRead, snap_contain
}
fn snap_axes_of_style(style: ComputedValuesView<'_>) -> FfiSnapAxes {
- let snap_type = style.misc_reset();
+ let snap_type = style.misc_interaction();
if snap_type.scroll_snap_strictness == scroll_snap_strictness::NONE {
return FfiSnapAxes::default();
}
@@ -90,7 +90,7 @@ pub(crate) fn scroll_snapport_rect(
let Some(style) = snap_style(arena, snap_container) else {
return scrollport;
};
- shrink_by_scroll_padding(scrollport, &style.misc_reset().scroll_padding)
+ shrink_by_scroll_padding(scrollport, &style.misc_interaction().scroll_padding)
}
fn shrink_by_scroll_padding(scrollport: CssPixelRect, scroll_padding: &ComputedLengthBox) -> CssPixelRect {
@@ -130,10 +130,10 @@ pub(crate) fn snap_container_geometry(
paintable_geometry::scrollable_overflow_rect(arena, snap_container)?;
let scrollport = paintable_geometry::absolute_padding_box_rect(arena, snap_container);
Some(FfiSnapContainerGeometry {
- snapport: shrink_by_scroll_padding(scrollport, &style.misc_reset().scroll_padding).into(),
+ snapport: shrink_by_scroll_padding(scrollport, &style.misc_interaction().scroll_padding).into(),
min_scroll_offset: minimum_scroll_offset(arena, snap_container).into(),
max_scroll_offset: maximum_scroll_offset(arena, snap_container).into(),
- strictness: style.misc_reset().scroll_snap_strictness,
+ strictness: style.misc_interaction().scroll_snap_strictness,
axes,
horizontal_writing_mode: style.writing_mode() == writing_mode::HORIZONTAL_TB,
})
@@ -150,7 +150,7 @@ pub(crate) fn for_each_snap_area(
};
let snapport = shrink_by_scroll_padding(
paintable_geometry::absolute_padding_box_rect(arena, snap_container),
- &container_style.misc_reset().scroll_padding,
+ &container_style.misc_interaction().scroll_padding,
);
let container_writing_mode = WritingModeFacts::of(container_style);
for_each_descendant_with_snap_alignment(arena, snap_container, &mut |snap_area, style| {
@@ -200,7 +200,7 @@ fn snap_area_geometry(
snapport: CssPixelRect,
container_writing_mode: WritingModeFacts,
) -> Option<FfiSnapAreaGeometry> {
- let misc = style.misc_reset();
+ let misc = style.misc_interaction();
let rect = inflate_by_scroll_margin(
captured_snap_area_rect(arena, snap_area, snap_container)?,
&misc.scroll_margin,
diff --git a/Libraries/LibWeb/Rust/src/painting/selection.rs b/Libraries/LibWeb/Rust/src/painting/selection.rs
index 7998fc83afd..3a7dc6ac65b 100644
--- a/Libraries/LibWeb/Rust/src/painting/selection.rs
+++ b/Libraries/LibWeb/Rust/src/painting/selection.rs
@@ -270,9 +270,9 @@ fn highlight_pseudo_style_of_record(
use crate::css::property_metadata::property_id;
let style = engine.published_record_view(style_record)?;
let dependency_flags = engine.published_record_dependency_flags(style_record).unwrap_or(0);
- let longhand_table = engine.published_record_longhand_table(style_record);
+ let longhands = engine.published_record_longhands(style_record);
let specified_as_current_color =
- |property_id: u16| longhand_table.is_some_and(|table| table.specified_value_is_current_color(property_id));
+ |property_id: u16| longhands.is_some_and(|longhands| longhands.specified_value_is_current_color(property_id));
// https://drafts.csswg.org/css-pseudo-4/#paired-defaults
// Paired default highlight colors must only be used when neither 'color' nor 'background-color' yield a
// cascaded value from the author origin (or inherit their value from the author origin).
@@ -281,7 +281,7 @@ fn highlight_pseudo_style_of_record(
..Default::default()
};
if facts.colors_authored {
- facts.background_color = Color(style.background().background_color);
+ facts.background_color = Color(style.background_color());
facts.background_color_is_current_color = specified_as_current_color(property_id::BACKGROUND_COLOR);
// https://drafts.csswg.org/css-pseudo-4/#highlight-text
// currentColor on a highlight pseudo-element's 'color' property represents the color of the next active
@@ -307,8 +307,8 @@ fn highlight_pseudo_style_of_record(
facts.wash_color = transform_selection_background_color(wash_color);
}
- let shadow_colors_are_current_color = longhand_table
- .map(|table| table.text_shadow_layer_colors_are_current_color())
+ let shadow_colors_are_current_color = longhands
+ .map(|longhands| longhands.text_shadow_layer_colors_are_current_color())
.unwrap_or_default();
let shadows: Vec<HighlightShadowLayer> = style
.inherited_text()
@@ -318,7 +318,7 @@ fn highlight_pseudo_style_of_record(
.enumerate()
.map(|(index, shadow)| HighlightShadowLayer {
layer: ShadowLayer {
- color: shadow.color,
+ color: shadow.color.resolve(style.current_color()),
offset_x: CssPixels::from_raw(shadow.offset_x),
offset_y: CssPixels::from_raw(shadow.offset_y),
blur_radius: CssPixels::from_raw(shadow.blur_radius),
@@ -336,7 +336,7 @@ fn highlight_pseudo_style_of_record(
facts.text_decoration_lines[..count].copy_from_slice(&lines[..count]);
facts.text_decoration_line_count = count as u32;
facts.text_decoration_style = text_reset.text_decoration_style;
- facts.text_decoration_color = Color(text_reset.text_decoration_color);
+ facts.text_decoration_color = Color(style.text_decoration_color());
facts.text_decoration_color_is_current_color = specified_as_current_color(property_id::TEXT_DECORATION_COLOR);
}
@@ -405,7 +405,6 @@ pub(crate) fn sync_highlight_pseudo_styles(
};
let text_rows: Vec<NodeSlotId> = arena.with_style_store(|engine| {
engine
- .tree()
.dom_children(element)
.filter(|child| child.text_index().is_some())
.map(|text| arena.bound_row(text))
diff --git a/Libraries/LibWeb/Rust/src/painting/style_queries.rs b/Libraries/LibWeb/Rust/src/painting/style_queries.rs
index 7dfe140264e..d99dd14bb63 100644
--- a/Libraries/LibWeb/Rust/src/painting/style_queries.rs
+++ b/Libraries/LibWeb/Rust/src/painting/style_queries.rs
@@ -83,14 +83,14 @@ fn fly_string_equals_ascii(string: &CssString, expected: &[u8]) -> bool {
}
fn will_change_has_any_property(style: ComputedValuesView<'_>, names: &[&[u8]]) -> bool {
- let hints = style.misc_reset().implicit_will_change.as_slice();
+ let hints = style.misc_interaction().implicit_will_change.as_slice();
if hints
.iter()
.any(|&property| names.contains(&property_name(property).as_bytes()))
{
return true;
}
- let Some(value) = handle_value(&style.misc_reset().will_change) else {
+ let Some(value) = handle_value(&style.misc_interaction().will_change) else {
return false;
};
let StyleValueData::ValueList { values, .. } = value else {
@@ -172,7 +172,7 @@ pub(crate) fn clip_path_has_value(mask: &MaskValues) -> bool {
}
fn view_transition_name_has_value(style: ComputedValuesView<'_>) -> bool {
- handle_value(&style.misc_reset().view_transition_name)
+ handle_value(&style.misc_interaction().view_transition_name)
.is_some_and(|value| matches!(value, StyleValueData::CustomIdent { .. }))
}
@@ -298,7 +298,7 @@ fn style_establishes_fixed_positioning_containing_block(
pub(crate) fn inline_establishes_absolute_position_containing_block(style: ComputedValuesView<'_>) -> bool {
let effects = style.effects();
- style.box_values().position != positioning::STATIC
+ style.position() != positioning::STATIC
|| filter_has_filters(&effects.filter)
|| filter_has_filters(&effects.backdrop_filter)
|| will_change_has_any_property(style, &[b"position", b"filter", b"backdrop-filter"])
@@ -324,7 +324,7 @@ pub(crate) fn establishes_positioning_containing_blocks(arena: &impl PaintRead,
return (true, true);
}
- if style.box_values().position != positioning::STATIC || will_change_has_property(style, b"position") {
+ if style.position() != positioning::STATIC || will_change_has_property(style, b"position") {
return (true, false);
}
@@ -423,11 +423,10 @@ fn used_transform_style_is_preserve_3d(arena: &impl PaintRead, node: NodeSlotId)
return false;
}
let effects = style.effects();
- let box_values = style.box_values();
let mask_values = style.mask();
let grouping_overflow = |value: u8| value != overflow::VISIBLE && value != overflow::CLIP;
- let has_transform_style_grouping_property = grouping_overflow(box_values.overflow_x)
- || grouping_overflow(box_values.overflow_y)
+ let has_transform_style_grouping_property = grouping_overflow(style.overflow_x())
+ || grouping_overflow(style.overflow_y())
|| effects.opacity < 1.0
|| filter_has_filters(&effects.filter)
|| effects.clip_is_rect
@@ -500,7 +499,7 @@ pub(crate) fn auto_outline_width() -> CssPixels {
}
pub(crate) fn outline_geometry(style: ComputedValuesView<'_>) -> Option<OutlineGeometry> {
- let misc = style.misc_reset();
+ let misc = style.misc_layout();
let (line_style, width) = if misc.outline_style == outline_style::AUTO {
(line_style::SOLID, auto_outline_width())
} else {
@@ -530,7 +529,7 @@ pub(crate) fn outline_data(
auto_outline_color: u32,
) -> Option<OutlineData> {
let style = arena.node_style_if_live(node)?;
- let is_auto = style.misc_reset().outline_style == outline_style::AUTO;
+ let is_auto = style.misc_layout().outline_style == outline_style::AUTO;
if is_auto && !window_is_focused() {
return None;
}
@@ -538,7 +537,7 @@ pub(crate) fn outline_data(
let color = if is_auto {
auto_outline_color
} else {
- style.misc_reset().outline_color
+ style.outline_color()
};
if color >> 24 == 0 {
return None;
@@ -553,7 +552,7 @@ pub(crate) fn outline_data(
pub(crate) fn outline_offset(arena: &impl PaintRead, node: NodeSlotId) -> CssPixels {
arena
.node_style_if_live(node)
- .map_or(CssPixels::from_raw(0), |style| style.misc_reset().outline_offset)
+ .map_or(CssPixels::from_raw(0), |style| style.misc_layout().outline_offset)
}
pub(crate) fn is_text_decoration_propagation_boundary(arena: &impl PaintRead, node: NodeSlotId) -> bool {
@@ -606,7 +605,7 @@ pub(crate) fn is_fixed_position(arena: &impl PaintRead, node: NodeSlotId) -> boo
}
pub(crate) fn is_sticky_position(style: ComputedValuesView<'_>) -> bool {
- style.box_values().position == positioning::STICKY
+ style.position() == positioning::STICKY
}
pub(crate) fn is_floating(arena: &impl PaintRead, node: NodeSlotId) -> bool {
@@ -696,7 +695,7 @@ pub(crate) fn establishes_stacking_context(arena: &impl PaintRead, node: NodeSlo
let box_values = style.box_values();
let will_change = |name: &[u8]| will_change_has_property(style, name);
- let position = box_values.position;
+ let position = style.position();
let has_z_index = box_values.has_z_index || will_change(b"z-index");
if (position == positioning::ABSOLUTE || position == positioning::RELATIVE) && has_z_index {
diff --git a/Libraries/LibWeb/Rust/src/painting/svg_paint_resources.rs b/Libraries/LibWeb/Rust/src/painting/svg_paint_resources.rs
index 1b286b2778e..70066ecd099 100644
--- a/Libraries/LibWeb/Rust/src/painting/svg_paint_resources.rs
+++ b/Libraries/LibWeb/Rust/src/painting/svg_paint_resources.rs
@@ -124,6 +124,7 @@ pub(crate) type SvgPaintResourceRows = HashMap<NodeSlotId, SvgPaintResourceRow>;
#[derive(Clone, Default)]
pub(crate) struct SvgPaintResources {
rows: Arc<SvgPaintResourceRows>,
+ writes: u64,
needs_sync: bool,
/// Whether any row enrolled a resource, which the document's host reads beside a frame in flight. A row the frame
/// enrolls asks for its resources to be resolved again itself.
@@ -172,6 +173,7 @@ pub(crate) fn published_paint_server_in(
impl SvgPaintResources {
fn rows_mut(&mut self) -> &mut SvgPaintResourceRows {
+ self.writes += 1;
Arc::make_mut(&mut self.rows)
}
@@ -180,9 +182,9 @@ impl SvgPaintResources {
self.rows.clone()
}
- /// Where the table is, which moves when a write copies the one a publication shares.
- pub(crate) fn address(&self) -> usize {
- Arc::as_ptr(&self.rows).addr()
+ /// How many writes the table took.
+ pub(crate) fn writes(&self) -> u64 {
+ self.writes
}
pub(crate) fn set_enrolled_kinds(&mut self, slot: NodeSlotId, kinds: u8) {
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_animation_builder.rs b/Libraries/LibWeb/Rust/src/painting/visual_animation_builder.rs
index 280582ee9b5..f51d512ed02 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_animation_builder.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_animation_builder.rs
@@ -20,6 +20,7 @@ use crate::css::style_value::{
FILTER_KIND_BLUR, FILTER_KIND_COLOR, FILTER_KIND_DROP_SHADOW, FILTER_KIND_HUE_ROTATE, RetainedStyleValueData,
StyleValueData, is_none_keyword,
};
+use crate::css::style_value::{ShadowPayload, TransformationPayload};
use crate::css::table_group_builder::{
TRANSFORM_PARAMETER_ANGLE, TRANSFORM_PARAMETER_LENGTH, TRANSFORM_PARAMETER_LENGTH_NONE,
TRANSFORM_PARAMETER_LENGTH_PERCENTAGE, TRANSFORM_PARAMETER_NUMBER, TRANSFORM_PARAMETER_NUMBER_PERCENTAGE,
@@ -222,7 +223,7 @@ fn opacity_from_style_value(value: &StyleValueData) -> Option<f32> {
}
fn is_legacy_color_function(value: &StyleValueData) -> bool {
- matches!(value, StyleValueData::ColorFunction { color_base, .. } if color_base.color_syntax == COLOR_SYNTAX_LEGACY)
+ matches!(value, StyleValueData::ColorFunction(color_function) if color_function.color_base.color_syntax == COLOR_SYNTAX_LEGACY)
}
/// Legacy sRGB colors interpolate in gamma-encoded sRGB, which the compositor sampler matches. Modern
@@ -274,16 +275,16 @@ fn filter_functions_from_style_value(value: &StyleValueData, request: &Request)
)
}
FILTER_KIND_DROP_SHADOW => {
- let StyleValueData::Shadow {
+ let StyleValueData::Shadow(shadow_payload) = value.data() else {
+ return None;
+ };
+ let ShadowPayload {
color,
offset_x,
offset_y,
blur_radius,
..
- } = value.data()
- else {
- return None;
- };
+ } = &**shadow_payload;
// Gfx filters hold 8-bit sRGB colors. Modern color syntaxes and currentcolor stay on the
// main thread until compositor filter values can retain their color space and syntax.
let color = color.optional_data().filter(|color| is_legacy_color_function(color))?;
@@ -471,15 +472,15 @@ fn transform_operations_from_style_value(
}
let lower = |transformation: &StyleValueData| {
- let StyleValueData::Transformation {
+ let StyleValueData::Transformation(transformation_payload) = transformation else {
+ return None;
+ };
+ let TransformationPayload {
transform_function,
values,
matrix_values,
..
- } = transformation
- else {
- return None;
- };
+ } = &**transformation_payload;
// Matrix-only precision inputs must not replace unwrapped animation interpolation arguments.
if !matrix_values.as_slice().is_empty() {
return None;
@@ -871,6 +872,8 @@ mod tests {
use super::*;
use crate::css::easing::{FfiEasingDescriptor, FfiEasingKind, FfiLinearEasingPoint};
use crate::css::style_value::{ColorBase, CssString, RetainedStyleValueDataList};
+ use crate::css::style_value::{ColorFunctionPayload, StyleValueBox};
+ use crate::css::style_value_arc::StyleValueArc;
use crate::css::table_group_builder::angle_unit_index;
use crate::painting::host::{FfiVisualAnimationFillMode, FfiVisualAnimationPlaybackDirection};
use crate::painting::visual_context::publish_compositor_animations;
@@ -918,12 +921,12 @@ mod tests {
}
fn transformation(function: u8, values: Vec<StyleValueData>) -> StyleValueData {
- StyleValueData::Transformation {
+ StyleValueData::Transformation(StyleValueBox::new(TransformationPayload {
property: property_id::TRANSFORM,
transform_function: function,
values: RetainedStyleValueDataList::from_retained_values(values.into_iter().map(retained).collect()),
matrix_values: crate::css::style_value::RetainedStyleValueDataList::from_retained_values(Vec::new()),
- }
+ }))
}
fn value_list(values: Vec<StyleValueData>) -> StyleValueData {
@@ -935,7 +938,7 @@ mod tests {
}
fn color_function(syntax: u8) -> StyleValueData {
- StyleValueData::ColorFunction {
+ StyleValueData::ColorFunction(StyleValueBox::new(ColorFunctionPayload {
color_base: ColorBase {
has_color_type: true,
color_type: crate::css::color_conversion::RGB,
@@ -948,7 +951,7 @@ mod tests {
has_name: false,
name: CssString::default(),
origin_color: RetainedStyleValueData::none(),
- }
+ }))
}
fn filter(kind: u8, color_operation: u8, value: StyleValueData) -> StyleValueData {
@@ -960,7 +963,7 @@ mod tests {
}
fn shadow(color: Option<StyleValueData>, offset_x: f64, offset_y: f64, blur_radius: Option<f64>) -> StyleValueData {
- StyleValueData::Shadow {
+ StyleValueData::Shadow(StyleValueBox::new(ShadowPayload {
shadow_type: 0,
color: color.map_or_else(RetainedStyleValueData::none, retained),
offset_x: retained(px(offset_x)),
@@ -968,20 +971,22 @@ mod tests {
blur_radius: blur_radius.map_or_else(RetainedStyleValueData::none, |radius| retained(px(radius))),
spread_distance: RetainedStyleValueData::none(),
placement: 0,
- }
+ }))
}
/// A main thread whose keyframe values are given up front, counting what the builder asks for.
#[derive(Default)]
struct TestHost {
- values: HashMap<(usize, u16, bool), Arc<StyleValueData>>,
+ values: HashMap<(usize, u16, bool), StyleValueArc>,
resolutions: RefCell<usize>,
}
impl TestHost {
fn with_value(mut self, keyframe_index: usize, property: AnimatedProperty, value: StyleValueData) -> Self {
- self.values
- .insert((keyframe_index, property.property_id(), false), Arc::new(value));
+ self.values.insert(
+ (keyframe_index, property.property_id(), false),
+ StyleValueArc::new(value),
+ );
self
}
@@ -991,8 +996,10 @@ mod tests {
property: AnimatedProperty,
value: StyleValueData,
) -> Self {
- self.values
- .insert((keyframe_index, property.property_id(), true), Arc::new(value));
+ self.values.insert(
+ (keyframe_index, property.property_id(), true),
+ StyleValueArc::new(value),
+ );
self
}
@@ -1014,7 +1021,9 @@ mod tests {
*host.resolutions.borrow_mut() += 1;
host.values
.get(&(keyframe_index, property_id, uses_underlying_style))
- .map_or(std::ptr::null(), |value| Arc::into_raw(Arc::clone(value)).cast())
+ .map_or(std::ptr::null(), |value| {
+ StyleValueArc::into_raw(StyleValueArc::clone(value)).cast()
+ })
}
fn linear_easing() -> FfiEasingDescriptor {
@@ -1223,9 +1232,10 @@ mod tests {
)
.is_some()
);
- let StyleValueData::Transformation { matrix_values, .. } = &mut value else {
+ let StyleValueData::Transformation(transformation_payload) = &mut value else {
unreachable!()
};
+ let TransformationPayload { matrix_values, .. } = &mut **transformation_payload;
*matrix_values = RetainedStyleValueDataList::from_retained_values(vec![retained(StyleValueData::Angle {
value: 1e30,
unit: crate::css::calc::ANGLE_UNIT_NAMES
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/basic_shapes.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/basic_shapes.rs
index d362869f636..ca37b243570 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_context/basic_shapes.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/basic_shapes.rs
@@ -9,6 +9,7 @@ use crate::css::css_enums::keyword;
use crate::css::css_pixels::CssPixels;
use crate::css::css_pixels::{CssPixelPoint, CssPixelRect, CssPixelSize};
use crate::css::style_value::{BasicShapeData, RetainedStyleValueData, StyleValueData};
+use crate::css::style_value::{BorderRadiusRectPayload, PositionPayload, RadialSizePayload};
use crate::layout::node_data::NodeSlotId;
use crate::painting::border_radii::{BorderRadii, normalize_border_radii_data};
use crate::painting::paint_read::PaintRead;
@@ -104,7 +105,10 @@ struct RadialSizeComponent<'a> {
}
fn radial_size_components(radius: &StyleValueData) -> Vec<RadialSizeComponent<'_>> {
- let StyleValueData::RadialSize {
+ let StyleValueData::RadialSize(radial_size_payload) = radius else {
+ unreachable!("computed basic-shape radius is a radial size value");
+ };
+ let RadialSizePayload {
component_count,
is_extent_0,
extent_0,
@@ -112,10 +116,7 @@ fn radial_size_components(radius: &StyleValueData) -> Vec<RadialSizeComponent<'_
is_extent_1,
extent_1,
value_1,
- } = radius
- else {
- unreachable!("computed basic-shape radius is a radial size value");
- };
+ } = &**radial_size_payload;
let mut components = vec![RadialSizeComponent {
is_extent: *is_extent_0,
extent: *extent_0,
@@ -226,12 +227,13 @@ pub(crate) fn resolve_ellipse_size(
}
pub(crate) fn position_resolved(position: Option<&StyleValueData>, rect: CssPixelRect) -> CssPixelPoint {
- let Some(StyleValueData::Position { edge_x, edge_y }) = position else {
+ let Some(StyleValueData::Position(position_payload)) = position else {
return CssPixelPoint::new(
rect.x + LengthPercentageRef::over(&StyleValueData::Percentage { value: 50.0 }).to_px(rect.width),
rect.y + LengthPercentageRef::over(&StyleValueData::Percentage { value: 50.0 }).to_px(rect.height),
);
};
+ let PositionPayload { edge_x, edge_y } = &**position_payload;
let offset_px = |edge: &RetainedStyleValueData, reference: CssPixels| -> CssPixels {
let StyleValueData::Edge { offset, .. } = edge.data() else {
unreachable!("computed position component is an edge value");
@@ -291,15 +293,15 @@ fn inset_to_path(
CssPixels::nearest_value_for_f32(bottom_edge - top_edge),
);
- let StyleValueData::BorderRadiusRect {
+ let StyleValueData::BorderRadiusRect(border_radius_rect_payload) = border_radius.data() else {
+ unreachable!("computed inset border-radius is a border-radius rect");
+ };
+ let BorderRadiusRectPayload {
top_left,
top_right,
bottom_right,
bottom_left,
- } = border_radius.data()
- else {
- unreachable!("computed inset border-radius is a border-radius rect");
- };
+ } = &**border_radius_rect_payload;
let radii = normalize_border_radii_data(
inset_rect,
reference_box,
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/incremental.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/incremental.rs
index 64b5196112d..a402be8f679 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_context/incremental.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/incremental.rs
@@ -275,9 +275,8 @@ pub(crate) fn register_scroll_like_node(
&& let Some(style) = layout_arena.node_style_if_live(owner_paintable)
{
use crate::css::css_enums::overflow;
- let box_values = style.box_values();
- if matches!(box_values.overflow_x, overflow::AUTO | overflow::SCROLL)
- || matches!(box_values.overflow_y, overflow::AUTO | overflow::SCROLL)
+ if matches!(style.overflow_x(), overflow::AUTO | overflow::SCROLL)
+ || matches!(style.overflow_y(), overflow::AUTO | overflow::SCROLL)
|| crate::painting::chrome_geometry::keeps_scrolls_along_some_axis(layout_arena, owner_paintable)
{
scroll_state.has_non_viewport_wheel_scroll_target_candidate = true;
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/node_values.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/node_values.rs
index 5db9db8f12b..10c729f254e 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_context/node_values.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/node_values.rs
@@ -10,6 +10,7 @@ use crate::css::computed_value_views::{ComputedValuesView, LengthPercentageRef};
use crate::css::css_enums;
use crate::css::css_pixels::CssPixelRect;
use crate::css::css_pixels::CssPixels;
+use crate::css::style_value::BorderRadiusPayload;
use crate::css::style_value::StyleValueData;
use crate::layout::node_data::NodeSlotId;
use crate::layout::node_facts::{self, NodeShape};
@@ -417,14 +418,14 @@ fn border_radius_pair(handle: &ComputedStyleValueHandle) -> (LengthPercentageRef
pub(crate) fn border_radius_pair_of_value(
value: &StyleValueData,
) -> (LengthPercentageRef<'_>, LengthPercentageRef<'_>) {
- let StyleValueData::BorderRadius {
+ let StyleValueData::BorderRadius(border_radius_payload) = value else {
+ unreachable!("computed border-radius is a border-radius value");
+ };
+ let BorderRadiusPayload {
horizontal_radius,
vertical_radius,
..
- } = value
- else {
- unreachable!("computed border-radius is a border-radius value");
- };
+ } = &**border_radius_payload;
(
LengthPercentageRef::over(horizontal_radius.data()),
LengthPercentageRef::over(vertical_radius.data()),
@@ -432,14 +433,14 @@ pub(crate) fn border_radius_pair_of_value(
}
fn border_radius_is_initial(handle: &ComputedStyleValueHandle) -> bool {
- let Some(StyleValueData::BorderRadius {
+ let Some(StyleValueData::BorderRadius(border_radius_payload)) = style_queries::handle_value(handle) else {
+ unreachable!("computed border-radius lost its style value");
+ };
+ let BorderRadiusPayload {
horizontal_radius,
vertical_radius,
..
- }) = style_queries::handle_value(handle)
- else {
- unreachable!("computed border-radius lost its style value");
- };
+ } = &**border_radius_payload;
let is_zero_px = |value: &StyleValueData| {
matches!(value, StyleValueData::Length { value, unit }
if *value == 0.0 && *unit == crate::css::style_compute::px_length_unit())
@@ -609,7 +610,7 @@ fn overflow_clip_edge_rect(
slot: NodeSlotId,
) -> CssPixelRect {
use crate::css::css_enums::background_box::{BORDER_BOX, CONTENT_BOX};
- let overflow_clip_margin = &style.misc_reset().overflow_clip_margin;
+ let overflow_clip_margin = &style.misc_layout().overflow_clip_margin;
// https://drafts.csswg.org/css-overflow-4/#overflow-clip-margin
// Values are defined as follows:
// '<visual-box>'
@@ -952,8 +953,8 @@ pub(crate) fn may_have_clip(layout_arena: &impl PaintRead, node: NodeSlotId) ->
return false;
};
let box_values = style.box_values();
- box_values.overflow_x != overflow::VISIBLE
- || box_values.overflow_y != overflow::VISIBLE
+ style.overflow_x() != overflow::VISIBLE
+ || style.overflow_y() != overflow::VISIBLE
|| box_values.paint_containment
|| style.content_visibility() == content_visibility::AUTO
}
@@ -976,8 +977,8 @@ fn used_overflow(
use crate::css::css_enums::{content_visibility, overflow};
let node = slot;
let box_values = style.box_values();
- let mut overflow_x = box_values.overflow_x;
- let mut overflow_y = box_values.overflow_y;
+ let mut overflow_x = style.overflow_x();
+ let mut overflow_y = style.overflow_y();
let style_has_paint_containment =
box_values.paint_containment || style.content_visibility() == content_visibility::AUTO;
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/offset_transform.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/offset_transform.rs
index 9986d2889a5..a20fdf9238d 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_context/offset_transform.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/offset_transform.rs
@@ -10,7 +10,10 @@
use crate::css::computed_value_views::{ComputedValuesView, LengthPercentageRef};
use crate::css::css_enums::keyword;
use crate::css::css_pixels::{CssPixelRect, CssPixels};
-use crate::css::style_value::{BasicShapeData, OwnedBasicShapeData, RetainedStyleValueData, StyleValueData};
+use crate::css::style_value::{
+ BasicShapeData, OwnedBasicShapeData, RetainedStyleValueData, StyleValueBox, StyleValueData,
+};
+use crate::css::style_value::{BorderRadiusPayload, BorderRadiusRectPayload, PositionPayload, RayPayload};
use crate::layout::node_data::NodeSlotId;
use crate::painting::paint_read::PaintRead;
use crate::painting::style_queries;
@@ -44,10 +47,10 @@ fn position_value_at(point: (f64, f64), rect: CssPixelRect) -> StyleValueData {
}),
})
};
- StyleValueData::Position {
+ StyleValueData::Position(StyleValueBox::new(PositionPayload {
edge_x: edge(point.0 - rect.x.to_double()),
edge_y: edge(point.1 - rect.y.to_double()),
- }
+ }))
}
/// inset(0 round X), where X is the border-radius of the containing block of `node`.
@@ -72,19 +75,21 @@ fn containing_block_inset_shape(arena: &impl PaintRead, node: NodeSlotId) -> Own
Some(value) => unsafe {
RetainedStyleValueData::from_retained_pointer(crate::css::style_value::retain_style_value(value))
},
- None => RetainedStyleValueData::from_owned(StyleValueData::BorderRadius {
- is_elliptical: false,
- horizontal_radius: zero(),
- vertical_radius: zero(),
- }),
+ None => RetainedStyleValueData::from_owned(StyleValueData::BorderRadius(StyleValueBox::new(
+ BorderRadiusPayload {
+ is_elliptical: false,
+ horizontal_radius: zero(),
+ vertical_radius: zero(),
+ },
+ ))),
}
};
- let radii = StyleValueData::BorderRadiusRect {
+ let radii = StyleValueData::BorderRadiusRect(StyleValueBox::new(BorderRadiusRectPayload {
top_left: radius(|border| &border.border_top_left_radius),
top_right: radius(|border| &border.border_top_right_radius),
bottom_right: radius(|border| &border.border_bottom_right_radius),
bottom_left: radius(|border| &border.border_bottom_left_radius),
- };
+ }));
OwnedBasicShapeData::new(BasicShapeData {
kind: basic_shape_kind::INSET,
v0: zero(),
@@ -201,12 +206,13 @@ pub(crate) fn compute_offset_transform(
let mut is_closed_loop = false;
let mut ray_contain_reduction = None;
let (path_length, point_at): (f64, Box<dyn Fn(f64) -> PathPosition>) = match path {
- Some(StyleValueData::Ray {
- size,
- contain,
- angle,
- position,
- }) => {
+ Some(StyleValueData::Ray(ray_payload)) => {
+ let RayPayload {
+ size,
+ contain,
+ angle,
+ position,
+ } = &**ray_payload;
// at <position>: Specifies the origin of the ray. If omitted, it uses the offset starting position of the
// element. If the element doesn't have an offset starting position either, it behaves as at center.
let origin = position
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_lines.rs b/Libraries/LibWeb/Rust/src/painting/visual_lines.rs
index ed34d27b3bd..e94346a58e4 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_lines.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_lines.rs
@@ -26,7 +26,7 @@ pub(crate) fn text_preserves_newlines(layout_arena: &impl PaintRead, text_node:
return false;
};
matches!(
- parent_style.inherited_text().white_space_collapse,
+ parent_style.white_space_collapse(),
crate::css::css_enums::white_space_collapse::PRESERVE
| crate::css::css_enums::white_space_collapse::PRESERVE_BREAKS
)
diff --git a/Libraries/LibWeb/Rust/src/render_state.rs b/Libraries/LibWeb/Rust/src/render_state.rs
index f8f6e76009b..c2ae8726028 100644
--- a/Libraries/LibWeb/Rust/src/render_state.rs
+++ b/Libraries/LibWeb/Rust/src/render_state.rs
@@ -4,10 +4,10 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-//! Each document's render state, which the StyleLayout thread owns.
+//! Each document's render state, which the Render thread owns.
//!
//! A document's [`RenderState`] is what its style, layout and paint preparation compute over: its layout arena and
-//! what lives beside it. It lives on the StyleLayout thread, the render owner, which makes it the first time a job of
+//! what lives beside it. It lives on the Render thread, the render owner, which makes it the first time a job of
//! the document reaches it and drops it there (see [`owner`]). The [`DocumentHost`] names it, and reaches it only with
//! a job it hands the owner: a job it runs there and waits for, the writes it queued, which go first or are posted
//! ahead, or a frame that flies beside the host until the host takes it in. Nothing on the host's thread can name the state, so nothing there reaches it.
@@ -20,6 +20,7 @@ mod clock;
mod devtools;
mod document_host;
mod owner;
+pub(crate) use owner::process_style;
mod wait;
pub use clock::FfiPlannedScrollTimeline;
@@ -53,15 +54,22 @@ pub(crate) struct RenderState {
}
impl RenderState {
- /// Makes the state `seed` describes.
- fn new(seed: owner::StateSeed) -> Self {
+ /// Makes the state `seed` describes, whose style engine shares `process_style` with the other documents', and whose
+ /// style passes run on `style_pool`.
+ fn new(
+ seed: owner::StateSeed,
+ process_style: &std::sync::Arc<crate::css::style::ProcessStyle>,
+ style_pool: &std::sync::Arc<crate::css::style::pipeline::pool::StylePool>,
+ ) -> Self {
let owner::StateSeed { shared } = seed;
let mut arena = Box::new(ArenaHandle::new());
let mut engine = Box::new(crate::css::style::StyleEngine::new());
+ engine.share_process_style(std::sync::Arc::clone(process_style));
+ engine.share_style_pool(style_pool.clone());
engine.share_element_random_base_values_exist(shared.element_random_base_values_exist);
engine.share_declaration_block_versions(shared.declaration_block_versions);
engine.share_container_effects_held(shared.container_effects_held);
- engine.share_tree_depth(shared.deepest_element, shared.staged_tree_rows);
+ engine.share_tree_depth(shared.deepest_element, shared.link_rows_written);
let engine = StyleEngineHandle::create(engine);
arena
.arena_mut()
@@ -166,7 +174,7 @@ impl RenderState {
let facts = StateFacts {
rows_version: self.rows_version(),
engine: EngineFacts {
- has_pending_style_transaction: engine.has_pending_transaction(),
+ has_pending_style_update: engine.has_pending_transaction(),
has_deferred_element_style_inputs: engine.has_deferred_element_style_inputs(),
has_size_containers_needing_evaluation_after_layout: engine
.has_size_containers_needing_evaluation_after_layout(),
@@ -181,6 +189,7 @@ impl RenderState {
selector_attribute_value_text_requirements_version: engine
.selector_attribute_value_text_requirements_version(),
relational_arrival_keys_version: engine.relational_arrival_keys_version(),
+ selectors_test_local_link: engine.selectors_test_local_link(),
};
let selector_value_text_names = std::sync::Arc::clone(engine.selector_attribute_value_text_names());
let selector_tested_attribute_names = std::sync::Arc::clone(engine.selector_tested_attribute_names());
@@ -189,6 +198,7 @@ impl RenderState {
work: std::mem::take(&mut self.owed),
deferred_inputs: self.engine_mut().take_moved_deferred_element_style_inputs(),
released_animation_overlay_records: self.engine_mut().take_released_animation_overlay_records(),
+ released_style_nodes: self.engine_mut().take_released_style_nodes(),
facts,
selector_value_text_names,
selector_tested_attribute_names,
@@ -208,6 +218,25 @@ impl RenderState {
unsafe { self.engine.get_mut() }
}
+ /// Installs the style records of `answer`, what a style job on this state answered, in the boxes of their
+ /// elements where the render side styles them as the host's install would, and notes in `answer` what it installed
+ /// and which boxes only the host styles.
+ pub(crate) fn install_styles(&mut self, answer: &mut crate::css::style::style_job::StyleJobAnswer) {
+ use crate::layout::tree_mutation::{HostCalls, OwedHostWork};
+ self.engine_mut().begin_reinheriting_for_install();
+ let arena = self.arena.arena_mut();
+ answer.note_host_styled_boxes(arena);
+ let work = OwedHostWork::default();
+ arena.queue_box_presence();
+ let styled = arena.install_styles(HostCalls(&work), answer.rows(), |node| answer.element_install(node));
+ let host_work = work.resolve(arena);
+ self.engine_mut().end_reinheriting_for_install();
+ if !host_work.is_empty() {
+ self.owed.push(host_work);
+ }
+ answer.note_styled(styled);
+ }
+
/// The style engine, and the layout arena beside it.
pub(crate) fn engine_and_arena(
&mut self,
@@ -234,48 +263,23 @@ impl RenderState {
&mut self.arena
}
- /// Runs `round` after `style`, the frame's style transaction, where the frame applies the transaction's rows to the
- /// boxes itself: the round lays out the boxes as the host's install of the rows leaves them. Answers the rows it
- /// applied, by element, and what the round owes the host with the rows it laid out, which the frame publishes.
- fn fly_round(
- &mut self,
- style: &crate::css::style::style_job::StyleJobAnswer,
- round: crate::layout::SealedRound,
- ) -> (
- Vec<crate::css::style::flight_style_rows::FlightStyleRow>,
- Option<(crate::layout::FlownRound, crate::layout::row_reads::RowSnapshot)>,
- ) {
- use crate::layout::tree_mutation::{HostCalls, OwedHostWork};
- let Ok(rows) = self.engine_ref().rows_the_flight_applies(style.rows()) else {
- return (Vec::new(), None);
- };
- // What applying the rows owes the host, the host's install of the rows makes good again.
- let work = OwedHostWork::default();
- let Ok(applied) = self.arena.arena_mut().apply_flight_style_rows(HostCalls(&work), rows) else {
- return (Vec::new(), None);
- };
- (applied, self.run_round(round, work))
- }
-
- /// Runs `round` in a frame, owing the host `work` besides what the round owes it. Answers what the round owes with
- /// the rows it published after it, where it laid anything out.
+ /// Runs `round` in a frame. Answers what the round owes with the rows it published after it, where it laid anything
+ /// out.
fn run_round(
&mut self,
round: crate::layout::SealedRound,
- work: crate::layout::tree_mutation::OwedHostWork,
) -> Option<(crate::layout::FlownRound, crate::layout::row_reads::RowSnapshot)> {
round
- .run(&mut self.arena, work)
+ .run(&mut self.arena)
.map(|round| (round, self.arena.arena_mut().publish_row_snapshot(false)))
}
}
-/// What a frame that flew brings its host back: what its style transaction answered, where it flew with one, the rows of
-/// the transaction it applied to the boxes itself, by element, what its first layout round owes with the rows it
-/// published after it, where it ran one, and the emptied buffer of the writes it took, which the host's queue keeps.
+/// What a frame that flew brings its host back: what its style update answered, where it flew with one, what its
+/// layout round owes with the rows it published after it, where it ran one, and the emptied buffer of the writes it
+/// took, which the host's queue keeps.
pub(crate) struct Landing {
style: Option<crate::css::style::style_job::StyleJobAnswer>,
- applied: Vec<crate::css::style::flight_style_rows::FlightStyleRow>,
round: Option<(crate::layout::FlownRound, crate::layout::row_reads::RowSnapshot)>,
changes: Vec<ArenaChange>,
/// The layout tree update marks the host lent the frame.
@@ -290,6 +294,8 @@ pub(crate) struct Owed {
work: Vec<crate::layout::tree_mutation::HostWorkDue>,
deferred_inputs: Option<Vec<crate::css::style::engine_calls::DeferredInput>>,
released_animation_overlay_records: crate::css::style::ReleasedAnimationOverlayRecords,
+ /// The style node identities the end of a transaction released, for the host to mint again.
+ released_style_nodes: Vec<u32>,
facts: StateFacts,
/// The attribute names whose value text the engine's selectors read, as of `facts`.
selector_value_text_names: crate::css::style::SelectorAttributeNames,
@@ -311,13 +317,15 @@ pub(crate) struct StateFacts {
pub(crate) selector_attribute_value_text_requirements_version: u64,
/// Where what an arrival has to carry to reach a `:has()` anchor is.
pub(crate) relational_arrival_keys_version: u64,
+ /// Whether the engine's selectors test `:local-link`.
+ pub(crate) selectors_test_local_link: bool,
}
/// What the style engine answers of itself as a job or a frame leaves it, which only a write to the engine moves (see
/// [`ArenaChange::moves`]).
#[derive(Clone, Copy)]
pub(crate) struct EngineFacts {
- pub(crate) has_pending_style_transaction: bool,
+ pub(crate) has_pending_style_update: bool,
pub(crate) has_deferred_element_style_inputs: bool,
pub(crate) has_size_containers_needing_evaluation_after_layout: bool,
}
@@ -434,18 +442,22 @@ impl ArenaChange {
}
}
+ /// Whether the change publishes what the host wrote of its elements since its last barrier.
+ fn is_publication(&self) -> bool {
+ matches!(
+ self,
+ Self::Engine(crate::css::style::engine_calls::EngineWrite::Publish(_))
+ )
+ }
+
/// Whether the change writes what the document's style engine computes from. A mint of style node identities does
- /// not: it makes them live, in the order the host minted them. Nor does a note of what an attribute name's forms
- /// are, or what an `attr()` reads it as: what the name is, which no style transaction can answer differently, so it
- /// need not wait for the drain of one that flew.
+ /// not: it makes them live in the engine's tree, in the order the host minted them, so it need not wait for the
+ /// drain of a transaction that flew.
fn writes_style(&self) -> bool {
use crate::css::style::engine_calls::EngineWrite;
match self {
Self::Style(_) => true,
- Self::Engine(write) => !matches!(
- write,
- EngineWrite::MintStyleNodes(_) | EngineWrite::AttributeNameForms { .. }
- ),
+ Self::Engine(write) => !matches!(write, EngineWrite::MintStyleNodes(_)),
Self::Rule(_) => true,
Self::Layout(_)
| Self::Paint(_)
@@ -525,10 +537,10 @@ struct ChangeQueue {
spare: Cell<Vec<ArenaChange>>,
/// What the writes queued may move of what the host knows of the render state.
moves: Cell<Moves>,
- /// The style writes queued beside a style transaction that flew, which wait to be queued behind the drain of its
+ /// The style writes queued beside a style update that flew, which wait to be queued behind the drain of its
/// reactions, whose next transaction's input they are.
held_style: RefCell<Vec<ArenaChange>>,
- /// Whether a style write queued now is held: a style transaction flew, whose reactions the host has not begun to
+ /// Whether a style write queued now is held: a style update flew, whose reactions the host has not begun to
/// drain.
holds_style: Cell<bool>,
/// The rows whose style record the writes queued set by name, where they write no other row's but anonymous rows'.
@@ -551,7 +563,7 @@ struct ChangeQueue {
}
/// A style write as it joins the writes the render state applies next, in the order it applies them: one the host
-/// queues beside a style transaction that flew joins them only behind the drain of its reactions. Only the change queue
+/// queues beside a style update that flew joins them only behind the drain of its reactions. Only the change queue
/// makes one, so what follows the engine as it applies the host's writes cannot follow them as the host makes them.
pub(crate) struct QueuedStyleChange<'a>(&'a crate::css::style::boundary::StyleChange);
@@ -624,16 +636,26 @@ impl ChangeQueue {
}
}
- /// Whether `change`, queued now, is held behind the drain of the reactions of the style transaction that flew.
+ /// Whether `change`, queued now, is held behind the drain of the reactions of the style update that flew.
fn holds(&self, change: &ArenaChange) -> bool {
self.holds_style.get() && change.writes_style()
}
- fn push(&self, change: ArenaChange, follow: impl FnOnce(QueuedStyleChange<'_>)) {
+ fn push(&self, change: ArenaChange, mut follow: impl FnMut(QueuedStyleChange<'_>)) {
use crate::css::style::boundary::StyleChange;
use crate::layout::layout_changes::LayoutChange;
use crate::painting::paint_changes::PaintChange;
- let mut queued = if self.holds(&change) {
+ let held = self.holds(&change);
+ // NB: A publication holds the rows the host has written so far, and says which it wrote since the one before:
+ // the publications held or set aside before it, whose rows it holds, go ahead of it, with the style writes
+ // they come with, or the engine reads their rows and hears of them only later.
+ if !held && change.is_publication() {
+ if self.held_style.borrow().iter().any(ArenaChange::is_publication) {
+ self.queue_held_style(&mut follow);
+ }
+ self.queue_style_set_aside_with_a_publication();
+ }
+ let mut queued = if held {
self.held_style.borrow_mut()
} else {
self.enqueue(&change, follow);
@@ -754,6 +776,15 @@ impl ChangeQueue {
self.queued.replace(Vec::with_capacity(capacity))
}
+ /// Puts `streamed`, writes taken for a stream the render state has not begun to apply, back in front of the writes
+ /// queued since, in the order the host made them. What they may move is still noted.
+ fn take_back_streamed(&self, mut streamed: Vec<ArenaChange>) {
+ self.replaced_paint_facts_positions.borrow_mut().clear();
+ let mut queued = self.queued.borrow_mut();
+ streamed.append(&mut queued);
+ *queued = streamed;
+ }
+
/// Sets the queued writes aside, until queue_set_aside(): the render state reads as it was before them meanwhile.
fn set_aside(&self) {
debug_assert!(
@@ -765,6 +796,22 @@ impl ChangeQueue {
*self.set_aside.borrow_mut() = self.queued.take();
}
+ /// Queues the style writes set aside where a publication is among them: the render state's layout goes on reading as
+ /// it was before the writes that stay set aside.
+ fn queue_style_set_aside_with_a_publication(&self) {
+ let mut set_aside = self.set_aside.borrow_mut();
+ if !set_aside.iter().any(ArenaChange::is_publication) {
+ return;
+ }
+ let mut queued = self.queued.borrow_mut();
+ let (style, others): (Vec<_>, Vec<_>) = std::mem::take(&mut *set_aside)
+ .into_iter()
+ .partition(ArenaChange::writes_style);
+ style.iter().for_each(|change| self.note(change));
+ queued.extend(style);
+ *set_aside = others;
+ }
+
/// Queues the writes set aside behind the writes queued meanwhile, and answers whether any of them stales the paint
/// and hit testing properties.
fn queue_set_aside(&self) -> bool {
@@ -787,37 +834,40 @@ impl ChangeQueue {
/// owner itself, as a host callback's while the owner runs another job, runs right there, and a unit test's jobs run on
/// the test's own thread.
///
-/// The calling thread becomes the owner for the job where it waits for nothing the StyleLayout thread runs: that thread
+/// The calling thread becomes the owner for the job where it waits for nothing the Render thread runs: that thread
/// has run every job the calling thread made for it, so the job comes after them as it would there, and the calling
-/// thread's stack has room for the job to recurse through a tree `tree_depth` levels deep. Otherwise the StyleLayout
+/// thread's stack has room for the job to recurse through a tree `tree_depth` levels deep. Otherwise the Render
/// thread runs it.
fn on_render_side<R: Send>(tree_depth: u32, job: impl FnOnce() -> R + Send) -> R {
if cfg!(test) {
return job();
}
- let thread = crate::stage_thread::style_layout_thread();
+ let thread = crate::stage_thread::render_thread();
if thread.is_current() || owner::is_held_here() {
return job();
}
- // OPTIMIZATION: A host waits for a job it hands the StyleLayout thread anyway, so running it right here saves both
+ // OPTIMIZATION: A host waits for a job it hands the Render thread anyway, so running it right here saves both
// threads a hand-off, which costs more than a small job such as a forced layout read takes.
- if thread.ran_every_job_handed_from_here() && stack_has_room_for_render_job(tree_depth) {
+ // A job claimed by the Render thread holds the slot as it runs, so the slot orders this one after it.
+ if (thread.ran_every_job_handed_from_here() || thread.only_claimed_jobs_unfinished_from_here())
+ && stack_has_room_for_render_job(tree_depth)
+ {
return owner::hold(job);
}
thread.run(job)
}
-/// Waits until the StyleLayout thread has run the jobs handed to it before. A thread that holds the render owner's slot
+/// Waits until the Render thread has run the jobs handed to it before. A thread that holds the render owner's slot
/// waits for nothing: no job on the render states runs elsewhere meanwhile, and one waiting for the slot waits for it.
fn wait_for_render_side() {
if cfg!(test) || owner::is_held_here() {
return;
}
- crate::stage_thread::style_layout_thread().run(|| ());
+ crate::stage_thread::render_thread().run(|| ());
}
/// Whether the calling thread's stack has room for a job on a render state that recurses through a tree `tree_depth`
-/// levels deep. Only the StyleLayout thread's stack is large enough for any tree.
+/// levels deep. Only the Render thread's stack is large enough for any tree.
#[cfg(not(test))]
fn stack_has_room_for_render_job(tree_depth: u32) -> bool {
/// The stack a job on a render state takes at most per level of the tree it recurses through, as it builds and
@@ -857,50 +907,49 @@ fn post_to_render_side(job: impl FnOnce() + Send + 'static) {
if cfg!(test) {
return job();
}
- crate::stage_thread::style_layout_thread().post(job);
+ crate::stage_thread::render_thread().post(job);
}
-/// Submits `job`, a style transaction of `host`'s document, if any, to the render owner, with the writes the host
-/// queued and `round`, the layout round the host sealed, and goes on: the frame flies beside the host until the host
-/// takes it in and drains the transaction's reactions, or pays the round. Only a frame that `_license` lets fly is
-/// submitted.
-///
-/// After a style transaction, the frame applies the transaction's rows to the boxes itself before the round, where it
-/// can: otherwise the round is left unrun, and the host lays out after it installs the rows.
-pub(crate) fn fly(
- host: &DocumentHost,
- job: Option<crate::css::style::style_job::StyleJob>,
- round: Option<crate::layout::SealedRound>,
- _license: &crate::painting::recording_slot::FlightLicense,
-) {
- let mut changes = host.take_queued_changes_for_flight(job.is_some());
+/// What a frame flies with: a style update of the host's document, or the first layout round of a rendering update
+/// whose style is up to date.
+pub(crate) enum FrameJob {
+ Style(crate::css::style::style_job::StyleJob),
+ Round(crate::layout::SealedRound),
+}
+
+/// Submits `job` of `host`'s document to the render owner, with the writes the host queued, and goes on: the frame flies
+/// beside the host until the host takes it in and drains the style update's reactions, or pays the round. Only a
+/// frame that `_license` lets fly is submitted.
+pub(crate) fn fly(host: &DocumentHost, job: FrameJob, _license: &crate::painting::recording_slot::FlightLicense) {
+ let with_style = matches!(job, FrameJob::Style(_));
+ let mut changes = host.take_queued_changes_for_flight(with_style);
// The round writes the rows the host has, which it copies rather than writes in place while the host holds them.
- if round.is_some() {
+ if !with_style {
host.let_go_of_rows();
}
#[cfg(not(test))]
- let lays_out_alone = job.is_none();
+ let lays_out_alone = !with_style || crate::painting::recording_slot::take_style_flight_hold_for_testing();
+ host.note_flight_tree_depth(host.tree_depth_bound(&changes));
host.let_frame_fly(|document, seed, marks| {
- // A host that waits for the frame says the stop word, and the frame comes back with its style alone.
+ // A host that waits for the frame says the stop word, and the frame comes back without running its round.
let run = move |stop: &crate::stage_thread::StopWord| {
clock::note_host_write(document);
owner::with_state(document, seed, |state| {
- let ((style, applied, round), marks) = state.with_marks(marks, |state| {
+ let ((style, round), marks) = state.with_marks(marks, |state| {
state.apply(changes.drain(..));
- let style = job.map(|job| job.run(state.engine_mut()));
- let (applied, round) = match (round, &style) {
- (Some(round), Some(style)) if !stop.is_said() => state.fly_round(style, round),
- (Some(round), None) if !stop.is_said() => {
- (Vec::new(), state.run_round(round, Default::default()))
+ match job {
+ FrameJob::Style(job) => {
+ let mut answer = job.run(state.engine_mut());
+ state.install_styles(&mut answer);
+ (Some(answer), None)
}
- _ => (Vec::new(), None),
- };
- (style, applied, round)
+ FrameJob::Round(round) if !stop.is_said() => (None, state.run_round(round)),
+ FrameJob::Round(_) => (None, None),
+ }
});
let owed = state.take_owed();
Landing {
style,
- applied,
round,
changes,
marks,
@@ -915,10 +964,14 @@ pub(crate) fn fly(
);
// A test may hold a frame that lays out alone before it reads anything, as it holds a recording.
#[cfg(not(test))]
+ // NB: A host that comes to wait for a frame the Render thread has not begun takes it back and runs it
+ // itself, holding the owner's slot, as the thread would. A frame that lays out alone then only applies what
+ // it flies with, as the stop word the waiting host says has it do on the thread.
if lays_out_alone {
- crate::painting::recording_slot::submit_layout(run)
+ crate::painting::recording_slot::submit_layout(run, |job| owner::hold(job))
} else {
- (crate::stage_thread::style_layout_thread().submit(run), false)
+ let flight = crate::stage_thread::render_thread().submit_reclaimable(run, |job| owner::hold(job));
+ (flight, false)
}
});
}
@@ -949,7 +1002,6 @@ impl crate::stage_thread::Flown for Landing {
#[cfg(test)]
mod tests {
use super::*;
- use std::ptr::NonNull;
use std::rc::Rc;
#[test]
@@ -1211,7 +1263,7 @@ mod tests {
#[test]
fn a_style_write_leaves_what_the_rows_are_to_read_from_the_rows_the_host_has() {
- use crate::layout::node_data::{NodeFlag, NodeKind, StylePayloadsRef};
+ use crate::layout::node_data::{LayoutStyleRef, NodeFlag, NodeKind};
let test_host = TestHost::new();
let host = test_host.host();
let row = host.with_arena_for_test(|arena| {
@@ -1223,7 +1275,7 @@ mod tests {
host.with_arena_untold_for_test(|arena| {
let mut shape = arena.write_shape(row);
- shape.set_style(StylePayloadsRef::new(NonNull::dangling().as_ptr()));
+ shape.set_style(Some(LayoutStyleRef::dangling()));
shape.mark();
});
assert!(host.rows().is_none(), "a style write leaves the rows stale");
diff --git a/Libraries/LibWeb/Rust/src/render_state/clock.rs b/Libraries/LibWeb/Rust/src/render_state/clock.rs
index 5750f6188c4..05b5e34e031 100644
--- a/Libraries/LibWeb/Rust/src/render_state/clock.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/clock.rs
@@ -6,7 +6,7 @@
//! The render clock's lanes of a document's presented frames.
//!
-//! Each frame of a document the host presents has a lane, which the render clock's ticks follow on the StyleLayout
+//! Each frame of a document the host presents has a lane, which the render clock's ticks follow on the Render
//! thread, as the render owner, from the frame on, until the lane of the host's next frame takes its place: a tick
//! hovers what is under the pointer, for real, as the host would as it handles the move (see [`hover`]), and samples
//! the running animations of the plan the frame's rendering update sealed at the tick's time beside a task, shows the
@@ -304,7 +304,7 @@ impl crate::stage_thread::Flown for ClockRecorder {
}
/// The right to sample a frame of a document for the Paint thread to present. Only a tick of the render clock and the
-/// commit of a rendering update mint one, in the job the StyleLayout thread runs them in, so a job the host hands the
+/// commit of a rendering update mint one, in the job the Render thread runs them in, so a job the host hands the
/// render owner to ask or write its render state cannot sample a frame.
pub(crate) struct SamplingTurn(());
@@ -831,6 +831,10 @@ impl Lane {
/// those styles move for the round's tree build to build again. An element whose animations `animated` samples
/// composes over its host's style, which only the host restyles.
fn restyle_size_query_dependents(&mut self, state: &mut RenderState, resized: &[StyleNodeID]) -> Result<(), Park> {
+ // NB: What a hover left to the host is pending on this fork, whose elements no record can be derived below.
+ if !state.engine_mut().takes_hover_transactions() {
+ return Err(Park("a hover left a restyle to the host"));
+ }
// An element whose box shows a sample, or what it inherits of one, shows it over the record the host installed,
// which a restyle would replace.
let animated: SmallVec<[StyleNodeID; 8]> = self
@@ -1480,10 +1484,8 @@ impl Lane {
if row.is_invalid() || !arena.slot_is_live(row) {
return None;
}
- let payloads = arena.style_payloads(row)?;
- let color = crate::layout::ComputedValuesView::new(&payloads.groups)
- .inherited_text()
- .color;
+ let payloads = arena.style_view(row)?;
+ let color = payloads.inherited_text().color;
Some((element, generated_for, color))
})
}));
@@ -1740,7 +1742,7 @@ pub extern "C" fn document_host_clock_lane_is_coming(host: &DocumentHost) -> boo
}
/// Hands the lanes of `host`'s document a tick at `frame_time_nanoseconds`, at which the compositor had scrolled to
-/// `scroll_offset`, if not null, and waits until the StyleLayout thread has run the jobs handed to it before, the tick
+/// `scroll_offset`, if not null, and waits until the Render thread has run the jobs handed to it before, the tick
/// among them, and the Paint thread the recording of the frame the tick presents. For a test, whose clock ticks only
/// where it injects them.
#[unsafe(no_mangle)]
@@ -1756,7 +1758,7 @@ pub extern "C" fn document_host_inject_clock_tick(
}
/// Waits until the Paint thread has run the jobs handed to it before, where a test holds no recording on it, then the
-/// StyleLayout thread, and the Paint thread again: the lane of a frame presented by then has come together, and the
+/// Render thread, and the Paint thread again: the lane of a frame presented by then has come together, and the
/// frames ticks recorded were presented. For a test.
pub(super) fn settle_lanes_for_testing() {
let settle_paint = || {
diff --git a/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs b/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs
index 047a61c3147..1c9a4c81953 100644
--- a/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs
@@ -503,17 +503,23 @@ impl Lane {
if row.is_invalid() {
continue;
}
- let host_record = self.host_record(state, row);
+ let Some(host_record) = state.engine_ref().host_record(self.host_record(state, row)).cloned() else {
+ composed = Err(NeedsHost);
+ break;
+ };
let mut inherited = AnimatedOverlay::default();
for &property in properties {
if let Some(entry) = overlay.get(property) {
inherited.set_owned(property, entry.clone_value(), true, false);
}
}
- match state
- .engine_mut()
- .compose_overlay_over_record(*descendant, host_record, &inherited, bounds)
- {
+ match state.engine_mut().compose_overlay_over_record(
+ *descendant,
+ crate::css::cascaded_properties::NO_PSEUDO_ELEMENT,
+ &host_record,
+ &inherited,
+ bounds,
+ ) {
Ok(sample) => samples.push((row, *descendant, sample, &properties[..])),
Err(needs_host) => {
composed = Err(needs_host);
@@ -616,10 +622,11 @@ impl Lane {
inherited.set_owned(property, entry.clone_value(), true, false);
}
}
- let sample = state.engine_mut().compose_overlay_over_pseudo_element_record(
+ let host_record = state.engine_ref().host_record(host_record).ok_or(NeedsHost)?.clone();
+ let sample = state.engine_mut().compose_overlay_over_record(
*node,
pseudo_kind_of(generated_for),
- host_record,
+ &host_record,
&inherited,
bounds,
)?;
diff --git a/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs b/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs
index 656f346adb5..69ecbc18b5f 100644
--- a/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs
@@ -120,7 +120,7 @@ impl Drop for PageCursor {
struct ReadOnlyHoverFrame {
rows: crate::painting::published_frame::PublishedRows,
bound_rows: crate::layout::PublishedBoundRows,
- cursors: crate::css::style::hover_lane::HoverCursorFacts,
+ cursors: Arc<crate::css::style::hover_lane::HoverCursorFacts>,
image_map_areas: crate::painting::image_map_areas::ImageMapAreaColumn,
visual_context: crate::painting::visual_context::VisualContextState,
_style_records: Arc<[u64]>,
@@ -133,7 +133,7 @@ pub(crate) struct HoverPlan {
/// The scroll offsets of the frame the rendering update presented, in device pixels, by scroll frame.
scroll_offsets: Vec<FloatPoint>,
chrome_metrics: FfiChromeMetrics,
- /// What the hover's style transactions take: the root and the document computation inputs of the host's last.
+ /// What the hover's style updates take: the root and the document computation inputs of the host's last.
style: Option<(StyleNodeID, Arc<SealedStyleInputs>)>,
/// The cursor of the document's page.
page_cursor: Option<PageCursor>,
@@ -196,7 +196,7 @@ impl HoverPlan {
};
if !state.engine_ref().takes_hover_transactions()
|| state.engine_ref().has_animation_overlay_records()
- || state.engine_ref().hover_needs_style_state(*root)
+ || state.engine_mut().hover_needs_style_state(*root)
{
return;
}
@@ -216,7 +216,7 @@ impl HoverPlan {
self.read_only_frame = Some(ReadOnlyHoverFrame {
rows: state.arena.arena_mut().publish_rows(),
bound_rows: state.arena.arena_mut().bound_rows_mut().publish(),
- cursors: state.engine_ref().hover_cursor_facts(),
+ cursors: state.engine_mut().hover_cursor_facts(),
image_map_areas: state.arena.arena().image_map_areas().clone(),
visual_context,
_style_records: style_records,
@@ -227,7 +227,7 @@ impl HoverPlan {
self.read_only_frame.is_none()
}
- /// Has the hover's style transactions take `inputs`, the document computation inputs the host sealed for its last
+ /// Has the hover's style updates take `inputs`, the document computation inputs the host sealed for its last
/// transaction under `root`.
pub(crate) fn with_style_inputs(self, style: Option<(StyleNodeID, Arc<SealedStyleInputs>)>) -> Self {
Self { style, ..self }
@@ -1257,7 +1257,7 @@ impl Lane {
let resolved = list.resolve_hit(arena, topmost.index, topmost.local_point);
let identity = if paintable_kind == NodeKind::Viewport {
// The viewport stands for the document, and a hit that falls through to it hits the root element, the root
- // of the style transactions the hover takes its own with. The cursor is the viewport's, as the host's is.
+ // of the style updates the hover takes its own with. The cursor is the viewport's, as the host's is.
let &(root, _) = plan.style.as_ref().ok_or(HoverDeclined::Unmoved("no root element"))?;
return Ok(HoverTarget::Element(CursorHit {
hit_node: paintable,
@@ -1452,7 +1452,7 @@ pub extern "C" fn document_host_move_pointer(
/// Hands the clock lanes of `host`'s document a pointer move to `x`, `y` in device pixels, beside the mouse event with
/// the input event id `input_event_id`, or none for 0, ticks them at `frame_time_nanoseconds`, and waits until the
-/// StyleLayout thread has run the tick and the Paint thread the recording of the frame it presents. For a test.
+/// Render thread has run the tick and the Paint thread the recording of the frame it presents. For a test.
#[unsafe(no_mangle)]
pub extern "C" fn document_host_inject_pointer(
host: &crate::render_state::DocumentHost,
diff --git a/Libraries/LibWeb/Rust/src/render_state/document_host.rs b/Libraries/LibWeb/Rust/src/render_state/document_host.rs
index a04be35f8bf..560a83a978b 100644
--- a/Libraries/LibWeb/Rust/src/render_state/document_host.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/document_host.rs
@@ -14,7 +14,6 @@ use super::{
ArenaChange, ArenaFacts, ChangeQueue, EngineFacts, ForcedRead, Landing, Moves, NoFrameInFlight, Owed, RenderState,
RenderWait, RowWrite, StateFacts, on_render_side, post_to_render_side,
};
-use crate::css::style::flight_style_rows::FlightStyleRow;
use crate::css::style::rule_writes::{PublishedRules, RuleWrite};
use crate::css::style::style_job::{SealedStyleInputs, StyleJobAnswer};
use crate::css::style::tree::StyleNodeID;
@@ -22,7 +21,7 @@ use crate::css::transition::HoverTransitions;
use crate::layout::node_data::NodeSlotId;
use crate::layout::row_reads::{RowIdentities, RowSnapshot, RowStyles};
use crate::layout::tree_update_marks::{LayoutTreeUpdateMarkWrite, LayoutTreeUpdateMarks};
-use crate::layout::{FlownRound, HostTables, RowsVersion, SealedRound};
+use crate::layout::{FlownRound, HostTables, RowsVersion};
use crate::painting::paint_read::PaintSource;
use crate::painting::record::recorder_state::AbsoluteRectMemo;
use crate::painting::recording_slot::{RecordingAnswer, RecordingSlot};
@@ -58,6 +57,9 @@ pub struct DocumentHost {
seed: Cell<Option<StateSeed>>,
/// The frame that flies beside the host, until the host takes it in.
away: RefCell<Option<InFlight<Landing>>>,
+ /// How deep the document's style tree may be once the frame in flight applied what it flies with, where the host
+ /// takes the frame back to run it itself.
+ away_tree_depth: Cell<u32>,
/// Whether the host waits for the frame: it flies, or a layout round that flew with it is not paid yet. The host's
/// scopes of a read and its document's layout read it where it is (see [`document_host_read_scope_view`]).
waits_for_frame: Cell<bool>,
@@ -65,9 +67,9 @@ pub struct DocumentHost {
recording: RefCell<RecordingSlot>,
/// The rows the render state published last, which the host reads between its jobs.
rows: RefCell<Option<Rc<RowSnapshot>>>,
- /// The reactions of the style transaction the host took last, which it reads until it ends the transaction.
- style_transaction: RefCell<Option<StyleJobAnswer>>,
- /// The first sample of the transitions a step the host read from the style transaction starts, by element, which
+ /// The reactions of the style update the host took last, which it reads until it ends the transaction.
+ style_update: RefCell<Option<StyleJobAnswer>>,
+ /// The first sample of the transitions a step the host read from the style update starts, by element, which
/// the sample the host takes next reads.
fresh_transition_sample: Cell<Option<(u32, crate::css::transition::FreshTransitionSample)>>,
/// The absolute rects the host's reads of the rows computed, kept for as long as the geometry they were computed
@@ -82,14 +84,12 @@ pub struct DocumentHost {
begun_read: BegunRead,
/// The writes the host queued that the render state has not applied yet, in the order the host made them.
changes: ChangeQueue,
- /// The style transaction that flew with the frame, from its landing until the host has drained its reactions.
+ /// The style update that flew with the frame, from its landing until the host has drained its reactions.
flown_style: RefCell<Option<FlownStyle>>,
/// Whether the paint and hit testing properties the document prepared last were prepared from the render state as it
/// is: nothing was written to it since, queued, in place or by a job. Preparing them again would find nothing
/// to do.
paint_preparation_is_current: Cell<bool>,
- /// The first layout round of a rendering update, sealed until the frame flies with it.
- sealed_round: RefCell<Option<SealedRound>>,
/// The layout round that flew with the frame, from its landing until the host's next layout update pays it.
flown_round: RefCell<Option<FlownRound>>,
/// Whether a job of the host runs, whose host callbacks see rows it freed and the host has not heard of yet.
@@ -97,6 +97,9 @@ pub struct DocumentHost {
/// Whether the host streamed writes to the render state since its last job or frame, which bring back what they owe
/// the host and the marks they made.
streamed: Cell<bool>,
+ /// The streams of writes the host posted to the render state that it may still take back, in the order it posted
+ /// them.
+ streams: RefCell<Vec<crate::stage_thread::Reclaimable<StreamedWrites>>>,
/// The document's layout tree update marks, which the host lends the render owner's jobs.
marks: RefCell<HostMarks>,
/// The rules the host published to each of its document's style sheets.
@@ -120,7 +123,7 @@ pub struct DocumentHost {
lane_transitions: RefCell<Vec<Arc<HoverTransitions>>>,
/// Whether the frame in flight waits for a test to release it.
frame_held_for_testing: Cell<bool>,
- /// The root and the sealed document computation inputs of the last style transaction the host took or let fly,
+ /// The root and the sealed document computation inputs of the last style update the host took or let fly,
/// which the hover of a lane takes its own transactions with.
style_inputs: RefCell<Option<(StyleNodeID, Arc<SealedStyleInputs>)>>,
/// The element the host asked the engine's hover to move to last: the one the events of the last mouse move it
@@ -143,6 +146,12 @@ pub struct DocumentHost {
lanes_planned: Cell<bool>,
}
+/// Writes the host streamed to the render state, with what the state is made from where they are the first.
+struct StreamedWrites {
+ changes: Vec<ArenaChange>,
+ seed: Option<StateSeed>,
+}
+
/// Pays what the writes a job applied owe the host, which only [`DocumentHost::pay`] makes.
pub(crate) struct OwedWorkPayment {
_private: (),
@@ -162,13 +171,13 @@ struct HostMarks {
written_beside_flight: Vec<LayoutTreeUpdateMarkWrite>,
}
-/// A style transaction that flew with the frame and has landed, or whose reactions the host drains. The style writes the
+/// A style update that flew with the frame and has landed, or whose reactions the host drains. The style writes the
/// host queued beside it reach the render state only behind its drain.
enum FlownStyle {
- /// What the transaction answered, and the rows of it the frame applied to the boxes itself, by element.
- Landed(StyleJobAnswer, Vec<FlightStyleRow>),
- /// The host drains the transaction's reactions, with the rows the frame applied.
- Draining(Vec<FlightStyleRow>),
+ /// What the transaction answered.
+ Landed(Box<StyleJobAnswer>),
+ /// The host drains the transaction's reactions.
+ Draining,
}
impl DocumentHost {
@@ -180,11 +189,12 @@ impl DocumentHost {
seed: Cell::new(Some(StateSeed { shared: shared.clone() })),
shared,
away: RefCell::default(),
+ away_tree_depth: Cell::new(0),
waits_for_frame: Cell::new(false),
host_tables: HostTables::default(),
recording: RefCell::default(),
rows: RefCell::default(),
- style_transaction: RefCell::default(),
+ style_update: RefCell::default(),
fresh_transition_sample: Cell::default(),
absolute_rects: RefCell::default(),
compositor_animations: RefCell::default(),
@@ -192,10 +202,10 @@ impl DocumentHost {
changes: ChangeQueue::default(),
flown_style: RefCell::default(),
paint_preparation_is_current: Cell::new(false),
- sealed_round: RefCell::default(),
flown_round: RefCell::default(),
in_job: Cell::new(false),
streamed: Cell::new(false),
+ streams: RefCell::default(),
marks: RefCell::new(HostMarks {
here: Some(LayoutTreeUpdateMarks::default()),
beside_flight: LayoutTreeUpdateMarks::default(),
@@ -242,6 +252,11 @@ impl DocumentHost {
&self.published_rules
}
+ /// The style atoms of the process, which the host interns names in.
+ pub(crate) fn style_atoms(&self) -> &std::sync::Arc<crate::css::style::ProcessAtoms> {
+ &self.shared.style_atoms
+ }
+
/// What the host learned of its document's style engine.
pub(crate) fn engine_memo(&self) -> &crate::css::style::engine_calls::EngineMemo {
&self.engine_memo
@@ -250,6 +265,7 @@ impl DocumentHost {
/// Writes `change` to the document's render state, before anything that reads what it changes: the render owner
/// applies it ahead of the host's next job. A write never reaches the render state as the host makes it.
pub(crate) fn queue_change(&self, change: ArenaChange) {
+ crate::css::style::host_atoms::note_attr_names_read_by_change(self, &change);
if change.stales_paint_preparation() {
self.note_render_state_write();
}
@@ -263,10 +279,15 @@ impl DocumentHost {
self.stream_writes_if_due();
}
- /// Whether a write the host queues now waits behind the drain of the reactions of a style transaction that flew,
- /// beside the writes the drain queues meanwhile.
- pub(crate) fn holds_style_writes(&self) -> bool {
- self.changes.holds_style.get()
+ /// Publishes what the host wrote of its elements since its last barrier, where it wrote anything: the barrier the
+ /// render state takes the host's projection rows at, behind the writes the host queued before. Each queued write the
+ /// render state applies reads the rows as of the barrier before it.
+ pub(crate) fn publish_element_writes(&self) {
+ if let Some(publication) = self.engine_memo.take_publication() {
+ self.queue_change(ArenaChange::Engine(
+ crate::css::style::engine_calls::EngineWrite::Publish(Box::new(publication)),
+ ));
+ }
}
/// How many writes the host queues before it streams them to the render state.
@@ -280,12 +301,68 @@ impl DocumentHost {
return;
}
let changes = self.changes.take_for_stream();
+ self.post_stream(changes);
+ }
+
+ /// Streams `changes`, taken from the queue, to the render state, which applies them beside the host's task unless
+ /// the host takes them back first. The first writes the host streams make the render state, as a job would, so that
+ /// the writes of a document's first task are applied beside it rather than all in its first job.
+ fn post_stream(&self, changes: Vec<ArenaChange>) {
self.streamed.set(true);
- let document = self.document;
- post_to_render_side(move || {
- super::clock::note_host_write(document);
- owner::with_state(document, None, |state| state.apply_streamed(changes));
- });
+ let (document, seed) = (self.document, self.seed.take());
+ if cfg!(test) {
+ return post_to_render_side(move || {
+ super::clock::note_host_write(document);
+ owner::with_state(document, seed, |state| state.apply_streamed(changes));
+ });
+ }
+ let stream = crate::stage_thread::render_thread().post_reclaimable(
+ StreamedWrites { changes, seed },
+ move |mut claim| {
+ // NB: The stream claims its writes holding the slot, so a host that takes back the streams not claimed
+ // yet orders its job after every one that was.
+ owner::hold(|| {
+ let Some(StreamedWrites { changes, seed }) = claim.claim() else {
+ return;
+ };
+ super::clock::note_host_write(document);
+ owner::with_state(document, seed, |state| state.apply_streamed(changes));
+ });
+ },
+ );
+ let mut streams = self.streams.borrow_mut();
+ streams.retain(|stream| !stream.is_taken());
+ streams.push(stream);
+ }
+
+ /// Takes back the writes of every stream the render state has not begun to apply, in front of the writes queued
+ /// since: a job the host runs applies them itself, rather than waiting for the Render thread to wake for them.
+ fn take_back_streams(&self) {
+ // NB: The streams are taken back from the last one posted: the Render thread claims them first to last, so
+ // once one is claimed every one before it is, and a stream it claims meanwhile still comes before those
+ // taken back, which the job applies after it.
+ let streams = std::mem::take(&mut *self.streams.borrow_mut());
+ let mut taken_back = Vec::new();
+ for stream in streams.iter().rev() {
+ let Some(writes) = stream.reclaim() else {
+ break;
+ };
+ taken_back.push(writes);
+ }
+ let mut changes = Vec::new();
+ for StreamedWrites {
+ changes: mut streamed,
+ seed,
+ } in taken_back.into_iter().rev()
+ {
+ if let Some(seed) = seed {
+ self.seed.set(Some(seed));
+ }
+ changes.append(&mut streamed);
+ }
+ if !changes.is_empty() {
+ self.changes.take_back_streamed(changes);
+ }
}
/// Commits the rendering update's frame to the render owner, spending `read`, and goes on: the owner applies the
@@ -297,6 +374,7 @@ impl DocumentHost {
commit: CommittedFrame,
) -> InFlight<RecordingAnswer> {
self.take_frame_in(read);
+ self.publish_element_writes();
// Writes the host may not stream beside its task the owner applies in a job first, which the frame reads as a
// read would.
let changes = match self.may_stream_writes() {
@@ -309,13 +387,13 @@ impl DocumentHost {
if !changes.is_empty() {
self.streamed.set(true);
}
- let document = self.document;
+ let (document, seed) = (self.document, self.seed.take());
let ticks = Arc::clone(&self.ticks);
- crate::stage_thread::style_layout_thread().submit_relayed(move |relay| {
+ crate::stage_thread::render_thread().submit_relayed(move |relay| {
if !changes.is_empty() {
super::clock::note_host_write(document);
}
- owner::with_state(document, None, |state| {
+ owner::with_state(document, seed, |state| {
if !changes.is_empty() {
state.apply_streamed(changes);
}
@@ -324,8 +402,8 @@ impl DocumentHost {
})
}
- /// Whether the render state may apply the writes the host queued now: a job made it, none runs, as a host callback
- /// of one does, no frame flies or waits to be taken in, and the host reads the state as of its writes.
+ /// Whether the render state may apply the writes the host queued now: no job runs, as a host callback of one does,
+ /// no frame flies or waits to be taken in, and the host reads the state as of its writes.
fn may_stream_writes(&self) -> bool {
if self.in_job.get()
|| self.away.borrow().is_some()
@@ -335,10 +413,22 @@ impl DocumentHost {
{
return false;
}
- let seed = self.seed.take();
- let made = seed.is_none();
- self.seed.set(seed);
- made && (cfg!(test) || !owner::is_held_here())
+ cfg!(test) || !owner::is_held_here()
+ }
+
+ /// Streams the writes the host queued to the render state now, however few, where nothing keeps them queued, making
+ /// the state where no job made it yet. The render owner applies them beside the host's task, so the host's next job
+ /// finds them applied rather than waiting on them.
+ pub(crate) fn stream_writes_now(&self) {
+ if !self.may_stream_writes() {
+ return;
+ }
+ self.publish_element_writes();
+ let changes = self.changes.take_for_stream();
+ if changes.is_empty() {
+ return;
+ }
+ self.post_stream(changes);
}
/// Notes that the document's render state is written, which leaves the paint and hit testing properties prepared
@@ -353,9 +443,10 @@ impl DocumentHost {
}
/// Takes the writes the host queued, for a frame that flies with them to the render owner. The style writes queued
- /// beside a frame that flies with a style transaction wait for its drain.
+ /// beside a frame that flies with a style update wait for its drain.
pub(super) fn take_queued_changes_for_flight(&self, with_style: bool) -> Vec<ArenaChange> {
debug_assert!(!self.has_flown_style(), "one frame of a document flies at a time");
+ self.publish_element_writes();
self.changes.take_for_flight(with_style)
}
@@ -366,6 +457,7 @@ impl DocumentHost {
work,
deferred_inputs,
released_animation_overlay_records,
+ released_style_nodes,
facts,
selector_value_text_names,
selector_tested_attribute_names,
@@ -374,9 +466,17 @@ impl DocumentHost {
) {
self.engine_memo
.forget_released_animation_overlay_records(&released_animation_overlay_records);
+ self.engine_memo.take_back_released_style_nodes(&released_style_nodes);
self.facts.set(Some(facts));
*self.selector_value_text_names.borrow_mut() = selector_value_text_names;
+ let tested_attribute_names_moved = !std::sync::Arc::ptr_eq(
+ &self.selector_tested_attribute_names.borrow(),
+ &selector_tested_attribute_names,
+ );
*self.selector_tested_attribute_names.borrow_mut() = selector_tested_attribute_names;
+ if tested_attribute_names_moved {
+ crate::css::style::host_atoms::forget_attribute_names_known_unread(self);
+ }
*self.relational_arrival_keys.borrow_mut() = relational_arrival_keys;
self.engine_memo
.deferred
@@ -385,14 +485,18 @@ impl DocumentHost {
// SAFETY: The host has its job or frame back, on its document's thread, or on the render owner in a host
// callback of a job the host waits for, as every host callback runs.
let main_thread = unsafe { crate::stage::from_ffi_entry(&OWED_WORK_PAYMENT, self) };
- crate::css::style::give_up_custom_property_data_let_go_beside_the_host(&main_thread);
for work in work {
work.pay(&main_thread);
}
}
+ /// Notes how deep the document's style tree may be once the frame about to fly applied what it flies with.
+ pub(super) fn note_flight_tree_depth(&self, tree_depth: u32) {
+ self.away_tree_depth.set(tree_depth);
+ }
+
/// Lets the frame fly beside the host, in the job `flight` submits to the owner with the document's name, until the
- /// host drains the reactions of the style transaction it flies with. `flight` also answers whether a test holds it.
+ /// host drains the reactions of the style update it flies with. `flight` also answers whether a test holds it.
pub(super) fn let_frame_fly(
&self,
flight: impl FnOnce(DocumentId, Option<StateSeed>, Option<LayoutTreeUpdateMarks>) -> (InFlight<Landing>, bool),
@@ -421,13 +525,13 @@ impl DocumentHost {
std::mem::take(&mut *self.lane_transitions.borrow_mut())
}
- /// Keeps the root and the sealed inputs of a style transaction the host takes or lets fly, for the hover of a lane
+ /// Keeps the root and the sealed inputs of a style update the host takes or lets fly, for the hover of a lane
/// to take its own with.
pub(crate) fn keep_style_inputs(&self, root: StyleNodeID, inputs: Arc<SealedStyleInputs>) {
*self.style_inputs.borrow_mut() = Some((root, inputs));
}
- /// The root and the sealed inputs of the last style transaction the host took or let fly.
+ /// The root and the sealed inputs of the last style update the host took or let fly.
pub(crate) fn style_inputs(&self) -> Option<(StyleNodeID, Arc<SealedStyleInputs>)> {
self.style_inputs.borrow().clone()
}
@@ -506,15 +610,24 @@ impl DocumentHost {
self.take_frame_in(read);
}
- /// Lands the frame in flight, waiting for it, spending `read`: the style transaction that flew with it waits to be
+ /// Lands the frame in flight, waiting for it, spending `read`: the style update that flew with it waits to be
/// drained.
fn land(&self, read: ForcedRead) {
if let Some(flight) = self.away.take() {
+ // A frame the Render thread has not begun the host takes back and runs itself, rather than waiting for
+ // the thread to wake for it.
+ let reclaimed = flight.reclaim();
// A frame a test holds goes on as soon as the host waits for it.
if self.frame_held_for_testing.take() {
crate::painting::recording_slot::release_held_recording_for_testing();
}
- self.landed(flight.join(read));
+ let landing = match reclaimed {
+ Some(job) => super::on_render_side(self.away_tree_depth.get(), move || {
+ job(&crate::stage_thread::StopWord::said())
+ }),
+ None => flight.join(read),
+ };
+ self.landed(landing);
}
}
@@ -522,7 +635,6 @@ impl DocumentHost {
&self,
Landing {
style,
- applied,
round,
changes,
marks,
@@ -536,11 +648,8 @@ impl DocumentHost {
let previous = self
.flown_style
.borrow_mut()
- .replace(FlownStyle::Landed(style, applied));
- debug_assert!(
- previous.is_none(),
- "one style transaction of a document flies at a time"
- );
+ .replace(FlownStyle::Landed(Box::new(style)));
+ debug_assert!(previous.is_none(), "one style update of a document flies at a time");
}
if let Some((round, rows)) = round {
// The layout round that flew with the frame wrote the render state the paint properties are prepared from.
@@ -556,16 +665,6 @@ impl DocumentHost {
self.note_frame_wait();
}
- /// Seals `round`, the first layout round of a rendering update, for the frame the update lets fly next.
- pub(crate) fn seal_round(&self, round: SealedRound) {
- *self.sealed_round.borrow_mut() = Some(round);
- }
-
- /// Takes the round the host sealed, for the frame that flies with it.
- pub(crate) fn take_sealed_round(&self) -> Option<SealedRound> {
- self.sealed_round.borrow_mut().take()
- }
-
/// Whether a layout round that flew waits for the host to take it in.
pub(crate) fn has_flown_round(&self) -> bool {
self.flown_round.borrow().is_some()
@@ -650,7 +749,10 @@ impl DocumentHost {
/// queued since may have moved what `holds` says they read.
fn facts_where(&self, holds: impl FnOnce(Moves) -> bool) -> Option<StateFacts> {
let facts = self.facts.get()?;
- (!self.in_job.get() && holds(self.changes.moves())).then_some(facts)
+ let mut moves = self.changes.moves();
+ // NB: What the host wrote of its elements and has yet to publish moves the engine's facts as a queued write does.
+ moves.engine_facts |= self.engine_memo.has_unpublished_writes();
+ (!self.in_job.get() && holds(moves)).then_some(facts)
}
/// The facts of the style engine, where the host knows them: it wrote nothing that may move them since its last job
@@ -715,6 +817,12 @@ impl DocumentHost {
Some(keys.iter().any(|key| names.contains(key)))
}
+ /// Whether the engine's selectors test `:local-link`, where the host knows: as it knows where their requirements are.
+ pub(crate) fn known_selectors_test_local_link(&self) -> Option<bool> {
+ self.facts_where(|moves| !moves.selectors)
+ .map(|facts| facts.selectors_test_local_link)
+ }
+
/// Whether the engine's selectors test an attribute that answers to any of `keys`, where the host knows: as it knows
/// where their requirements are.
pub(crate) fn known_selectors_test_attribute(
@@ -860,35 +968,39 @@ impl DocumentHost {
}
}
- /// Whether the host let a style transaction fly whose reactions it has not begun to drain.
+ /// Whether the host let a style update fly whose reactions it has not begun to drain.
#[inline]
pub(crate) fn has_flown_style(&self) -> bool {
self.frame_flies() || matches!(*self.flown_style.borrow(), Some(FlownStyle::Landed(..)))
}
- /// Takes what the style transaction that flew answered, for the host to drain its reactions, once `read` took the
+ /// Takes what the style update that flew answered, for the host to drain its reactions, once `read` took the
/// frame in. The writes the host queued beside the transaction wait for the drain to end.
pub(crate) fn begin_style_drain(&self, read: impl RenderWait) -> StyleJobAnswer {
self.take_frame_in(read);
let mut flown = self.flown_style.borrow_mut();
- let Some(FlownStyle::Landed(answer, applied)) = flown.take() else {
- panic!("the host drains a style transaction that flew and has landed");
+ let Some(FlownStyle::Landed(answer)) = flown.take() else {
+ panic!("the host drains a style update that flew and has landed");
};
- *flown = Some(FlownStyle::Draining(applied));
+ *flown = Some(FlownStyle::Draining);
self.changes.stop_holding_style();
- answer
+ *answer
}
- /// Whether the frame the host drains the style transaction of applied the element `style_node` names its record
- /// `style_record` ahead of the host, and marked the relayout the move asks for.
- pub(crate) fn frame_marked_relayout(&self, style_node: StyleNodeID, style_record: u64) -> bool {
- let flown = self.flown_style.borrow();
- let Some(FlownStyle::Draining(applied)) = &*flown else {
- return false;
- };
- applied
- .binary_search_by_key(&style_node, |row| row.style_node)
- .is_ok_and(|index| applied[index].new_style_record == style_record && applied[index].relayout)
+ /// Whether the render state installed `style_record`, the record of the element `style_node` names, in its box ahead
+ /// of the host, and marked the relayout the move asks for: the render side installed it with the style update
+ /// the host took last.
+ pub(crate) fn render_state_installed(&self, style_node: StyleNodeID, style_record: u64) -> bool {
+ self.style_update
+ .borrow()
+ .as_ref()
+ .is_some_and(|answer| answer.render_state_installed(style_node, style_record))
+ }
+
+ /// The style record the render side installed in the box `slot` with the style update the host took last,
+ /// which the host adopts without publishing it again, if it installed one.
+ pub(crate) fn render_state_installed_box_record(&self, slot: crate::layout::node_data::NodeSlotId) -> Option<u64> {
+ self.style_update.borrow().as_ref()?.render_state_installed_box(slot)
}
/// Sets the writes the host queued aside, for it to read its render state as a frame that flew left it, until
@@ -906,10 +1018,10 @@ impl DocumentHost {
}
}
- /// Ends the drain of the style transaction that flew: the writes the host queued beside it are queued again, behind
+ /// Ends the drain of the style update that flew: the writes the host queued beside it are queued again, behind
/// what the drain wrote.
pub(crate) fn end_style_drain(&self) {
- let Some(FlownStyle::Draining(_)) = self.flown_style.borrow_mut().take() else {
+ let Some(FlownStyle::Draining) = self.flown_style.borrow_mut().take() else {
panic!("the host ends the drain it began");
};
self.changes
@@ -996,6 +1108,8 @@ impl DocumentHost {
self.note_render_state_write();
}
self.take_frame_in(wait);
+ self.publish_element_writes();
+ self.take_back_streams();
let job = Waited(job);
let (answer, marks) = self.changes.drain(|changes| {
let (document, seed, marks) = (self.document, self.seed.take(), self.lend_marks());
@@ -1034,14 +1148,14 @@ impl DocumentHost {
}
/// How deep the document's style tree may be once a job applies `changes`: as deep as its deepest element ever was,
- /// and a level deeper for each relation row the engine staged and has not settled, and for each tree delta of
- /// `changes`.
- fn tree_depth_bound(&self, changes: &[ArenaChange]) -> u32 {
+ /// and a level deeper for each element whose links the engine wrote since it last released a transaction, and for
+ /// each tree delta of `changes`.
+ pub(super) fn tree_depth_bound(&self, changes: &[ArenaChange]) -> u32 {
let queued_tree_deltas = changes
.iter()
.map(|change| match change {
- ArenaChange::Engine(crate::css::style::engine_calls::EngineWrite::ApplyTransaction(input)) => {
- input.tree_delta_count()
+ ArenaChange::Engine(crate::css::style::engine_calls::EngineWrite::Publish(publication)) => {
+ publication.link_rows_written()
}
_ => 0,
})
@@ -1049,7 +1163,7 @@ impl DocumentHost {
self.shared
.deepest_element
.load(Ordering::Relaxed)
- .saturating_add(self.shared.staged_tree_rows.load(Ordering::Relaxed))
+ .saturating_add(self.shared.link_rows_written.load(Ordering::Relaxed))
.saturating_add(u32::try_from(queued_tree_deltas).unwrap_or(u32::MAX))
}
@@ -1235,39 +1349,49 @@ impl DocumentHost {
self.rows.borrow_mut().take();
}
- /// Keeps what the style transaction the host took answered, until the host ends the transaction.
- pub(crate) fn keep_style_transaction(&self, answer: StyleJobAnswer) -> std::cell::Ref<'_, StyleJobAnswer> {
- // The atoms the host interned forget the ones the engine reclaimed, before the host interns a name again.
- self.engine_memo
- .atoms
- .borrow_mut()
- .forget(answer.reclaimed_style_atoms());
- *self.style_transaction.borrow_mut() = Some(answer);
- std::cell::Ref::map(self.style_transaction.borrow(), |answer| {
+ /// Keeps what the style update the host took answered, until the host ends the transaction.
+ pub(crate) fn keep_style_update(&self, answer: StyleJobAnswer) -> std::cell::Ref<'_, StyleJobAnswer> {
+ // The atoms the host interned forget the ones the engine reclaimed, before the host interns a name again, and
+ // so do the catalogs its projection rows are spelled with.
+ self.engine_memo.forget_reclaimed_atoms(answer.reclaimed_style_atoms());
+ let previous = self.style_update.borrow_mut().replace(answer);
+ debug_assert!(
+ previous.is_none_or(|mut previous| previous.take_pinned_records().is_empty()),
+ "the host ends a transaction the render side pinned records for"
+ );
+ std::cell::Ref::map(self.style_update.borrow(), |answer| {
answer.as_ref().expect("the answer was kept above")
})
}
- /// The view of `record`, one the rows of the style transaction the host took last name, and the custom-property
+ /// Takes the records the render side pinned for the host as it installed the style update the host took last,
+ /// for the host to unpin once it installed the transaction.
+ pub(crate) fn take_style_update_pinned_records(&self) -> Vec<u64> {
+ self.style_update
+ .borrow_mut()
+ .as_mut()
+ .map(crate::css::style::style_job::StyleJobAnswer::take_pinned_records)
+ .unwrap_or_default()
+ }
+
+ /// The style of `record`, one the rows of the style update the host took last name, and the custom-property
/// environment it was computed in.
- pub(crate) fn transaction_record(
- &self,
- record: u64,
- ) -> Option<(crate::css::style::bridge::FfiStyleRecordView, Option<u64>)> {
- self.style_transaction.borrow().as_ref()?.record(record)
+ pub(crate) fn transaction_record(&self, record: u64) -> Option<*const std::ffi::c_void> {
+ self.style_update.borrow().as_ref()?.record(record)
}
- /// What the style transaction the host took last answered of the pseudo-elements of `node`, where the host composes
- /// its row.
- pub(crate) fn transaction_pseudo_styles(
+ /// Takes what the main thread does to take the style installation of the style update the host took last.
+ pub(crate) fn take_transaction_installation(
&self,
- node: u32,
- ) -> Option<crate::css::style::style_job::ComposedPseudoStyles> {
- self.style_transaction.borrow().as_ref()?.composed_pseudo_styles(node)
+ ) -> Option<crate::css::style::pipeline::install::StyleInstallation> {
+ self.style_update
+ .borrow_mut()
+ .as_mut()
+ .map(crate::css::style::style_job::StyleJobAnswer::take_installation)
}
/// Hands `hand_over` the actions of the transition step `decision` asks of a target with the `existing` transitions,
- /// where the style transaction the host took last decided it beside the row of the step's element, `node`, over the
+ /// where the style update the host took last decided it beside the row of the step's element, `node`, over the
/// same inputs. Answers whether it did. The transitions such a step starts are what the host samples next, which
/// reads the transaction's first sample of them.
pub(crate) fn answer_decided_transition_step(
@@ -1277,7 +1401,7 @@ impl DocumentHost {
existing: &[crate::css::transition::FfiExistingTransition],
hand_over: impl FnOnce(&[crate::css::transition::FfiTransitionAction]),
) -> bool {
- let transaction = self.style_transaction.borrow();
+ let transaction = self.style_update.borrow();
let step = transaction
.as_ref()
.and_then(|answer| answer.decided_transition_step(node))
@@ -1312,10 +1436,16 @@ impl DocumentHost {
Some(result)
}
- /// Lets go of what the style transaction the host took last answered.
- pub(crate) fn end_style_transaction(&self) {
+ /// Lets go of what the style update the host took last answered, answering the records the render side pinned
+ /// for the host as it installed the transaction, which the host unpins.
+ #[must_use = "the records the render side pinned for the host are unpinned"]
+ pub(crate) fn end_style_update(&self) -> Vec<u64> {
self.fresh_transition_sample.take();
- self.style_transaction.borrow_mut().take();
+ self.style_update
+ .borrow_mut()
+ .take()
+ .map(|mut answer| answer.take_pinned_records())
+ .unwrap_or_default()
}
/// Starts an update pass of the document's compositor animations, with none published.
@@ -1352,7 +1482,7 @@ struct Waited<T>(T);
// SAFETY: The host waits for the job, so what the job borrows of the host's stays live and unwritten until the render
// owner has answered, and the host reads what the answer names of the render state's before its next job, which is
-// what may write it. The host callbacks a job makes run on the owner while the host waits, as a style transaction's do.
+// what may write it. The host callbacks a job makes run on the owner while the host waits, as a style update's do.
unsafe impl<T> Send for Waited<T> {}
impl<T> Waited<T> {
@@ -1492,8 +1622,7 @@ impl DocumentHost {
mod tests {
use super::*;
use crate::css::style::boundary::StyleChange;
- use crate::css::style::engine_calls::{EngineWrite, absorb_element_style_input, has_deferred_element_style_input};
- use crate::css::style::transaction::STYLE_REACTION_INHERITED_STYLE;
+ use crate::css::style::input_types::STYLE_REACTION_PSEUDO_INPUTS_MAY_HAVE_CHANGED;
use crate::render_state::ScriptForcedRead;
const INHERITED_STYLE_GROUPS: u8 = 0b0010;
@@ -1510,42 +1639,16 @@ mod tests {
fn record_input(host: &DocumentHost, node: StyleNodeID) {
host.queue_change(ArenaChange::Style(StyleChange::RecordDerivedElementStyleInput {
node: Some(node),
- reaction: STYLE_REACTION_INHERITED_STYLE,
+ reaction: STYLE_REACTION_PSEUDO_INPUTS_MAY_HAVE_CHANGED,
inherited_style_groups: INHERITED_STYLE_GROUPS,
}));
}
- fn hold_style_writes(host: &DocumentHost) {
- assert!(host.changes.is_empty());
- host.changes.give_back(host.changes.take_for_flight(true));
- }
-
fn begin_drain(host: &DocumentHost) {
- *host.flown_style.borrow_mut() = Some(FlownStyle::Draining(Vec::new()));
+ *host.flown_style.borrow_mut() = Some(FlownStyle::Draining);
host.changes.stop_holding_style();
}
- fn absorb_input(host: &DocumentHost, node: StyleNodeID) -> u32 {
- absorb_element_style_input(
- host,
- host.read_for_test(),
- node,
- STYLE_REACTION_INHERITED_STYLE,
- INHERITED_STYLE_GROUPS,
- false,
- )
- }
-
- fn host_has_deferred_input(host: &DocumentHost, node: StyleNodeID) -> bool {
- has_deferred_element_style_input(host, host.read_for_test(), node)
- }
-
- fn engine_has_deferred_input(host: &DocumentHost, node: StyleNodeID) -> bool {
- host.ask(ScriptForcedRead::for_test(), |state| {
- state.engine_mut().has_deferred_element_style_input(node)
- })
- }
-
#[test]
fn the_plan_of_an_earlier_update_leaves_a_later_take_in_standing() {
let host = TestHost::new();
@@ -1562,56 +1665,6 @@ mod tests {
assert!(!host.lanes_wait_for_the_update());
}
- #[test]
- fn a_drain_beside_held_style_writes_folds_style_inputs_without_a_job() {
- let host = DocumentHost::for_test();
- let [parent, child, held] = style_nodes(&host);
- hold_style_writes(&host);
- record_input(&host, held);
- begin_drain(&host);
- // The parent's applied reaction defers inputs the host cannot name, until the drain's next job.
- record_input(&host, child);
- host.queue_change(ArenaChange::Style(StyleChange::NoteStyleReactionApplied {
- node: Some(parent),
- reaction: STYLE_REACTION_INHERITED_STYLE,
- inherited_style_groups_changed: INHERITED_STYLE_GROUPS,
- changed_non_inherited_style_groups: 0,
- facts: 0,
- }));
- host.ask(ScriptForcedRead::for_test(), |_| ());
-
- assert_eq!(
- absorb_input(&host, child),
- u32::from(STYLE_REACTION_INHERITED_STYLE) | (u32::from(INHERITED_STYLE_GROUPS) << 8)
- );
- assert!(
- matches!(
- host.changes.queued.borrow().last(),
- Some(ArenaChange::Engine(EngineWrite::AbsorbElementStyleInput { .. }))
- ),
- "the host folds the input without a job, and queues the fold for the engine"
- );
- assert!(!engine_has_deferred_input(&host, child));
- host.end_style_drain();
- }
-
- #[test]
- fn a_held_style_write_defers_an_input_once_the_drain_queues_it() {
- let host = DocumentHost::for_test();
- let [node] = style_nodes(&host);
- hold_style_writes(&host);
- record_input(&host, node);
- begin_drain(&host);
- // No job applies the held write until the drain ends.
- assert!(!host_has_deferred_input(&host, node));
- assert_eq!(absorb_input(&host, node), 0);
- assert!(!engine_has_deferred_input(&host, node));
-
- host.end_style_drain();
- assert!(host_has_deferred_input(&host, node));
- assert!(engine_has_deferred_input(&host, node));
- }
-
fn render_state_has_deferred_inputs(host: &DocumentHost, nodes: &[StyleNodeID]) -> bool {
owner::with_state(host.document, None, |state| {
nodes
diff --git a/Libraries/LibWeb/Rust/src/render_state/owner.rs b/Libraries/LibWeb/Rust/src/render_state/owner.rs
index 44bfbe746dc..216b3bfd6fc 100644
--- a/Libraries/LibWeb/Rust/src/render_state/owner.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/owner.rs
@@ -6,8 +6,8 @@
//! The render owner: whichever thread holds the slot every document's render state lives in.
//!
-//! The StyleLayout thread holds the slot for the jobs it runs, and a host's thread holds it for a job it runs itself,
-//! while it waits for nothing the StyleLayout thread runs (see [`super::on_render_side`]). A thread holds the slot only
+//! The Render thread holds the slot for the jobs it runs, and a host's thread holds it for a job it runs itself,
+//! while it waits for nothing the Render thread runs (see [`super::on_render_side`]). A thread holds the slot only
//! for the length of a job, never between them, so no thread waits for another to run script. The host names its
//! document's state by the [`DocumentId`] it minted, and reaches it only with a job. The owner makes a state the first
//! time a job reaches it, from what the host's [`StateSeed`] says, so a document that never sends its state anything
@@ -52,15 +52,18 @@ pub(crate) struct SharedWithHost {
pub(super) declaration_block_versions: Arc<AtomicU32>,
/// The depth of the deepest element the state's style tree ever held.
pub(super) deepest_element: Arc<AtomicU32>,
- /// How many relation rows the state's style engine staged and has not settled yet, each of which may deepen the
- /// tree by a level.
- pub(super) staged_tree_rows: Arc<AtomicU32>,
+ /// How many elements' links the state's style engine wrote since it last released a transaction, each of which may
+ /// deepen the tree by a level until the tree settles them.
+ pub(super) link_rows_written: Arc<AtomicU32>,
+ /// The style atoms of the process, which the host interns names in beside the state's style engine.
+ pub(super) style_atoms: Arc<crate::css::style::ProcessAtoms>,
}
impl SharedWithHost {
pub(super) fn new() -> Self {
Self {
declaration_block_versions: Arc::new(AtomicU32::new(1)),
+ style_atoms: Arc::clone(SLOT.process_style.atoms()),
..Self::default()
}
}
@@ -72,8 +75,12 @@ struct Slot {
/// Each document's render state and clock lanes, which only the thread that holds the slot reaches. An entry is
/// boxed, so a job reaching it keeps reaching it while the job makes another document's state.
states: RefCell<HashMap<DocumentId, Box<DocumentEntry>>>,
+ /// The style data every document's style engine shares with the others.
+ process_style: Arc<crate::css::style::ProcessStyle>,
/// What names the slot to ThreadSanitizer, which sees the ordering holding it gives only through it.
tsan_key: AtomicBool,
+ /// The threads the style passes of every document run on besides the owner's.
+ style_pool: Arc<crate::css::style::pipeline::pool::StylePool>,
}
// SAFETY: Only the thread that holds the slot reaches its states, which may cross threads, and holding it orders what
@@ -90,9 +97,17 @@ const _: () = {
static SLOT: LazyLock<Slot> = LazyLock::new(|| Slot {
held: Mutex::new(()),
states: RefCell::new(HashMap::new()),
+ process_style: Arc::default(),
tsan_key: AtomicBool::new(false),
+ style_pool: Arc::new(crate::css::style::pipeline::pool::StylePool::of_process()),
});
+/// The style data every document's style engine shares with the others, which any thread reaches without the slot: only
+/// what it guards itself is written once it is made.
+pub(crate) fn process_style() -> &'static Arc<crate::css::style::ProcessStyle> {
+ &SLOT.process_style
+}
+
thread_local! {
/// How many holds of the slot the calling thread is in, which a host callback of a job takes again.
static HOLDS: Cell<u32> = const { Cell::new(0) };
@@ -177,7 +192,7 @@ pub(super) fn with_state<R>(
let entry = match seed {
Some(seed) => states.entry(document).or_insert_with(|| {
Box::new(DocumentEntry {
- state: UnsafeCell::new(RenderState::new(seed)),
+ state: UnsafeCell::new(RenderState::new(seed, &SLOT.process_style, &SLOT.style_pool)),
lanes: Cell::default(),
job_runs_on_state: Cell::new(false),
})
diff --git a/Libraries/LibWeb/Rust/src/stage_thread.rs b/Libraries/LibWeb/Rust/src/stage_thread.rs
index 6a5b2323d21..a875f7d82b5 100644
--- a/Libraries/LibWeb/Rust/src/stage_thread.rs
+++ b/Libraries/LibWeb/Rust/src/stage_thread.rs
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-//! The threads a document's rendering runs on beside the host's: the StyleLayout thread, which runs the jobs on every
+//! The threads a document's rendering runs on beside the host's: the Render thread, which runs the jobs on every
//! document's render state that the host does not run itself, and the Paint thread, which records display lists from
//! the frames the render states publish.
//!
@@ -25,7 +25,7 @@ use std::cell::{Cell, RefCell, UnsafeCell};
use std::marker::PhantomData;
use std::panic::AssertUnwindSafe;
use std::ptr::NonNull;
-use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicUsize, Ordering};
+use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicU8, AtomicUsize, Ordering};
use std::sync::{Arc, Mutex, OnceLock, PoisonError};
use std::thread::Thread;
@@ -84,7 +84,14 @@ impl Shared {
/// How many of the jobs a thread made for each stage thread have yet to run, by the address of what the stage thread
/// shares.
-type UnfinishedJobCounts = SmallVec<[(usize, Arc<AtomicUsize>); 2]>;
+/// Beside each count, how many of those jobs are reclaimable ones that claimed their payload and have yet to finish.
+type UnfinishedJobCounts = SmallVec<[(usize, HandedCounts); 2]>;
+
+#[derive(Clone, Default)]
+struct HandedCounts {
+ unfinished: Arc<AtomicUsize>,
+ claimed: Arc<AtomicUsize>,
+}
thread_local! {
/// How many of the jobs the calling thread made for each stage thread have yet to run.
@@ -202,17 +209,86 @@ impl StageThread {
};
let flight = InFlight {
flight,
+ reclaimable: None,
not_send_or_sync: PhantomData,
};
(flight, parked)
}
+ /// Submits `job` as [`Self::submit`] does, but the submitting thread may take it back with [`InFlight::reclaim`]
+ /// until this thread claims it, which it does inside `hold`, as it runs it: whatever orders the job against the
+ /// submitting thread's own work, such as the render owner's slot.
+ pub(crate) fn submit_reclaimable<R: Send + 'static>(
+ &'static self,
+ job: impl FnOnce(&StopWord) -> R + Send + 'static,
+ hold: fn(&mut dyn FnMut()),
+ ) -> InFlight<R> {
+ let flight = Flight::pending();
+ let landing = Arc::clone(&flight);
+ let job: FlightJob<R> = Box::new(job);
+ // NB: A submitted job lands its answer after it gave up the hold, so it never counts as claimed.
+ let reclaimable = self.post_reclaimable_counting(job, false, move |mut claim| {
+ let mut answer = None;
+ hold(&mut || {
+ if let Some(job) = claim.claim() {
+ answer = Some(std::panic::catch_unwind(AssertUnwindSafe(|| job(&landing.stop))));
+ }
+ });
+ // NB: The job counts as run before it lands, so the submitting thread that lands it finds nothing left to
+ // wait for.
+ drop(claim);
+ if let Some(answer) = answer {
+ land_relayed(&landing, answer);
+ }
+ });
+ InFlight {
+ flight,
+ reclaimable: Some(reclaimable),
+ not_send_or_sync: PhantomData,
+ }
+ }
+
/// Posts `job` to this thread and goes on: the job owns what it reads, runs after the jobs handed to the thread
/// before it, and answers nothing. A job posted from this thread runs once the job it is posted from is done.
pub(crate) fn post(&self, job: impl FnOnce() + Send + 'static) {
self.hand(PostedJob::give_up(job, self.count_unfinished()));
}
+ /// Posts a job to this thread that runs `run` with what `claim` takes of `payload`, as [`Self::post`] does, but which
+ /// the calling thread may take `payload` back from with [`Reclaimable::reclaim`] until the job claims it. A job whose
+ /// payload was taken back counts as run: the calling thread has done its work itself.
+ pub(crate) fn post_reclaimable<T: Send + 'static>(
+ &self,
+ payload: T,
+ run: impl FnOnce(Claim<T>) + Send + 'static,
+ ) -> Reclaimable<T> {
+ self.post_reclaimable_counting(payload, true, run)
+ }
+
+ /// Posts a reclaimable job, which counts as claimed (see [`Self::only_claimed_jobs_unfinished_from_here`]) from the
+ /// time it claims its payload to the time its claim is dropped where `counts_claim`.
+ fn post_reclaimable_counting<T: Send + 'static>(
+ &self,
+ payload: T,
+ counts_claim: bool,
+ run: impl FnOnce(Claim<T>) + Send + 'static,
+ ) -> Reclaimable<T> {
+ let job = Arc::new(ReclaimableJob {
+ state: AtomicU8::new(ReclaimableJob::<T>::PENDING),
+ payload: Mutex::new(Some(payload)),
+ unfinished: self.count_unfinished(),
+ claimed: counts_claim.then(|| self.handed_counts().claimed),
+ });
+ let claim = Claim {
+ job: Arc::clone(&job),
+ claimed: false,
+ };
+ // NB: The job is counted among the unfinished ones through `ReclaimableJob::unfinished`, which whoever takes the
+ // payload uncounts, so the posted job itself counts nothing.
+ self.hand(PostedJob::give_up(move || run(claim), Arc::new(AtomicUsize::new(1))));
+ Reclaimable(job)
+ }
+
/// Hands the job `header` heads to this thread, which runs it after the jobs handed to it before.
fn hand(&self, header: NonNull<JobHeader>) {
tsan::release(&self.shared.tsan_key);
@@ -234,18 +310,21 @@ impl StageThread {
/// Counts a job the calling thread makes for this thread among those that have yet to run, which the job uncounts
/// once it has run.
fn count_unfinished(&self) -> Arc<AtomicUsize> {
+ let counts = self.handed_counts();
+ counts.unfinished.fetch_add(1, Ordering::Relaxed);
+ counts.unfinished
+ }
+
+ /// The counts of the jobs the calling thread made for this thread.
+ fn handed_counts(&self) -> HandedCounts {
let key = self.key();
- UNFINISHED_HANDED.with_borrow_mut(|unfinished| {
- let count = match unfinished.iter().find(|(of, _)| *of == key) {
- Some((_, count)) => Arc::clone(count),
- None => {
- let count = Arc::new(AtomicUsize::new(0));
- unfinished.push((key, Arc::clone(&count)));
- count
- }
- };
- count.fetch_add(1, Ordering::Relaxed);
- count
+ UNFINISHED_HANDED.with_borrow_mut(|handed| match handed.iter().find(|(of, _)| *of == key) {
+ Some((_, counts)) => counts.clone(),
+ None => {
+ let counts = HandedCounts::default();
+ handed.push((key, counts.clone()));
+ counts
+ }
})
}
@@ -257,7 +336,7 @@ impl StageThread {
unfinished
.iter()
.find(|(of, _)| *of == key)
- .is_none_or(|(_, count)| count.load(Ordering::Acquire) == 0)
+ .is_none_or(|(_, counts)| counts.unfinished.load(Ordering::Acquire) == 0)
});
if done {
tsan::acquire(&self.shared.tsan_key);
@@ -265,6 +344,21 @@ impl StageThread {
done
}
+ /// Whether every job the calling thread made for this thread that has yet to finish is a reclaimable one that
+ /// claimed its payload: each claims inside whatever orders it against the calling thread's own work, such as the
+ /// render owner's slot, so work the calling thread does under that same order runs after all of them.
+ pub(crate) fn only_claimed_jobs_unfinished_from_here(&self) -> bool {
+ let key = self.key();
+ UNFINISHED_HANDED.with_borrow(|handed| {
+ handed.iter().find(|(of, _)| *of == key).is_none_or(|(_, counts)| {
+ // NB: The jobs unfinished are counted before the claimed ones. No job is made meanwhile, so every job
+ // counted claimed then was unfinished before: as many claimed as were unfinished means all were.
+ let unfinished = counts.unfinished.load(Ordering::Acquire);
+ unfinished <= counts.claimed.load(Ordering::Acquire)
+ })
+ })
+ }
+
/// The key the calling thread counts the jobs it made for this thread by.
fn key(&self) -> usize {
std::ptr::from_ref(self.shared).addr()
@@ -442,6 +536,81 @@ impl<F: FnOnce() + Send> PostedJob<F> {
}
}
+/// A job posted with [`StageThread::post_reclaimable`], whose payload either its thread or the thread that posted it
+/// takes, whichever comes first.
+struct ReclaimableJob<T> {
+ state: AtomicU8,
+ payload: Mutex<Option<T>>,
+ /// The count of unfinished jobs of the thread that posted the job, which counts it until its payload is taken and,
+ /// where the job took it, it has run.
+ unfinished: Arc<AtomicUsize>,
+ /// The count of the reclaimable jobs of that thread that claimed their payload and have yet to finish, where the job
+ /// counts in it.
+ claimed: Option<Arc<AtomicUsize>>,
+}
+
+impl<T> ReclaimableJob<T> {
+ const PENDING: u8 = 0;
+ const RUNNING: u8 = 1;
+ const RECLAIMED: u8 = 2;
+
+ fn take(&self, state: u8) -> Option<T> {
+ self.state
+ .compare_exchange(Self::PENDING, state, Ordering::AcqRel, Ordering::Acquire)
+ .ok()?;
+ self.payload.lock().unwrap_or_else(PoisonError::into_inner).take()
+ }
+}
+
+/// The handle the thread that posted a reclaimable job keeps of it.
+pub(crate) struct Reclaimable<T>(Arc<ReclaimableJob<T>>);
+
+impl<T> Reclaimable<T> {
+ /// Takes the job's payload back where the job has not claimed it yet, so that the job does nothing and counts as
+ /// run.
+ pub(crate) fn reclaim(&self) -> Option<T> {
+ let payload = self.0.take(ReclaimableJob::<T>::RECLAIMED)?;
+ self.0.unfinished.fetch_sub(1, Ordering::Release);
+ Some(payload)
+ }
+
+ /// Whether the job claimed its payload or had it taken back.
+ pub(crate) fn is_taken(&self) -> bool {
+ self.0.state.load(Ordering::Acquire) != ReclaimableJob::<T>::PENDING
+ }
+}
+
+/// What a reclaimable job claims its payload with, where the thread that posted it has not taken it back. Whatever
+/// orders the job against the posting thread's own work, such as the render owner's slot, has to be held as it claims.
+pub(crate) struct Claim<T> {
+ job: Arc<ReclaimableJob<T>>,
+ claimed: bool,
+}
+
+impl<T> Claim<T> {
+ /// The payload, unless the thread that posted the job took it back.
+ pub(crate) fn claim(&mut self) -> Option<T> {
+ let payload = self.job.take(ReclaimableJob::<T>::RUNNING)?;
+ if let Some(claimed) = &self.job.claimed {
+ claimed.fetch_add(1, Ordering::Release);
+ }
+ self.claimed = true;
+ Some(payload)
+ }
+}
+
+impl<T> Drop for Claim<T> {
+ fn drop(&mut self) {
+ if self.claimed {
+ // NB: Uncounted as claimed before as unfinished, so that it never counts as claimed and not unfinished.
+ if let Some(claimed) = &self.job.claimed {
+ claimed.fetch_sub(1, Ordering::Release);
+ }
+ self.job.unfinished.fetch_sub(1, Ordering::Release);
+ }
+ }
+}
+
/// What a submitted job shares with the thread that submitted it.
struct Flight<R> {
/// Whether the job has finished, and its answer has landed.
@@ -456,6 +625,11 @@ struct Flight<R> {
pub(crate) struct StopWord(AtomicBool);
impl StopWord {
+ /// A stop word that is said, for a job its submitting thread took back to run while it waits.
+ pub(crate) fn said() -> Self {
+ Self(AtomicBool::new(true))
+ }
+
/// Whether the thread that submitted the job waits for it.
pub(crate) fn is_said(&self) -> bool {
self.0.load(Ordering::Relaxed)
@@ -549,15 +723,21 @@ pub(crate) trait Flown {
/// top of its event loop, and waits for one elsewhere only by spending the right to.
pub(crate) struct InFlight<R> {
flight: Arc<Flight<R>>,
+ /// The job, where the submitting thread may still take it back.
+ reclaimable: Option<Reclaimable<FlightJob<R>>>,
not_send_or_sync: PhantomData<*const ()>,
}
+/// A submitted job, as the thread that submitted it may take it back.
+pub(crate) type FlightJob<R> = Box<dyn FnOnce(&StopWord) -> R + Send>;
+
impl<R> InFlight<R> {
/// A flight that has landed with `answer`, for a unit test, whose render states stay on the test's own thread.
#[cfg(test)]
pub(crate) fn landed(answer: R) -> Self {
Self {
flight: Flight::landed(answer),
+ reclaimable: None,
not_send_or_sync: PhantomData,
}
}
@@ -585,6 +765,15 @@ impl<R> InFlight<R> {
self.flight.wait_for_answer()
}
+ /// Takes the job back where it was submitted with [`StageThread::submit_reclaimable`] and the thread has not
+ /// claimed it yet, for the submitting thread to run it itself. The flight never lands then, so its thread is told as
+ /// it would be of a landing: what waits behind the flight on its event loop goes on only once that wakes.
+ pub(crate) fn reclaim(&self) -> Option<FlightJob<R>> {
+ let job = self.reclaimable.as_ref()?.reclaim()?;
+ note_flight_finished();
+ Some(job)
+ }
+
/// Tells the job that the thread that submitted it waits for it.
fn say_stop(&self) {
self.flight.stop.0.store(true, Ordering::Relaxed);
@@ -594,7 +783,7 @@ impl<R> InFlight<R> {
impl StageThread {
/// Submits `job` to this thread, as [`Self::submit`] does, but lends it the relay of its flight rather than landing
/// what it answers: the job hands the relay on to the thread that answers, as the commit of a rendering update hands
- /// the frame it sampled on the StyleLayout thread to the Paint thread, which records it. The flight lands as the
+ /// the frame it sampled on the Render thread to the Paint thread, which records it. The flight lands as the
/// relay does.
pub(crate) fn submit_relayed<R: Send + 'static>(&self, job: impl FnOnce(Relay<R>) + Send + 'static) -> InFlight<R> {
let flight = Flight::pending();
@@ -603,6 +792,7 @@ impl StageThread {
self.post(move || drop(std::panic::catch_unwind(AssertUnwindSafe(|| job(relay)))));
InFlight {
flight,
+ reclaimable: None,
not_send_or_sync: PhantomData,
}
}
@@ -639,6 +829,10 @@ impl<R> Drop for Relay<R> {
/// Lands `answer` in `flight`, and has the thread that submitted the job take it in, as a submitted job's.
fn land_relayed<R>(flight: &Flight<R>, answer: std::thread::Result<R>) {
flight.land(answer);
+ note_flight_finished();
+}
+
+fn note_flight_finished() {
if let Some(finished) = FLIGHT_FINISHED.get() {
finished();
}
@@ -688,16 +882,11 @@ fn wait_for<T>(mut ready: impl FnMut() -> Option<T>) -> T {
}
}
-static STYLE_LAYOUT_THREAD: OnceLock<StageThread> = OnceLock::new();
-
-/// The StyleLayout thread, which runs the jobs on every document's render state that the host does not run itself.
-pub(crate) fn style_layout_thread() -> &'static StageThread {
- STYLE_LAYOUT_THREAD.get_or_init(|| StageThread::spawn("StyleLayout"))
-}
+static RENDER_THREAD: OnceLock<StageThread> = OnceLock::new();
-/// Whether the calling thread is the StyleLayout thread, without starting it.
-pub(crate) fn is_on_style_layout_thread() -> bool {
- STYLE_LAYOUT_THREAD.get().is_some_and(StageThread::is_current)
+/// The Render thread, which runs the jobs on every document's render state that the host does not run itself.
+pub(crate) fn render_thread() -> &'static StageThread {
+ RENDER_THREAD.get_or_init(|| StageThread::spawn("Render"))
}
#[cfg(test)]
@@ -777,6 +966,91 @@ mod tests {
assert_eq!(test_thread().run(|| ran.load(Ordering::Relaxed)), 1);
}
+ #[test]
+ fn a_reclaimed_job_runs_nothing_and_counts_as_run() {
+ let (open, wait) = gate();
+ test_thread().post(wait);
+ let ran = Arc::new(AtomicUsize::new(0));
+ let job_ran = Arc::clone(&ran);
+ let job = test_thread().post_reclaimable(7_usize, move |mut claim| {
+ if let Some(payload) = claim.claim() {
+ job_ran.fetch_add(payload, Ordering::Relaxed);
+ }
+ });
+ assert!(!job.is_taken());
+ assert_eq!(job.reclaim(), Some(7));
+ assert_eq!(job.reclaim(), None, "a payload is taken once");
+ open.store(true, Ordering::Release);
+ test_thread().run(|| ());
+ assert_eq!(ran.load(Ordering::Relaxed), 0);
+ assert!(test_thread().ran_every_job_handed_from_here());
+ }
+
+ #[test]
+ fn a_submitted_job_taken_back_runs_where_it_is_taken() {
+ let (open, wait) = gate();
+ test_thread().post(wait);
+ let flight = test_thread().submit_reclaimable(|stop| stop.is_said(), |job| job());
+ let job = flight.reclaim().expect("the thread has not begun the job");
+ assert!(flight.reclaim().is_none(), "a job is taken back once");
+ assert!(job(&StopWord::said()));
+ open.store(true, Ordering::Release);
+ test_thread().run(|| ());
+ assert!(!flight.has_finished(), "a job taken back never lands");
+ assert!(test_thread().ran_every_job_handed_from_here());
+
+ let flight = test_thread().submit_reclaimable(|_| 5_u32, |job| job());
+ test_thread().run(|| ());
+ assert!(flight.reclaim().is_none(), "the thread claimed the job");
+ assert_eq!(flight.join(()), 5);
+ }
+
+ #[test]
+ fn a_claimed_job_cannot_be_reclaimed() {
+ let ran = Arc::new(AtomicUsize::new(0));
+ let job_ran = Arc::clone(&ran);
+ let job = test_thread().post_reclaimable(3_usize, move |mut claim| {
+ if let Some(payload) = claim.claim() {
+ job_ran.fetch_add(payload, Ordering::Relaxed);
+ }
+ });
+ test_thread().run(|| ());
+ assert!(job.is_taken());
+ assert_eq!(job.reclaim(), None);
+ assert_eq!(ran.load(Ordering::Relaxed), 3);
+ assert!(test_thread().ran_every_job_handed_from_here());
+ }
+
+ #[test]
+ fn a_thread_knows_whether_only_claimed_jobs_it_handed_are_unfinished() {
+ let (claimed, wait_for_claim) = gate();
+ let (open, wait) = gate();
+ let job = test_thread().post_reclaimable((), move |mut claim| {
+ if claim.claim().is_some() {
+ claimed.store(true, Ordering::Release);
+ wait();
+ }
+ });
+ wait_for_claim();
+ assert!(job.is_taken());
+ assert!(!test_thread().ran_every_job_handed_from_here());
+ assert!(
+ test_thread().only_claimed_jobs_unfinished_from_here(),
+ "the job claimed its payload"
+ );
+ test_thread().post(|| ());
+ assert!(
+ !test_thread().only_claimed_jobs_unfinished_from_here(),
+ "a posted job waits behind the claimed one"
+ );
+ let flight = test_thread().submit_reclaimable(|_| 2_u32, |job| job());
+ open.store(true, Ordering::Release);
+ assert_eq!(flight.join(()), 2);
+ test_thread().run(|| ());
+ assert!(test_thread().only_claimed_jobs_unfinished_from_here());
+ assert!(test_thread().ran_every_job_handed_from_here());
+ }
+
#[test]
fn a_thread_knows_whether_the_jobs_it_handed_have_run() {
let (open, wait) = gate();
diff --git a/Services/WebContent/PageClient.cpp b/Services/WebContent/PageClient.cpp
index 55f251c689c..de164ff25d4 100644
--- a/Services/WebContent/PageClient.cpp
+++ b/Services/WebContent/PageClient.cpp
@@ -153,7 +153,7 @@ PageClient::PageClient(PageHost& owner, Web::PageId id, Optional<Web::HTML::Cros
{
setup_palette();
- // A hover of the render clock asks for its cursor on the StyleLayout thread, as the main thread does on its own: both
+ // A hover of the render clock asks for its cursor on the Render thread, as the main thread does on its own: both
// over the one connection, under the page cursor's lock.
m_page->cursor().set_send([&client = client(), id = m_id](Gfx::Cursor const& cursor) {
client.async_did_request_cursor_change(id, cursor);
diff --git a/Tests/LibWeb/Crash/CSS/custom-property-change-while-elements-are-removed-beside-style-flight.html b/Tests/LibWeb/Crash/CSS/custom-property-change-while-elements-are-removed-beside-style-flight.html
index 559a66488d9..c6d2e13155a 100644
--- a/Tests/LibWeb/Crash/CSS/custom-property-change-while-elements-are-removed-beside-style-flight.html
+++ b/Tests/LibWeb/Crash/CSS/custom-property-change-while-elements-are-removed-beside-style-flight.html
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<!-- A custom property on the root changes every few milliseconds while tasks remove the elements inheriting it, so
- some are removed while a style transaction moving their environment is in flight. -->
+ some are removed while a style update moving their environment is in flight. -->
<html class="test-wait">
<body>
<div id="root"></div>
diff --git a/Tests/LibWeb/Ref/expected/pseudo-element-inherits-its-own-elements-animated-color-among-shared-styles-ref.html b/Tests/LibWeb/Ref/expected/pseudo-element-inherits-its-own-elements-animated-color-among-shared-styles-ref.html
new file mode 100644
index 00000000000..aeade25da78
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/pseudo-element-inherits-its-own-elements-animated-color-among-shared-styles-ref.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<style>
+ div {
+ width: 50px;
+ height: 20px;
+ }
+</style>
+<div style="background-color: rgb(0, 0, 0)"></div>
+<div style="background-color: rgb(0, 0, 50)"></div>
+<div style="background-color: rgb(0, 0, 100)"></div>
+<div style="background-color: rgb(0, 0, 150)"></div>
+<div style="background-color: rgb(0, 0, 200)"></div>
diff --git a/Tests/LibWeb/Ref/input/pseudo-element-inherits-its-own-elements-animated-color-among-shared-styles.html b/Tests/LibWeb/Ref/input/pseudo-element-inherits-its-own-elements-animated-color-among-shared-styles.html
new file mode 100644
index 00000000000..8ba425225f6
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/pseudo-element-inherits-its-own-elements-animated-color-among-shared-styles.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<link rel="match" href="../expected/pseudo-element-inherits-its-own-elements-animated-color-among-shared-styles-ref.html">
+<style>
+ @keyframes fade {
+ from { color: rgb(0, 0, 0); }
+ to { color: rgb(0, 0, 250); }
+ }
+ .target {
+ animation: fade 10s linear paused;
+ }
+ .target::before {
+ content: "";
+ display: block;
+ width: 50px;
+ height: 20px;
+ background-color: currentcolor;
+ }
+ .restyled .target {
+ animation-play-state: paused;
+ }
+</style>
+<div id="container">
+ <div class="target"></div>
+ <div class="target"></div>
+ <div class="target"></div>
+ <div class="target"></div>
+ <div class="target"></div>
+</div>
+<script>
+ // Restyling the targets in one pass lets them share a style, but each one's pseudo-element inherits the
+ // composition of its own element's animation.
+ const nextFrame = () => new Promise(resolve => requestAnimationFrame(resolve));
+ window.onload = async () => {
+ [...container.children].forEach((target, index) => (target.getAnimations()[0].currentTime = 2000 * index));
+ await nextFrame();
+ await nextFrame();
+ container.className = "restyled";
+ await nextFrame();
+ await nextFrame();
+ document.documentElement.classList.remove("reftest-wait");
+ };
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/animation-promise-rejected-by-a-style-drain.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/animation-promise-rejected-by-a-style-drain.txt
new file mode 100644
index 00000000000..ad96ee7ae83
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/animation-promise-rejected-by-a-style-drain.txt
@@ -0,0 +1,2 @@
+finished promise rejected: AbortError
+beside the layout: laying-out, the reaction ran before this task: true
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/element-moved-beside-the-layout-that-builds-its-box.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/element-moved-beside-the-layout-that-builds-its-box.txt
new file mode 100644
index 00000000000..dae235c87d8
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/element-moved-beside-the-layout-that-builds-its-box.txt
@@ -0,0 +1 @@
+source height: 0
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/element-removed-beside-a-layout-taken-in-after-a-publication.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/element-removed-beside-a-layout-taken-in-after-a-publication.txt
new file mode 100644
index 00000000000..d23057e8284
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/element-removed-beside-a-layout-taken-in-after-a-publication.txt
@@ -0,0 +1,3 @@
+height before: 20
+height after: 10
+computed height: 10px
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/element-removed-beside-the-layout-that-builds-its-box.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/element-removed-beside-the-layout-that-builds-its-box.txt
new file mode 100644
index 00000000000..dae235c87d8
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/element-removed-beside-the-layout-that-builds-its-box.txt
@@ -0,0 +1 @@
+source height: 0
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/elements-arriving-beside-a-style-drain-that-publishes.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/elements-arriving-beside-a-style-drain-that-publishes.txt
new file mode 100644
index 00000000000..bc4616e6164
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/elements-arriving-beside-a-style-drain-that-publishes.txt
@@ -0,0 +1,3 @@
+a frame is in flight: true
+height before: 7
+height after: 9
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/font-table-change-beside-a-style-drain-that-publishes.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/font-table-change-beside-a-style-drain-that-publishes.txt
new file mode 100644
index 00000000000..00f1a00ee61
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/font-table-change-beside-a-style-drain-that-publishes.txt
@@ -0,0 +1 @@
+the text is set in the face: true
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-keeps-candidates-for-a-file-input.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-keeps-candidates-for-a-file-input.txt
new file mode 100644
index 00000000000..4d7b85244ff
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-keeps-candidates-for-a-file-input.txt
@@ -0,0 +1 @@
+hover presented by: clock
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-keeps-candidates-for-ua-hover-rules.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-keeps-candidates-for-ua-hover-rules.txt
new file mode 100644
index 00000000000..4d7b85244ff
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-keeps-candidates-for-ua-hover-rules.txt
@@ -0,0 +1 @@
+hover presented by: clock
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-nth-child-of-hover.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-nth-child-of-hover.txt
new file mode 100644
index 00000000000..6703ae7ceaa
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-nth-child-of-hover.txt
@@ -0,0 +1,2 @@
+box width on screen: undefined
+box width once the main thread handled the move: 150px
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-scope-root-hover.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-scope-root-hover.txt
new file mode 100644
index 00000000000..6703ae7ceaa
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-scope-root-hover.txt
@@ -0,0 +1,2 @@
+box width on screen: undefined
+box width once the main thread handled the move: 150px
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-seals-a-frame-no-hover-rule-can-restyle.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-seals-a-frame-no-hover-rule-can-restyle.txt
new file mode 100644
index 00000000000..7f012c5094a
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-seals-a-frame-no-hover-rule-can-restyle.txt
@@ -0,0 +1 @@
+hover presented by: commit
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-transition-beside-a-child-inheriting-another-group.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-transition-beside-a-child-inheriting-another-group.txt
new file mode 100644
index 00000000000..9b6cb67db40
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-transition-beside-a-child-inheriting-another-group.txt
@@ -0,0 +1,4 @@
+a tick presented the last frame: true
+link matches :hover: true
+label color: rgb(255, 0, 0)
+label box-sizing: content-box
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-uppercase-type-selector.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-uppercase-type-selector.txt
new file mode 100644
index 00000000000..574fff343a1
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-uppercase-type-selector.txt
@@ -0,0 +1,2 @@
+box width on screen: 150
+box width once the main thread handled the move: 150px
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/press-after-a-focusable-ancestor-caught-up-its-animations.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/press-after-a-focusable-ancestor-caught-up-its-animations.txt
new file mode 100644
index 00000000000..aaecaf93c4a
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/press-after-a-focusable-ancestor-caught-up-its-animations.txt
@@ -0,0 +1 @@
+PASS (didn't crash)
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/recording-flight-canceled-animation-style.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/recording-flight-canceled-animation-style.txt
index 6f7c64d865c..1394b6ee32a 100644
--- a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/recording-flight-canceled-animation-style.txt
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/recording-flight-canceled-animation-style.txt
@@ -1,4 +1,2 @@
-dropped overlays kept beside the recording: true
-dropped overlays kept once it landed: 0
margin-left: 0px
hit test finds the box: true
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/recording-flight-replaced-animation-style.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/recording-flight-replaced-animation-style.txt
index 56b9a31a76a..bab5ecad101 100644
--- a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/recording-flight-replaced-animation-style.txt
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/recording-flight-replaced-animation-style.txt
@@ -1,4 +1,2 @@
-replaced overlays kept beside the recording: true
-replaced overlays kept once it landed: 0
margin-left: 50px
hit test finds the box: true
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/style-input-beside-a-flight-requests-a-frame.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/style-input-beside-a-flight-requests-a-frame.txt
new file mode 100644
index 00000000000..da9e077292b
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/style-input-beside-a-flight-requests-a-frame.txt
@@ -0,0 +1,3 @@
+a class change beside a flight took effect
+an arrival beside a flight took effect
+a change after other input took effect
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/style-layout-flight-iframe-child-only.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/style-layout-flight-iframe-child-only.txt
index efd50773418..1ee4d66e40a 100644
--- a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/style-layout-flight-iframe-child-only.txt
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/style-layout-flight-iframe-child-only.txt
@@ -2,5 +2,4 @@ state in the next task: in-flight
child resize observed before the next task: nothing
child resize observed: 80x20
child box: 80x20
-container styles recomputed: 0
container box: 50x20, iframe: 200x100
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/style-text-changed-beside-the-layout-that-builds-its-box.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/style-text-changed-beside-the-layout-that-builds-its-box.txt
new file mode 100644
index 00000000000..47a8651b485
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/style-text-changed-beside-the-layout-that-builds-its-box.txt
@@ -0,0 +1 @@
+style has height: true
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/style-update-samples-where-script-observed-the-timeline.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/style-update-samples-where-script-observed-the-timeline.txt
new file mode 100644
index 00000000000..d6cba5df326
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/style-update-samples-where-script-observed-the-timeline.txt
@@ -0,0 +1,6 @@
+timeline ahead of the end of the transitions: true
+scroll width: true
+drawer: hidden
+list: hidden
+item: hidden
+link: hidden
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/table-moved-beside-the-layout-that-builds-its-box.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/table-moved-beside-the-layout-that-builds-its-box.txt
new file mode 100644
index 00000000000..9ab543d087e
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/table-moved-beside-the-layout-that-builds-its-box.txt
@@ -0,0 +1 @@
+source: 100x0
diff --git a/Tests/LibWeb/Text/expected/css/animation-pseudo-element-display-none-ancestor-toggle.txt b/Tests/LibWeb/Text/expected/css/animation-pseudo-element-display-none-ancestor-toggle.txt
new file mode 100644
index 00000000000..553dd5b971f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/animation-pseudo-element-display-none-ancestor-toggle.txt
@@ -0,0 +1,5 @@
+shown: 1
+hidden 1: 0
+revealed 1: 1
+hidden 2: 0
+revealed 2: 1
diff --git a/Tests/LibWeb/Text/expected/css/custom-property-animated-beneath-an-inherited-one-pseudo-element.txt b/Tests/LibWeb/Text/expected/css/custom-property-animated-beneath-an-inherited-one-pseudo-element.txt
new file mode 100644
index 00000000000..689c498e779
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/custom-property-animated-beneath-an-inherited-one-pseudo-element.txt
@@ -0,0 +1,4 @@
+10s: transform matrix(1, 0, 0, 1.12, 0, 0), custom properties give 1.120
+20s: transform matrix(1, 0, 0, 1.28, 0, 0), custom properties give 1.280
+30s: transform matrix(1, 0, 0, 1.48, 0, 0), custom properties give 1.480
+40s: transform matrix(1, 0, 0, 1.72, 0, 0), custom properties give 1.720
diff --git a/Tests/LibWeb/Text/expected/css/custom-property-animated-beneath-an-inherited-one.txt b/Tests/LibWeb/Text/expected/css/custom-property-animated-beneath-an-inherited-one.txt
new file mode 100644
index 00000000000..689c498e779
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/custom-property-animated-beneath-an-inherited-one.txt
@@ -0,0 +1,4 @@
+10s: transform matrix(1, 0, 0, 1.12, 0, 0), custom properties give 1.120
+20s: transform matrix(1, 0, 0, 1.28, 0, 0), custom properties give 1.280
+30s: transform matrix(1, 0, 0, 1.48, 0, 0), custom properties give 1.480
+40s: transform matrix(1, 0, 0, 1.72, 0, 0), custom properties give 1.720
diff --git a/Tests/LibWeb/Text/expected/css/custom-property-animation-feeding-itself.txt b/Tests/LibWeb/Text/expected/css/custom-property-animation-feeding-itself.txt
new file mode 100644
index 00000000000..2068ce0d9b0
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/custom-property-animation-feeding-itself.txt
@@ -0,0 +1,5 @@
+a cycle through a declaration: --animated "0px", --declared "", width 0px, child 0px
+after a write: --animated "0px", --declared "", width 0px, child 0px
+a cycle within keyframes: "" ""
+a cycle through a function ends: true
+no cycle: "5px" "5px"
diff --git a/Tests/LibWeb/Text/expected/css/custom-property-animation-removed-by-style.txt b/Tests/LibWeb/Text/expected/css/custom-property-animation-removed-by-style.txt
new file mode 100644
index 00000000000..4d36d047dea
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/custom-property-animation-removed-by-style.txt
@@ -0,0 +1,14 @@
+name running: 10px "10px", child 10px 10px, 1 animations
+value-with-name running: 10px "10px", child 10px 10px, 1 animations
+name-then-value running: 10px "10px", child 10px 10px, 1 animations
+declared running: 10px "10px", child 10px 10px, 1 animations
+class running: 10px "10px", child 10px 10px, 1 animations
+undisplayed running: 10px "10px", child 10px 10px, 1 animations
+undisplayed-with-value running: 10px "10px", child 10px 10px, 1 animations
+animation-name none: 0px "", child 0px 1px, 0 animations
+a declared value and animation-name none together: 5px "", child 5px 1px, 0 animations
+a declared value after animation-name none: 5px "", child 5px 1px, 0 animations
+canceled over declared values: 5px "6px", child 5px 6px, 0 animations
+class removed: 0px "", child 0px 1px, 0 animations
+display none: 0px "", child 0px 1px, 0 animations
+display none with a declared value: 5px "", child 5px 1px, 0 animations
diff --git a/Tests/LibWeb/Text/expected/css/custom-property-animation-setting-display.txt b/Tests/LibWeb/Text/expected/css/custom-property-animation-setting-display.txt
new file mode 100644
index 00000000000..06451906a4e
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/custom-property-animation-setting-display.txt
@@ -0,0 +1,6 @@
+rgb(0, 0, 0)
+rgb(0, 0, 0)
+rgb(0, 0, 0)
+rgb(0, 0, 0)
+rgb(0, 0, 0)
+rgb(0, 0, 0)
diff --git a/Tests/LibWeb/Text/expected/css/custom-property-animations-chain-read-first.txt b/Tests/LibWeb/Text/expected/css/custom-property-animations-chain-read-first.txt
new file mode 100644
index 00000000000..e7acc24fec7
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/custom-property-animations-chain-read-first.txt
@@ -0,0 +1,6 @@
+its custom property: 24px
+::first-line: 24px
+::marker: 24px
+::selection: 24px
+::placeholder: 24px
+::before: 24px
diff --git a/Tests/LibWeb/Text/expected/css/custom-property-animations-chain-read.txt b/Tests/LibWeb/Text/expected/css/custom-property-animations-chain-read.txt
new file mode 100644
index 00000000000..47d913f9406
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/custom-property-animations-chain-read.txt
@@ -0,0 +1,2 @@
+read of the element below a chain of 24: 24px
+read of its ::before: 24px
diff --git a/Tests/LibWeb/Text/expected/css/custom-property-declared-reading-animated-and-inherited.txt b/Tests/LibWeb/Text/expected/css/custom-property-declared-reading-animated-and-inherited.txt
new file mode 100644
index 00000000000..819be68dd82
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/custom-property-declared-reading-animated-and-inherited.txt
@@ -0,0 +1,8 @@
+10s, in the same task: --sum 0.12, transform matrix(1, 0, 0, 1.12, 0, 0), rotate 0.12deg, the custom properties give 0.12
+10s, after two frames: --sum 0.12, transform matrix(1, 0, 0, 1.12, 0, 0), rotate 0.12deg, the custom properties give 0.12
+20s, in the same task: --sum 0.28, transform matrix(1, 0, 0, 1.28, 0, 0), rotate 0.28deg, the custom properties give 0.28
+20s, after two frames: --sum 0.28, transform matrix(1, 0, 0, 1.28, 0, 0), rotate 0.28deg, the custom properties give 0.28
+30s, in the same task: --sum 0.48, transform matrix(1, 0, 0, 1.48, 0, 0), rotate 0.48deg, the custom properties give 0.48
+30s, after two frames: --sum 0.48, transform matrix(1, 0, 0, 1.48, 0, 0), rotate 0.48deg, the custom properties give 0.48
+40s, in the same task: --sum 0.72, transform matrix(1, 0, 0, 1.72, 0, 0), rotate 0.72deg, the custom properties give 0.72
+40s, after two frames: --sum 0.72, transform matrix(1, 0, 0, 1.72, 0, 0), rotate 0.72deg, the custom properties give 0.72
diff --git a/Tests/LibWeb/Text/expected/css/custom-property-on-root-reaches-children-after-animation-cancel.txt b/Tests/LibWeb/Text/expected/css/custom-property-on-root-reaches-children-after-animation-cancel.txt
new file mode 100644
index 00000000000..417aa40266c
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/custom-property-on-root-reaches-children-after-animation-cancel.txt
@@ -0,0 +1,3 @@
+root: 1
+body: 1
+target: 1
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/animated-element-pseudo-element-composition.txt b/Tests/LibWeb/Text/expected/css/style-engine/animated-element-pseudo-element-composition.txt
new file mode 100644
index 00000000000..c00c1d6d8ed
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/animated-element-pseudo-element-composition.txt
@@ -0,0 +1,2 @@
+style update pass guard hits: 0
+rgb(50, 0, 150) rgb(50, 0, 150) rgb(0, 128, 0)
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/animated-inherited-values-descendants-engine-computed.txt b/Tests/LibWeb/Text/expected/css/style-engine/animated-inherited-values-descendants.txt
similarity index 52%
rename from Tests/LibWeb/Text/expected/css/style-engine/animated-inherited-values-descendants-engine-computed.txt
rename to Tests/LibWeb/Text/expected/css/style-engine/animated-inherited-values-descendants.txt
index 24ffb36611a..bcc9c1f53c9 100644
--- a/Tests/LibWeb/Text/expected/css/style-engine/animated-inherited-values-descendants-engine-computed.txt
+++ b/Tests/LibWeb/Text/expected/css/style-engine/animated-inherited-values-descendants.txt
@@ -1,3 +1 @@
-engine records: 3
-C++ recomputations: 0
grandchild: width 30px, color rgb(0, 0, 100)
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.txt
new file mode 100644
index 00000000000..860b6d98cbe
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/hover-restyle-updates-box.txt
@@ -0,0 +1,5 @@
+initial: width=100px background=rgb(0, 128, 0) box.width=100
+hovered by the render clock: box width on screen=150
+cold passes since: 0
+hovered: width=150px background=rgb(255, 0, 0) box.width=150
+unhovered: width=100px background=rgb(0, 128, 0) box.width=100
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/pseudo-element-animated-custom-property-survives-reclamation.txt b/Tests/LibWeb/Text/expected/css/style-engine/pseudo-element-animated-custom-property-survives-reclamation.txt
new file mode 100644
index 00000000000..d34e5815c0f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/pseudo-element-animated-custom-property-survives-reclamation.txt
@@ -0,0 +1,2 @@
+before: 10deg
+seen: 10deg
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/restyle-animated-inheritance.txt b/Tests/LibWeb/Text/expected/css/style-engine/restyle-animated-inheritance.txt
new file mode 100644
index 00000000000..369d51cb7fe
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/restyle-animated-inheritance.txt
@@ -0,0 +1,7 @@
+child: rgb(25, 25, 25) 25px
+grandchild: rgb(25, 25, 25) 25px
+child after seeking: rgb(50, 50, 50) 50px
+grandchild after seeking: rgb(50, 50, 50) 50px
+inserted child: rgb(50, 50, 50) 50px
+child after cancelling: rgb(0, 0, 0) normal
+inserted child after cancelling: rgb(0, 0, 0) normal
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/restyle-css-animations.txt b/Tests/LibWeb/Text/expected/css/style-engine/restyle-css-animations.txt
new file mode 100644
index 00000000000..348a9b51965
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/restyle-css-animations.txt
@@ -0,0 +1,9 @@
+before: 10 10px
+started: CSSAnimation(grow)
+halfway: 150 150px
+renamed: CSSAnimation(shrink)
+renamed halfway: 30 30px
+removed: none
+removed: 10 10px
+shadow: CSSAnimation(grow)
+shadow halfway: 350 350px
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/restyle-pseudo-element-animations.txt b/Tests/LibWeb/Text/expected/css/style-engine/restyle-pseudo-element-animations.txt
new file mode 100644
index 00000000000..77edc5f29a7
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/restyle-pseudo-element-animations.txt
@@ -0,0 +1,5 @@
+initial: before color=rgb(0, 0, 0) first-letter --tone=rgb(1, 2, 3) selection --tone=rgb(4, 5, 6) animations=none
+animated halfway: before color=rgb(100, 0, 100) first-letter --tone=rgb(1, 2, 3) selection --tone=rgb(4, 5, 6) animations=CSSAnimation(::before)
+animation removed: before color=rgb(100, 0, 100) first-letter --tone=rgb(1, 2, 3) selection --tone=rgb(4, 5, 6) animations=CSSTransition(::before)
+transition halfway: before color=rgb(50, 100, 50) first-letter --tone=rgb(1, 2, 3) selection --tone=rgb(4, 5, 6) animations=CSSTransition(::before)
+retoned: before color=rgb(0, 200, 0) first-letter --tone=rgb(7, 8, 9) selection --tone=rgb(10, 11, 12) animations=none
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/restyle-transitions.txt b/Tests/LibWeb/Text/expected/css/style-engine/restyle-transitions.txt
new file mode 100644
index 00000000000..b94c044906f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/restyle-transitions.txt
@@ -0,0 +1,9 @@
+before: 100 100px
+started: CSSTransition(width)
+halfway: 150 150px
+still: none
+still: 200 200px
+narrowed: none
+narrowed: 100 100px
+started again: CSSTransition(width)
+a quarter of the way: 125 125px
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/restyle-web-animations.txt b/Tests/LibWeb/Text/expected/css/style-engine/restyle-web-animations.txt
new file mode 100644
index 00000000000..7f0316071ee
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/restyle-web-animations.txt
@@ -0,0 +1,3 @@
+animated: 150x10 150px
+restyled under the animation: 150x30 150px
+canceled: 10x30 10px
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/transition-beside-a-custom-property-set-to-initial.txt b/Tests/LibWeb/Text/expected/css/style-engine/transition-beside-a-custom-property-set-to-initial.txt
new file mode 100644
index 00000000000..c19b22d8179
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/transition-beside-a-custom-property-set-to-initial.txt
@@ -0,0 +1 @@
+The update settled with 1 transition running
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/transition-start-composition-survives-pseudo-element-restyle.txt b/Tests/LibWeb/Text/expected/css/style-engine/transition-start-composition-survives-pseudo-element-restyle.txt
new file mode 100644
index 00000000000..f42a93c6d01
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/transition-start-composition-survives-pseudo-element-restyle.txt
@@ -0,0 +1,4 @@
+target color starts the transition: rgb(0, 0, 0)
+child inherits the transition's start: rgb(0, 0, 0)
+::before inherits the transition's start: rgb(0, 0, 0)
+::before background starts its own transition: rgb(0, 0, 0)
diff --git a/Tests/LibWeb/Text/expected/css/transition-beside-a-registered-custom-property-settles.txt b/Tests/LibWeb/Text/expected/css/transition-beside-a-registered-custom-property-settles.txt
new file mode 100644
index 00000000000..c19b22d8179
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/transition-beside-a-registered-custom-property-settles.txt
@@ -0,0 +1 @@
+The update settled with 1 transition running
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-1.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-1.txt
index f2fbdca3617..b3efbde4cfb 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-1.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-1.txt
@@ -430,16 +430,16 @@ PRESERVED: display list-item -> table-cell in block flex | following sibling
PRESERVED: display list-item -> table-cell in block flex | following sibling descendant
STATS: display list-item -> table-cell in block flex | rebuilt subtree roots=1, escaped=false
PASS: display list-item -> table-cell in block flex | incremental tree matches full rebuild
-RECREATED: display list-item -> block flex in contents | fixture ancestor
-RECREATED: display list-item -> block flex in contents | distant sibling
-RECREATED: display list-item -> block flex in contents | distant sibling descendant
+PRESERVED: display list-item -> block flex in contents | fixture ancestor
+PRESERVED: display list-item -> block flex in contents | distant sibling
+PRESERVED: display list-item -> block flex in contents | distant sibling descendant
ABSENT: display list-item -> block flex in contents | DOM parent
-RECREATED: display list-item -> block flex in contents | preceding sibling
-RECREATED: display list-item -> block flex in contents | preceding sibling descendant
+PRESERVED: display list-item -> block flex in contents | preceding sibling
+PRESERVED: display list-item -> block flex in contents | preceding sibling descendant
RECREATED: display list-item -> block flex in contents | target
RECREATED: display list-item -> block flex in contents | target descendant
-RECREATED: display list-item -> block flex in contents | following sibling
-RECREATED: display list-item -> block flex in contents | following sibling descendant
+PRESERVED: display list-item -> block flex in contents | following sibling
+PRESERVED: display list-item -> block flex in contents | following sibling descendant
STATS: display list-item -> block flex in contents | rebuilt subtree roots=1, escaped=false
PASS: display list-item -> block flex in contents | incremental tree matches full rebuild
PRESERVED: display inline list-item -> none in flex | fixture ancestor
@@ -2014,16 +2014,16 @@ PRESERVED: display block flow list-item -> flow-root in flow-root | following si
PRESERVED: display block flow list-item -> flow-root in flow-root | following sibling descendant
STATS: display block flow list-item -> flow-root in flow-root | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> flow-root in flow-root | incremental tree matches full rebuild
-RECREATED: display block flow list-item -> inline-grid in inline-grid | fixture ancestor
-RECREATED: display block flow list-item -> inline-grid in inline-grid | distant sibling
-RECREATED: display block flow list-item -> inline-grid in inline-grid | distant sibling descendant
-RECREATED: display block flow list-item -> inline-grid in inline-grid | DOM parent
-RECREATED: display block flow list-item -> inline-grid in inline-grid | preceding sibling
-RECREATED: display block flow list-item -> inline-grid in inline-grid | preceding sibling descendant
+PRESERVED: display block flow list-item -> inline-grid in inline-grid | fixture ancestor
+PRESERVED: display block flow list-item -> inline-grid in inline-grid | distant sibling
+PRESERVED: display block flow list-item -> inline-grid in inline-grid | distant sibling descendant
+PRESERVED: display block flow list-item -> inline-grid in inline-grid | DOM parent
+PRESERVED: display block flow list-item -> inline-grid in inline-grid | preceding sibling
+PRESERVED: display block flow list-item -> inline-grid in inline-grid | preceding sibling descendant
RECREATED: display block flow list-item -> inline-grid in inline-grid | target
RECREATED: display block flow list-item -> inline-grid in inline-grid | target descendant
-RECREATED: display block flow list-item -> inline-grid in inline-grid | following sibling
-RECREATED: display block flow list-item -> inline-grid in inline-grid | following sibling descendant
+PRESERVED: display block flow list-item -> inline-grid in inline-grid | following sibling
+PRESERVED: display block flow list-item -> inline-grid in inline-grid | following sibling descendant
STATS: display block flow list-item -> inline-grid in inline-grid | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> inline-grid in inline-grid | incremental tree matches full rebuild
RECREATED: display block flow list-item -> table-footer-group in table-footer-group | fixture ancestor
@@ -2101,13 +2101,13 @@ PASS: display inline flow list-item -> table-column-group in table-column | incr
PRESERVED: display inline flow list-item -> inline flex in block grid | fixture ancestor
PRESERVED: display inline flow list-item -> inline flex in block grid | distant sibling
PRESERVED: display inline flow list-item -> inline flex in block grid | distant sibling descendant
-RECREATED: display inline flow list-item -> inline flex in block grid | DOM parent
-RECREATED: display inline flow list-item -> inline flex in block grid | preceding sibling
-RECREATED: display inline flow list-item -> inline flex in block grid | preceding sibling descendant
+PRESERVED: display inline flow list-item -> inline flex in block grid | DOM parent
+PRESERVED: display inline flow list-item -> inline flex in block grid | preceding sibling
+PRESERVED: display inline flow list-item -> inline flex in block grid | preceding sibling descendant
RECREATED: display inline flow list-item -> inline flex in block grid | target
RECREATED: display inline flow list-item -> inline flex in block grid | target descendant
-RECREATED: display inline flow list-item -> inline flex in block grid | following sibling
-RECREATED: display inline flow list-item -> inline flex in block grid | following sibling descendant
+PRESERVED: display inline flow list-item -> inline flex in block grid | following sibling
+PRESERVED: display inline flow list-item -> inline flex in block grid | following sibling descendant
STATS: display inline flow list-item -> inline flex in block grid | rebuilt subtree roots=1, escaped=false
PASS: display inline flow list-item -> inline flex in block grid | incremental tree matches full rebuild
176 cases; 176 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-2.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-2.txt
index 6c2c8fd712e..146e5ff3f2d 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-2.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-2.txt
@@ -2074,16 +2074,16 @@ PRESERVED: display inline flow list-item -> inline list-item in flex | following
PRESERVED: display inline flow list-item -> inline list-item in flex | following sibling descendant
STATS: display inline flow list-item -> inline list-item in flex | no layout tree build
PASS: display inline flow list-item -> inline list-item in flex | incremental tree matches full rebuild
-RECREATED: display inline flow list-item -> -webkit-box in -webkit-inline-box | fixture ancestor
-RECREATED: display inline flow list-item -> -webkit-box in -webkit-inline-box | distant sibling
-RECREATED: display inline flow list-item -> -webkit-box in -webkit-inline-box | distant sibling descendant
-RECREATED: display inline flow list-item -> -webkit-box in -webkit-inline-box | DOM parent
-RECREATED: display inline flow list-item -> -webkit-box in -webkit-inline-box | preceding sibling
-RECREATED: display inline flow list-item -> -webkit-box in -webkit-inline-box | preceding sibling descendant
+PRESERVED: display inline flow list-item -> -webkit-box in -webkit-inline-box | fixture ancestor
+PRESERVED: display inline flow list-item -> -webkit-box in -webkit-inline-box | distant sibling
+PRESERVED: display inline flow list-item -> -webkit-box in -webkit-inline-box | distant sibling descendant
+PRESERVED: display inline flow list-item -> -webkit-box in -webkit-inline-box | DOM parent
+PRESERVED: display inline flow list-item -> -webkit-box in -webkit-inline-box | preceding sibling
+PRESERVED: display inline flow list-item -> -webkit-box in -webkit-inline-box | preceding sibling descendant
RECREATED: display inline flow list-item -> -webkit-box in -webkit-inline-box | target
RECREATED: display inline flow list-item -> -webkit-box in -webkit-inline-box | target descendant
-RECREATED: display inline flow list-item -> -webkit-box in -webkit-inline-box | following sibling
-RECREATED: display inline flow list-item -> -webkit-box in -webkit-inline-box | following sibling descendant
+PRESERVED: display inline flow list-item -> -webkit-box in -webkit-inline-box | following sibling
+PRESERVED: display inline flow list-item -> -webkit-box in -webkit-inline-box | following sibling descendant
STATS: display inline flow list-item -> -webkit-box in -webkit-inline-box | rebuilt subtree roots=1, escaped=false
PASS: display inline flow list-item -> -webkit-box in -webkit-inline-box | incremental tree matches full rebuild
RECREATED: display inline flow list-item -> table-column in table-caption | fixture ancestor
@@ -2098,16 +2098,16 @@ RECREATED: display inline flow list-item -> table-column in table-caption | foll
RECREATED: display inline flow list-item -> table-column in table-caption | following sibling descendant
STATS: display inline flow list-item -> table-column in table-caption | rebuilt subtree roots=1, escaped=false
PASS: display inline flow list-item -> table-column in table-caption | incremental tree matches full rebuild
-RECREATED: display inline flow list-item -> block grid in inline grid | fixture ancestor
-RECREATED: display inline flow list-item -> block grid in inline grid | distant sibling
-RECREATED: display inline flow list-item -> block grid in inline grid | distant sibling descendant
-RECREATED: display inline flow list-item -> block grid in inline grid | DOM parent
-RECREATED: display inline flow list-item -> block grid in inline grid | preceding sibling
-RECREATED: display inline flow list-item -> block grid in inline grid | preceding sibling descendant
+PRESERVED: display inline flow list-item -> block grid in inline grid | fixture ancestor
+PRESERVED: display inline flow list-item -> block grid in inline grid | distant sibling
+PRESERVED: display inline flow list-item -> block grid in inline grid | distant sibling descendant
+PRESERVED: display inline flow list-item -> block grid in inline grid | DOM parent
+PRESERVED: display inline flow list-item -> block grid in inline grid | preceding sibling
+PRESERVED: display inline flow list-item -> block grid in inline grid | preceding sibling descendant
RECREATED: display inline flow list-item -> block grid in inline grid | target
RECREATED: display inline flow list-item -> block grid in inline grid | target descendant
-RECREATED: display inline flow list-item -> block grid in inline grid | following sibling
-RECREATED: display inline flow list-item -> block grid in inline grid | following sibling descendant
+PRESERVED: display inline flow list-item -> block grid in inline grid | following sibling
+PRESERVED: display inline flow list-item -> block grid in inline grid | following sibling descendant
STATS: display inline flow list-item -> block grid in inline grid | rebuilt subtree roots=1, escaped=false
PASS: display inline flow list-item -> block grid in inline grid | incremental tree matches full rebuild
176 cases; 176 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-3.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-3.txt
index 8e0869e06d1..ee1f7a4292e 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-3.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-3.txt
@@ -406,17 +406,17 @@ PRESERVED: display list-item -> inline list-item in -webkit-box | following sibl
PRESERVED: display list-item -> inline list-item in -webkit-box | following sibling descendant
STATS: display list-item -> inline list-item in -webkit-box | no layout tree build
PASS: display list-item -> inline list-item in -webkit-box | incremental tree matches full rebuild
-RECREATED: display list-item -> -webkit-box in table-column | fixture ancestor
-RECREATED: display list-item -> -webkit-box in table-column | distant sibling
-RECREATED: display list-item -> -webkit-box in table-column | distant sibling descendant
-RECREATED: display list-item -> -webkit-box in table-column | DOM parent
+PRESERVED: display list-item -> -webkit-box in table-column | fixture ancestor
+PRESERVED: display list-item -> -webkit-box in table-column | distant sibling
+PRESERVED: display list-item -> -webkit-box in table-column | distant sibling descendant
+PRESERVED: display list-item -> -webkit-box in table-column | DOM parent
ABSENT: display list-item -> -webkit-box in table-column | preceding sibling
ABSENT: display list-item -> -webkit-box in table-column | preceding sibling descendant
ABSENT: display list-item -> -webkit-box in table-column | target
ABSENT: display list-item -> -webkit-box in table-column | target descendant
ABSENT: display list-item -> -webkit-box in table-column | following sibling
ABSENT: display list-item -> -webkit-box in table-column | following sibling descendant
-STATS: display list-item -> -webkit-box in table-column | rebuilt subtree roots=1, escaped=false
+STATS: display list-item -> -webkit-box in table-column | rebuilt subtree roots=0, escaped=true
PASS: display list-item -> -webkit-box in table-column | incremental tree matches full rebuild
PRESERVED: display list-item -> table-column in block grid | fixture ancestor
PRESERVED: display list-item -> table-column in block grid | distant sibling
@@ -430,16 +430,16 @@ PRESERVED: display list-item -> table-column in block grid | following sibling
PRESERVED: display list-item -> table-column in block grid | following sibling descendant
STATS: display list-item -> table-column in block grid | rebuilt subtree roots=1, escaped=false
PASS: display list-item -> table-column in block grid | incremental tree matches full rebuild
-RECREATED: display list-item -> block grid in inline | fixture ancestor
-RECREATED: display list-item -> block grid in inline | distant sibling
-RECREATED: display list-item -> block grid in inline | distant sibling descendant
-RECREATED: display list-item -> block grid in inline | DOM parent
-RECREATED: display list-item -> block grid in inline | preceding sibling
-RECREATED: display list-item -> block grid in inline | preceding sibling descendant
+PRESERVED: display list-item -> block grid in inline | fixture ancestor
+PRESERVED: display list-item -> block grid in inline | distant sibling
+PRESERVED: display list-item -> block grid in inline | distant sibling descendant
+PRESERVED: display list-item -> block grid in inline | DOM parent
+PRESERVED: display list-item -> block grid in inline | preceding sibling
+PRESERVED: display list-item -> block grid in inline | preceding sibling descendant
RECREATED: display list-item -> block grid in inline | target
RECREATED: display list-item -> block grid in inline | target descendant
-RECREATED: display list-item -> block grid in inline | following sibling
-RECREATED: display list-item -> block grid in inline | following sibling descendant
+PRESERVED: display list-item -> block grid in inline | following sibling
+PRESERVED: display list-item -> block grid in inline | following sibling descendant
STATS: display list-item -> block grid in inline | rebuilt subtree roots=1, escaped=false
PASS: display list-item -> block grid in inline | incremental tree matches full rebuild
PRESERVED: display inline list-item -> block in grid | fixture ancestor
@@ -2041,13 +2041,13 @@ PASS: display block flow list-item -> table-cell in table-cell | incremental tre
PRESERVED: display block flow list-item -> block flex in block flex | fixture ancestor
PRESERVED: display block flow list-item -> block flex in block flex | distant sibling
PRESERVED: display block flow list-item -> block flex in block flex | distant sibling descendant
-RECREATED: display block flow list-item -> block flex in block flex | DOM parent
-RECREATED: display block flow list-item -> block flex in block flex | preceding sibling
-RECREATED: display block flow list-item -> block flex in block flex | preceding sibling descendant
+PRESERVED: display block flow list-item -> block flex in block flex | DOM parent
+PRESERVED: display block flow list-item -> block flex in block flex | preceding sibling
+PRESERVED: display block flow list-item -> block flex in block flex | preceding sibling descendant
RECREATED: display block flow list-item -> block flex in block flex | target
RECREATED: display block flow list-item -> block flex in block flex | target descendant
-RECREATED: display block flow list-item -> block flex in block flex | following sibling
-RECREATED: display block flow list-item -> block flex in block flex | following sibling descendant
+PRESERVED: display block flow list-item -> block flex in block flex | following sibling
+PRESERVED: display block flow list-item -> block flex in block flex | following sibling descendant
STATS: display block flow list-item -> block flex in block flex | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> block flex in block flex | incremental tree matches full rebuild
PRESERVED: display inline flow list-item -> contents in block | fixture ancestor
@@ -2062,16 +2062,16 @@ RECREATED: display inline flow list-item -> contents in block | following siblin
RECREATED: display inline flow list-item -> contents in block | following sibling descendant
STATS: display inline flow list-item -> contents in block | rebuilt subtree roots=1, escaped=false
PASS: display inline flow list-item -> contents in block | incremental tree matches full rebuild
-RECREATED: display inline flow list-item -> flex in inline-flex | fixture ancestor
-RECREATED: display inline flow list-item -> flex in inline-flex | distant sibling
-RECREATED: display inline flow list-item -> flex in inline-flex | distant sibling descendant
-RECREATED: display inline flow list-item -> flex in inline-flex | DOM parent
-RECREATED: display inline flow list-item -> flex in inline-flex | preceding sibling
-RECREATED: display inline flow list-item -> flex in inline-flex | preceding sibling descendant
+PRESERVED: display inline flow list-item -> flex in inline-flex | fixture ancestor
+PRESERVED: display inline flow list-item -> flex in inline-flex | distant sibling
+PRESERVED: display inline flow list-item -> flex in inline-flex | distant sibling descendant
+PRESERVED: display inline flow list-item -> flex in inline-flex | DOM parent
+PRESERVED: display inline flow list-item -> flex in inline-flex | preceding sibling
+PRESERVED: display inline flow list-item -> flex in inline-flex | preceding sibling descendant
RECREATED: display inline flow list-item -> flex in inline-flex | target
RECREATED: display inline flow list-item -> flex in inline-flex | target descendant
-RECREATED: display inline flow list-item -> flex in inline-flex | following sibling
-RECREATED: display inline flow list-item -> flex in inline-flex | following sibling descendant
+PRESERVED: display inline flow list-item -> flex in inline-flex | following sibling
+PRESERVED: display inline flow list-item -> flex in inline-flex | following sibling descendant
STATS: display inline flow list-item -> flex in inline-flex | rebuilt subtree roots=1, escaped=false
PASS: display inline flow list-item -> flex in inline-flex | incremental tree matches full rebuild
RECREATED: display inline flow list-item -> -webkit-inline-box in table-row-group | fixture ancestor
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-4.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-4.txt
index fb1b63329cf..c17f9dacd67 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-4.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-4.txt
@@ -394,16 +394,16 @@ PRESERVED: display list-item -> none in inline list-item | following sibling
PRESERVED: display list-item -> none in inline list-item | following sibling descendant
STATS: display list-item -> none in inline list-item | rebuilt subtree roots=0, escaped=false
PASS: display list-item -> none in inline list-item | incremental tree matches full rebuild
-RECREATED: display list-item -> flex in -webkit-inline-box | fixture ancestor
-RECREATED: display list-item -> flex in -webkit-inline-box | distant sibling
-RECREATED: display list-item -> flex in -webkit-inline-box | distant sibling descendant
-RECREATED: display list-item -> flex in -webkit-inline-box | DOM parent
-RECREATED: display list-item -> flex in -webkit-inline-box | preceding sibling
-RECREATED: display list-item -> flex in -webkit-inline-box | preceding sibling descendant
+PRESERVED: display list-item -> flex in -webkit-inline-box | fixture ancestor
+PRESERVED: display list-item -> flex in -webkit-inline-box | distant sibling
+PRESERVED: display list-item -> flex in -webkit-inline-box | distant sibling descendant
+PRESERVED: display list-item -> flex in -webkit-inline-box | DOM parent
+PRESERVED: display list-item -> flex in -webkit-inline-box | preceding sibling
+PRESERVED: display list-item -> flex in -webkit-inline-box | preceding sibling descendant
RECREATED: display list-item -> flex in -webkit-inline-box | target
RECREATED: display list-item -> flex in -webkit-inline-box | target descendant
-RECREATED: display list-item -> flex in -webkit-inline-box | following sibling
-RECREATED: display list-item -> flex in -webkit-inline-box | following sibling descendant
+PRESERVED: display list-item -> flex in -webkit-inline-box | following sibling
+PRESERVED: display list-item -> flex in -webkit-inline-box | following sibling descendant
STATS: display list-item -> flex in -webkit-inline-box | rebuilt subtree roots=1, escaped=false
PASS: display list-item -> flex in -webkit-inline-box | incremental tree matches full rebuild
RECREATED: display list-item -> -webkit-inline-box in table-caption | fixture ancestor
@@ -2038,16 +2038,16 @@ ABSENT: display block flow list-item -> table-column-group in table-column-group
ABSENT: display block flow list-item -> table-column-group in table-column-group | following sibling descendant
STATS: display block flow list-item -> table-column-group in table-column-group | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> table-column-group in table-column-group | incremental tree matches full rebuild
-RECREATED: display block flow list-item -> inline flex in inline flex | fixture ancestor
-RECREATED: display block flow list-item -> inline flex in inline flex | distant sibling
-RECREATED: display block flow list-item -> inline flex in inline flex | distant sibling descendant
-RECREATED: display block flow list-item -> inline flex in inline flex | DOM parent
-RECREATED: display block flow list-item -> inline flex in inline flex | preceding sibling
-RECREATED: display block flow list-item -> inline flex in inline flex | preceding sibling descendant
+PRESERVED: display block flow list-item -> inline flex in inline flex | fixture ancestor
+PRESERVED: display block flow list-item -> inline flex in inline flex | distant sibling
+PRESERVED: display block flow list-item -> inline flex in inline flex | distant sibling descendant
+PRESERVED: display block flow list-item -> inline flex in inline flex | DOM parent
+PRESERVED: display block flow list-item -> inline flex in inline flex | preceding sibling
+PRESERVED: display block flow list-item -> inline flex in inline flex | preceding sibling descendant
RECREATED: display block flow list-item -> inline flex in inline flex | target
RECREATED: display block flow list-item -> inline flex in inline flex | target descendant
-RECREATED: display block flow list-item -> inline flex in inline flex | following sibling
-RECREATED: display block flow list-item -> inline flex in inline flex | following sibling descendant
+PRESERVED: display block flow list-item -> inline flex in inline flex | following sibling
+PRESERVED: display block flow list-item -> inline flex in inline flex | following sibling descendant
STATS: display block flow list-item -> inline flex in inline flex | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> inline flex in inline flex | incremental tree matches full rebuild
RECREATED: display inline flow list-item -> block in inline | fixture ancestor
@@ -2065,13 +2065,13 @@ PASS: display inline flow list-item -> block in inline | incremental tree matche
PRESERVED: display inline flow list-item -> inline-flex in grid | fixture ancestor
PRESERVED: display inline flow list-item -> inline-flex in grid | distant sibling
PRESERVED: display inline flow list-item -> inline-flex in grid | distant sibling descendant
-RECREATED: display inline flow list-item -> inline-flex in grid | DOM parent
-RECREATED: display inline flow list-item -> inline-flex in grid | preceding sibling
-RECREATED: display inline flow list-item -> inline-flex in grid | preceding sibling descendant
+PRESERVED: display inline flow list-item -> inline-flex in grid | DOM parent
+PRESERVED: display inline flow list-item -> inline-flex in grid | preceding sibling
+PRESERVED: display inline flow list-item -> inline-flex in grid | preceding sibling descendant
RECREATED: display inline flow list-item -> inline-flex in grid | target
RECREATED: display inline flow list-item -> inline-flex in grid | target descendant
-RECREATED: display inline flow list-item -> inline-flex in grid | following sibling
-RECREATED: display inline flow list-item -> inline-flex in grid | following sibling descendant
+PRESERVED: display inline flow list-item -> inline-flex in grid | following sibling
+PRESERVED: display inline flow list-item -> inline-flex in grid | following sibling descendant
STATS: display inline flow list-item -> inline-flex in grid | rebuilt subtree roots=1, escaped=false
PASS: display inline flow list-item -> inline-flex in grid | incremental tree matches full rebuild
RECREATED: display inline flow list-item -> table-row-group in table-header-group | fixture ancestor
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-5.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-5.txt
index 941e44c756a..76c6a563379 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-5.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-5.txt
@@ -2017,13 +2017,13 @@ PASS: display block flow list-item -> inline list-item in inline list-item | inc
PRESERVED: display block flow list-item -> -webkit-box in -webkit-box | fixture ancestor
PRESERVED: display block flow list-item -> -webkit-box in -webkit-box | distant sibling
PRESERVED: display block flow list-item -> -webkit-box in -webkit-box | distant sibling descendant
-RECREATED: display block flow list-item -> -webkit-box in -webkit-box | DOM parent
-RECREATED: display block flow list-item -> -webkit-box in -webkit-box | preceding sibling
-RECREATED: display block flow list-item -> -webkit-box in -webkit-box | preceding sibling descendant
+PRESERVED: display block flow list-item -> -webkit-box in -webkit-box | DOM parent
+PRESERVED: display block flow list-item -> -webkit-box in -webkit-box | preceding sibling
+PRESERVED: display block flow list-item -> -webkit-box in -webkit-box | preceding sibling descendant
RECREATED: display block flow list-item -> -webkit-box in -webkit-box | target
RECREATED: display block flow list-item -> -webkit-box in -webkit-box | target descendant
-RECREATED: display block flow list-item -> -webkit-box in -webkit-box | following sibling
-RECREATED: display block flow list-item -> -webkit-box in -webkit-box | following sibling descendant
+PRESERVED: display block flow list-item -> -webkit-box in -webkit-box | following sibling
+PRESERVED: display block flow list-item -> -webkit-box in -webkit-box | following sibling descendant
STATS: display block flow list-item -> -webkit-box in -webkit-box | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> -webkit-box in -webkit-box | incremental tree matches full rebuild
RECREATED: display block flow list-item -> table-column in table-column | fixture ancestor
@@ -2041,13 +2041,13 @@ PASS: display block flow list-item -> table-column in table-column | incremental
PRESERVED: display block flow list-item -> block grid in block grid | fixture ancestor
PRESERVED: display block flow list-item -> block grid in block grid | distant sibling
PRESERVED: display block flow list-item -> block grid in block grid | distant sibling descendant
-RECREATED: display block flow list-item -> block grid in block grid | DOM parent
-RECREATED: display block flow list-item -> block grid in block grid | preceding sibling
-RECREATED: display block flow list-item -> block grid in block grid | preceding sibling descendant
+PRESERVED: display block flow list-item -> block grid in block grid | DOM parent
+PRESERVED: display block flow list-item -> block grid in block grid | preceding sibling
+PRESERVED: display block flow list-item -> block grid in block grid | preceding sibling descendant
RECREATED: display block flow list-item -> block grid in block grid | target
RECREATED: display block flow list-item -> block grid in block grid | target descendant
-RECREATED: display block flow list-item -> block grid in block grid | following sibling
-RECREATED: display block flow list-item -> block grid in block grid | following sibling descendant
+PRESERVED: display block flow list-item -> block grid in block grid | following sibling
+PRESERVED: display block flow list-item -> block grid in block grid | following sibling descendant
STATS: display block flow list-item -> block grid in block grid | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> block grid in block grid | incremental tree matches full rebuild
PRESERVED: display inline flow list-item -> inline in flow-root | fixture ancestor
@@ -2062,16 +2062,16 @@ RECREATED: display inline flow list-item -> inline in flow-root | following sibl
RECREATED: display inline flow list-item -> inline in flow-root | following sibling descendant
STATS: display inline flow list-item -> inline in flow-root | rebuilt subtree roots=1, escaped=false
PASS: display inline flow list-item -> inline in flow-root | incremental tree matches full rebuild
-RECREATED: display inline flow list-item -> grid in inline-grid | fixture ancestor
-RECREATED: display inline flow list-item -> grid in inline-grid | distant sibling
-RECREATED: display inline flow list-item -> grid in inline-grid | distant sibling descendant
-RECREATED: display inline flow list-item -> grid in inline-grid | DOM parent
-RECREATED: display inline flow list-item -> grid in inline-grid | preceding sibling
-RECREATED: display inline flow list-item -> grid in inline-grid | preceding sibling descendant
+PRESERVED: display inline flow list-item -> grid in inline-grid | fixture ancestor
+PRESERVED: display inline flow list-item -> grid in inline-grid | distant sibling
+PRESERVED: display inline flow list-item -> grid in inline-grid | distant sibling descendant
+PRESERVED: display inline flow list-item -> grid in inline-grid | DOM parent
+PRESERVED: display inline flow list-item -> grid in inline-grid | preceding sibling
+PRESERVED: display inline flow list-item -> grid in inline-grid | preceding sibling descendant
RECREATED: display inline flow list-item -> grid in inline-grid | target
RECREATED: display inline flow list-item -> grid in inline-grid | target descendant
-RECREATED: display inline flow list-item -> grid in inline-grid | following sibling
-RECREATED: display inline flow list-item -> grid in inline-grid | following sibling descendant
+PRESERVED: display inline flow list-item -> grid in inline-grid | following sibling
+PRESERVED: display inline flow list-item -> grid in inline-grid | following sibling descendant
STATS: display inline flow list-item -> grid in inline-grid | rebuilt subtree roots=1, escaped=false
PASS: display inline flow list-item -> grid in inline-grid | incremental tree matches full rebuild
RECREATED: display inline flow list-item -> table-header-group in table-footer-group | fixture ancestor
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-6.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-6.txt
index 5a7f69b95a2..3a5a1e66257 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-6.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-6.txt
@@ -2005,25 +2005,25 @@ PASS: display block flow list-item -> contents in contents | incremental tree ma
PRESERVED: display block flow list-item -> flex in flex | fixture ancestor
PRESERVED: display block flow list-item -> flex in flex | distant sibling
PRESERVED: display block flow list-item -> flex in flex | distant sibling descendant
-RECREATED: display block flow list-item -> flex in flex | DOM parent
-RECREATED: display block flow list-item -> flex in flex | preceding sibling
-RECREATED: display block flow list-item -> flex in flex | preceding sibling descendant
+PRESERVED: display block flow list-item -> flex in flex | DOM parent
+PRESERVED: display block flow list-item -> flex in flex | preceding sibling
+PRESERVED: display block flow list-item -> flex in flex | preceding sibling descendant
RECREATED: display block flow list-item -> flex in flex | target
RECREATED: display block flow list-item -> flex in flex | target descendant
-RECREATED: display block flow list-item -> flex in flex | following sibling
-RECREATED: display block flow list-item -> flex in flex | following sibling descendant
+PRESERVED: display block flow list-item -> flex in flex | following sibling
+PRESERVED: display block flow list-item -> flex in flex | following sibling descendant
STATS: display block flow list-item -> flex in flex | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> flex in flex | incremental tree matches full rebuild
-RECREATED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | fixture ancestor
-RECREATED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | distant sibling
-RECREATED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | distant sibling descendant
-RECREATED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | DOM parent
-RECREATED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | preceding sibling
-RECREATED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | preceding sibling descendant
+PRESERVED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | fixture ancestor
+PRESERVED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | distant sibling
+PRESERVED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | distant sibling descendant
+PRESERVED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | DOM parent
+PRESERVED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | preceding sibling
+PRESERVED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | preceding sibling descendant
RECREATED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | target
RECREATED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | target descendant
-RECREATED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | following sibling
-RECREATED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | following sibling descendant
+PRESERVED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | following sibling
+PRESERVED: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | following sibling descendant
STATS: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> -webkit-inline-box in -webkit-inline-box | incremental tree matches full rebuild
RECREATED: display block flow list-item -> table-caption in table-caption | fixture ancestor
@@ -2038,16 +2038,16 @@ RECREATED: display block flow list-item -> table-caption in table-caption | foll
RECREATED: display block flow list-item -> table-caption in table-caption | following sibling descendant
STATS: display block flow list-item -> table-caption in table-caption | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> table-caption in table-caption | incremental tree matches full rebuild
-RECREATED: display block flow list-item -> inline grid in inline grid | fixture ancestor
-RECREATED: display block flow list-item -> inline grid in inline grid | distant sibling
-RECREATED: display block flow list-item -> inline grid in inline grid | distant sibling descendant
-RECREATED: display block flow list-item -> inline grid in inline grid | DOM parent
-RECREATED: display block flow list-item -> inline grid in inline grid | preceding sibling
-RECREATED: display block flow list-item -> inline grid in inline grid | preceding sibling descendant
+PRESERVED: display block flow list-item -> inline grid in inline grid | fixture ancestor
+PRESERVED: display block flow list-item -> inline grid in inline grid | distant sibling
+PRESERVED: display block flow list-item -> inline grid in inline grid | distant sibling descendant
+PRESERVED: display block flow list-item -> inline grid in inline grid | DOM parent
+PRESERVED: display block flow list-item -> inline grid in inline grid | preceding sibling
+PRESERVED: display block flow list-item -> inline grid in inline grid | preceding sibling descendant
RECREATED: display block flow list-item -> inline grid in inline grid | target
RECREATED: display block flow list-item -> inline grid in inline grid | target descendant
-RECREATED: display block flow list-item -> inline grid in inline grid | following sibling
-RECREATED: display block flow list-item -> inline grid in inline grid | following sibling descendant
+PRESERVED: display block flow list-item -> inline grid in inline grid | following sibling
+PRESERVED: display block flow list-item -> inline grid in inline grid | following sibling descendant
STATS: display block flow list-item -> inline grid in inline grid | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> inline grid in inline grid | incremental tree matches full rebuild
RECREATED: display inline flow list-item -> flow-root in inline-block | fixture ancestor
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-7.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-7.txt
index 96ea761f336..797c6d21424 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-7.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-7.txt
@@ -478,16 +478,16 @@ RECREATED: display inline list-item -> table-column-group in block grid | follow
RECREATED: display inline list-item -> table-column-group in block grid | following sibling descendant
STATS: display inline list-item -> table-column-group in block grid | rebuilt subtree roots=1, escaped=false
PASS: display inline list-item -> table-column-group in block grid | incremental tree matches full rebuild
-RECREATED: display inline list-item -> inline flex in inline | fixture ancestor
-RECREATED: display inline list-item -> inline flex in inline | distant sibling
-RECREATED: display inline list-item -> inline flex in inline | distant sibling descendant
-RECREATED: display inline list-item -> inline flex in inline | DOM parent
-RECREATED: display inline list-item -> inline flex in inline | preceding sibling
-RECREATED: display inline list-item -> inline flex in inline | preceding sibling descendant
+PRESERVED: display inline list-item -> inline flex in inline | fixture ancestor
+PRESERVED: display inline list-item -> inline flex in inline | distant sibling
+PRESERVED: display inline list-item -> inline flex in inline | distant sibling descendant
+PRESERVED: display inline list-item -> inline flex in inline | DOM parent
+PRESERVED: display inline list-item -> inline flex in inline | preceding sibling
+PRESERVED: display inline list-item -> inline flex in inline | preceding sibling descendant
RECREATED: display inline list-item -> inline flex in inline | target
RECREATED: display inline list-item -> inline flex in inline | target descendant
-RECREATED: display inline list-item -> inline flex in inline | following sibling
-RECREATED: display inline list-item -> inline flex in inline | following sibling descendant
+PRESERVED: display inline list-item -> inline flex in inline | following sibling
+PRESERVED: display inline list-item -> inline flex in inline | following sibling descendant
STATS: display inline list-item -> inline flex in inline | rebuilt subtree roots=1, escaped=false
PASS: display inline list-item -> inline flex in inline | incremental tree matches full rebuild
PRESERVED: display flex -> contents in grid | fixture ancestor
@@ -2002,16 +2002,16 @@ PRESERVED: display block flow list-item -> block in block | following sibling
PRESERVED: display block flow list-item -> block in block | following sibling descendant
STATS: display block flow list-item -> block in block | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> block in block | incremental tree matches full rebuild
-RECREATED: display block flow list-item -> inline-flex in inline-flex | fixture ancestor
-RECREATED: display block flow list-item -> inline-flex in inline-flex | distant sibling
-RECREATED: display block flow list-item -> inline-flex in inline-flex | distant sibling descendant
-RECREATED: display block flow list-item -> inline-flex in inline-flex | DOM parent
-RECREATED: display block flow list-item -> inline-flex in inline-flex | preceding sibling
-RECREATED: display block flow list-item -> inline-flex in inline-flex | preceding sibling descendant
+PRESERVED: display block flow list-item -> inline-flex in inline-flex | fixture ancestor
+PRESERVED: display block flow list-item -> inline-flex in inline-flex | distant sibling
+PRESERVED: display block flow list-item -> inline-flex in inline-flex | distant sibling descendant
+PRESERVED: display block flow list-item -> inline-flex in inline-flex | DOM parent
+PRESERVED: display block flow list-item -> inline-flex in inline-flex | preceding sibling
+PRESERVED: display block flow list-item -> inline-flex in inline-flex | preceding sibling descendant
RECREATED: display block flow list-item -> inline-flex in inline-flex | target
RECREATED: display block flow list-item -> inline-flex in inline-flex | target descendant
-RECREATED: display block flow list-item -> inline-flex in inline-flex | following sibling
-RECREATED: display block flow list-item -> inline-flex in inline-flex | following sibling descendant
+PRESERVED: display block flow list-item -> inline-flex in inline-flex | following sibling
+PRESERVED: display block flow list-item -> inline-flex in inline-flex | following sibling descendant
STATS: display block flow list-item -> inline-flex in inline-flex | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> inline-flex in inline-flex | incremental tree matches full rebuild
RECREATED: display block flow list-item -> table-row-group in table-row-group | fixture ancestor
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-8.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-8.txt
index 75581067c62..8fd01ea7465 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-8.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-display-8.txt
@@ -2005,13 +2005,13 @@ PASS: display block flow list-item -> inline in inline | incremental tree matche
PRESERVED: display block flow list-item -> grid in grid | fixture ancestor
PRESERVED: display block flow list-item -> grid in grid | distant sibling
PRESERVED: display block flow list-item -> grid in grid | distant sibling descendant
-RECREATED: display block flow list-item -> grid in grid | DOM parent
-RECREATED: display block flow list-item -> grid in grid | preceding sibling
-RECREATED: display block flow list-item -> grid in grid | preceding sibling descendant
+PRESERVED: display block flow list-item -> grid in grid | DOM parent
+PRESERVED: display block flow list-item -> grid in grid | preceding sibling
+PRESERVED: display block flow list-item -> grid in grid | preceding sibling descendant
RECREATED: display block flow list-item -> grid in grid | target
RECREATED: display block flow list-item -> grid in grid | target descendant
-RECREATED: display block flow list-item -> grid in grid | following sibling
-RECREATED: display block flow list-item -> grid in grid | following sibling descendant
+PRESERVED: display block flow list-item -> grid in grid | following sibling
+PRESERVED: display block flow list-item -> grid in grid | following sibling descendant
STATS: display block flow list-item -> grid in grid | rebuilt subtree roots=1, escaped=false
PASS: display block flow list-item -> grid in grid | incremental tree matches full rebuild
RECREATED: display block flow list-item -> table-header-group in table-header-group | fixture ancestor
@@ -2086,16 +2086,16 @@ ABSENT: display inline flow list-item -> table-cell in table-column-group | foll
ABSENT: display inline flow list-item -> table-cell in table-column-group | following sibling descendant
STATS: display inline flow list-item -> table-cell in table-column-group | rebuilt subtree roots=1, escaped=false
PASS: display inline flow list-item -> table-cell in table-column-group | incremental tree matches full rebuild
-RECREATED: display inline flow list-item -> block flex in inline flex | fixture ancestor
-RECREATED: display inline flow list-item -> block flex in inline flex | distant sibling
-RECREATED: display inline flow list-item -> block flex in inline flex | distant sibling descendant
-RECREATED: display inline flow list-item -> block flex in inline flex | DOM parent
-RECREATED: display inline flow list-item -> block flex in inline flex | preceding sibling
-RECREATED: display inline flow list-item -> block flex in inline flex | preceding sibling descendant
+PRESERVED: display inline flow list-item -> block flex in inline flex | fixture ancestor
+PRESERVED: display inline flow list-item -> block flex in inline flex | distant sibling
+PRESERVED: display inline flow list-item -> block flex in inline flex | distant sibling descendant
+PRESERVED: display inline flow list-item -> block flex in inline flex | DOM parent
+PRESERVED: display inline flow list-item -> block flex in inline flex | preceding sibling
+PRESERVED: display inline flow list-item -> block flex in inline flex | preceding sibling descendant
RECREATED: display inline flow list-item -> block flex in inline flex | target
RECREATED: display inline flow list-item -> block flex in inline flex | target descendant
-RECREATED: display inline flow list-item -> block flex in inline flex | following sibling
-RECREATED: display inline flow list-item -> block flex in inline flex | following sibling descendant
+PRESERVED: display inline flow list-item -> block flex in inline flex | following sibling
+PRESERVED: display inline flow list-item -> block flex in inline flex | following sibling descendant
STATS: display inline flow list-item -> block flex in inline flex | rebuilt subtree roots=1, escaped=false
PASS: display inline flow list-item -> block flex in inline flex | incremental tree matches full rebuild
175 cases; 175 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-1.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-1.txt
index aad008ecf4a..2dedac8d049 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-1.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-1.txt
@@ -432,14 +432,14 @@ STATS: slot fallback child display list-item -> table-cell | rebuilt subtree roo
PASS: slot fallback child display list-item -> table-cell | incremental tree matches full rebuild
PRESERVED: assigned slottable display list-item -> block flex | fixture ancestor
PRESERVED: assigned slottable display list-item -> block flex | distant sibling
-RECREATED: assigned slottable display list-item -> block flex | shadow host
-RECREATED: assigned slottable display list-item -> block flex | shadow container
-RECREATED: assigned slottable display list-item -> block flex | preceding flat-tree sibling
-RECREATED: assigned slottable display list-item -> block flex | preceding sibling descendant
+PRESERVED: assigned slottable display list-item -> block flex | shadow host
+PRESERVED: assigned slottable display list-item -> block flex | shadow container
+PRESERVED: assigned slottable display list-item -> block flex | preceding flat-tree sibling
+PRESERVED: assigned slottable display list-item -> block flex | preceding sibling descendant
RECREATED: assigned slottable display list-item -> block flex | target
RECREATED: assigned slottable display list-item -> block flex | target descendant
-RECREATED: assigned slottable display list-item -> block flex | following flat-tree sibling
-RECREATED: assigned slottable display list-item -> block flex | following sibling descendant
+PRESERVED: assigned slottable display list-item -> block flex | following flat-tree sibling
+PRESERVED: assigned slottable display list-item -> block flex | following sibling descendant
STATS: assigned slottable display list-item -> block flex | rebuilt subtree roots=1, escaped=false
PASS: assigned slottable display list-item -> block flex | incremental tree matches full rebuild
PRESERVED: slot fallback child display inline list-item -> none | fixture ancestor
@@ -468,7 +468,7 @@ STATS: slot fallback child display inline list-item -> flex | rebuilt subtree ro
PASS: slot fallback child display inline list-item -> flex | incremental tree matches full rebuild
PRESERVED: assigned slottable display inline list-item -> -webkit-inline-box | fixture ancestor
PRESERVED: assigned slottable display inline list-item -> -webkit-inline-box | distant sibling
-RECREATED: assigned slottable display inline list-item -> -webkit-inline-box | shadow host
+PRESERVED: assigned slottable display inline list-item -> -webkit-inline-box | shadow host
RECREATED: assigned slottable display inline list-item -> -webkit-inline-box | shadow container
RECREATED: assigned slottable display inline list-item -> -webkit-inline-box | preceding flat-tree sibling
RECREATED: assigned slottable display inline list-item -> -webkit-inline-box | preceding sibling descendant
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-3.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-3.txt
index 82577248eac..252faa24bb7 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-3.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-3.txt
@@ -409,13 +409,13 @@ PASS: direct shadow child display list-item -> inline list-item | incremental tr
PRESERVED: slot fallback child display list-item -> -webkit-box | fixture ancestor
PRESERVED: slot fallback child display list-item -> -webkit-box | distant sibling
PRESERVED: slot fallback child display list-item -> -webkit-box | shadow host
-RECREATED: slot fallback child display list-item -> -webkit-box | shadow container
-RECREATED: slot fallback child display list-item -> -webkit-box | preceding flat-tree sibling
-RECREATED: slot fallback child display list-item -> -webkit-box | preceding sibling descendant
+PRESERVED: slot fallback child display list-item -> -webkit-box | shadow container
+PRESERVED: slot fallback child display list-item -> -webkit-box | preceding flat-tree sibling
+PRESERVED: slot fallback child display list-item -> -webkit-box | preceding sibling descendant
RECREATED: slot fallback child display list-item -> -webkit-box | target
RECREATED: slot fallback child display list-item -> -webkit-box | target descendant
-RECREATED: slot fallback child display list-item -> -webkit-box | following flat-tree sibling
-RECREATED: slot fallback child display list-item -> -webkit-box | following sibling descendant
+PRESERVED: slot fallback child display list-item -> -webkit-box | following flat-tree sibling
+PRESERVED: slot fallback child display list-item -> -webkit-box | following sibling descendant
STATS: slot fallback child display list-item -> -webkit-box | rebuilt subtree roots=1, escaped=false
PASS: slot fallback child display list-item -> -webkit-box | incremental tree matches full rebuild
PRESERVED: assigned slottable display list-item -> table-column | fixture ancestor
@@ -433,13 +433,13 @@ PASS: assigned slottable display list-item -> table-column | incremental tree ma
PRESERVED: direct shadow child display list-item -> block grid | fixture ancestor
PRESERVED: direct shadow child display list-item -> block grid | distant sibling
PRESERVED: direct shadow child display list-item -> block grid | shadow host
-RECREATED: direct shadow child display list-item -> block grid | shadow container
-RECREATED: direct shadow child display list-item -> block grid | preceding flat-tree sibling
-RECREATED: direct shadow child display list-item -> block grid | preceding sibling descendant
+PRESERVED: direct shadow child display list-item -> block grid | shadow container
+PRESERVED: direct shadow child display list-item -> block grid | preceding flat-tree sibling
+PRESERVED: direct shadow child display list-item -> block grid | preceding sibling descendant
RECREATED: direct shadow child display list-item -> block grid | target
RECREATED: direct shadow child display list-item -> block grid | target descendant
-RECREATED: direct shadow child display list-item -> block grid | following flat-tree sibling
-RECREATED: direct shadow child display list-item -> block grid | following sibling descendant
+PRESERVED: direct shadow child display list-item -> block grid | following flat-tree sibling
+PRESERVED: direct shadow child display list-item -> block grid | following sibling descendant
STATS: direct shadow child display list-item -> block grid | rebuilt subtree roots=1, escaped=false
PASS: direct shadow child display list-item -> block grid | incremental tree matches full rebuild
PRESERVED: assigned slottable display inline list-item -> block | fixture ancestor
@@ -2041,13 +2041,13 @@ PASS: assigned slottable display block flow list-item -> table-cell | incrementa
PRESERVED: direct shadow child display block flow list-item -> block flex | fixture ancestor
PRESERVED: direct shadow child display block flow list-item -> block flex | distant sibling
PRESERVED: direct shadow child display block flow list-item -> block flex | shadow host
-RECREATED: direct shadow child display block flow list-item -> block flex | shadow container
-RECREATED: direct shadow child display block flow list-item -> block flex | preceding flat-tree sibling
-RECREATED: direct shadow child display block flow list-item -> block flex | preceding sibling descendant
+PRESERVED: direct shadow child display block flow list-item -> block flex | shadow container
+PRESERVED: direct shadow child display block flow list-item -> block flex | preceding flat-tree sibling
+PRESERVED: direct shadow child display block flow list-item -> block flex | preceding sibling descendant
RECREATED: direct shadow child display block flow list-item -> block flex | target
RECREATED: direct shadow child display block flow list-item -> block flex | target descendant
-RECREATED: direct shadow child display block flow list-item -> block flex | following flat-tree sibling
-RECREATED: direct shadow child display block flow list-item -> block flex | following sibling descendant
+PRESERVED: direct shadow child display block flow list-item -> block flex | following flat-tree sibling
+PRESERVED: direct shadow child display block flow list-item -> block flex | following sibling descendant
STATS: direct shadow child display block flow list-item -> block flex | rebuilt subtree roots=1, escaped=false
PASS: direct shadow child display block flow list-item -> block flex | incremental tree matches full rebuild
PRESERVED: slot fallback child display inline flow list-item -> contents | fixture ancestor
@@ -2100,7 +2100,7 @@ STATS: slot fallback child display inline flow list-item -> table-caption | rebu
PASS: slot fallback child display inline flow list-item -> table-caption | incremental tree matches full rebuild
PRESERVED: assigned slottable display inline flow list-item -> inline grid | fixture ancestor
PRESERVED: assigned slottable display inline flow list-item -> inline grid | distant sibling
-RECREATED: assigned slottable display inline flow list-item -> inline grid | shadow host
+PRESERVED: assigned slottable display inline flow list-item -> inline grid | shadow host
RECREATED: assigned slottable display inline flow list-item -> inline grid | shadow container
RECREATED: assigned slottable display inline flow list-item -> inline grid | preceding flat-tree sibling
RECREATED: assigned slottable display inline flow list-item -> inline grid | preceding sibling descendant
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-4.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-4.txt
index 1240265fc49..281511966c4 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-4.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-4.txt
@@ -396,14 +396,14 @@ STATS: assigned slottable display list-item -> none | rebuilt subtree roots=1, e
PASS: assigned slottable display list-item -> none | incremental tree matches full rebuild
PRESERVED: assigned slottable display list-item -> flex | fixture ancestor
PRESERVED: assigned slottable display list-item -> flex | distant sibling
-RECREATED: assigned slottable display list-item -> flex | shadow host
-RECREATED: assigned slottable display list-item -> flex | shadow container
-RECREATED: assigned slottable display list-item -> flex | preceding flat-tree sibling
-RECREATED: assigned slottable display list-item -> flex | preceding sibling descendant
+PRESERVED: assigned slottable display list-item -> flex | shadow host
+PRESERVED: assigned slottable display list-item -> flex | shadow container
+PRESERVED: assigned slottable display list-item -> flex | preceding flat-tree sibling
+PRESERVED: assigned slottable display list-item -> flex | preceding sibling descendant
RECREATED: assigned slottable display list-item -> flex | target
RECREATED: assigned slottable display list-item -> flex | target descendant
-RECREATED: assigned slottable display list-item -> flex | following flat-tree sibling
-RECREATED: assigned slottable display list-item -> flex | following sibling descendant
+PRESERVED: assigned slottable display list-item -> flex | following flat-tree sibling
+PRESERVED: assigned slottable display list-item -> flex | following sibling descendant
STATS: assigned slottable display list-item -> flex | rebuilt subtree roots=1, escaped=false
PASS: assigned slottable display list-item -> flex | incremental tree matches full rebuild
PRESERVED: direct shadow child display list-item -> -webkit-inline-box | fixture ancestor
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-5.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-5.txt
index 4a71f3bb52f..0f14c314d8c 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-5.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-5.txt
@@ -2016,14 +2016,14 @@ STATS: slot fallback child display block flow list-item -> inline list-item | re
PASS: slot fallback child display block flow list-item -> inline list-item | incremental tree matches full rebuild
PRESERVED: assigned slottable display block flow list-item -> -webkit-box | fixture ancestor
PRESERVED: assigned slottable display block flow list-item -> -webkit-box | distant sibling
-RECREATED: assigned slottable display block flow list-item -> -webkit-box | shadow host
-RECREATED: assigned slottable display block flow list-item -> -webkit-box | shadow container
-RECREATED: assigned slottable display block flow list-item -> -webkit-box | preceding flat-tree sibling
-RECREATED: assigned slottable display block flow list-item -> -webkit-box | preceding sibling descendant
+PRESERVED: assigned slottable display block flow list-item -> -webkit-box | shadow host
+PRESERVED: assigned slottable display block flow list-item -> -webkit-box | shadow container
+PRESERVED: assigned slottable display block flow list-item -> -webkit-box | preceding flat-tree sibling
+PRESERVED: assigned slottable display block flow list-item -> -webkit-box | preceding sibling descendant
RECREATED: assigned slottable display block flow list-item -> -webkit-box | target
RECREATED: assigned slottable display block flow list-item -> -webkit-box | target descendant
-RECREATED: assigned slottable display block flow list-item -> -webkit-box | following flat-tree sibling
-RECREATED: assigned slottable display block flow list-item -> -webkit-box | following sibling descendant
+PRESERVED: assigned slottable display block flow list-item -> -webkit-box | following flat-tree sibling
+PRESERVED: assigned slottable display block flow list-item -> -webkit-box | following sibling descendant
STATS: assigned slottable display block flow list-item -> -webkit-box | rebuilt subtree roots=1, escaped=false
PASS: assigned slottable display block flow list-item -> -webkit-box | incremental tree matches full rebuild
PRESERVED: direct shadow child display block flow list-item -> table-column | fixture ancestor
@@ -2041,13 +2041,13 @@ PASS: direct shadow child display block flow list-item -> table-column | increme
PRESERVED: slot fallback child display block flow list-item -> block grid | fixture ancestor
PRESERVED: slot fallback child display block flow list-item -> block grid | distant sibling
PRESERVED: slot fallback child display block flow list-item -> block grid | shadow host
-RECREATED: slot fallback child display block flow list-item -> block grid | shadow container
-RECREATED: slot fallback child display block flow list-item -> block grid | preceding flat-tree sibling
-RECREATED: slot fallback child display block flow list-item -> block grid | preceding sibling descendant
+PRESERVED: slot fallback child display block flow list-item -> block grid | shadow container
+PRESERVED: slot fallback child display block flow list-item -> block grid | preceding flat-tree sibling
+PRESERVED: slot fallback child display block flow list-item -> block grid | preceding sibling descendant
RECREATED: slot fallback child display block flow list-item -> block grid | target
RECREATED: slot fallback child display block flow list-item -> block grid | target descendant
-RECREATED: slot fallback child display block flow list-item -> block grid | following flat-tree sibling
-RECREATED: slot fallback child display block flow list-item -> block grid | following sibling descendant
+PRESERVED: slot fallback child display block flow list-item -> block grid | following flat-tree sibling
+PRESERVED: slot fallback child display block flow list-item -> block grid | following sibling descendant
STATS: slot fallback child display block flow list-item -> block grid | rebuilt subtree roots=1, escaped=false
PASS: slot fallback child display block flow list-item -> block grid | incremental tree matches full rebuild
PRESERVED: assigned slottable display inline flow list-item -> inline | fixture ancestor
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-6.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-6.txt
index 183ee167556..b396767b802 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-6.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-6.txt
@@ -397,13 +397,13 @@ PASS: direct shadow child display list-item -> block | incremental tree matches
PRESERVED: direct shadow child display list-item -> grid | fixture ancestor
PRESERVED: direct shadow child display list-item -> grid | distant sibling
PRESERVED: direct shadow child display list-item -> grid | shadow host
-RECREATED: direct shadow child display list-item -> grid | shadow container
-RECREATED: direct shadow child display list-item -> grid | preceding flat-tree sibling
-RECREATED: direct shadow child display list-item -> grid | preceding sibling descendant
+PRESERVED: direct shadow child display list-item -> grid | shadow container
+PRESERVED: direct shadow child display list-item -> grid | preceding flat-tree sibling
+PRESERVED: direct shadow child display list-item -> grid | preceding sibling descendant
RECREATED: direct shadow child display list-item -> grid | target
RECREATED: direct shadow child display list-item -> grid | target descendant
-RECREATED: direct shadow child display list-item -> grid | following flat-tree sibling
-RECREATED: direct shadow child display list-item -> grid | following sibling descendant
+PRESERVED: direct shadow child display list-item -> grid | following flat-tree sibling
+PRESERVED: direct shadow child display list-item -> grid | following sibling descendant
STATS: direct shadow child display list-item -> grid | rebuilt subtree roots=1, escaped=false
PASS: direct shadow child display list-item -> grid | incremental tree matches full rebuild
PRESERVED: slot fallback child display list-item -> table-header-group | fixture ancestor
@@ -2005,13 +2005,13 @@ PASS: assigned slottable display block flow list-item -> contents | incremental
PRESERVED: direct shadow child display block flow list-item -> flex | fixture ancestor
PRESERVED: direct shadow child display block flow list-item -> flex | distant sibling
PRESERVED: direct shadow child display block flow list-item -> flex | shadow host
-RECREATED: direct shadow child display block flow list-item -> flex | shadow container
-RECREATED: direct shadow child display block flow list-item -> flex | preceding flat-tree sibling
-RECREATED: direct shadow child display block flow list-item -> flex | preceding sibling descendant
+PRESERVED: direct shadow child display block flow list-item -> flex | shadow container
+PRESERVED: direct shadow child display block flow list-item -> flex | preceding flat-tree sibling
+PRESERVED: direct shadow child display block flow list-item -> flex | preceding sibling descendant
RECREATED: direct shadow child display block flow list-item -> flex | target
RECREATED: direct shadow child display block flow list-item -> flex | target descendant
-RECREATED: direct shadow child display block flow list-item -> flex | following flat-tree sibling
-RECREATED: direct shadow child display block flow list-item -> flex | following sibling descendant
+PRESERVED: direct shadow child display block flow list-item -> flex | following flat-tree sibling
+PRESERVED: direct shadow child display block flow list-item -> flex | following sibling descendant
STATS: direct shadow child display block flow list-item -> flex | rebuilt subtree roots=1, escaped=false
PASS: direct shadow child display block flow list-item -> flex | incremental tree matches full rebuild
PRESERVED: slot fallback child display block flow list-item -> -webkit-inline-box | fixture ancestor
@@ -2064,7 +2064,7 @@ STATS: slot fallback child display inline flow list-item -> flow-root | rebuilt
PASS: slot fallback child display inline flow list-item -> flow-root | incremental tree matches full rebuild
PRESERVED: assigned slottable display inline flow list-item -> inline-grid | fixture ancestor
PRESERVED: assigned slottable display inline flow list-item -> inline-grid | distant sibling
-RECREATED: assigned slottable display inline flow list-item -> inline-grid | shadow host
+PRESERVED: assigned slottable display inline flow list-item -> inline-grid | shadow host
RECREATED: assigned slottable display inline flow list-item -> inline-grid | shadow container
RECREATED: assigned slottable display inline flow list-item -> inline-grid | preceding flat-tree sibling
RECREATED: assigned slottable display inline flow list-item -> inline-grid | preceding sibling descendant
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-8.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-8.txt
index a97fcd085e9..cdf5cef53ab 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-8.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-flat-tree-8.txt
@@ -2005,13 +2005,13 @@ PASS: direct shadow child display block flow list-item -> inline | incremental t
PRESERVED: slot fallback child display block flow list-item -> grid | fixture ancestor
PRESERVED: slot fallback child display block flow list-item -> grid | distant sibling
PRESERVED: slot fallback child display block flow list-item -> grid | shadow host
-RECREATED: slot fallback child display block flow list-item -> grid | shadow container
-RECREATED: slot fallback child display block flow list-item -> grid | preceding flat-tree sibling
-RECREATED: slot fallback child display block flow list-item -> grid | preceding sibling descendant
+PRESERVED: slot fallback child display block flow list-item -> grid | shadow container
+PRESERVED: slot fallback child display block flow list-item -> grid | preceding flat-tree sibling
+PRESERVED: slot fallback child display block flow list-item -> grid | preceding sibling descendant
RECREATED: slot fallback child display block flow list-item -> grid | target
RECREATED: slot fallback child display block flow list-item -> grid | target descendant
-RECREATED: slot fallback child display block flow list-item -> grid | following flat-tree sibling
-RECREATED: slot fallback child display block flow list-item -> grid | following sibling descendant
+PRESERVED: slot fallback child display block flow list-item -> grid | following flat-tree sibling
+PRESERVED: slot fallback child display block flow list-item -> grid | following sibling descendant
STATS: slot fallback child display block flow list-item -> grid | rebuilt subtree roots=1, escaped=false
PASS: slot fallback child display block flow list-item -> grid | incremental tree matches full rebuild
PRESERVED: assigned slottable display block flow list-item -> table-header-group | fixture ancestor
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-1.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-1.txt
index 141a28d18cd..dd35d3c032a 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-1.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-1.txt
@@ -8,7 +8,7 @@ ABSENT: ::before create none on none in contents | target
ABSENT: ::before create none on none in contents | target descendant
PRESERVED: ::before create none on none in contents | following sibling
PRESERVED: ::before create none on none in contents | following sibling descendant
-STATS: ::before create none on none in contents | rebuilt subtree roots=0, escaped=false
+STATS: ::before create none on none in contents | no layout tree build
PASS: ::before create none on none in contents | incremental tree matches full rebuild
PRESERVED: ::before create inline-grid on none in table | fixture ancestor
PRESERVED: ::before create inline-grid on none in table | distant sibling
@@ -20,7 +20,7 @@ ABSENT: ::before create inline-grid on none in table | target
ABSENT: ::before create inline-grid on none in table | target descendant
PRESERVED: ::before create inline-grid on none in table | following sibling
PRESERVED: ::before create inline-grid on none in table | following sibling descendant
-STATS: ::before create inline-grid on none in table | rebuilt subtree roots=0, escaped=false
+STATS: ::before create inline-grid on none in table | no layout tree build
PASS: ::before create inline-grid on none in table | incremental tree matches full rebuild
PRESERVED: ::before create table-column on none in table-caption | fixture ancestor
PRESERVED: ::before create table-column on none in table-caption | distant sibling
@@ -32,7 +32,7 @@ ABSENT: ::before create table-column on none in table-caption | target
ABSENT: ::before create table-column on none in table-caption | target descendant
PRESERVED: ::before create table-column on none in table-caption | following sibling
PRESERVED: ::before create table-column on none in table-caption | following sibling descendant
-STATS: ::before create table-column on none in table-caption | rebuilt subtree roots=0, escaped=false
+STATS: ::before create table-column on none in table-caption | no layout tree build
PASS: ::before create table-column on none in table-caption | incremental tree matches full rebuild
PRESERVED: ::before create block flow list-item on none in inline flow list-item | fixture ancestor
PRESERVED: ::before create block flow list-item on none in inline flow list-item | distant sibling
@@ -44,43 +44,43 @@ ABSENT: ::before create block flow list-item on none in inline flow list-item |
ABSENT: ::before create block flow list-item on none in inline flow list-item | target descendant
PRESERVED: ::before create block flow list-item on none in inline flow list-item | following sibling
PRESERVED: ::before create block flow list-item on none in inline flow list-item | following sibling descendant
-STATS: ::before create block flow list-item on none in inline flow list-item | rebuilt subtree roots=0, escaped=false
+STATS: ::before create block flow list-item on none in inline flow list-item | no layout tree build
PASS: ::before create block flow list-item on none in inline flow list-item | incremental tree matches full rebuild
-RECREATED: ::after change position inline-flex on none in inline-grid | fixture ancestor
-RECREATED: ::after change position inline-flex on none in inline-grid | distant sibling
-RECREATED: ::after change position inline-flex on none in inline-grid | distant sibling descendant
-RECREATED: ::after change position inline-flex on none in inline-grid | DOM parent
-RECREATED: ::after change position inline-flex on none in inline-grid | preceding sibling
-RECREATED: ::after change position inline-flex on none in inline-grid | preceding sibling descendant
+PRESERVED: ::after change position inline-flex on none in inline-grid | fixture ancestor
+PRESERVED: ::after change position inline-flex on none in inline-grid | distant sibling
+PRESERVED: ::after change position inline-flex on none in inline-grid | distant sibling descendant
+PRESERVED: ::after change position inline-flex on none in inline-grid | DOM parent
+PRESERVED: ::after change position inline-flex on none in inline-grid | preceding sibling
+PRESERVED: ::after change position inline-flex on none in inline-grid | preceding sibling descendant
ABSENT: ::after change position inline-flex on none in inline-grid | target
ABSENT: ::after change position inline-flex on none in inline-grid | target descendant
-RECREATED: ::after change position inline-flex on none in inline-grid | following sibling
-RECREATED: ::after change position inline-flex on none in inline-grid | following sibling descendant
-STATS: ::after change position inline-flex on none in inline-grid | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change position inline-flex on none in inline-grid | following sibling
+PRESERVED: ::after change position inline-flex on none in inline-grid | following sibling descendant
+STATS: ::after change position inline-flex on none in inline-grid | no layout tree build
PASS: ::after change position inline-flex on none in inline-grid | incremental tree matches full rebuild
-RECREATED: ::after change position table-cell on none in table-column | fixture ancestor
-RECREATED: ::after change position table-cell on none in table-column | distant sibling
-RECREATED: ::after change position table-cell on none in table-column | distant sibling descendant
-RECREATED: ::after change position table-cell on none in table-column | DOM parent
+PRESERVED: ::after change position table-cell on none in table-column | fixture ancestor
+PRESERVED: ::after change position table-cell on none in table-column | distant sibling
+PRESERVED: ::after change position table-cell on none in table-column | distant sibling descendant
+PRESERVED: ::after change position table-cell on none in table-column | DOM parent
ABSENT: ::after change position table-cell on none in table-column | preceding sibling
ABSENT: ::after change position table-cell on none in table-column | preceding sibling descendant
ABSENT: ::after change position table-cell on none in table-column | target
ABSENT: ::after change position table-cell on none in table-column | target descendant
ABSENT: ::after change position table-cell on none in table-column | following sibling
ABSENT: ::after change position table-cell on none in table-column | following sibling descendant
-STATS: ::after change position table-cell on none in table-column | rebuilt subtree roots=1, escaped=false
+STATS: ::after change position table-cell on none in table-column | no layout tree build
PASS: ::after change position table-cell on none in table-column | incremental tree matches full rebuild
PRESERVED: ::after change position block table on none in block flow list-item | fixture ancestor
PRESERVED: ::after change position block table on none in block flow list-item | distant sibling
PRESERVED: ::after change position block table on none in block flow list-item | distant sibling descendant
-RECREATED: ::after change position block table on none in block flow list-item | DOM parent
-RECREATED: ::after change position block table on none in block flow list-item | preceding sibling
-RECREATED: ::after change position block table on none in block flow list-item | preceding sibling descendant
+PRESERVED: ::after change position block table on none in block flow list-item | DOM parent
+PRESERVED: ::after change position block table on none in block flow list-item | preceding sibling
+PRESERVED: ::after change position block table on none in block flow list-item | preceding sibling descendant
ABSENT: ::after change position block table on none in block flow list-item | target
ABSENT: ::after change position block table on none in block flow list-item | target descendant
-RECREATED: ::after change position block table on none in block flow list-item | following sibling
-RECREATED: ::after change position block table on none in block flow list-item | following sibling descendant
-STATS: ::after change position block table on none in block flow list-item | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change position block table on none in block flow list-item | following sibling
+PRESERVED: ::after change position block table on none in block flow list-item | following sibling descendant
+STATS: ::after change position block table on none in block flow list-item | no layout tree build
PASS: ::after change position block table on none in block flow list-item | incremental tree matches full rebuild
RECREATED: ::before change float inline list-item on contents in inline-flex | fixture ancestor
RECREATED: ::before change float inline list-item on contents in inline-flex | distant sibling
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-10.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-10.txt
index 0e1f1289bc4..4cd2657c5bc 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-10.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-10.txt
@@ -1,74 +1,74 @@
-RECREATED: ::before change float flex on none in inline-flex | fixture ancestor
-RECREATED: ::before change float flex on none in inline-flex | distant sibling
-RECREATED: ::before change float flex on none in inline-flex | distant sibling descendant
-RECREATED: ::before change float flex on none in inline-flex | DOM parent
-RECREATED: ::before change float flex on none in inline-flex | preceding sibling
-RECREATED: ::before change float flex on none in inline-flex | preceding sibling descendant
+PRESERVED: ::before change float flex on none in inline-flex | fixture ancestor
+PRESERVED: ::before change float flex on none in inline-flex | distant sibling
+PRESERVED: ::before change float flex on none in inline-flex | distant sibling descendant
+PRESERVED: ::before change float flex on none in inline-flex | DOM parent
+PRESERVED: ::before change float flex on none in inline-flex | preceding sibling
+PRESERVED: ::before change float flex on none in inline-flex | preceding sibling descendant
ABSENT: ::before change float flex on none in inline-flex | target
ABSENT: ::before change float flex on none in inline-flex | target descendant
-RECREATED: ::before change float flex on none in inline-flex | following sibling
-RECREATED: ::before change float flex on none in inline-flex | following sibling descendant
-STATS: ::before change float flex on none in inline-flex | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change float flex on none in inline-flex | following sibling
+PRESERVED: ::before change float flex on none in inline-flex | following sibling descendant
+STATS: ::before change float flex on none in inline-flex | no layout tree build
PASS: ::before change float flex on none in inline-flex | incremental tree matches full rebuild
-RECREATED: ::before change float table-row on none in table-cell | fixture ancestor
-RECREATED: ::before change float table-row on none in table-cell | distant sibling
-RECREATED: ::before change float table-row on none in table-cell | distant sibling descendant
-RECREATED: ::before change float table-row on none in table-cell | DOM parent
-RECREATED: ::before change float table-row on none in table-cell | preceding sibling
-RECREATED: ::before change float table-row on none in table-cell | preceding sibling descendant
+PRESERVED: ::before change float table-row on none in table-cell | fixture ancestor
+PRESERVED: ::before change float table-row on none in table-cell | distant sibling
+PRESERVED: ::before change float table-row on none in table-cell | distant sibling descendant
+PRESERVED: ::before change float table-row on none in table-cell | DOM parent
+PRESERVED: ::before change float table-row on none in table-cell | preceding sibling
+PRESERVED: ::before change float table-row on none in table-cell | preceding sibling descendant
ABSENT: ::before change float table-row on none in table-cell | target
ABSENT: ::before change float table-row on none in table-cell | target descendant
-RECREATED: ::before change float table-row on none in table-cell | following sibling
-RECREATED: ::before change float table-row on none in table-cell | following sibling descendant
-STATS: ::before change float table-row on none in table-cell | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change float table-row on none in table-cell | following sibling
+PRESERVED: ::before change float table-row on none in table-cell | following sibling descendant
+STATS: ::before change float table-row on none in table-cell | no layout tree build
PASS: ::before change float table-row on none in table-cell | incremental tree matches full rebuild
-RECREATED: ::before change float inline grid on none in block table | fixture ancestor
-RECREATED: ::before change float inline grid on none in block table | distant sibling
-RECREATED: ::before change float inline grid on none in block table | distant sibling descendant
-RECREATED: ::before change float inline grid on none in block table | DOM parent
-RECREATED: ::before change float inline grid on none in block table | preceding sibling
-RECREATED: ::before change float inline grid on none in block table | preceding sibling descendant
+PRESERVED: ::before change float inline grid on none in block table | fixture ancestor
+PRESERVED: ::before change float inline grid on none in block table | distant sibling
+PRESERVED: ::before change float inline grid on none in block table | distant sibling descendant
+PRESERVED: ::before change float inline grid on none in block table | DOM parent
+PRESERVED: ::before change float inline grid on none in block table | preceding sibling
+PRESERVED: ::before change float inline grid on none in block table | preceding sibling descendant
ABSENT: ::before change float inline grid on none in block table | target
ABSENT: ::before change float inline grid on none in block table | target descendant
-RECREATED: ::before change float inline grid on none in block table | following sibling
-RECREATED: ::before change float inline grid on none in block table | following sibling descendant
-STATS: ::before change float inline grid on none in block table | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change float inline grid on none in block table | following sibling
+PRESERVED: ::before change float inline grid on none in block table | following sibling descendant
+STATS: ::before change float inline grid on none in block table | no layout tree build
PASS: ::before change float inline grid on none in block table | incremental tree matches full rebuild
PRESERVED: ::after change display list-item on none in flex | fixture ancestor
PRESERVED: ::after change display list-item on none in flex | distant sibling
PRESERVED: ::after change display list-item on none in flex | distant sibling descendant
-RECREATED: ::after change display list-item on none in flex | DOM parent
-RECREATED: ::after change display list-item on none in flex | preceding sibling
-RECREATED: ::after change display list-item on none in flex | preceding sibling descendant
+PRESERVED: ::after change display list-item on none in flex | DOM parent
+PRESERVED: ::after change display list-item on none in flex | preceding sibling
+PRESERVED: ::after change display list-item on none in flex | preceding sibling descendant
ABSENT: ::after change display list-item on none in flex | target
ABSENT: ::after change display list-item on none in flex | target descendant
-RECREATED: ::after change display list-item on none in flex | following sibling
-RECREATED: ::after change display list-item on none in flex | following sibling descendant
-STATS: ::after change display list-item on none in flex | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change display list-item on none in flex | following sibling
+PRESERVED: ::after change display list-item on none in flex | following sibling descendant
+STATS: ::after change display list-item on none in flex | no layout tree build
PASS: ::after change display list-item on none in flex | incremental tree matches full rebuild
-RECREATED: ::after change display table-header-group on none in table-row | fixture ancestor
-RECREATED: ::after change display table-header-group on none in table-row | distant sibling
-RECREATED: ::after change display table-header-group on none in table-row | distant sibling descendant
-RECREATED: ::after change display table-header-group on none in table-row | DOM parent
-RECREATED: ::after change display table-header-group on none in table-row | preceding sibling
-RECREATED: ::after change display table-header-group on none in table-row | preceding sibling descendant
+PRESERVED: ::after change display table-header-group on none in table-row | fixture ancestor
+PRESERVED: ::after change display table-header-group on none in table-row | distant sibling
+PRESERVED: ::after change display table-header-group on none in table-row | distant sibling descendant
+PRESERVED: ::after change display table-header-group on none in table-row | DOM parent
+PRESERVED: ::after change display table-header-group on none in table-row | preceding sibling
+PRESERVED: ::after change display table-header-group on none in table-row | preceding sibling descendant
ABSENT: ::after change display table-header-group on none in table-row | target
ABSENT: ::after change display table-header-group on none in table-row | target descendant
-RECREATED: ::after change display table-header-group on none in table-row | following sibling
-RECREATED: ::after change display table-header-group on none in table-row | following sibling descendant
-STATS: ::after change display table-header-group on none in table-row | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change display table-header-group on none in table-row | following sibling
+PRESERVED: ::after change display table-header-group on none in table-row | following sibling descendant
+STATS: ::after change display table-header-group on none in table-row | no layout tree build
PASS: ::after change display table-header-group on none in table-row | incremental tree matches full rebuild
-RECREATED: ::after change display inline flex on none in inline grid | fixture ancestor
-RECREATED: ::after change display inline flex on none in inline grid | distant sibling
-RECREATED: ::after change display inline flex on none in inline grid | distant sibling descendant
-RECREATED: ::after change display inline flex on none in inline grid | DOM parent
-RECREATED: ::after change display inline flex on none in inline grid | preceding sibling
-RECREATED: ::after change display inline flex on none in inline grid | preceding sibling descendant
+PRESERVED: ::after change display inline flex on none in inline grid | fixture ancestor
+PRESERVED: ::after change display inline flex on none in inline grid | distant sibling
+PRESERVED: ::after change display inline flex on none in inline grid | distant sibling descendant
+PRESERVED: ::after change display inline flex on none in inline grid | DOM parent
+PRESERVED: ::after change display inline flex on none in inline grid | preceding sibling
+PRESERVED: ::after change display inline flex on none in inline grid | preceding sibling descendant
ABSENT: ::after change display inline flex on none in inline grid | target
ABSENT: ::after change display inline flex on none in inline grid | target descendant
-RECREATED: ::after change display inline flex on none in inline grid | following sibling
-RECREATED: ::after change display inline flex on none in inline grid | following sibling descendant
-STATS: ::after change display inline flex on none in inline grid | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change display inline flex on none in inline grid | following sibling
+PRESERVED: ::after change display inline flex on none in inline grid | following sibling descendant
+STATS: ::after change display inline flex on none in inline grid | no layout tree build
PASS: ::after change display inline flex on none in inline grid | incremental tree matches full rebuild
PRESERVED: ::before create inline-block on contents in list-item | fixture ancestor
PRESERVED: ::before create inline-block on contents in list-item | distant sibling
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-11.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-11.txt
index 52cee0ea6c8..5ad628f0d8b 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-11.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-11.txt
@@ -34,41 +34,41 @@ PRESERVED: ::before change clear block table on none in inline table | following
PRESERVED: ::before change clear block table on none in inline table | following sibling descendant
STATS: ::before change clear block table on none in inline table | no layout tree build
PASS: ::before change clear block table on none in inline table | incremental tree matches full rebuild
-RECREATED: ::after change float inline list-item on none in inline-flex | fixture ancestor
-RECREATED: ::after change float inline list-item on none in inline-flex | distant sibling
-RECREATED: ::after change float inline list-item on none in inline-flex | distant sibling descendant
-RECREATED: ::after change float inline list-item on none in inline-flex | DOM parent
-RECREATED: ::after change float inline list-item on none in inline-flex | preceding sibling
-RECREATED: ::after change float inline list-item on none in inline-flex | preceding sibling descendant
+PRESERVED: ::after change float inline list-item on none in inline-flex | fixture ancestor
+PRESERVED: ::after change float inline list-item on none in inline-flex | distant sibling
+PRESERVED: ::after change float inline list-item on none in inline-flex | distant sibling descendant
+PRESERVED: ::after change float inline list-item on none in inline-flex | DOM parent
+PRESERVED: ::after change float inline list-item on none in inline-flex | preceding sibling
+PRESERVED: ::after change float inline list-item on none in inline-flex | preceding sibling descendant
ABSENT: ::after change float inline list-item on none in inline-flex | target
ABSENT: ::after change float inline list-item on none in inline-flex | target descendant
-RECREATED: ::after change float inline list-item on none in inline-flex | following sibling
-RECREATED: ::after change float inline list-item on none in inline-flex | following sibling descendant
-STATS: ::after change float inline list-item on none in inline-flex | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change float inline list-item on none in inline-flex | following sibling
+PRESERVED: ::after change float inline list-item on none in inline-flex | following sibling descendant
+STATS: ::after change float inline list-item on none in inline-flex | no layout tree build
PASS: ::after change float inline list-item on none in inline-flex | incremental tree matches full rebuild
-RECREATED: ::after change float table-footer-group on none in table-cell | fixture ancestor
-RECREATED: ::after change float table-footer-group on none in table-cell | distant sibling
-RECREATED: ::after change float table-footer-group on none in table-cell | distant sibling descendant
-RECREATED: ::after change float table-footer-group on none in table-cell | DOM parent
-RECREATED: ::after change float table-footer-group on none in table-cell | preceding sibling
-RECREATED: ::after change float table-footer-group on none in table-cell | preceding sibling descendant
+PRESERVED: ::after change float table-footer-group on none in table-cell | fixture ancestor
+PRESERVED: ::after change float table-footer-group on none in table-cell | distant sibling
+PRESERVED: ::after change float table-footer-group on none in table-cell | distant sibling descendant
+PRESERVED: ::after change float table-footer-group on none in table-cell | DOM parent
+PRESERVED: ::after change float table-footer-group on none in table-cell | preceding sibling
+PRESERVED: ::after change float table-footer-group on none in table-cell | preceding sibling descendant
ABSENT: ::after change float table-footer-group on none in table-cell | target
ABSENT: ::after change float table-footer-group on none in table-cell | target descendant
-RECREATED: ::after change float table-footer-group on none in table-cell | following sibling
-RECREATED: ::after change float table-footer-group on none in table-cell | following sibling descendant
-STATS: ::after change float table-footer-group on none in table-cell | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change float table-footer-group on none in table-cell | following sibling
+PRESERVED: ::after change float table-footer-group on none in table-cell | following sibling descendant
+STATS: ::after change float table-footer-group on none in table-cell | no layout tree build
PASS: ::after change float table-footer-group on none in table-cell | incremental tree matches full rebuild
-RECREATED: ::after change float block grid on none in block table | fixture ancestor
-RECREATED: ::after change float block grid on none in block table | distant sibling
-RECREATED: ::after change float block grid on none in block table | distant sibling descendant
-RECREATED: ::after change float block grid on none in block table | DOM parent
-RECREATED: ::after change float block grid on none in block table | preceding sibling
-RECREATED: ::after change float block grid on none in block table | preceding sibling descendant
+PRESERVED: ::after change float block grid on none in block table | fixture ancestor
+PRESERVED: ::after change float block grid on none in block table | distant sibling
+PRESERVED: ::after change float block grid on none in block table | distant sibling descendant
+PRESERVED: ::after change float block grid on none in block table | DOM parent
+PRESERVED: ::after change float block grid on none in block table | preceding sibling
+PRESERVED: ::after change float block grid on none in block table | preceding sibling descendant
ABSENT: ::after change float block grid on none in block table | target
ABSENT: ::after change float block grid on none in block table | target descendant
-RECREATED: ::after change float block grid on none in block table | following sibling
-RECREATED: ::after change float block grid on none in block table | following sibling descendant
-STATS: ::after change float block grid on none in block table | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change float block grid on none in block table | following sibling
+PRESERVED: ::after change float block grid on none in block table | following sibling descendant
+STATS: ::after change float block grid on none in block table | no layout tree build
PASS: ::after change float block grid on none in block table | incremental tree matches full rebuild
RECREATED: ::before remove run-in on contents in inline list-item | fixture ancestor
RECREATED: ::before remove run-in on contents in inline list-item | distant sibling
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-12.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-12.txt
index cf9be8606b6..3011638d5c0 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-12.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-12.txt
@@ -1,38 +1,38 @@
-RECREATED: ::before change position grid on none in inline-grid | fixture ancestor
-RECREATED: ::before change position grid on none in inline-grid | distant sibling
-RECREATED: ::before change position grid on none in inline-grid | distant sibling descendant
-RECREATED: ::before change position grid on none in inline-grid | DOM parent
-RECREATED: ::before change position grid on none in inline-grid | preceding sibling
-RECREATED: ::before change position grid on none in inline-grid | preceding sibling descendant
+PRESERVED: ::before change position grid on none in inline-grid | fixture ancestor
+PRESERVED: ::before change position grid on none in inline-grid | distant sibling
+PRESERVED: ::before change position grid on none in inline-grid | distant sibling descendant
+PRESERVED: ::before change position grid on none in inline-grid | DOM parent
+PRESERVED: ::before change position grid on none in inline-grid | preceding sibling
+PRESERVED: ::before change position grid on none in inline-grid | preceding sibling descendant
ABSENT: ::before change position grid on none in inline-grid | target
ABSENT: ::before change position grid on none in inline-grid | target descendant
-RECREATED: ::before change position grid on none in inline-grid | following sibling
-RECREATED: ::before change position grid on none in inline-grid | following sibling descendant
-STATS: ::before change position grid on none in inline-grid | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change position grid on none in inline-grid | following sibling
+PRESERVED: ::before change position grid on none in inline-grid | following sibling descendant
+STATS: ::before change position grid on none in inline-grid | no layout tree build
PASS: ::before change position grid on none in inline-grid | incremental tree matches full rebuild
-RECREATED: ::before change position table-column-group on none in table-column | fixture ancestor
-RECREATED: ::before change position table-column-group on none in table-column | distant sibling
-RECREATED: ::before change position table-column-group on none in table-column | distant sibling descendant
-RECREATED: ::before change position table-column-group on none in table-column | DOM parent
+PRESERVED: ::before change position table-column-group on none in table-column | fixture ancestor
+PRESERVED: ::before change position table-column-group on none in table-column | distant sibling
+PRESERVED: ::before change position table-column-group on none in table-column | distant sibling descendant
+PRESERVED: ::before change position table-column-group on none in table-column | DOM parent
ABSENT: ::before change position table-column-group on none in table-column | preceding sibling
ABSENT: ::before change position table-column-group on none in table-column | preceding sibling descendant
ABSENT: ::before change position table-column-group on none in table-column | target
ABSENT: ::before change position table-column-group on none in table-column | target descendant
ABSENT: ::before change position table-column-group on none in table-column | following sibling
ABSENT: ::before change position table-column-group on none in table-column | following sibling descendant
-STATS: ::before change position table-column-group on none in table-column | rebuilt subtree roots=1, escaped=false
+STATS: ::before change position table-column-group on none in table-column | no layout tree build
PASS: ::before change position table-column-group on none in table-column | incremental tree matches full rebuild
PRESERVED: ::before change position inline table on none in block flow list-item | fixture ancestor
PRESERVED: ::before change position inline table on none in block flow list-item | distant sibling
PRESERVED: ::before change position inline table on none in block flow list-item | distant sibling descendant
-RECREATED: ::before change position inline table on none in block flow list-item | DOM parent
-RECREATED: ::before change position inline table on none in block flow list-item | preceding sibling
-RECREATED: ::before change position inline table on none in block flow list-item | preceding sibling descendant
+PRESERVED: ::before change position inline table on none in block flow list-item | DOM parent
+PRESERVED: ::before change position inline table on none in block flow list-item | preceding sibling
+PRESERVED: ::before change position inline table on none in block flow list-item | preceding sibling descendant
ABSENT: ::before change position inline table on none in block flow list-item | target
ABSENT: ::before change position inline table on none in block flow list-item | target descendant
-RECREATED: ::before change position inline table on none in block flow list-item | following sibling
-RECREATED: ::before change position inline table on none in block flow list-item | following sibling descendant
-STATS: ::before change position inline table on none in block flow list-item | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change position inline table on none in block flow list-item | following sibling
+PRESERVED: ::before change position inline table on none in block flow list-item | following sibling descendant
+STATS: ::before change position inline table on none in block flow list-item | no layout tree build
PASS: ::before change position inline table on none in block flow list-item | incremental tree matches full rebuild
PRESERVED: ::after change clear flex on none in grid | fixture ancestor
PRESERVED: ::after change clear flex on none in grid | distant sibling
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-2.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-2.txt
index 26f6fc0a3a7..3f9fd8fef19 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-2.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-2.txt
@@ -8,7 +8,7 @@ ABSENT: ::before remove contents on none in block | target
ABSENT: ::before remove contents on none in block | target descendant
PRESERVED: ::before remove contents on none in block | following sibling
PRESERVED: ::before remove contents on none in block | following sibling descendant
-STATS: ::before remove contents on none in block | rebuilt subtree roots=0, escaped=false
+STATS: ::before remove contents on none in block | no layout tree build
PASS: ::before remove contents on none in block | incremental tree matches full rebuild
PRESERVED: ::before remove table on none in inline-table | fixture ancestor
PRESERVED: ::before remove table on none in inline-table | distant sibling
@@ -20,7 +20,7 @@ ABSENT: ::before remove table on none in inline-table | target
ABSENT: ::before remove table on none in inline-table | target descendant
PRESERVED: ::before remove table on none in inline-table | following sibling
PRESERVED: ::before remove table on none in inline-table | following sibling descendant
-STATS: ::before remove table on none in inline-table | rebuilt subtree roots=0, escaped=false
+STATS: ::before remove table on none in inline-table | no layout tree build
PASS: ::before remove table on none in inline-table | incremental tree matches full rebuild
PRESERVED: ::before remove table-caption on none in block flow | fixture ancestor
PRESERVED: ::before remove table-caption on none in block flow | distant sibling
@@ -32,7 +32,7 @@ ABSENT: ::before remove table-caption on none in block flow | target
ABSENT: ::before remove table-caption on none in block flow | target descendant
PRESERVED: ::before remove table-caption on none in block flow | following sibling
PRESERVED: ::before remove table-caption on none in block flow | following sibling descendant
-STATS: ::before remove table-caption on none in block flow | rebuilt subtree roots=0, escaped=false
+STATS: ::before remove table-caption on none in block flow | no layout tree build
PASS: ::before remove table-caption on none in block flow | incremental tree matches full rebuild
PRESERVED: ::before remove inline flow list-item on none in contents | fixture ancestor
PRESERVED: ::before remove inline flow list-item on none in contents | distant sibling
@@ -44,7 +44,7 @@ ABSENT: ::before remove inline flow list-item on none in contents | target
ABSENT: ::before remove inline flow list-item on none in contents | target descendant
PRESERVED: ::before remove inline flow list-item on none in contents | following sibling
PRESERVED: ::before remove inline flow list-item on none in contents | following sibling descendant
-STATS: ::before remove inline flow list-item on none in contents | rebuilt subtree roots=0, escaped=false
+STATS: ::before remove inline flow list-item on none in contents | no layout tree build
PASS: ::before remove inline flow list-item on none in contents | incremental tree matches full rebuild
PRESERVED: ::after create grid on none in table | fixture ancestor
PRESERVED: ::after create grid on none in table | distant sibling
@@ -56,7 +56,7 @@ ABSENT: ::after create grid on none in table | target
ABSENT: ::after create grid on none in table | target descendant
PRESERVED: ::after create grid on none in table | following sibling
PRESERVED: ::after create grid on none in table | following sibling descendant
-STATS: ::after create grid on none in table | rebuilt subtree roots=0, escaped=false
+STATS: ::after create grid on none in table | no layout tree build
PASS: ::after create grid on none in table | incremental tree matches full rebuild
PRESERVED: ::after create table-column-group on none in table-caption | fixture ancestor
PRESERVED: ::after create table-column-group on none in table-caption | distant sibling
@@ -68,7 +68,7 @@ ABSENT: ::after create table-column-group on none in table-caption | target
ABSENT: ::after create table-column-group on none in table-caption | target descendant
PRESERVED: ::after create table-column-group on none in table-caption | following sibling
PRESERVED: ::after create table-column-group on none in table-caption | following sibling descendant
-STATS: ::after create table-column-group on none in table-caption | rebuilt subtree roots=0, escaped=false
+STATS: ::after create table-column-group on none in table-caption | no layout tree build
PASS: ::after create table-column-group on none in table-caption | incremental tree matches full rebuild
PRESERVED: ::after create inline table on none in inline flow list-item | fixture ancestor
PRESERVED: ::after create inline table on none in inline flow list-item | distant sibling
@@ -80,7 +80,7 @@ ABSENT: ::after create inline table on none in inline flow list-item | target
ABSENT: ::after create inline table on none in inline flow list-item | target descendant
PRESERVED: ::after create inline table on none in inline flow list-item | following sibling
PRESERVED: ::after create inline table on none in inline flow list-item | following sibling descendant
-STATS: ::after create inline table on none in inline flow list-item | rebuilt subtree roots=0, escaped=false
+STATS: ::after create inline table on none in inline flow list-item | no layout tree build
PASS: ::after create inline table on none in inline flow list-item | incremental tree matches full rebuild
PRESERVED: ::before change clear flex on contents in grid | fixture ancestor
PRESERVED: ::before change clear flex on contents in grid | distant sibling
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-3.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-3.txt
index b2eeded8b45..ad49905be0b 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-3.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-3.txt
@@ -1,14 +1,14 @@
-RECREATED: ::before change display block on none in inline | fixture ancestor
-RECREATED: ::before change display block on none in inline | distant sibling
-RECREATED: ::before change display block on none in inline | distant sibling descendant
-RECREATED: ::before change display block on none in inline | DOM parent
-RECREATED: ::before change display block on none in inline | preceding sibling
-RECREATED: ::before change display block on none in inline | preceding sibling descendant
+PRESERVED: ::before change display block on none in inline | fixture ancestor
+PRESERVED: ::before change display block on none in inline | distant sibling
+PRESERVED: ::before change display block on none in inline | distant sibling descendant
+PRESERVED: ::before change display block on none in inline | DOM parent
+PRESERVED: ::before change display block on none in inline | preceding sibling
+PRESERVED: ::before change display block on none in inline | preceding sibling descendant
ABSENT: ::before change display block on none in inline | target
ABSENT: ::before change display block on none in inline | target descendant
-RECREATED: ::before change display block on none in inline | following sibling
-RECREATED: ::before change display block on none in inline | following sibling descendant
-STATS: ::before change display block on none in inline | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change display block on none in inline | following sibling
+PRESERVED: ::before change display block on none in inline | following sibling descendant
+STATS: ::before change display block on none in inline | no layout tree build
PASS: ::before change display block on none in inline | incremental tree matches full rebuild
PRESERVED: ::before change display inline-table on none in math | fixture ancestor
PRESERVED: ::before change display inline-table on none in math | distant sibling
@@ -20,19 +20,19 @@ ABSENT: ::before change display inline-table on none in math | target
ABSENT: ::before change display inline-table on none in math | target descendant
PRESERVED: ::before change display inline-table on none in math | following sibling
PRESERVED: ::before change display inline-table on none in math | following sibling descendant
-STATS: ::before change display inline-table on none in math | rebuilt subtree roots=0, escaped=false
+STATS: ::before change display inline-table on none in math | no layout tree build
PASS: ::before change display inline-table on none in math | incremental tree matches full rebuild
-RECREATED: ::before change display block flow on none in inline flow | fixture ancestor
-RECREATED: ::before change display block flow on none in inline flow | distant sibling
-RECREATED: ::before change display block flow on none in inline flow | distant sibling descendant
-RECREATED: ::before change display block flow on none in inline flow | DOM parent
-RECREATED: ::before change display block flow on none in inline flow | preceding sibling
-RECREATED: ::before change display block flow on none in inline flow | preceding sibling descendant
+PRESERVED: ::before change display block flow on none in inline flow | fixture ancestor
+PRESERVED: ::before change display block flow on none in inline flow | distant sibling
+PRESERVED: ::before change display block flow on none in inline flow | distant sibling descendant
+PRESERVED: ::before change display block flow on none in inline flow | DOM parent
+PRESERVED: ::before change display block flow on none in inline flow | preceding sibling
+PRESERVED: ::before change display block flow on none in inline flow | preceding sibling descendant
ABSENT: ::before change display block flow on none in inline flow | target
ABSENT: ::before change display block flow on none in inline flow | target descendant
-RECREATED: ::before change display block flow on none in inline flow | following sibling
-RECREATED: ::before change display block flow on none in inline flow | following sibling descendant
-STATS: ::before change display block flow on none in inline flow | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change display block flow on none in inline flow | following sibling
+PRESERVED: ::before change display block flow on none in inline flow | following sibling descendant
+STATS: ::before change display block flow on none in inline flow | no layout tree build
PASS: ::before change display block flow on none in inline flow | incremental tree matches full rebuild
PRESERVED: ::after remove none on none in block | fixture ancestor
PRESERVED: ::after remove none on none in block | distant sibling
@@ -44,7 +44,7 @@ ABSENT: ::after remove none on none in block | target
ABSENT: ::after remove none on none in block | target descendant
PRESERVED: ::after remove none on none in block | following sibling
PRESERVED: ::after remove none on none in block | following sibling descendant
-STATS: ::after remove none on none in block | rebuilt subtree roots=0, escaped=false
+STATS: ::after remove none on none in block | no layout tree build
PASS: ::after remove none on none in block | incremental tree matches full rebuild
PRESERVED: ::after remove inline-grid on none in inline-table | fixture ancestor
PRESERVED: ::after remove inline-grid on none in inline-table | distant sibling
@@ -56,7 +56,7 @@ ABSENT: ::after remove inline-grid on none in inline-table | target
ABSENT: ::after remove inline-grid on none in inline-table | target descendant
PRESERVED: ::after remove inline-grid on none in inline-table | following sibling
PRESERVED: ::after remove inline-grid on none in inline-table | following sibling descendant
-STATS: ::after remove inline-grid on none in inline-table | rebuilt subtree roots=0, escaped=false
+STATS: ::after remove inline-grid on none in inline-table | no layout tree build
PASS: ::after remove inline-grid on none in inline-table | incremental tree matches full rebuild
PRESERVED: ::after remove table-column on none in block flow | fixture ancestor
PRESERVED: ::after remove table-column on none in block flow | distant sibling
@@ -68,7 +68,7 @@ ABSENT: ::after remove table-column on none in block flow | target
ABSENT: ::after remove table-column on none in block flow | target descendant
PRESERVED: ::after remove table-column on none in block flow | following sibling
PRESERVED: ::after remove table-column on none in block flow | following sibling descendant
-STATS: ::after remove table-column on none in block flow | rebuilt subtree roots=0, escaped=false
+STATS: ::after remove table-column on none in block flow | no layout tree build
PASS: ::after remove table-column on none in block flow | incremental tree matches full rebuild
PRESERVED: ::after remove block flow list-item on none in contents | fixture ancestor
PRESERVED: ::after remove block flow list-item on none in contents | distant sibling
@@ -80,7 +80,7 @@ ABSENT: ::after remove block flow list-item on none in contents | target
ABSENT: ::after remove block flow list-item on none in contents | target descendant
PRESERVED: ::after remove block flow list-item on none in contents | following sibling
PRESERVED: ::after remove block flow list-item on none in contents | following sibling descendant
-STATS: ::after remove block flow list-item on none in contents | rebuilt subtree roots=0, escaped=false
+STATS: ::after remove block flow list-item on none in contents | no layout tree build
PASS: ::after remove block flow list-item on none in contents | incremental tree matches full rebuild
RECREATED: ::before change position inline-flex on contents in inline-grid | fixture ancestor
RECREATED: ::before change position inline-flex on contents in inline-grid | distant sibling
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-4.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-4.txt
index 7e8a1a3f893..6066c1dc4a8 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-4.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-4.txt
@@ -1,74 +1,74 @@
PRESERVED: ::before change float inline on none in flow-root | fixture ancestor
PRESERVED: ::before change float inline on none in flow-root | distant sibling
PRESERVED: ::before change float inline on none in flow-root | distant sibling descendant
-RECREATED: ::before change float inline on none in flow-root | DOM parent
-RECREATED: ::before change float inline on none in flow-root | preceding sibling
-RECREATED: ::before change float inline on none in flow-root | preceding sibling descendant
+PRESERVED: ::before change float inline on none in flow-root | DOM parent
+PRESERVED: ::before change float inline on none in flow-root | preceding sibling
+PRESERVED: ::before change float inline on none in flow-root | preceding sibling descendant
ABSENT: ::before change float inline on none in flow-root | target
ABSENT: ::before change float inline on none in flow-root | target descendant
-RECREATED: ::before change float inline on none in flow-root | following sibling
-RECREATED: ::before change float inline on none in flow-root | following sibling descendant
-STATS: ::before change float inline on none in flow-root | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change float inline on none in flow-root | following sibling
+PRESERVED: ::before change float inline on none in flow-root | following sibling descendant
+STATS: ::before change float inline on none in flow-root | no layout tree build
PASS: ::before change float inline on none in flow-root | incremental tree matches full rebuild
PRESERVED: ::before change float math on none in -webkit-box | fixture ancestor
PRESERVED: ::before change float math on none in -webkit-box | distant sibling
PRESERVED: ::before change float math on none in -webkit-box | distant sibling descendant
-RECREATED: ::before change float math on none in -webkit-box | DOM parent
-RECREATED: ::before change float math on none in -webkit-box | preceding sibling
-RECREATED: ::before change float math on none in -webkit-box | preceding sibling descendant
+PRESERVED: ::before change float math on none in -webkit-box | DOM parent
+PRESERVED: ::before change float math on none in -webkit-box | preceding sibling
+PRESERVED: ::before change float math on none in -webkit-box | preceding sibling descendant
ABSENT: ::before change float math on none in -webkit-box | target
ABSENT: ::before change float math on none in -webkit-box | target descendant
-RECREATED: ::before change float math on none in -webkit-box | following sibling
-RECREATED: ::before change float math on none in -webkit-box | following sibling descendant
-STATS: ::before change float math on none in -webkit-box | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change float math on none in -webkit-box | following sibling
+PRESERVED: ::before change float math on none in -webkit-box | following sibling descendant
+STATS: ::before change float math on none in -webkit-box | no layout tree build
PASS: ::before change float math on none in -webkit-box | incremental tree matches full rebuild
PRESERVED: ::before change float inline flow on none in block flow-root | fixture ancestor
PRESERVED: ::before change float inline flow on none in block flow-root | distant sibling
PRESERVED: ::before change float inline flow on none in block flow-root | distant sibling descendant
-RECREATED: ::before change float inline flow on none in block flow-root | DOM parent
-RECREATED: ::before change float inline flow on none in block flow-root | preceding sibling
-RECREATED: ::before change float inline flow on none in block flow-root | preceding sibling descendant
+PRESERVED: ::before change float inline flow on none in block flow-root | DOM parent
+PRESERVED: ::before change float inline flow on none in block flow-root | preceding sibling
+PRESERVED: ::before change float inline flow on none in block flow-root | preceding sibling descendant
ABSENT: ::before change float inline flow on none in block flow-root | target
ABSENT: ::before change float inline flow on none in block flow-root | target descendant
-RECREATED: ::before change float inline flow on none in block flow-root | following sibling
-RECREATED: ::before change float inline flow on none in block flow-root | following sibling descendant
-STATS: ::before change float inline flow on none in block flow-root | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change float inline flow on none in block flow-root | following sibling
+PRESERVED: ::before change float inline flow on none in block flow-root | following sibling descendant
+STATS: ::before change float inline flow on none in block flow-root | no layout tree build
PASS: ::before change float inline flow on none in block flow-root | incremental tree matches full rebuild
-RECREATED: ::after change display contents on none in inline | fixture ancestor
-RECREATED: ::after change display contents on none in inline | distant sibling
-RECREATED: ::after change display contents on none in inline | distant sibling descendant
-RECREATED: ::after change display contents on none in inline | DOM parent
-RECREATED: ::after change display contents on none in inline | preceding sibling
-RECREATED: ::after change display contents on none in inline | preceding sibling descendant
+PRESERVED: ::after change display contents on none in inline | fixture ancestor
+PRESERVED: ::after change display contents on none in inline | distant sibling
+PRESERVED: ::after change display contents on none in inline | distant sibling descendant
+PRESERVED: ::after change display contents on none in inline | DOM parent
+PRESERVED: ::after change display contents on none in inline | preceding sibling
+PRESERVED: ::after change display contents on none in inline | preceding sibling descendant
ABSENT: ::after change display contents on none in inline | target
ABSENT: ::after change display contents on none in inline | target descendant
-RECREATED: ::after change display contents on none in inline | following sibling
-RECREATED: ::after change display contents on none in inline | following sibling descendant
-STATS: ::after change display contents on none in inline | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change display contents on none in inline | following sibling
+PRESERVED: ::after change display contents on none in inline | following sibling descendant
+STATS: ::after change display contents on none in inline | no layout tree build
PASS: ::after change display contents on none in inline | incremental tree matches full rebuild
-RECREATED: ::after change display table on none in math | fixture ancestor
-RECREATED: ::after change display table on none in math | distant sibling
-RECREATED: ::after change display table on none in math | distant sibling descendant
-RECREATED: ::after change display table on none in math | DOM parent
-RECREATED: ::after change display table on none in math | preceding sibling
-RECREATED: ::after change display table on none in math | preceding sibling descendant
+PRESERVED: ::after change display table on none in math | fixture ancestor
+PRESERVED: ::after change display table on none in math | distant sibling
+PRESERVED: ::after change display table on none in math | distant sibling descendant
+PRESERVED: ::after change display table on none in math | DOM parent
+PRESERVED: ::after change display table on none in math | preceding sibling
+PRESERVED: ::after change display table on none in math | preceding sibling descendant
ABSENT: ::after change display table on none in math | target
ABSENT: ::after change display table on none in math | target descendant
-RECREATED: ::after change display table on none in math | following sibling
-RECREATED: ::after change display table on none in math | following sibling descendant
-STATS: ::after change display table on none in math | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change display table on none in math | following sibling
+PRESERVED: ::after change display table on none in math | following sibling descendant
+STATS: ::after change display table on none in math | no layout tree build
PASS: ::after change display table on none in math | incremental tree matches full rebuild
-RECREATED: ::after change display table-caption on none in inline flow | fixture ancestor
-RECREATED: ::after change display table-caption on none in inline flow | distant sibling
-RECREATED: ::after change display table-caption on none in inline flow | distant sibling descendant
-RECREATED: ::after change display table-caption on none in inline flow | DOM parent
-RECREATED: ::after change display table-caption on none in inline flow | preceding sibling
-RECREATED: ::after change display table-caption on none in inline flow | preceding sibling descendant
+PRESERVED: ::after change display table-caption on none in inline flow | fixture ancestor
+PRESERVED: ::after change display table-caption on none in inline flow | distant sibling
+PRESERVED: ::after change display table-caption on none in inline flow | distant sibling descendant
+PRESERVED: ::after change display table-caption on none in inline flow | DOM parent
+PRESERVED: ::after change display table-caption on none in inline flow | preceding sibling
+PRESERVED: ::after change display table-caption on none in inline flow | preceding sibling descendant
ABSENT: ::after change display table-caption on none in inline flow | target
ABSENT: ::after change display table-caption on none in inline flow | target descendant
-RECREATED: ::after change display table-caption on none in inline flow | following sibling
-RECREATED: ::after change display table-caption on none in inline flow | following sibling descendant
-STATS: ::after change display table-caption on none in inline flow | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change display table-caption on none in inline flow | following sibling
+PRESERVED: ::after change display table-caption on none in inline flow | following sibling descendant
+STATS: ::after change display table-caption on none in inline flow | no layout tree build
PASS: ::after change display table-caption on none in inline flow | incremental tree matches full rebuild
PRESERVED: ::after change display inline flow list-item on none in block | fixture ancestor
PRESERVED: ::after change display inline flow list-item on none in block | distant sibling
@@ -80,7 +80,7 @@ ABSENT: ::after change display inline flow list-item on none in block | target
ABSENT: ::after change display inline flow list-item on none in block | target descendant
PRESERVED: ::after change display inline flow list-item on none in block | following sibling
PRESERVED: ::after change display inline flow list-item on none in block | following sibling descendant
-STATS: ::after change display inline flow list-item on none in block | rebuilt subtree roots=0, escaped=false
+STATS: ::after change display inline flow list-item on none in block | no layout tree build
PASS: ::after change display inline flow list-item on none in block | incremental tree matches full rebuild
RECREATED: ::before create grid on contents in table | fixture ancestor
RECREATED: ::before create grid on contents in table | distant sibling
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-5.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-5.txt
index 0b35c9d8a90..df301e9a1aa 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-5.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-5.txt
@@ -37,38 +37,38 @@ PASS: ::before change clear block flow-root on none in inline flow-root | increm
PRESERVED: ::after change float block on none in flow-root | fixture ancestor
PRESERVED: ::after change float block on none in flow-root | distant sibling
PRESERVED: ::after change float block on none in flow-root | distant sibling descendant
-RECREATED: ::after change float block on none in flow-root | DOM parent
-RECREATED: ::after change float block on none in flow-root | preceding sibling
-RECREATED: ::after change float block on none in flow-root | preceding sibling descendant
+PRESERVED: ::after change float block on none in flow-root | DOM parent
+PRESERVED: ::after change float block on none in flow-root | preceding sibling
+PRESERVED: ::after change float block on none in flow-root | preceding sibling descendant
ABSENT: ::after change float block on none in flow-root | target
ABSENT: ::after change float block on none in flow-root | target descendant
-RECREATED: ::after change float block on none in flow-root | following sibling
-RECREATED: ::after change float block on none in flow-root | following sibling descendant
-STATS: ::after change float block on none in flow-root | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change float block on none in flow-root | following sibling
+PRESERVED: ::after change float block on none in flow-root | following sibling descendant
+STATS: ::after change float block on none in flow-root | no layout tree build
PASS: ::after change float block on none in flow-root | incremental tree matches full rebuild
PRESERVED: ::after change float inline-table on none in -webkit-box | fixture ancestor
PRESERVED: ::after change float inline-table on none in -webkit-box | distant sibling
PRESERVED: ::after change float inline-table on none in -webkit-box | distant sibling descendant
-RECREATED: ::after change float inline-table on none in -webkit-box | DOM parent
-RECREATED: ::after change float inline-table on none in -webkit-box | preceding sibling
-RECREATED: ::after change float inline-table on none in -webkit-box | preceding sibling descendant
+PRESERVED: ::after change float inline-table on none in -webkit-box | DOM parent
+PRESERVED: ::after change float inline-table on none in -webkit-box | preceding sibling
+PRESERVED: ::after change float inline-table on none in -webkit-box | preceding sibling descendant
ABSENT: ::after change float inline-table on none in -webkit-box | target
ABSENT: ::after change float inline-table on none in -webkit-box | target descendant
-RECREATED: ::after change float inline-table on none in -webkit-box | following sibling
-RECREATED: ::after change float inline-table on none in -webkit-box | following sibling descendant
-STATS: ::after change float inline-table on none in -webkit-box | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change float inline-table on none in -webkit-box | following sibling
+PRESERVED: ::after change float inline-table on none in -webkit-box | following sibling descendant
+STATS: ::after change float inline-table on none in -webkit-box | no layout tree build
PASS: ::after change float inline-table on none in -webkit-box | incremental tree matches full rebuild
PRESERVED: ::after change float block flow on none in block flow-root | fixture ancestor
PRESERVED: ::after change float block flow on none in block flow-root | distant sibling
PRESERVED: ::after change float block flow on none in block flow-root | distant sibling descendant
-RECREATED: ::after change float block flow on none in block flow-root | DOM parent
-RECREATED: ::after change float block flow on none in block flow-root | preceding sibling
-RECREATED: ::after change float block flow on none in block flow-root | preceding sibling descendant
+PRESERVED: ::after change float block flow on none in block flow-root | DOM parent
+PRESERVED: ::after change float block flow on none in block flow-root | preceding sibling
+PRESERVED: ::after change float block flow on none in block flow-root | preceding sibling descendant
ABSENT: ::after change float block flow on none in block flow-root | target
ABSENT: ::after change float block flow on none in block flow-root | target descendant
-RECREATED: ::after change float block flow on none in block flow-root | following sibling
-RECREATED: ::after change float block flow on none in block flow-root | following sibling descendant
-STATS: ::after change float block flow on none in block flow-root | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change float block flow on none in block flow-root | following sibling
+PRESERVED: ::after change float block flow on none in block flow-root | following sibling descendant
+STATS: ::after change float block flow on none in block flow-root | no layout tree build
PASS: ::after change float block flow on none in block flow-root | incremental tree matches full rebuild
PRESERVED: ::before remove none on contents in block | fixture ancestor
PRESERVED: ::before remove none on contents in block | distant sibling
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-6.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-6.txt
index ecfe75e7113..c2d47d5a186 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-6.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-6.txt
@@ -1,38 +1,38 @@
PRESERVED: ::before change position inline-block on none in run-in | fixture ancestor
PRESERVED: ::before change position inline-block on none in run-in | distant sibling
PRESERVED: ::before change position inline-block on none in run-in | distant sibling descendant
-RECREATED: ::before change position inline-block on none in run-in | DOM parent
-RECREATED: ::before change position inline-block on none in run-in | preceding sibling
-RECREATED: ::before change position inline-block on none in run-in | preceding sibling descendant
+PRESERVED: ::before change position inline-block on none in run-in | DOM parent
+PRESERVED: ::before change position inline-block on none in run-in | preceding sibling
+PRESERVED: ::before change position inline-block on none in run-in | preceding sibling descendant
ABSENT: ::before change position inline-block on none in run-in | target
ABSENT: ::before change position inline-block on none in run-in | target descendant
-RECREATED: ::before change position inline-block on none in run-in | following sibling
-RECREATED: ::before change position inline-block on none in run-in | following sibling descendant
-STATS: ::before change position inline-block on none in run-in | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change position inline-block on none in run-in | following sibling
+PRESERVED: ::before change position inline-block on none in run-in | following sibling descendant
+STATS: ::before change position inline-block on none in run-in | no layout tree build
PASS: ::before change position inline-block on none in run-in | incremental tree matches full rebuild
-RECREATED: ::before change position -webkit-inline-box on none in table-row-group | fixture ancestor
-RECREATED: ::before change position -webkit-inline-box on none in table-row-group | distant sibling
-RECREATED: ::before change position -webkit-inline-box on none in table-row-group | distant sibling descendant
-RECREATED: ::before change position -webkit-inline-box on none in table-row-group | DOM parent
-RECREATED: ::before change position -webkit-inline-box on none in table-row-group | preceding sibling
-RECREATED: ::before change position -webkit-inline-box on none in table-row-group | preceding sibling descendant
+PRESERVED: ::before change position -webkit-inline-box on none in table-row-group | fixture ancestor
+PRESERVED: ::before change position -webkit-inline-box on none in table-row-group | distant sibling
+PRESERVED: ::before change position -webkit-inline-box on none in table-row-group | distant sibling descendant
+PRESERVED: ::before change position -webkit-inline-box on none in table-row-group | DOM parent
+PRESERVED: ::before change position -webkit-inline-box on none in table-row-group | preceding sibling
+PRESERVED: ::before change position -webkit-inline-box on none in table-row-group | preceding sibling descendant
ABSENT: ::before change position -webkit-inline-box on none in table-row-group | target
ABSENT: ::before change position -webkit-inline-box on none in table-row-group | target descendant
-RECREATED: ::before change position -webkit-inline-box on none in table-row-group | following sibling
-RECREATED: ::before change position -webkit-inline-box on none in table-row-group | following sibling descendant
-STATS: ::before change position -webkit-inline-box on none in table-row-group | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change position -webkit-inline-box on none in table-row-group | following sibling
+PRESERVED: ::before change position -webkit-inline-box on none in table-row-group | following sibling descendant
+STATS: ::before change position -webkit-inline-box on none in table-row-group | no layout tree build
PASS: ::before change position -webkit-inline-box on none in table-row-group | incremental tree matches full rebuild
PRESERVED: ::before change position inline flow-root on none in block flex | fixture ancestor
PRESERVED: ::before change position inline flow-root on none in block flex | distant sibling
PRESERVED: ::before change position inline flow-root on none in block flex | distant sibling descendant
-RECREATED: ::before change position inline flow-root on none in block flex | DOM parent
-RECREATED: ::before change position inline flow-root on none in block flex | preceding sibling
-RECREATED: ::before change position inline flow-root on none in block flex | preceding sibling descendant
+PRESERVED: ::before change position inline flow-root on none in block flex | DOM parent
+PRESERVED: ::before change position inline flow-root on none in block flex | preceding sibling
+PRESERVED: ::before change position inline flow-root on none in block flex | preceding sibling descendant
ABSENT: ::before change position inline flow-root on none in block flex | target
ABSENT: ::before change position inline flow-root on none in block flex | target descendant
-RECREATED: ::before change position inline flow-root on none in block flex | following sibling
-RECREATED: ::before change position inline flow-root on none in block flex | following sibling descendant
-STATS: ::before change position inline flow-root on none in block flex | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change position inline flow-root on none in block flex | following sibling
+PRESERVED: ::before change position inline flow-root on none in block flex | following sibling descendant
+STATS: ::before change position inline flow-root on none in block flex | no layout tree build
PASS: ::before change position inline flow-root on none in block flex | incremental tree matches full rebuild
PRESERVED: ::after change clear inline on none in inline-block | fixture ancestor
PRESERVED: ::after change clear inline on none in inline-block | distant sibling
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-7.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-7.txt
index 0b6bca6855d..fc3c2fab4fe 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-7.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-7.txt
@@ -8,7 +8,7 @@ ABSENT: ::before create run-in on none in list-item | target
ABSENT: ::before create run-in on none in list-item | target descendant
PRESERVED: ::before create run-in on none in list-item | following sibling
PRESERVED: ::before create run-in on none in list-item | following sibling descendant
-STATS: ::before create run-in on none in list-item | rebuilt subtree roots=0, escaped=false
+STATS: ::before create run-in on none in list-item | no layout tree build
PASS: ::before create run-in on none in list-item | incremental tree matches full rebuild
PRESERVED: ::before create table-row-group on none in table-header-group | fixture ancestor
PRESERVED: ::before create table-row-group on none in table-header-group | distant sibling
@@ -20,7 +20,7 @@ ABSENT: ::before create table-row-group on none in table-header-group | target
ABSENT: ::before create table-row-group on none in table-header-group | target descendant
PRESERVED: ::before create table-row-group on none in table-header-group | following sibling
PRESERVED: ::before create table-row-group on none in table-header-group | following sibling descendant
-STATS: ::before create table-row-group on none in table-header-group | rebuilt subtree roots=0, escaped=false
+STATS: ::before create table-row-group on none in table-header-group | no layout tree build
PASS: ::before create table-row-group on none in table-header-group | incremental tree matches full rebuild
PRESERVED: ::before create block flex on none in inline flex | fixture ancestor
PRESERVED: ::before create block flex on none in inline flex | distant sibling
@@ -32,43 +32,43 @@ ABSENT: ::before create block flex on none in inline flex | target
ABSENT: ::before create block flex on none in inline flex | target descendant
PRESERVED: ::before create block flex on none in inline flex | following sibling
PRESERVED: ::before create block flex on none in inline flex | following sibling descendant
-STATS: ::before create block flex on none in inline flex | rebuilt subtree roots=0, escaped=false
+STATS: ::before create block flex on none in inline flex | no layout tree build
PASS: ::before create block flex on none in inline flex | incremental tree matches full rebuild
PRESERVED: ::after change position flow-root on none in run-in | fixture ancestor
PRESERVED: ::after change position flow-root on none in run-in | distant sibling
PRESERVED: ::after change position flow-root on none in run-in | distant sibling descendant
-RECREATED: ::after change position flow-root on none in run-in | DOM parent
-RECREATED: ::after change position flow-root on none in run-in | preceding sibling
-RECREATED: ::after change position flow-root on none in run-in | preceding sibling descendant
+PRESERVED: ::after change position flow-root on none in run-in | DOM parent
+PRESERVED: ::after change position flow-root on none in run-in | preceding sibling
+PRESERVED: ::after change position flow-root on none in run-in | preceding sibling descendant
ABSENT: ::after change position flow-root on none in run-in | target
ABSENT: ::after change position flow-root on none in run-in | target descendant
-RECREATED: ::after change position flow-root on none in run-in | following sibling
-RECREATED: ::after change position flow-root on none in run-in | following sibling descendant
-STATS: ::after change position flow-root on none in run-in | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change position flow-root on none in run-in | following sibling
+PRESERVED: ::after change position flow-root on none in run-in | following sibling descendant
+STATS: ::after change position flow-root on none in run-in | no layout tree build
PASS: ::after change position flow-root on none in run-in | incremental tree matches full rebuild
-RECREATED: ::after change position -webkit-box on none in table-row-group | fixture ancestor
-RECREATED: ::after change position -webkit-box on none in table-row-group | distant sibling
-RECREATED: ::after change position -webkit-box on none in table-row-group | distant sibling descendant
-RECREATED: ::after change position -webkit-box on none in table-row-group | DOM parent
-RECREATED: ::after change position -webkit-box on none in table-row-group | preceding sibling
-RECREATED: ::after change position -webkit-box on none in table-row-group | preceding sibling descendant
+PRESERVED: ::after change position -webkit-box on none in table-row-group | fixture ancestor
+PRESERVED: ::after change position -webkit-box on none in table-row-group | distant sibling
+PRESERVED: ::after change position -webkit-box on none in table-row-group | distant sibling descendant
+PRESERVED: ::after change position -webkit-box on none in table-row-group | DOM parent
+PRESERVED: ::after change position -webkit-box on none in table-row-group | preceding sibling
+PRESERVED: ::after change position -webkit-box on none in table-row-group | preceding sibling descendant
ABSENT: ::after change position -webkit-box on none in table-row-group | target
ABSENT: ::after change position -webkit-box on none in table-row-group | target descendant
-RECREATED: ::after change position -webkit-box on none in table-row-group | following sibling
-RECREATED: ::after change position -webkit-box on none in table-row-group | following sibling descendant
-STATS: ::after change position -webkit-box on none in table-row-group | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change position -webkit-box on none in table-row-group | following sibling
+PRESERVED: ::after change position -webkit-box on none in table-row-group | following sibling descendant
+STATS: ::after change position -webkit-box on none in table-row-group | no layout tree build
PASS: ::after change position -webkit-box on none in table-row-group | incremental tree matches full rebuild
PRESERVED: ::after change position block flow-root on none in block flex | fixture ancestor
PRESERVED: ::after change position block flow-root on none in block flex | distant sibling
PRESERVED: ::after change position block flow-root on none in block flex | distant sibling descendant
-RECREATED: ::after change position block flow-root on none in block flex | DOM parent
-RECREATED: ::after change position block flow-root on none in block flex | preceding sibling
-RECREATED: ::after change position block flow-root on none in block flex | preceding sibling descendant
+PRESERVED: ::after change position block flow-root on none in block flex | DOM parent
+PRESERVED: ::after change position block flow-root on none in block flex | preceding sibling
+PRESERVED: ::after change position block flow-root on none in block flex | preceding sibling descendant
ABSENT: ::after change position block flow-root on none in block flex | target
ABSENT: ::after change position block flow-root on none in block flex | target descendant
-RECREATED: ::after change position block flow-root on none in block flex | following sibling
-RECREATED: ::after change position block flow-root on none in block flex | following sibling descendant
-STATS: ::after change position block flow-root on none in block flex | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::after change position block flow-root on none in block flex | following sibling
+PRESERVED: ::after change position block flow-root on none in block flex | following sibling descendant
+STATS: ::after change position block flow-root on none in block flex | no layout tree build
PASS: ::after change position block flow-root on none in block flex | incremental tree matches full rebuild
PRESERVED: ::before change float block on contents in flow-root | fixture ancestor
PRESERVED: ::before change float block on contents in flow-root | distant sibling
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-8.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-8.txt
index c44aff77437..bcedd5f5414 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-8.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-8.txt
@@ -8,7 +8,7 @@ ABSENT: ::before remove list-item on none in inline list-item | target
ABSENT: ::before remove list-item on none in inline list-item | target descendant
PRESERVED: ::before remove list-item on none in inline list-item | following sibling
PRESERVED: ::before remove list-item on none in inline list-item | following sibling descendant
-STATS: ::before remove list-item on none in inline list-item | rebuilt subtree roots=0, escaped=false
+STATS: ::before remove list-item on none in inline list-item | no layout tree build
PASS: ::before remove list-item on none in inline list-item | incremental tree matches full rebuild
PRESERVED: ::before remove table-header-group on none in table-footer-group | fixture ancestor
PRESERVED: ::before remove table-header-group on none in table-footer-group | distant sibling
@@ -20,7 +20,7 @@ ABSENT: ::before remove table-header-group on none in table-footer-group | targe
ABSENT: ::before remove table-header-group on none in table-footer-group | target descendant
PRESERVED: ::before remove table-header-group on none in table-footer-group | following sibling
PRESERVED: ::before remove table-header-group on none in table-footer-group | following sibling descendant
-STATS: ::before remove table-header-group on none in table-footer-group | rebuilt subtree roots=0, escaped=false
+STATS: ::before remove table-header-group on none in table-footer-group | no layout tree build
PASS: ::before remove table-header-group on none in table-footer-group | incremental tree matches full rebuild
PRESERVED: ::before remove inline flex on none in block grid | fixture ancestor
PRESERVED: ::before remove inline flex on none in block grid | distant sibling
@@ -32,7 +32,7 @@ ABSENT: ::before remove inline flex on none in block grid | target
ABSENT: ::before remove inline flex on none in block grid | target descendant
PRESERVED: ::before remove inline flex on none in block grid | following sibling
PRESERVED: ::before remove inline flex on none in block grid | following sibling descendant
-STATS: ::before remove inline flex on none in block grid | rebuilt subtree roots=0, escaped=false
+STATS: ::before remove inline flex on none in block grid | no layout tree build
PASS: ::before remove inline flex on none in block grid | incremental tree matches full rebuild
PRESERVED: ::after create inline-block on none in list-item | fixture ancestor
PRESERVED: ::after create inline-block on none in list-item | distant sibling
@@ -44,7 +44,7 @@ ABSENT: ::after create inline-block on none in list-item | target
ABSENT: ::after create inline-block on none in list-item | target descendant
PRESERVED: ::after create inline-block on none in list-item | following sibling
PRESERVED: ::after create inline-block on none in list-item | following sibling descendant
-STATS: ::after create inline-block on none in list-item | rebuilt subtree roots=0, escaped=false
+STATS: ::after create inline-block on none in list-item | no layout tree build
PASS: ::after create inline-block on none in list-item | incremental tree matches full rebuild
PRESERVED: ::after create -webkit-inline-box on none in table-header-group | fixture ancestor
PRESERVED: ::after create -webkit-inline-box on none in table-header-group | distant sibling
@@ -56,7 +56,7 @@ ABSENT: ::after create -webkit-inline-box on none in table-header-group | target
ABSENT: ::after create -webkit-inline-box on none in table-header-group | target descendant
PRESERVED: ::after create -webkit-inline-box on none in table-header-group | following sibling
PRESERVED: ::after create -webkit-inline-box on none in table-header-group | following sibling descendant
-STATS: ::after create -webkit-inline-box on none in table-header-group | rebuilt subtree roots=0, escaped=false
+STATS: ::after create -webkit-inline-box on none in table-header-group | no layout tree build
PASS: ::after create -webkit-inline-box on none in table-header-group | incremental tree matches full rebuild
PRESERVED: ::after create inline flow-root on none in inline flex | fixture ancestor
PRESERVED: ::after create inline flow-root on none in inline flex | distant sibling
@@ -68,7 +68,7 @@ ABSENT: ::after create inline flow-root on none in inline flex | target
ABSENT: ::after create inline flow-root on none in inline flex | target descendant
PRESERVED: ::after create inline flow-root on none in inline flex | following sibling
PRESERVED: ::after create inline flow-root on none in inline flex | following sibling descendant
-STATS: ::after create inline flow-root on none in inline flex | rebuilt subtree roots=0, escaped=false
+STATS: ::after create inline flow-root on none in inline flex | no layout tree build
PASS: ::after create inline flow-root on none in inline flex | incremental tree matches full rebuild
PRESERVED: ::before change clear inline on contents in inline-block | fixture ancestor
PRESERVED: ::before change clear inline on contents in inline-block | distant sibling
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-9.txt b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-9.txt
index b4153522ea7..0d35ae0b002 100644
--- a/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-9.txt
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/style-invalidation-scope-pseudo-elements-9.txt
@@ -1,38 +1,38 @@
PRESERVED: ::before change display inline list-item on none in flex | fixture ancestor
PRESERVED: ::before change display inline list-item on none in flex | distant sibling
PRESERVED: ::before change display inline list-item on none in flex | distant sibling descendant
-RECREATED: ::before change display inline list-item on none in flex | DOM parent
-RECREATED: ::before change display inline list-item on none in flex | preceding sibling
-RECREATED: ::before change display inline list-item on none in flex | preceding sibling descendant
+PRESERVED: ::before change display inline list-item on none in flex | DOM parent
+PRESERVED: ::before change display inline list-item on none in flex | preceding sibling
+PRESERVED: ::before change display inline list-item on none in flex | preceding sibling descendant
ABSENT: ::before change display inline list-item on none in flex | target
ABSENT: ::before change display inline list-item on none in flex | target descendant
-RECREATED: ::before change display inline list-item on none in flex | following sibling
-RECREATED: ::before change display inline list-item on none in flex | following sibling descendant
-STATS: ::before change display inline list-item on none in flex | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change display inline list-item on none in flex | following sibling
+PRESERVED: ::before change display inline list-item on none in flex | following sibling descendant
+STATS: ::before change display inline list-item on none in flex | no layout tree build
PASS: ::before change display inline list-item on none in flex | incremental tree matches full rebuild
-RECREATED: ::before change display table-footer-group on none in table-row | fixture ancestor
-RECREATED: ::before change display table-footer-group on none in table-row | distant sibling
-RECREATED: ::before change display table-footer-group on none in table-row | distant sibling descendant
-RECREATED: ::before change display table-footer-group on none in table-row | DOM parent
-RECREATED: ::before change display table-footer-group on none in table-row | preceding sibling
-RECREATED: ::before change display table-footer-group on none in table-row | preceding sibling descendant
+PRESERVED: ::before change display table-footer-group on none in table-row | fixture ancestor
+PRESERVED: ::before change display table-footer-group on none in table-row | distant sibling
+PRESERVED: ::before change display table-footer-group on none in table-row | distant sibling descendant
+PRESERVED: ::before change display table-footer-group on none in table-row | DOM parent
+PRESERVED: ::before change display table-footer-group on none in table-row | preceding sibling
+PRESERVED: ::before change display table-footer-group on none in table-row | preceding sibling descendant
ABSENT: ::before change display table-footer-group on none in table-row | target
ABSENT: ::before change display table-footer-group on none in table-row | target descendant
-RECREATED: ::before change display table-footer-group on none in table-row | following sibling
-RECREATED: ::before change display table-footer-group on none in table-row | following sibling descendant
-STATS: ::before change display table-footer-group on none in table-row | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change display table-footer-group on none in table-row | following sibling
+PRESERVED: ::before change display table-footer-group on none in table-row | following sibling descendant
+STATS: ::before change display table-footer-group on none in table-row | no layout tree build
PASS: ::before change display table-footer-group on none in table-row | incremental tree matches full rebuild
-RECREATED: ::before change display block grid on none in inline grid | fixture ancestor
-RECREATED: ::before change display block grid on none in inline grid | distant sibling
-RECREATED: ::before change display block grid on none in inline grid | distant sibling descendant
-RECREATED: ::before change display block grid on none in inline grid | DOM parent
-RECREATED: ::before change display block grid on none in inline grid | preceding sibling
-RECREATED: ::before change display block grid on none in inline grid | preceding sibling descendant
+PRESERVED: ::before change display block grid on none in inline grid | fixture ancestor
+PRESERVED: ::before change display block grid on none in inline grid | distant sibling
+PRESERVED: ::before change display block grid on none in inline grid | distant sibling descendant
+PRESERVED: ::before change display block grid on none in inline grid | DOM parent
+PRESERVED: ::before change display block grid on none in inline grid | preceding sibling
+PRESERVED: ::before change display block grid on none in inline grid | preceding sibling descendant
ABSENT: ::before change display block grid on none in inline grid | target
ABSENT: ::before change display block grid on none in inline grid | target descendant
-RECREATED: ::before change display block grid on none in inline grid | following sibling
-RECREATED: ::before change display block grid on none in inline grid | following sibling descendant
-STATS: ::before change display block grid on none in inline grid | rebuilt subtree roots=1, escaped=false
+PRESERVED: ::before change display block grid on none in inline grid | following sibling
+PRESERVED: ::before change display block grid on none in inline grid | following sibling descendant
+STATS: ::before change display block grid on none in inline grid | no layout tree build
PASS: ::before change display block grid on none in inline grid | incremental tree matches full rebuild
PRESERVED: ::after remove run-in on none in inline list-item | fixture ancestor
PRESERVED: ::after remove run-in on none in inline list-item | distant sibling
@@ -44,7 +44,7 @@ ABSENT: ::after remove run-in on none in inline list-item | target
ABSENT: ::after remove run-in on none in inline list-item | target descendant
PRESERVED: ::after remove run-in on none in inline list-item | following sibling
PRESERVED: ::after remove run-in on none in inline list-item | following sibling descendant
-STATS: ::after remove run-in on none in inline list-item | rebuilt subtree roots=0, escaped=false
+STATS: ::after remove run-in on none in inline list-item | no layout tree build
PASS: ::after remove run-in on none in inline list-item | incremental tree matches full rebuild
PRESERVED: ::after remove table-row-group on none in table-footer-group | fixture ancestor
PRESERVED: ::after remove table-row-group on none in table-footer-group | distant sibling
@@ -56,7 +56,7 @@ ABSENT: ::after remove table-row-group on none in table-footer-group | target
ABSENT: ::after remove table-row-group on none in table-footer-group | target descendant
PRESERVED: ::after remove table-row-group on none in table-footer-group | following sibling
PRESERVED: ::after remove table-row-group on none in table-footer-group | following sibling descendant
-STATS: ::after remove table-row-group on none in table-footer-group | rebuilt subtree roots=0, escaped=false
+STATS: ::after remove table-row-group on none in table-footer-group | no layout tree build
PASS: ::after remove table-row-group on none in table-footer-group | incremental tree matches full rebuild
PRESERVED: ::after remove block flex on none in block grid | fixture ancestor
PRESERVED: ::after remove block flex on none in block grid | distant sibling
@@ -68,7 +68,7 @@ ABSENT: ::after remove block flex on none in block grid | target
ABSENT: ::after remove block flex on none in block grid | target descendant
PRESERVED: ::after remove block flex on none in block grid | following sibling
PRESERVED: ::after remove block flex on none in block grid | following sibling descendant
-STATS: ::after remove block flex on none in block grid | rebuilt subtree roots=0, escaped=false
+STATS: ::after remove block flex on none in block grid | no layout tree build
PASS: ::after remove block flex on none in block grid | incremental tree matches full rebuild
PRESERVED: ::before change position flow-root on contents in run-in | fixture ancestor
PRESERVED: ::before change position flow-root on contents in run-in | distant sibling
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/animation-promise-rejected-by-a-style-drain.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/animation-promise-rejected-by-a-style-drain.html
new file mode 100644
index 00000000000..fdc78f39f52
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/animation-promise-rejected-by-a-style-drain.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ @keyframes move { from { margin-left: 0 } to { margin-left: 100px } }
+ #box.animated { animation: move 1000s linear; }
+</style>
+<div id="box" class="animated"></div>
+<script>
+ // The animation goes away with the style its rendering update computes, and the drain of that style update rejects
+ // its finished promise between two tasks. The update holds back the tasks of the document until then, and goes no
+ // further as its layout flies, so the first of them comes right after the drain. The reaction runs in the checkpoint
+ // before it, not in the one after it.
+ asyncTest(async done => {
+ await twoFramesLanded();
+ const [animation] = box.getAnimations();
+ let reacted = false;
+ animation.finished.catch(error => {
+ reacted = true;
+ println(`finished promise rejected: ${error.name}`);
+ });
+ await whileRecordingInFlight(
+ () => box.classList.remove("animated"),
+ state => println(`beside the layout: ${state}, the reaction ran before this task: ${reacted}`),
+ "layout"
+ );
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/element-moved-beside-the-layout-that-builds-its-box.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/element-moved-beside-the-layout-that-builds-its-box.html
new file mode 100644
index 00000000000..ea298dce107
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/element-moved-beside-the-layout-that-builds-its-box.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<div id="target"><span id="reference"></span></div>
+<div id="source"></div>
+<script>
+ // An element moved beside the layout that builds its box leaves nothing of that box where it was.
+ asyncTest(async done => {
+ const built = document.createElement("table");
+ await twoFramesLanded();
+ internals.setManualRenderingOpportunities(true);
+ requestAnimationFrame(() => {
+ internals.holdNextFrame("layout");
+ source.append(built);
+ });
+ internals.injectRenderingOpportunity(performance.now());
+ while (internals.frameSchedulerState() !== "laying-out")
+ await nextTask();
+ target.moveBefore(built, reference);
+ internals.releaseHeldFrame();
+ while (internals.frameSchedulerState() !== "idle")
+ await nextTask();
+ internals.setManualRenderingOpportunities(false);
+ await twoFramesLanded();
+ println(`source height: ${source.offsetHeight}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/element-removed-beside-a-layout-taken-in-after-a-publication.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/element-removed-beside-a-layout-taken-in-after-a-publication.html
new file mode 100644
index 00000000000..9b97b8074ba
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/element-removed-beside-a-layout-taken-in-after-a-publication.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ #box.wide { width: 200px; }
+ #target { height: 10px; }
+ #previous + #target { height: 20px; }
+</style>
+<div id="box"></div>
+<div id="previous"></div>
+<div id="target"></div>
+<div id="host"><span id="slotted"></span></div>
+<script>
+ // The update takes the last update's layout in behind its animation frame callbacks, with what they wrote set aside
+ // until it has. Assigning a slot publishes the rows, and the element removed after it is published as the update
+ // reads the layout's size containers: the rows of the later publication hold the earlier one's, which has to go
+ // ahead of it for the removal to stand.
+ asyncTest(async done => {
+ await twoFramesLanded();
+ internals.setManualRenderingOpportunities(true);
+ const slot = document.createElement("slot");
+ host.attachShadow({ mode: "open", slotAssignment: "manual" }).append(slot);
+ println(`height before: ${target.offsetHeight}`);
+ requestAnimationFrame(() => {
+ internals.holdNextFrame("layout");
+ box.classList.add("wide");
+ });
+ internals.injectRenderingOpportunity(performance.now());
+ while (internals.frameSchedulerState() !== "laying-out")
+ await nextTask();
+ const { promise, resolve } = Promise.withResolvers();
+ requestAnimationFrame(() => {
+ slot.assign(slotted);
+ previous.remove();
+ internals.releaseHeldFrame();
+ resolve();
+ });
+ internals.injectRenderingOpportunity(performance.now());
+ await promise;
+ while (internals.frameSchedulerState() !== "idle")
+ await nextTask();
+ println(`height after: ${target.offsetHeight}`);
+ println(`computed height: ${getComputedStyle(target).height}`);
+ internals.setManualRenderingOpportunities(false);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/element-removed-beside-the-layout-that-builds-its-box.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/element-removed-beside-the-layout-that-builds-its-box.html
new file mode 100644
index 00000000000..afc08f8a14a
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/element-removed-beside-the-layout-that-builds-its-box.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<div id="source"></div>
+<script>
+ // An element removed beside the layout that builds its box leaves nothing of that box behind.
+ asyncTest(async done => {
+ const built = document.createElement("table");
+ await twoFramesLanded();
+ internals.setManualRenderingOpportunities(true);
+ requestAnimationFrame(() => {
+ internals.holdNextFrame("layout");
+ source.append(built);
+ });
+ internals.injectRenderingOpportunity(performance.now());
+ while (internals.frameSchedulerState() !== "laying-out")
+ await nextTask();
+ built.remove();
+ internals.releaseHeldFrame();
+ while (internals.frameSchedulerState() !== "idle")
+ await nextTask();
+ internals.setManualRenderingOpportunities(false);
+ await twoFramesLanded();
+ println(`source height: ${source.offsetHeight}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/elements-arriving-beside-a-style-drain-that-publishes.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/elements-arriving-beside-a-style-drain-that-publishes.html
new file mode 100644
index 00000000000..1f5f1634259
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/elements-arriving-beside-a-style-drain-that-publishes.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ #box.moved { color: rgb(1, 2, 3); }
+ #kid { height: 7px; }
+ #kid.taller { height: 9px; }
+</style>
+<div id="box"></div>
+<div id="host"></div>
+<div id="other"></div>
+<script>
+ // The elements added beside the flight arrive with a publication the drain of the style update holds, and the
+ // shadow tree of the text control, which the drain builds, with one it does not hold. The arrivals have to be taken
+ // in ahead of the later publication: the child's restyle computes from a style its parent holds.
+ asyncTest(async done => {
+ await twoFramesLanded();
+ await new Promise(resolve => {
+ requestAnimationFrame(() => {
+ internals.holdNextFrame("layout");
+ internals.setManualRenderingOpportunities(true);
+ box.classList.add("moved");
+ const input = document.createElement("input");
+ input.value = "text";
+ other.append(input);
+ setTimeout(resolve, 0);
+ });
+ });
+ println(`a frame is in flight: ${internals.frameSchedulerState() !== "idle"}`);
+ const parent = document.createElement("div");
+ const kid = document.createElement("div");
+ kid.id = "kid";
+ parent.append(kid);
+ host.append(parent);
+ println(`height before: ${kid.offsetHeight}`);
+ internals.releaseHeldFrame();
+ while (internals.frameSchedulerState() !== "idle")
+ await nextTask();
+ kid.classList.add("taller");
+ println(`height after: ${kid.offsetHeight}`);
+ internals.setManualRenderingOpportunities(false);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/font-table-change-beside-a-style-drain-that-publishes.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/font-table-change-beside-a-style-drain-that-publishes.html
new file mode 100644
index 00000000000..90d3c4432c3
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/font-table-change-beside-a-style-drain-that-publishes.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<span id="text" style="font: 20px monospace">beside the frame</span>
+<script>
+ // A transaction that flies past a change to the @font-face table resolves the font it selects against the older
+ // table, into a cascade of its own. The text control the drain builds publishes the newer table ahead of the end of
+ // the drain, which still takes the cascade in, so that the face the element waits on reaches it once it loads.
+ asyncTest(async done => {
+ await twoFramesLanded();
+ const widthWithoutFace = text.offsetWidth;
+ const face = new FontFace("WaitingFace", "url(../../../../Assets/HashSans.woff)");
+ document.fonts.add(face);
+ await twoFramesLanded();
+ await whileRecordingInFlight(() => {
+ text.style.fontFamily = "WaitingFace, monospace";
+ document.body.append(document.createElement("input"));
+ }, () => {
+ document.fonts.add(new FontFace("OtherFace", "url(../../../../Assets/HashSans.woff)"));
+ }, "style");
+ await twoFramesLanded();
+ await face.load();
+ await twoFramesLanded();
+ println(`the text is set in the face: ${text.offsetWidth !== widthWithoutFace}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/frame-in-flight.js b/Tests/LibWeb/Text/input/HTML/frame-in-flight/frame-in-flight.js
index 0183bb08c12..4cbdcc3be13 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/frame-in-flight.js
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/frame-in-flight.js
@@ -4,13 +4,14 @@
// paints, and holds the recording that update lets fly. `during` then runs in a task while the recording is held, and
// gets the frame scheduler's state then. The recording is released once `during` is done. No rendering opportunity
// comes meanwhile but those `during` injects: the tasks after a rendering task wait for the frame in flight with it.
-async function whileRecordingInFlight(mutate, during) {
+// `hold` says what internals.holdNextFrame() holds.
+async function whileRecordingInFlight(mutate, during, hold = "") {
if (document.readyState !== "complete")
await new Promise(resolve => window.addEventListener("load", resolve, { once: true }));
await twoFramesLanded();
return new Promise((resolve, reject) => {
requestAnimationFrame(() => {
- internals.holdNextFrame();
+ internals.holdNextFrame(hold);
internals.setManualRenderingOpportunities(true);
mutate();
setTimeout(async () => {
@@ -45,11 +46,15 @@ async function twoFrames() {
}
// Resolves in the first task after two rendering updates once nothing of theirs is in flight. A frame that is still in
-// flight spends a hold that a test arms next, which is then not the hold of the rendering update the test means.
+// flight spends a hold that a test arms next, which is then not the hold of the rendering update the test means. No
+// rendering opportunity comes meanwhile: a running animation asks for one frame after another, and where each comes as
+// the last one lands, no task may ever find none in flight.
async function twoFramesLanded() {
await twoFrames();
+ internals.setManualRenderingOpportunities(true);
do await nextTask();
while (internals.frameSchedulerState() !== "idle");
+ internals.setManualRenderingOpportunities(false);
}
// Has the clock lane of the document's presented frame sample its animations beside a task.
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-keeps-candidates-for-a-file-input.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-keeps-candidates-for-a-file-input.html
new file mode 100644
index 00000000000..6006c7c6b56
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-keeps-candidates-for-a-file-input.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ #target { display: block; width: 300px; height: 100px; }
+</style>
+<input id="target" type="file">
+<script>
+ // Default.css restyles the element backing ::file-selector-button on hover, so the lane has to restyle for an
+ // <input type=file>.
+ asyncTest(async done => {
+ const by = await whileLaneHovers(async frameTime => {
+ internals.moveHoverPointer(10, 50);
+ await nextTask();
+ internals.injectClockTick(frameTime + 32);
+ return internals.lastFramePresentedBy(document);
+ });
+ println(`hover presented by: ${by}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-keeps-candidates-for-ua-hover-rules.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-keeps-candidates-for-ua-hover-rules.html
new file mode 100644
index 00000000000..c8583c12905
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-keeps-candidates-for-ua-hover-rules.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ #target { display: block; width: 300px; height: 100px; }
+</style>
+<button id="target"></button>
+<script>
+ // Default.css restyles a <button> on hover, so the lane has to restyle for one.
+ asyncTest(async done => {
+ const by = await whileLaneHovers(async frameTime => {
+ internals.moveHoverPointer(50, 50);
+ await nextTask();
+ internals.injectClockTick(frameTime + 32);
+ return internals.lastFramePresentedBy(document);
+ });
+ println(`hover presented by: ${by}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-nth-child-of-hover.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-nth-child-of-hover.html
new file mode 100644
index 00000000000..cf2a586d375
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-nth-child-of-hover.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ div { width: 100px; height: 100px; outline: 1px solid rgb(0, 0, 255); }
+ :nth-child(1 of :hover) { width: 150px; outline-color: rgb(0, 128, 0); }
+</style>
+<div id="box"></div>
+<script>
+ // A selector can test :hover only inside the "of" of :nth-child(), which no compound of its own does.
+ // FIXME: The lane leaves such a move to the main thread, and only a rendering update shows it.
+ asyncTest(async done => {
+ const width = await whileLaneHovers(async frameTime => {
+ internals.moveHoverPointer(50, 50);
+ box.offsetWidth;
+ await nextTask();
+ internals.injectClockTick(frameTime + 32);
+ return internals.presentedBorderBox(box)?.width;
+ });
+ println(`box width on screen: ${width}`);
+ internals.queueMouseMove(50, 50);
+ await twoFrames();
+ println(`box width once the main thread handled the move: ${getComputedStyle(box).width}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-scope-root-hover.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-scope-root-hover.html
new file mode 100644
index 00000000000..2a85b0172d4
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-scope-root-hover.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ div { width: 100px; height: 100px; outline: 1px solid rgb(0, 0, 255); }
+ @scope (:hover) { :scope { width: 150px; outline-color: rgb(0, 128, 0); } }
+</style>
+<div id="box"></div>
+<script>
+ // The roots of a scope can test :hover where no compound of the selector does.
+ // FIXME: The lane leaves such a move to the main thread, and only a rendering update shows it.
+ asyncTest(async done => {
+ const width = await whileLaneHovers(async frameTime => {
+ internals.moveHoverPointer(50, 50);
+ box.offsetWidth;
+ await nextTask();
+ internals.injectClockTick(frameTime + 32);
+ return internals.presentedBorderBox(box)?.width;
+ });
+ println(`box width on screen: ${width}`);
+ internals.queueMouseMove(50, 50);
+ await twoFrames();
+ println(`box width once the main thread handled the move: ${getComputedStyle(box).width}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-seals-a-frame-no-hover-rule-can-restyle.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-seals-a-frame-no-hover-rule-can-restyle.html
new file mode 100644
index 00000000000..cbaf8ccc511
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-seals-a-frame-no-hover-rule-can-restyle.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ #target { display: block; width: 300px; height: 100px; }
+</style>
+<div id="target"></div>
+<script>
+ // No rule testing :hover can match an element here, Default.css's included, so the frame is read-only.
+ asyncTest(async done => {
+ const by = await whileLaneHovers(async frameTime => {
+ internals.moveHoverPointer(50, 50);
+ await nextTask();
+ internals.injectClockTick(frameTime + 32);
+ return internals.lastFramePresentedBy(document);
+ });
+ println(`hover presented by: ${by}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-transition-beside-a-child-inheriting-another-group.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-transition-beside-a-child-inheriting-another-group.html
new file mode 100644
index 00000000000..fe2c2c723dd
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-transition-beside-a-child-inheriting-another-group.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ a { display: block; width: 200px; height: 40px; color: rgb(0, 0, 255); background-color: rgb(255, 255, 255); transition: background-color 100s linear; }
+ a:hover { color: rgb(255, 0, 0); background-color: rgb(0, 128, 0); }
+ span { box-sizing: inherit; }
+</style>
+<a id="link" href="#"><span id="label">Link</span></a>
+<script>
+ // A child that explicitly inherits a property its parent's transition does not animate reads nothing of the
+ // transition's composition: the hover beside the task stays on the lane.
+ asyncTest(async done => {
+ const presentedBy = await whileLaneHovers(() => {
+ internals.injectHoverPointer(150, 20);
+ return internals.lastFramePresentedBy(document);
+ });
+ println(`a tick presented the last frame: ${presentedBy === "clock"}`);
+ await nextFrame();
+ println(`link matches :hover: ${link.matches(":hover")}`);
+ println(`label color: ${getComputedStyle(label).color}`);
+ println(`label box-sizing: ${getComputedStyle(label).boxSizing}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-uppercase-type-selector.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-uppercase-type-selector.html
new file mode 100644
index 00000000000..b7ca78daab1
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-uppercase-type-selector.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ div { width: 100px; height: 100px; outline: 1px solid rgb(0, 0, 255); }
+ DIV:hover { width: 150px; outline-color: rgb(0, 128, 0); }
+</style>
+<div id="box"></div>
+<script>
+ // A type selector matches an HTML element whatever the case the sheet writes it in, so the lane has to take the
+ // uppercase compound as one a hover can restyle.
+ asyncTest(async done => {
+ const width = await whileLaneHovers(async frameTime => {
+ internals.moveHoverPointer(50, 50);
+ box.offsetWidth;
+ await nextTask();
+ internals.injectClockTick(frameTime + 32);
+ return internals.presentedBorderBox(box)?.width;
+ });
+ println(`box width on screen: ${width}`);
+ internals.queueMouseMove(50, 50);
+ await twoFrames();
+ println(`box width once the main thread handled the move: ${getComputedStyle(box).width}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/layout-flight-adopted-sheets.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/layout-flight-adopted-sheets.html
index a04832cd4ca..acbe360e9ae 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/layout-flight-adopted-sheets.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/layout-flight-adopted-sheets.html
@@ -4,7 +4,7 @@
<div id="box" style="height: 10px"></div>
<div class="x" id="target">x</div>
<script>
- // Style sheets adopted beside a frame in flight drain its style transaction first, and reach the style engine in
+ // Style sheets adopted beside a frame in flight drain its style update first, and reach the style engine in
// the order they were adopted: each attachment publishes more input as it runs, which goes in with it, ahead of
// the attachments queued behind it.
asyncTest(async done => {
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/layout-flight-style-inputs.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/layout-flight-style-inputs.html
index ea66badb034..ad86fe39bcf 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/layout-flight-style-inputs.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/layout-flight-style-inputs.html
@@ -9,7 +9,7 @@
<script>
// Style inputs beside a frame in flight: a style sheet attached, a rule inserted, an inline style edited and an
// attribute value a selector reads. A write that reaches the style engine in place, as a sheet write does, drains
- // the frame's style transaction first, and the next style update takes all of them.
+ // the frame's style update first, and the next style update takes all of them.
asyncTest(async done => {
const result = await whileRecordingInFlight(() => {
box.style.height = "20px";
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/press-after-a-focusable-ancestor-caught-up-its-animations.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/press-after-a-focusable-ancestor-caught-up-its-animations.html
new file mode 100644
index 00000000000..08cce56b1c7
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/press-after-a-focusable-ancestor-caught-up-its-animations.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ button {
+ color: rgb(255, 255, 255);
+ background-color: rgb(0, 0, 0);
+ transition: color 1s linear, background-color 1s linear;
+ }
+ button:hover {
+ color: rgb(0, 0, 0);
+ background-color: rgb(255, 255, 255);
+ }
+ svg {
+ display: block;
+ width: 20px;
+ height: 20px;
+ }
+</style>
+<button id="button"><svg viewBox="0 0 20 20" stroke="currentColor"><path d="M0 0h20v20h-20z"/></svg></button>
+<script>
+ // Looking for the editing host of the pressed node asks the button whether it is focusable, which samples the
+ // animations of the button at the time script would observe, as its background runs on the compositor. That moves
+ // the color its SVG icon lays out from, and the hit test that follows reads the layout.
+ asyncTest(async done => {
+ await twoFramesLanded();
+ internals.setManualRenderingOpportunities(true);
+ await nextTask();
+ const rect = button.getBoundingClientRect();
+ const [x, y] = [rect.left + rect.width / 2, rect.top + rect.height / 2];
+ internals.mouseMove(x, y);
+
+ // Rendering updates make the transitions ready and put the background on the compositor.
+ let frameTime = performance.now();
+ do {
+ internals.injectRenderingOpportunity(frameTime);
+ frameTime += 1;
+ do await nextTask();
+ while (internals.frameSchedulerState() !== "idle");
+ } while (button.getAnimations().some(animation => animation.pending));
+
+ // No more of them come, so script now observes the timeline ahead of what they sampled.
+ while (performance.now() < frameTime + 20) await nextTask();
+ internals.mouseDown(x, y);
+ internals.mouseUp(x, y);
+ internals.setManualRenderingOpportunities(false);
+ println("PASS (didn't crash)");
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-canceled-animation-style.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-canceled-animation-style.html
index 12c76fe2de7..df6b6c27a4b 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-canceled-animation-style.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-canceled-animation-style.html
@@ -21,8 +21,7 @@
// much the document styles meanwhile. Once the recording lands, the dropped style is freed though nothing styles.
asyncTest(async done => {
const animation = box.getAnimations()[0];
- const retiredOverlays = () => internals.styleEngineCounters().retiredAnimationOverlayRecords;
- const keptBeside = await whileRecordingInFlight(() => {
+ await whileRecordingInFlight(() => {
animation.currentTime = 10000;
// Laid out here, so that what the rendering update lets fly is its recording.
box.offsetWidth;
@@ -36,11 +35,8 @@
document.body.appendChild(element);
}
document.body.offsetWidth;
- return retiredOverlays();
});
await twoFrames();
- println(`dropped overlays kept beside the recording: ${keptBeside > 0}`);
- println(`dropped overlays kept once it landed: ${retiredOverlays()}`);
println(`margin-left: ${getComputedStyle(box).marginLeft}`);
println(`hit test finds the box: ${document.elementFromPoint(30, 30) === box}`);
done();
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-presents-from-flight.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-presents-from-flight.html
index 52ecb93b096..60e9b8ab76f 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-presents-from-flight.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-presents-from-flight.html
@@ -4,7 +4,7 @@
<div id="box">first</div>
<script>
// The frame a rendering update commits is sampled by the render owner and recorded and presented beside the event
- // loop: taking its recording in between two tasks presents nothing more. A change of text alone has no style transaction to fly first.
+ // loop: taking its recording in between two tasks presents nothing more. A change of text alone has no style update to fly first.
asyncTest(async done => {
await whileRecordingInFlight(() => {
box.firstChild.data = "second";
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-reads-beside.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-reads-beside.html
index 95a3f9b3b98..36564b41c1c 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-reads-beside.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-reads-beside.html
@@ -6,7 +6,7 @@
</style>
<div id="box" style="width: 10px; height: 10px; background: green"></div>
<script>
- // Reads beside a frame in flight: a read of style or layout joins the style transaction of the frame, drains its
+ // Reads beside a frame in flight: a read of style or layout joins the style update of the frame, drains its
// reactions, and runs in step behind it. The next rendering update paints what the reads changed.
asyncTest(async done => {
const result = await whileRecordingInFlight(() => {
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-replaced-animation-style.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-replaced-animation-style.html
index 1e31eaee053..9a6b57f7055 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-replaced-animation-style.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-replaced-animation-style.html
@@ -21,19 +21,15 @@
// Once the recording lands, the replaced style is freed though nothing styles.
asyncTest(async done => {
const animation = box.getAnimations()[0];
- const retiredOverlays = () => internals.styleEngineCounters().retiredAnimationOverlayRecords;
- const keptBeside = await whileRecordingInFlight(() => {
+ await whileRecordingInFlight(() => {
animation.currentTime = 10000;
// Laid out here, so that what the rendering update lets fly is its recording.
box.offsetWidth;
}, () => {
animation.currentTime = 50000;
box.offsetWidth;
- return retiredOverlays();
});
await twoFrames();
- println(`replaced overlays kept beside the recording: ${keptBeside > 0}`);
- println(`replaced overlays kept once it landed: ${retiredOverlays()}`);
println(`margin-left: ${getComputedStyle(box).marginLeft}`);
println(`hit test finds the box: ${document.elementFromPoint(80, 30) === box}`);
done();
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-mutation-then-read.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-mutation-then-read.html
index 6bfbac57281..f1f3a5c4ade 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-mutation-then-read.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-mutation-then-read.html
@@ -6,7 +6,7 @@
</style>
<div id="old">Old</div>
<script>
- // A read beside a style transaction in flight joins it, and drains its reactions against the tree it was sealed
+ // A read beside a style update in flight joins it, and drains its reactions against the tree it was sealed
// with first. The body removed beside it, and the body and sheet added beside it, are the next transaction's, which
// the read then runs in step.
asyncTest(async done => {
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-queries-ids-fonts.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-queries-ids-fonts.html
index 957db0c3992..cc9a53d4e70 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-queries-ids-fonts.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-queries-ids-fonts.html
@@ -12,7 +12,7 @@
<span id="text">flight</span>
<script>
// Selector queries the DOM answers alone, a first-seen id and a font face added beside a frame in flight leave the
- // frame in flight; a sheet's conditions, which the style engine evaluates in place, drain its style transaction
+ // frame in flight; a sheet's conditions, which the style engine evaluates in place, drain its style update
// first. The next style update sees each of them.
asyncTest(async done => {
const face = new FontFace("StyleFlightFace", "url(../../../../Assets/HashSans.woff)");
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-style-element-in-inserted-subtree.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-style-element-in-inserted-subtree.html
index b4494346921..46ce66777f4 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-style-element-in-inserted-subtree.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-style-element-in-inserted-subtree.html
@@ -4,7 +4,7 @@
<div id="box"></div>
<script>
// A subtree inserted beside a frame in flight, with a <style> ahead of other elements: the <style>'s insertion steps
- // write its sheet to the style engine in place, which drains the style transaction that flew while the elements
+ // write its sheet to the style engine in place, which drains the style update that flew while the elements
// after the <style> have yet to run their own insertion steps. They arrive in the style engine with their features
// all the same, and the next style update styles them.
asyncTest(async done => {
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-stylesheets.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-stylesheets.html
index 614eed2dad2..60a5343791d 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-stylesheets.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-flight-stylesheets.html
@@ -8,7 +8,7 @@
<div id="other" class="other"></div>
<script>
// Style sheets inserted, edited, replaced and removed beside a frame in flight: a change that writes the sheets to
- // the style engine in place drains the style transaction that flew first, so it lands behind the changes made
+ // the style engine in place drains the style update that flew first, so it lands behind the changes made
// beside the transaction, and a read or the next style update sees them all, in cascade order.
function describe() {
const style = getComputedStyle(box);
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-input-beside-a-flight-requests-a-frame.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-input-beside-a-flight-requests-a-frame.html
new file mode 100644
index 00000000000..1cd67f44fdf
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-input-beside-a-flight-requests-a-frame.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ .target { transition: color 1000s; color: rgb(0, 0, 255); }
+ .target.moved { color: rgb(0, 128, 0); }
+ @keyframes arrives { from { opacity: 0; } }
+ .arrived { animation: arrives 1000s; }
+</style>
+<div class="target" id="first"></div>
+<div class="target" id="second"></div>
+<script>
+ // Style input recorded beside a rendering update in flight, and nothing else, has to ask for the frame that takes it
+ // in, which the transition or animation it starts shows: nothing here reads style or touches layout. The test times
+ // out if not.
+ let flights = 0;
+ asyncTest(async done => {
+ const fired = (element, name) => new Promise(resolve => element.addEventListener(name, () => resolve(), { once: true }));
+ const flight = during => whileRecordingInFlight(() => { document.body.style.outlineColor = `rgb(${++flights}, 0, 0)`; }, during);
+
+ let changed;
+ await flight(async () => {
+ changed = fired(first, "transitionrun");
+ first.classList.add("moved");
+ });
+ await changed;
+ println("a class change beside a flight took effect");
+
+ let arrived;
+ await flight(async () => {
+ const element = document.createElement("div");
+ element.className = "arrived";
+ arrived = fired(element, "animationstart");
+ document.body.append(element);
+ });
+ await arrived;
+ println("an arrival beside a flight took effect");
+
+ // The second input beside a flight finds input recorded, and asks for nothing.
+ let secondChange;
+ await flight(async () => {
+ secondChange = fired(second, "transitionrun");
+ second.dataset.first = "1";
+ second.style.setProperty("--x", "1");
+ second.classList.add("moved");
+ });
+ await secondChange;
+ println("a change after other input took effect");
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-layout-flight-iframe-child-only.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-layout-flight-iframe-child-only.html
index 84c952b7cf5..9b7a03150ac 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-layout-flight-iframe-child-only.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-layout-flight-iframe-child-only.html
@@ -22,7 +22,6 @@
const result = await whileRecordingInFlight(() => {
observed.length = 0;
- internals.resetStyleInvalidationCounters();
inner.style.width = "80px";
}, state => ({ state, observed: observed.join(", ") || "nothing" }));
println(`state in the next task: ${result.state}`);
@@ -30,7 +29,6 @@
await twoFrames();
println(`child resize observed: ${observed.join(", ")}`);
println(`child box: ${inner.offsetWidth}x${inner.offsetHeight}`);
- println(`container styles recomputed: ${internals.getStyleInvalidationCounters().elementStyleRecomputations}`);
println(`container box: ${box.offsetWidth}x${box.offsetHeight}, iframe: ${frameElement.offsetWidth}x${frameElement.offsetHeight}`);
observer.disconnect();
done();
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-text-changed-beside-the-layout-that-builds-its-box.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-text-changed-beside-the-layout-that-builds-its-box.html
new file mode 100644
index 00000000000..4adb45e0298
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-text-changed-beside-the-layout-that-builds-its-box.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<div id="source"></div>
+<script>
+ // A rendered style element whose text changes beside the layout that builds its box shows the new text.
+ asyncTest(async done => {
+ const built = document.createElement("style");
+ built.style.display = "block";
+ await twoFramesLanded();
+ internals.setManualRenderingOpportunities(true);
+ requestAnimationFrame(() => {
+ internals.holdNextFrame("layout");
+ source.append(built);
+ });
+ internals.injectRenderingOpportunity(performance.now());
+ while (internals.frameSchedulerState() !== "laying-out")
+ await nextTask();
+ built.textContent = "text";
+ internals.releaseHeldFrame();
+ while (internals.frameSchedulerState() !== "idle")
+ await nextTask();
+ internals.setManualRenderingOpportunities(false);
+ await twoFramesLanded();
+ println(`style has height: ${built.offsetHeight > 0}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-update-samples-where-script-observed-the-timeline.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-update-samples-where-script-observed-the-timeline.html
new file mode 100644
index 00000000000..271fefaef27
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/style-update-samples-where-script-observed-the-timeline.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ #compositor {
+ width: 50px;
+ height: 50px;
+ background: green;
+ }
+ .hidden #drawer {
+ visibility: hidden;
+ transition: visibility 20ms;
+ }
+ .hidden #list, .hidden #item, .hidden #link {
+ transition: all 20ms;
+ }
+</style>
+<div id="compositor"></div>
+<div id="other">text</div>
+<div id="drawer">
+ <ul id="list"><li id="item"><a id="link" href="#">link</a></li></ul>
+</div>
+<script>
+ // The transitions run in the last rendering update and have ended by the time script observes the timeline, ahead of
+ // that update as an animation runs on the compositor. A read then samples them at the time script observed, where
+ // they have ended, and over the records its style update installs. Both have to agree on that time, or the elements
+ // keep flipping between the values of the two times.
+ asyncTest(async done => {
+ await twoFramesLanded();
+ internals.setManualRenderingOpportunities(true);
+ await nextTask();
+ const frame = async time => {
+ internals.injectRenderingOpportunity(time);
+ do await nextTask();
+ while (internals.frameSchedulerState() !== "idle");
+ };
+ compositor.animate({ opacity: [0, 1] }, { duration: 100000 });
+ const start = performance.now();
+ document.documentElement.classList.add("hidden");
+ await frame(start);
+ await frame(start + 5);
+ while (performance.now() < start + 50) await nextTask();
+
+ println(`timeline ahead of the end of the transitions: ${document.timeline.currentTime > start + 25}`);
+ other.style.marginTop = "1px";
+ println(`scroll width: ${list.scrollWidth > 0}`);
+ for (const element of [drawer, list, item, link]) println(`${element.id}: ${getComputedStyle(element).visibility}`);
+ internals.setManualRenderingOpportunities(false);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/table-moved-beside-the-layout-that-builds-its-box.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/table-moved-beside-the-layout-that-builds-its-box.html
new file mode 100644
index 00000000000..c2a9693d19c
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/table-moved-beside-the-layout-that-builds-its-box.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<div id="source"></div>
+<script>
+ // A table moved beside the layout that builds its box has not heard of the box, or of the wrapper around it. The
+ // table's old parent has to be built again for the wrapper to go with the box: a wrapper alone cannot be laid out.
+ // NB: The parser would not nest these options.
+ const target = document.createElement("option");
+ const reference = target.appendChild(document.createElement("option"));
+ document.body.prepend(target);
+
+ asyncTest(async done => {
+ const built = document.createElement("table");
+ await twoFramesLanded();
+ internals.setManualRenderingOpportunities(true);
+ requestAnimationFrame(() => {
+ internals.holdNextFrame("layout");
+ source.append(built);
+ });
+ internals.injectRenderingOpportunity(performance.now());
+ while (internals.frameSchedulerState() !== "laying-out")
+ await nextTask();
+ target.moveBefore(built, reference);
+ internals.releaseHeldFrame();
+ while (internals.frameSchedulerState() !== "idle")
+ await nextTask();
+ internals.setManualRenderingOpportunities(false);
+ await twoFramesLanded();
+ source.style.width = "100px";
+ println(`source: ${source.offsetWidth}x${source.offsetHeight}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/task-beside-flight-font-load.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/task-beside-flight-font-load.html
index fbbdcc03ea7..4f021cf533b 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/task-beside-flight-font-load.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/task-beside-flight-font-load.html
@@ -3,7 +3,7 @@
<script src="frame-in-flight.js"></script>
<span id="text" style="font: 20px monospace">beside the frame</span>
<script>
- // A web face that finishes loading beside a frame in flight whose style transaction selected it for an element:
+ // A web face that finishes loading beside a frame in flight whose style update selected it for an element:
// the element holds the transaction's style once its drain installs it, and the loaded face reaches it then.
asyncTest(async done => {
const widthWithoutFace = text.offsetWidth;
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/task-beside-flight-language-editability-top-layer.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/task-beside-flight-language-editability-top-layer.html
index 795b5ea3752..bc008b44350 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/task-beside-flight-language-editability-top-layer.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/task-beside-flight-language-editability-top-layer.html
@@ -11,7 +11,7 @@
<dialog id="dialog">dialog</dialog>
<script>
// A task beside a frame in flight that changes an element's language, makes an empty element an editing host, and
- // takes an element whose ::backdrop the frame's style transaction styled out of the top layer: once the frame has
+ // takes an element whose ::backdrop the frame's style update styled out of the top layer: once the frame has
// landed, the text is cased by the new language, the editing host holds a line, and the backdrop is gone.
asyncTest(async done => {
const states = await whileRecordingInFlight(() => {
diff --git a/Tests/LibWeb/Text/input/css/animation-pseudo-element-display-none-ancestor-toggle.html b/Tests/LibWeb/Text/input/css/animation-pseudo-element-display-none-ancestor-toggle.html
new file mode 100644
index 00000000000..69fc628d23e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/animation-pseudo-element-display-none-ancestor-toggle.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
+ .hidden { display: none; }
+ #target::before { content: "x"; animation: fade 1s linear; }
+</style>
+<div id="host"><div id="target"></div></div>
+<script>
+ test(() => {
+ internals.updateStyle();
+ println(`shown: ${document.getAnimations().length}`);
+ for (let i = 1; i <= 2; ++i) {
+ host.classList.add("hidden");
+ internals.updateStyle();
+ println(`hidden ${i}: ${document.getAnimations().length}`);
+ host.classList.remove("hidden");
+ internals.updateStyle();
+ println(`revealed ${i}: ${document.getAnimations().length}`);
+ }
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/custom-property-animated-beneath-an-inherited-one-pseudo-element.html b/Tests/LibWeb/Text/input/css/custom-property-animated-beneath-an-inherited-one-pseudo-element.html
new file mode 100644
index 00000000000..e826ce13ac8
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/custom-property-animated-beneath-an-inherited-one-pseudo-element.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ @property --amp { syntax: "<number>"; inherits: false; initial-value: 1; }
+ @property --mix { syntax: "<number>"; inherits: true; initial-value: 0; }
+ @keyframes amp { from { --amp: 1 } to { --amp: 3 } }
+ @keyframes mix { from { --mix: 0 } to { --mix: 1 } }
+ #track { animation: mix 100s linear paused; }
+ #bar::before { content: ""; display: block; width: 10px; height: 10px; transform: scaleY(calc(1 + var(--amp) * var(--mix))); animation: amp 100s linear paused; }
+</style>
+<div id="track"><div><span id="bar"></span></div></div>
+<script>
+ // A pseudo-element's own animation samples --amp, and an ancestor's animation hands it --mix. Each time both move,
+ // the transform reading both reads the --mix the pseudo-element's custom properties hold, not the one of a sample
+ // before.
+ asyncTest(async done => {
+ const [mix] = track.getAnimations();
+ const [amp] = bar.getAnimations({ subtree: true });
+ const frames = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
+ await frames();
+ for (const seconds of [10, 20, 30, 40]) {
+ mix.currentTime = seconds * 1000;
+ amp.currentTime = seconds * 1000;
+ await frames();
+ const style = getComputedStyle(bar, "::before");
+ const expected = 1 + parseFloat(style.getPropertyValue("--amp")) * parseFloat(style.getPropertyValue("--mix"));
+ println(`${seconds}s: transform ${style.transform}, custom properties give ${expected.toFixed(3)}`);
+ }
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/custom-property-animated-beneath-an-inherited-one.html b/Tests/LibWeb/Text/input/css/custom-property-animated-beneath-an-inherited-one.html
new file mode 100644
index 00000000000..4aea2842580
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/custom-property-animated-beneath-an-inherited-one.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ @property --amp { syntax: "<number>"; inherits: false; initial-value: 1; }
+ @property --mix { syntax: "<number>"; inherits: true; initial-value: 0; }
+ @keyframes amp { from { --amp: 1 } to { --amp: 3 } }
+ @keyframes mix { from { --mix: 0 } to { --mix: 1 } }
+ #track { animation: mix 100s linear paused; }
+ #bar { display: inline-block; width: 10px; height: 10px; transform: scaleY(calc(1 + var(--amp) * var(--mix))); animation: amp 100s linear paused; }
+</style>
+<div id="track"><div><span id="bar"></span></div></div>
+<script>
+ // An element's own animation samples --amp, and an ancestor's animation hands it --mix. Each time both move, the
+ // transform reading both reads the --mix the element's custom properties hold, not the one of a sample before.
+ asyncTest(async done => {
+ const [mix] = track.getAnimations();
+ const [amp] = bar.getAnimations();
+ const frames = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
+ await frames();
+ for (const seconds of [10, 20, 30, 40]) {
+ mix.currentTime = seconds * 1000;
+ amp.currentTime = seconds * 1000;
+ await frames();
+ const style = getComputedStyle(bar);
+ const expected = 1 + parseFloat(style.getPropertyValue("--amp")) * parseFloat(style.getPropertyValue("--mix"));
+ println(`${seconds}s: transform ${style.transform}, custom properties give ${expected.toFixed(3)}`);
+ }
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/custom-property-animation-feeding-itself.html b/Tests/LibWeb/Text/input/css/custom-property-animation-feeding-itself.html
new file mode 100644
index 00000000000..7c0c1884e24
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/custom-property-animation-feeding-itself.html
@@ -0,0 +1,90 @@
+<!DOCTYPE html>
+<style>
+ @property --animated {
+ syntax: "<length>";
+ inherits: true;
+ initial-value: 0px;
+ }
+ @keyframes feed {
+ from {
+ --animated: calc(var(--declared, 0px) + 1px);
+ }
+ to {
+ --animated: calc(var(--declared, 0px) + 1px);
+ }
+ }
+ @keyframes within {
+ from {
+ --one: var(--two);
+ --two: var(--one);
+ }
+ to {
+ --one: var(--two);
+ --two: var(--one);
+ }
+ }
+ #within {
+ animation: within 1000s linear both;
+ }
+ @keyframes plain {
+ from {
+ --animated: calc(var(--read) + 1px);
+ }
+ to {
+ --animated: calc(var(--read) + 1px);
+ }
+ }
+ #no-cycle {
+ animation: plain 1000s linear both;
+ --read: 4px;
+ --declared: var(--animated);
+ }
+ @function --read-declared() {
+ result: var(--declared, 0px);
+ }
+ @keyframes hidden-read {
+ from {
+ --animated: calc(--read-declared() + 1px);
+ }
+ to {
+ --animated: calc(--read-declared() + 1px);
+ }
+ }
+ #through-function {
+ animation: hidden-read 1000s linear both;
+ --declared: var(--animated);
+ }
+ #target {
+ animation: feed 1000s linear both;
+ --declared: var(--animated);
+ width: var(--animated);
+ }
+</style>
+<div id="target"><div id="child" style="width: var(--animated)"></div></div>
+<div id="within"></div>
+<div id="no-cycle"></div>
+<div id="through-function"></div>
+<script src="../include.js"></script>
+<script>
+ test(() => {
+ const target = document.getElementById("target");
+ const child = document.getElementById("child");
+ const report = name => {
+ const style = getComputedStyle(target);
+ println(`${name}: --animated "${style.getPropertyValue("--animated")}", --declared "${style.getPropertyValue("--declared")}", width ${style.width}, child ${getComputedStyle(child).width}`);
+ };
+ report("a cycle through a declaration");
+ target.style.color = "red";
+ report("after a write");
+
+ const within = document.getElementById("within");
+ const style = getComputedStyle(within);
+ println(`a cycle within keyframes: "${style.getPropertyValue("--one")}" "${style.getPropertyValue("--two")}"`);
+ // FIXME: A cycle through a custom function, whose reads are not known ahead, should be invalid as the others are.
+ // It only stops growing, at a value this does not print.
+ const throughFunction = getComputedStyle(document.getElementById("through-function"));
+ println(`a cycle through a function ends: ${throughFunction.getPropertyValue("--animated").endsWith("px")}`);
+ const noCycle = getComputedStyle(document.getElementById("no-cycle"));
+ println(`no cycle: "${noCycle.getPropertyValue("--animated")}" "${noCycle.getPropertyValue("--declared")}"`);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/custom-property-animation-removed-by-style.html b/Tests/LibWeb/Text/input/css/custom-property-animation-removed-by-style.html
new file mode 100644
index 00000000000..9d0517645e2
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/custom-property-animation-removed-by-style.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<style>
+ @property --registered {
+ syntax: "<length>";
+ inherits: true;
+ initial-value: 0px;
+ }
+ @keyframes grow {
+ from {
+ --registered: 10px;
+ --plain: 10px;
+ }
+ to {
+ --registered: 30px;
+ --plain: 30px;
+ }
+ }
+ .animated {
+ animation: grow 1000s -500s step-end both;
+ }
+ .reader {
+ width: var(--registered);
+ height: var(--plain, 1px);
+ }
+</style>
+<div id="name" class="animated"><div class="reader"></div></div>
+<div id="value-with-name" class="animated"><div class="reader"></div></div>
+<div id="name-then-value" class="animated"><div class="reader"></div></div>
+<div id="declared" style="--registered: 5px; --plain: 6px" class="animated"><div class="reader"></div></div>
+<div id="class" class="animated"><div class="reader"></div></div>
+<div id="undisplayed" class="animated"><div class="reader"></div></div>
+<div id="undisplayed-with-value" class="animated"><div class="reader"></div></div>
+<script src="../include.js"></script>
+<script>
+ test(() => {
+ const element = id => document.getElementById(id);
+ const report = (name, id) => {
+ const style = getComputedStyle(element(id));
+ const child = getComputedStyle(element(id).firstElementChild);
+ println(`${name}: ${style.getPropertyValue("--registered")} "${style.getPropertyValue("--plain")}", child ${child.width} ${child.height}, ${element(id).getAnimations().length} animations`);
+ };
+
+ for (const child of document.querySelectorAll(".animated")) report(`${child.id} running`, child.id);
+
+ element("name").style.animationName = "none";
+ report("animation-name none", "name");
+
+ element("value-with-name").style.setProperty("--registered", "5px");
+ element("value-with-name").style.animationName = "none";
+ report("a declared value and animation-name none together", "value-with-name");
+
+ element("name-then-value").style.animationName = "none";
+ element("name-then-value").offsetWidth;
+ element("name-then-value").style.setProperty("--registered", "5px");
+ report("a declared value after animation-name none", "name-then-value");
+
+ element("declared").getAnimations()[0].cancel();
+ report("canceled over declared values", "declared");
+
+ element("class").className = "";
+ report("class removed", "class");
+
+ element("undisplayed").style.display = "none";
+ report("display none", "undisplayed");
+
+ element("undisplayed-with-value").style.display = "none";
+ element("undisplayed-with-value").style.setProperty("--registered", "5px");
+ report("display none with a declared value", "undisplayed-with-value");
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/custom-property-animation-setting-display.html b/Tests/LibWeb/Text/input/css/custom-property-animation-setting-display.html
new file mode 100644
index 00000000000..f33965e8b81
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/custom-property-animation-setting-display.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<style>
+ @keyframes hide {
+ 0%,
+ 100% {
+ --display: none;
+ }
+ }
+ .hiding {
+ animation: hide 1s infinite;
+ display: var(--display, block);
+ }
+</style>
+<body>
+<script src="../include.js"></script>
+<script>
+ asyncTest(async done => {
+ // FIXME: The animation should keep running, with the element not displayed. Its element not being displayed ends
+ // it for now, which brings the element back and starts it again, so this tests only that the update ends.
+ const frame = () => new Promise(requestAnimationFrame);
+ const outer = document.createElement("div");
+ const inner = document.createElement("div");
+ const leaf = document.createElement("div");
+ inner.append(leaf);
+ outer.append(inner);
+ document.body.append(outer);
+ await frame();
+ outer.classList.add("hiding");
+ await frame();
+ const read = element => {
+ getComputedStyle(element, "::first-line").color;
+ return getComputedStyle(element).getPropertyValue("color");
+ };
+ println(read(leaf));
+ await frame();
+ println(read(leaf));
+ const late = document.createElement("div");
+ inner.append(late);
+ println(read(late));
+ const animation = outer.getAnimations()[0];
+ animation?.pause();
+ if (animation)
+ animation.currentTime = 500;
+ println(read(leaf));
+ animation?.cancel();
+ println(read(leaf));
+ await frame();
+ println(read(leaf));
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/custom-property-animations-chain-read-first.html b/Tests/LibWeb/Text/input/css/custom-property-animations-chain-read-first.html
new file mode 100644
index 00000000000..7dcd5a56b51
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/custom-property-animations-chain-read-first.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<body>
+<script src="../include.js"></script>
+<script>
+ test(() => {
+ const depth = 24;
+ const style = document.createElement("style");
+ for (let level = 1; level <= depth; ++level) {
+ CSS.registerProperty({ name: `--level${level}`, syntax: "<length>", inherits: true, initialValue: "0px" });
+ const previous = level === 1 ? "0px" : `var(--level${level - 1})`;
+ const value = `--level${level}: calc(${previous} + 1px)`;
+ style.textContent += `@keyframes level${level} { from { ${value} } to { ${value} } }\n`;
+ }
+ document.head.append(style);
+
+ // The chain moves one level per style pass, past the number of passes a style update runs at once, so what
+ // the first read of an element below it asks for has to wait for all of them.
+ function chain(tag) {
+ const section = document.createElement("section");
+ let parent = section;
+ for (let level = 1; level <= depth; ++level) {
+ const element = document.createElement("div");
+ element.style.animation = `level${level} 1000s linear both`;
+ parent.append(element);
+ parent = element;
+ }
+ const last = document.createElement(tag);
+ parent.append(last);
+ document.body.append(section);
+ return last;
+ }
+
+ const name = `--level${depth}`;
+ println(`its custom property: ${getComputedStyle(chain("div")).getPropertyValue(name)}`);
+ for (const [tag, pseudoElement] of [
+ ["div", "::first-line"],
+ ["li", "::marker"],
+ ["div", "::selection"],
+ ["input", "::placeholder"],
+ ["div", "::before"],
+ ])
+ println(`${pseudoElement}: ${getComputedStyle(chain(tag), pseudoElement).getPropertyValue(name)}`);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/custom-property-animations-chain-read.html b/Tests/LibWeb/Text/input/css/custom-property-animations-chain-read.html
new file mode 100644
index 00000000000..0ac43e991c7
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/custom-property-animations-chain-read.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<body>
+<script src="../include.js"></script>
+<script>
+ test(() => {
+ const depth = 24;
+ const style = document.createElement("style");
+ let parent = document.body;
+ for (let level = 1; level <= depth; ++level) {
+ CSS.registerProperty({ name: `--level${level}`, syntax: "<length>", inherits: true, initialValue: "0px" });
+ const previous = level === 1 ? "0px" : `var(--level${level - 1})`;
+ const value = `--level${level}: calc(${previous} + 1px)`;
+ style.textContent += `@keyframes level${level} { from { ${value} } to { ${value} } }\n`;
+ const element = document.createElement("div");
+ element.style.animation = `level${level} 1000s linear both`;
+ parent.append(element);
+ parent = element;
+ }
+ document.head.append(style);
+ const last = document.createElement("div");
+ last.style.width = `var(--level${depth})`;
+ parent.append(last);
+ println(`read of the element below a chain of ${depth}: ${getComputedStyle(last).width}`);
+ println(`read of its ::before: ${getComputedStyle(last, "::before").getPropertyValue(`--level${depth}`)}`);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/custom-property-declared-reading-animated-and-inherited.html b/Tests/LibWeb/Text/input/css/custom-property-declared-reading-animated-and-inherited.html
new file mode 100644
index 00000000000..c9b24fcce79
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/custom-property-declared-reading-animated-and-inherited.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ @property --amp { syntax: "<number>"; inherits: false; initial-value: 1; }
+ @property --mix { syntax: "<number>"; inherits: true; initial-value: 0; }
+ @property --sum { syntax: "<number>"; inherits: false; initial-value: 0; }
+ @keyframes amp { from { --amp: 1 } to { --amp: 3 } }
+ @keyframes mix { from { --mix: 0 } to { --mix: 1 } }
+ #track { animation: mix 100s linear paused; }
+ #bar { --sum: calc(var(--amp) * var(--mix)); --plain: calc(var(--amp) * var(--mix)); display: inline-block; width: 10px; height: 10px; transform: scaleY(calc(1 + var(--sum))); rotate: calc(var(--plain) * 1deg); animation: amp 100s linear paused; }
+</style>
+<div id="track"><div><span id="bar"></span></div></div>
+<script>
+ // The custom properties the element declares read both --amp, which its own animation samples, and --mix, which an
+ // ancestor's animation hands it. What reads them follows both as soon as they move, and after the frames that follow.
+ asyncTest(async done => {
+ const [mix] = track.getAnimations();
+ const [amp] = bar.getAnimations();
+ const frames = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
+ const report = (name) => {
+ const style = getComputedStyle(bar);
+ const product = parseFloat(style.getPropertyValue("--amp")) * parseFloat(style.getPropertyValue("--mix"));
+ println(`${name}: --sum ${style.getPropertyValue("--sum")}, transform ${style.transform}, rotate ${style.rotate}, the custom properties give ${product.toFixed(2)}`);
+ };
+ await frames();
+ for (const seconds of [10, 20, 30, 40]) {
+ mix.currentTime = seconds * 1000;
+ amp.currentTime = seconds * 1000;
+ report(`${seconds}s, in the same task`);
+ await frames();
+ report(`${seconds}s, after two frames`);
+ }
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/custom-property-on-root-reaches-children-after-animation-cancel.html b/Tests/LibWeb/Text/input/css/custom-property-on-root-reaches-children-after-animation-cancel.html
new file mode 100644
index 00000000000..98e90855c9f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/custom-property-on-root-reaches-children-after-animation-cancel.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html><head><script src="../include.js"></script></head><body><div id="target"></div></body>
+<script>
+ test(() => {
+ const animation = document.documentElement.animate({ opacity: [0.5, 1] }, { duration: 100000 });
+ getComputedStyle(document.documentElement).opacity;
+ // The root gains a custom property while its animation runs, and the animation ends before the next style
+ // update: its children and their descendants still inherit it.
+ const style = document.createElement("style");
+ style.textContent = ":root { --x: 1; }";
+ document.head.append(style);
+ animation.cancel();
+ document.documentElement.offsetWidth;
+ document.documentElement.offsetWidth;
+ println(`root: ${getComputedStyle(document.documentElement).getPropertyValue("--x")}`);
+ println(`body: ${getComputedStyle(document.body).getPropertyValue("--x")}`);
+ println(`target: ${getComputedStyle(target).getPropertyValue("--x")}`);
+ });
+</script>
+</html>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/animated-element-pseudo-element-composition.html b/Tests/LibWeb/Text/input/css/style-engine/animated-element-pseudo-element-composition.html
new file mode 100644
index 00000000000..bfca67629d0
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/animated-element-pseudo-element-composition.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<style id="registrations"></style>
+<style>
+ #target { color: black; }
+ #target::before { content: "x"; background-color: red; }
+ @container style(--pseudo-query: 10px) {
+ #target::before { background-color: green; }
+ }
+</style>
+<div><span id="target"></span></div>
+<script>
+ promiseTest(async () => {
+ const target = document.getElementById("target");
+ internals.updateStyle();
+ const animation = target.animate([{ color: "rgb(200, 0, 0)" }, { color: "rgb(0, 0, 200)" }], { duration: 1000 });
+ animation.pause();
+ await animation.ready;
+ for (const currentTime of [250, 500, 750]) {
+ animation.currentTime = currentTime;
+ getComputedStyle(target).color;
+ }
+ const guardHitsBefore = internals.getStyleInvalidationCounters().styleUpdatePassGuardHits;
+ registrations.sheet.insertRule("@property --pseudo-query { syntax: '<length>'; inherits: false; initial-value: 10px; }");
+ internals.updateStyle();
+ const guardHits = internals.getStyleInvalidationCounters().styleUpdatePassGuardHits - guardHitsBefore;
+ println(`style update pass guard hits: ${guardHits}`);
+ println(`${getComputedStyle(target).color} ${getComputedStyle(target, "::before").color} ${getComputedStyle(target, "::before").backgroundColor}`);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/animated-inherited-values-descendants-engine-computed.html b/Tests/LibWeb/Text/input/css/style-engine/animated-inherited-values-descendants.html
similarity index 62%
rename from Tests/LibWeb/Text/input/css/style-engine/animated-inherited-values-descendants-engine-computed.html
rename to Tests/LibWeb/Text/input/css/style-engine/animated-inherited-values-descendants.html
index 152ca2b084f..b27e531393b 100644
--- a/Tests/LibWeb/Text/input/css/style-engine/animated-inherited-values-descendants-engine-computed.html
+++ b/Tests/LibWeb/Text/input/css/style-engine/animated-inherited-values-descendants.html
@@ -11,10 +11,9 @@
<div id="grandparent"><div id="child"><div id="grandchild"></div></div></div>
<script>
// An animation on the grandparent moves values its descendants inherit, among them a registered
- // custom property the grandchild reads. C++ records a reaction for each descendant as it applies
- // the animated style. The child of the animating element composes its parent's animations; the
- // grandchild only inherits. Count who computes them, and check the grandchild takes the
- // animated values.
+ // custom property the grandchild reads. The child of the animating element composes its
+ // parent's animations; the grandchild only inherits. Check the grandchild takes the animated
+ // values.
test(() => {
const grandparent = document.getElementById("grandparent");
grandparent.style.animation = "grows 1000s linear paused";
@@ -24,12 +23,8 @@
};
seek(0);
internals.updateStyle();
- const before = internals.getStyleInvalidationCounters();
seek(500000);
internals.updateStyle();
- const after = internals.getStyleInvalidationCounters();
- println(`engine records: ${after.engineComputedStyleRecords - before.engineComputedStyleRecords}`);
- println(`C++ recomputations: ${after.elementStyleRecomputations - before.elementStyleRecomputations}`);
const style = getComputedStyle(document.getElementById("grandchild"));
println(`grandchild: width ${style.width}, color ${style.color}`);
});
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.html
new file mode 100644
index 00000000000..6095acb3320
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/hover-restyle-updates-box.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<style>
+ body { margin: 0; }
+ #box { width: 100px; height: 50px; background: rgb(0, 128, 0); }
+ #box:hover { width: 150px; background: rgb(255, 0, 0); }
+</style>
+<div id="box"></div>
+<script src="../../include.js"></script>
+<script src="../../HTML/frame-in-flight/frame-in-flight.js"></script>
+<script>
+ asyncTest(async done => {
+ const box = document.getElementById("box");
+ const read = (label) => {
+ const style = getComputedStyle(box);
+ println(`${label}: width=${style.width} background=${style.backgroundColor} box.width=${box.getBoundingClientRect().width}`);
+ };
+ internals.updateStyle();
+ const coldPasses = internals.styleLiveReport(false).coldPasses;
+ 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.
+ const onScreen = await whileLaneHovers(async frameTime => {
+ internals.injectHoverPointer(20, 20, frameTime + 16);
+ 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}`);
+ internals.mouseMove(20, 20);
+ read("hovered");
+ internals.mouseMove(300, 300);
+ read("unhovered");
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/pseudo-element-animated-custom-property-survives-reclamation.html b/Tests/LibWeb/Text/input/css/style-engine/pseudo-element-animated-custom-property-survives-reclamation.html
new file mode 100644
index 00000000000..77d01f5d9e8
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/pseudo-element-animated-custom-property-survives-reclamation.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<style>
+ @keyframes angle {
+ from { --angle: 10deg; }
+ to { --angle: 10deg; }
+ }
+ #target::after {
+ content: "";
+ display: block;
+ height: 10px;
+ background-image: linear-gradient(var(--angle, 90deg), red, blue);
+ animation: angle 1000s infinite;
+ }
+</style>
+<div id="target">x</div>
+<script>
+ asyncTest(async done => {
+ // A restyle of the pseudo-element reads the animated value its animation sampled, which holds still here, so
+ // nothing publishes it again. The engine frees the records the color changes leave behind, and with them the
+ // custom property environments no record names, which must not take that sample.
+ const angle = () => getComputedStyle(target, "::after").backgroundImage.slice("linear-gradient(".length, -1).split(",")[0];
+ const nextFrame = () => new Promise(resolve => requestAnimationFrame(resolve));
+ await nextFrame();
+ await nextFrame();
+ println(`before: ${angle()}`);
+ const seen = new Set();
+ for (let i = 0; i < 1500; ++i) {
+ target.style.color = `rgb(${i % 256}, ${i >> 8}, 0)`;
+ target.offsetWidth;
+ seen.add(angle());
+ if (i % 20 === 0)
+ await nextFrame();
+ }
+ println(`seen: ${[...seen].join(", ")}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/restyle-animated-inheritance.html b/Tests/LibWeb/Text/input/css/style-engine/restyle-animated-inheritance.html
new file mode 100644
index 00000000000..3defc0be29e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/restyle-animated-inheritance.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<style>
+ #parent { color: rgb(0, 0, 0); letter-spacing: 0px; }
+</style>
+<div id="parent"><span id="child">child</span><div><span id="grandchild">grandchild</span></div></div>
+<script src="../../include.js"></script>
+<script>
+ test(() => {
+ const parent = document.getElementById("parent");
+ const child = document.getElementById("child");
+ const grandchild = document.getElementById("grandchild");
+ const read = (label, element) => {
+ const style = getComputedStyle(element);
+ println(`${label}: ${style.color} ${style.letterSpacing}`);
+ };
+ internals.updateStyle();
+ const animation = parent.animate(
+ { color: ["rgb(0, 0, 0)", "rgb(100, 100, 100)"], letterSpacing: ["0px", "100px"] },
+ 1000000
+ );
+ animation.pause();
+ animation.currentTime = 250000;
+ read("child", child);
+ read("grandchild", grandchild);
+ animation.currentTime = 500000;
+ const inserted = document.createElement("span");
+ parent.appendChild(inserted);
+ read("child after seeking", child);
+ read("grandchild after seeking", grandchild);
+ read("inserted child", inserted);
+ animation.cancel();
+ read("child after cancelling", child);
+ read("inserted child after cancelling", inserted);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/restyle-css-animations.html b/Tests/LibWeb/Text/input/css/style-engine/restyle-css-animations.html
new file mode 100644
index 00000000000..84b8e403462
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/restyle-css-animations.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<style>
+ @keyframes grow { from { width: 100px; } to { width: 200px; } }
+ @keyframes shrink { from { width: 50px; } to { width: 10px; } }
+ #box { width: 10px; height: 10px; }
+ #box.grow { animation: grow 1s linear paused; }
+ #box.shrink { animation-name: shrink; }
+</style>
+<div id="box"></div>
+<div id="host"></div>
+<script src="../../include.js"></script>
+<script>
+ test(() => {
+ const box = document.getElementById("box");
+ const read = (element, label) => println(`${label}: ${element.offsetWidth} ${getComputedStyle(element).width}`);
+ const animations = (element) => element.getAnimations().map(animation => `${animation.constructor.name}(${animation.animationName})`).join(", ") || "none";
+ internals.updateStyle();
+ read(box, "before");
+ box.classList.add("grow");
+ internals.updateStyle();
+ println(`started: ${animations(box)}`);
+ box.getAnimations()[0].currentTime = 500;
+ read(box, "halfway");
+ // Naming other keyframes replaces the animation.
+ box.classList.add("shrink");
+ internals.updateStyle();
+ println(`renamed: ${animations(box)}`);
+ box.getAnimations()[0].currentTime = 500;
+ read(box, "renamed halfway");
+ box.classList.remove("grow", "shrink");
+ internals.updateStyle();
+ println(`removed: ${animations(box)}`);
+ read(box, "removed");
+
+ // An animation-name a shadow tree's sheet declares names the shadow tree's @keyframes.
+ const root = document.getElementById("host").attachShadow({ mode: "open" });
+ root.innerHTML = `<style>
+ @keyframes grow { from { width: 300px; } to { width: 400px; } }
+ div { height: 10px; animation: grow 1s linear paused; }
+ </style><div></div>`;
+ const inner = root.querySelector("div");
+ internals.updateStyle();
+ println(`shadow: ${animations(inner)}`);
+ inner.getAnimations()[0].currentTime = 500;
+ read(inner, "shadow halfway");
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/restyle-pseudo-element-animations.html b/Tests/LibWeb/Text/input/css/style-engine/restyle-pseudo-element-animations.html
new file mode 100644
index 00000000000..7483466d78d
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/restyle-pseudo-element-animations.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<style>
+ @keyframes fade { from { color: rgb(200, 0, 0); } to { color: rgb(0, 0, 200); } }
+ body { margin: 0; font: 16px/20px serif; }
+ #box::first-letter { --tone: rgb(1, 2, 3); }
+ #box::before { content: "x"; color: rgb(0, 0, 0); transition: color 1s linear; }
+ #box.animated::before { animation: fade 1s linear paused; }
+ #box.moved::before { color: rgb(0, 200, 0); }
+ #box::selection { --tone: rgb(4, 5, 6); }
+ #box.retoned::first-letter { --tone: rgb(7, 8, 9); }
+ #box.retoned::selection { --tone: rgb(10, 11, 12); }
+</style>
+<div id="box">hello</div>
+<script src="../../include.js"></script>
+<script>
+ test(() => {
+ const box = document.getElementById("box");
+ const animations = () => document.getAnimations().map(animation => `${animation.constructor.name}(${animation.effect.pseudoElement})`).join(", ") || "none";
+ const read = (label) => {
+ const before = getComputedStyle(box, "::before");
+ const firstLetter = getComputedStyle(box, "::first-letter");
+ const selection = getComputedStyle(box, "::selection");
+ println(`${label}: before color=${before.color} first-letter --tone=${firstLetter.getPropertyValue("--tone")} selection --tone=${selection.getPropertyValue("--tone")} animations=${animations()}`);
+ };
+ document.getSelection().selectAllChildren(box);
+ internals.updateStyle();
+ read("initial");
+
+ box.classList.add("animated");
+ internals.updateStyle();
+ document.getAnimations()[0].currentTime = 500;
+ read("animated halfway");
+ box.classList.remove("animated");
+ internals.updateStyle();
+ read("animation removed");
+
+ box.classList.add("moved");
+ internals.updateStyle();
+ for (const animation of document.getAnimations()) {
+ animation.pause();
+ animation.currentTime = 500;
+ }
+ read("transition halfway");
+ for (const animation of document.getAnimations())
+ animation.finish();
+
+ box.classList.add("retoned");
+ internals.updateStyle();
+ read("retoned");
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/restyle-transitions.html b/Tests/LibWeb/Text/input/css/style-engine/restyle-transitions.html
new file mode 100644
index 00000000000..b07dc8624cd
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/restyle-transitions.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<style>
+ #box { width: 100px; height: 10px; transition: width 1s linear; }
+ #box.wide { width: 200px; }
+ #box.still { transition: none; }
+</style>
+<div id="box"></div>
+<script src="../../include.js"></script>
+<script>
+ test(() => {
+ const box = document.getElementById("box");
+ const read = (label) => println(`${label}: ${box.offsetWidth} ${getComputedStyle(box).width}`);
+ const transitions = () => box.getAnimations().map(animation => `${animation.constructor.name}(${animation.transitionProperty})`).join(", ") || "none";
+ internals.updateStyle();
+ read("before");
+ box.classList.add("wide");
+ internals.updateStyle();
+ println(`started: ${transitions()}`);
+ const [transition] = box.getAnimations();
+ transition.pause();
+ transition.currentTime = 500;
+ read("halfway");
+ // A move to a style that declares no transitions ends the ones running.
+ box.classList.add("still");
+ internals.updateStyle();
+ println(`still: ${transitions()}`);
+ read("still");
+ box.classList.remove("wide");
+ internals.updateStyle();
+ println(`narrowed: ${transitions()}`);
+ read("narrowed");
+ // Declaring transitions again starts one on the next move.
+ box.classList.remove("still");
+ internals.updateStyle();
+ box.classList.add("wide");
+ internals.updateStyle();
+ println(`started again: ${transitions()}`);
+ box.getAnimations()[0].pause();
+ box.getAnimations()[0].currentTime = 250;
+ read("a quarter of the way");
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/restyle-web-animations.html b/Tests/LibWeb/Text/input/css/style-engine/restyle-web-animations.html
new file mode 100644
index 00000000000..123b2e72920
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/restyle-web-animations.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<style>
+ #box { width: 10px; height: 10px; }
+ #box.wide { height: 30px; }
+</style>
+<div id="box"></div>
+<script src="../../include.js"></script>
+<script>
+ test(() => {
+ const box = document.getElementById("box");
+ const read = (label) => println(`${label}: ${box.offsetWidth}x${box.offsetHeight} ${getComputedStyle(box).width}`);
+ internals.updateStyle();
+ const animation = box.animate([{ width: "100px" }, { width: "200px" }], { duration: 1000, fill: "both" });
+ animation.pause();
+ animation.currentTime = 500;
+ read("animated");
+ box.classList.add("wide");
+ internals.updateStyle();
+ read("restyled under the animation");
+ animation.cancel();
+ read("canceled");
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/transition-beside-a-custom-property-set-to-initial.html b/Tests/LibWeb/Text/input/css/style-engine/transition-beside-a-custom-property-set-to-initial.html
new file mode 100644
index 00000000000..c3216ca7c05
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/transition-beside-a-custom-property-set-to-initial.html
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<!-- A custom property set to `initial` holds a value the cascade makes anew each time, which must not read as a new
+ style: the transition's composition would restyle the element's pseudo-elements, and that the element, forever. -->
+<style>
+ .button {
+ --bg: red;
+ --before-top: -5px;
+ --after-top: 5px;
+ --before-rotate: 0deg;
+ --after-rotate: 0deg;
+ display: flex;
+ }
+ .button.on {
+ --bg: transparent;
+ --before-top: 0;
+ --after-top: 0;
+ --before-rotate: -45deg;
+ --after-rotate: 45deg;
+ }
+ .button:not(.on) span {
+ transition: background-color;
+ transition-duration: 100s;
+ }
+ .button span {
+ --own: initial;
+ background-color: var(--bg);
+ }
+ .button span, .button span::after, .button span::before {
+ height: 2px;
+ position: relative;
+ width: 16px;
+ }
+ .button span::after, .button span::before {
+ background-color: blue;
+ content: "";
+ left: 0;
+ position: absolute;
+ transition: top, transform;
+ transition-duration: 100s;
+ transition-timing-function: ease-in-out;
+ }
+ .button span::after {
+ top: var(--after-top);
+ transform: rotate(var(--after-rotate));
+ }
+ .button span::before {
+ top: var(--before-top);
+ transform: rotate(var(--before-rotate));
+ }
+</style>
+<a class="button"><span></span></a>
+<script src="../../include.js"></script>
+<script>
+ asyncTest(async done => {
+ const button = document.querySelector(".button");
+ const span = button.firstChild;
+ const settle = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
+ getComputedStyle(span).backgroundColor;
+ await settle();
+ button.classList.add("on");
+ document.body.offsetWidth;
+ await settle();
+ button.classList.remove("on");
+ document.body.offsetWidth;
+ await settle();
+ println(`The update settled with ${span.getAnimations().length} transition running`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/style-engine/transition-start-composition-survives-pseudo-element-restyle.html b/Tests/LibWeb/Text/input/css/style-engine/transition-start-composition-survives-pseudo-element-restyle.html
new file mode 100644
index 00000000000..130409f644a
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/transition-start-composition-survives-pseudo-element-restyle.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<style>
+ #target { color: rgb(0, 0, 0); transition: color 1000s linear; }
+ #target.changed { color: rgb(100, 100, 100); }
+ #target::before { content: "pseudo"; background-color: rgb(0, 0, 0); transition: background-color 1000s linear; }
+ #target.changed::before { background-color: rgb(200, 200, 200); }
+</style>
+<div id="target"><span id="child">child</span></div>
+<script>
+ test(() => {
+ const target = document.getElementById("target");
+ const child = document.getElementById("child");
+ internals.updateStyle();
+ target.classList.add("changed");
+ internals.updateStyle();
+ println(`target color starts the transition: ${getComputedStyle(target).color}`);
+ println(`child inherits the transition's start: ${getComputedStyle(child).color}`);
+ println(`::before inherits the transition's start: ${getComputedStyle(target, "::before").color}`);
+ println(`::before background starts its own transition: ${getComputedStyle(target, "::before").backgroundColor}`);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/css/transition-beside-a-registered-custom-property-settles.html b/Tests/LibWeb/Text/input/css/transition-beside-a-registered-custom-property-settles.html
new file mode 100644
index 00000000000..22de163d7a5
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/transition-beside-a-registered-custom-property-settles.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<!-- A custom property registered as not inheriting is held in a store made anew each time the element computes, which
+ must not read as a new style: the transition's composition would restyle the element's pseudo-element, and that the
+ element, forever. -->
+<style>
+ @property --own {
+ syntax: "*";
+ inherits: false;
+ }
+ .button {
+ --own: 1px;
+ background-color: red;
+ transition: background-color 100s;
+ }
+ .button.on {
+ background-color: blue;
+ }
+ .button::before {
+ content: "";
+ }
+</style>
+<a class="button"></a>
+<script src="../include.js"></script>
+<script>
+ asyncTest(async done => {
+ const button = document.querySelector(".button");
+ const settle = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
+ getComputedStyle(button).backgroundColor;
+ await settle();
+ button.classList.add("on");
+ document.body.offsetWidth;
+ await settle();
+ println(`The update settled with ${button.getAnimations().length} transition running`);
+ done();
+ });
+</script>