Truly independent web browser
LibWeb: Let a shared layout arena reach only the style engine's reads
Aliaksandr Kalenik93fa5b2efb24
diff --git a/Libraries/LibWeb/Rust/src/css/style/layout_style.rs b/Libraries/LibWeb/Rust/src/css/style/layout_style.rsindex 27229c859b5..2fbe64a366b 100644--- a/Libraries/LibWeb/Rust/src/css/style/layout_style.rs+++ b/Libraries/LibWeb/Rust/src/css/style/layout_style.rs@@ -111,7 +111,7 @@ impl Drop for LayoutStyle {}impl LayoutStyle {- pub(crate) fn from_record(engine: &StyleEngine, record: u64) -> Self {+ pub(crate) fn from_record(engine: &super::RetainedState, record: u64) -> Self {let view = engine.style_record_view(record).expect("layout style record must be live");diff --git a/Libraries/LibWeb/Rust/src/css/style/position_try.rs b/Libraries/LibWeb/Rust/src/css/style/position_try.rsindex 9399f67a129..c8940efc32c 100644--- a/Libraries/LibWeb/Rust/src/css/style/position_try.rs+++ b/Libraries/LibWeb/Rust/src/css/style/position_try.rs@@ -9,7 +9,7 @@//! https://drafts.csswg.org/css-anchor-position-1/#fallbackuse super::HashMap;-use super::StyleEngine;+use super::RetainedState;use super::layout_style::LayoutStyle;use super::tree::{StyleNodeID, TreeScopeID};use crate::css::computed_longhand_table::ComputedLonghandTable;@@ -632,7 +632,7 @@ pub(crate) enum PositionOptionStyle {Applied(Box<LayoutStyle>),}-impl StyleEngine {+impl RetainedState {/// https://drafts.csswg.org/css-anchor-position-1/#position-options-list/// The first `limit` entries of the `position-try-fallbacks` of the box of `node`, whose record is `record`, that/// add a position option to its position options list: the index of each, and the identity of the `@position-try`diff --git a/Libraries/LibWeb/Rust/src/layout/counters.rs b/Libraries/LibWeb/Rust/src/layout/counters.rsindex 2825239b8f9..6964cf669a7 100644--- a/Libraries/LibWeb/Rust/src/layout/counters.rs+++ b/Libraries/LibWeb/Rust/src/layout/counters.rs@@ -13,7 +13,7 @@ use super::node_data::{};use crate::css::computed_value_views::ComputedValuesView;use crate::css::css_string::CssString;-use crate::css::style::StyleEngine;+use crate::css::style::RetainedState;use crate::css::style::fast_hash::FastMap as HashMap;use crate::css::style::tree::StyleNodeID;use crate::painting::paint_read::PaintRead;@@ -190,7 +190,7 @@ pub(crate) fn style_resets_forward_list_item_counter(style: ComputedValuesView<'/// `::backdrop`, so that one is read from the box it was built with.pub(crate) fn style_of<'a>(arena: &'a LayoutNodeArena,- engine: &'a StyleEngine,+ engine: &'a RetainedState,owner: CounterOwner,) -> Option<ComputedValuesView<'a>> {match owner.generated_for {@@ -209,7 +209,7 @@ pub(crate) fn style_of<'a>(}/// The element's parent element, or the originating element of a pseudo-element.-fn parent_element(engine: &StyleEngine, owner: CounterOwner) -> Option<StyleNodeID> {+fn parent_element(engine: &RetainedState, owner: CounterOwner) -> Option<StyleNodeID> {if owner.generated_for != 0 {return Some(owner.element);}@@ -308,7 +308,7 @@ fn last_counter_with_name<'a>(counters: &'a mut [Counter], name: &CssString) ->// https://drafts.csswg.org/css-lists-3/#instantiate-counterfn instantiate_a_counter<'a>(arena: &LayoutNodeArena,- engine: &StyleEngine,+ engine: &RetainedState,counters: &'a mut Vec<Counter>,name: CssString,element: CounterOwner,@@ -350,7 +350,7 @@ fn instantiate_a_counter<'a>(// https://drafts.csswg.org/css-lists-3/#propdef-counter-setfn set_a_counter(arena: &LayoutNodeArena,- engine: &StyleEngine,+ engine: &RetainedState,counters: &mut Vec<Counter>,name: &CssString,element: CounterOwner,@@ -371,7 +371,7 @@ fn set_a_counter(// https://drafts.csswg.org/css-lists-3/#propdef-counter-incrementfn increment_a_counter(arena: &LayoutNodeArena,- engine: &StyleEngine,+ engine: &RetainedState,counters: &mut Vec<Counter>,name: &CssString,element: CounterOwner,@@ -450,7 +450,7 @@ fn apply_reversed_counter_contribution(}fn walk_reversed_counter_sibling_run(- engine: &StyleEngine,+ engine: &RetainedState,state: &mut ReversedScopeWalkState<'_>,first: Option<StyleNodeID>,) -> ReversedScopeWalkDecision {@@ -492,7 +492,7 @@ fn walk_reversed_counter_sibling_run(// 4. Add lastNonZeroIncrementNegated to num.// 5. Return num."fn reversed_counter_start_value(- engine: &StyleEngine,+ engine: &RetainedState,name: &CssString,originating_element: CounterOwner,style: ComputedValuesView<'_>,@@ -521,7 +521,7 @@ fn reversed_counter_start_value(// https://drafts.csswg.org/css-lists-3/#inherit-countersfn inherit_counters(arena: &LayoutNodeArena,- engine: &StyleEngine,+ engine: &RetainedState,sets: &CountersSets,element: CounterOwner,) -> Option<CountersSet> {diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rsindex 85dd5f4cc48..b92aceef0c5 100644--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs@@ -34,7 +34,6 @@ use crate::layout::tree_mutation::HostCalls;use crate::painting::paint_read::{GeometryRead, PaintRead};use crate::render_state::DocumentHost;use crate::stage::MainThread;-use std::cell::Cell;use std::cell::RefCell;use std::ffi::c_void;use std::hash::Hash;@@ -676,6 +675,10 @@ pub(crate) struct BoxPresenceHost(*mut c_void, unsafe extern "C" fn(*mut c_void,// pays it on the host's thread once it is over (see [`LayoutNodeArena::queue_box_presence`]).unsafe impl Send for BoxPresenceHost {}+// SAFETY: The arena only carries the host's context and callback, to hand them out with what the host is due to hear.+// Only [`DueBoxPresence::tell`], on the host's thread, calls the callback, so a shared arena reaches nothing of the host.+unsafe impl Sync for BoxPresenceHost {}+/// What the host is to hear of the boxes the nodes a change changed have: each node's identity, 0 for the document,/// and what boxes it has, as the change left them.#[derive(Default)]@@ -702,6 +705,16 @@ impl DueBoxPresence {}}+/// The style engine of the arena's document. A shared borrow of the arena reads only the engine's retained state, and+/// changing the engine takes the arena exclusively.+#[derive(Clone, Copy)]+struct ArenaStyleEngine(crate::css::style::StyleEngineHandle);++// SAFETY: Through a shared borrow of the arena, the engine is reached only as its retained state, which is Sync, and a+// mutable borrow of the engine takes the arena exclusively (see [`LayoutNodeArena::with_style_store`] and+// [`LayoutNodeArena::with_style_engine`]). What the handle asks of every borrow of the engine still holds.+unsafe impl Sync for ArenaStyleEngine {}+/// A row is bound to the node.pub const BOX_PRESENCE_HAS_LAYOUT_BOX: u8 = 1 << 0;/// The bound row has a committed box.@@ -1202,8 +1215,8 @@ pub(crate) struct LayoutNodeArena {document_style_node: Option<StyleNodeID>,/// The style engine the document registered, which owns the records rows are built from;/// null when it registered none, as in a layout test.- style_engine: Cell<crate::css::style::StyleEngineHandle>,- box_presence_host: Cell<Option<BoxPresenceHost>>,+ style_engine: ArenaStyleEngine,+ box_presence_host: Option<BoxPresenceHost>,/// The nodes whose boxes a running tree build or layout write changed, which the host hears of/// once it is over, or `None` while none runs.queued_box_presence: Option<Vec<BoundNode>>,@@ -1334,8 +1347,8 @@ impl LayoutNodeArena {bound_rows: Default::default(),viewport_scroll_offset: CssPixelPoint::default(),document_style_node: (None),- style_engine: Cell::new(crate::css::style::StyleEngineHandle::null()),- box_presence_host: Cell::new(None),+ style_engine: ArenaStyleEngine(crate::css::style::StyleEngineHandle::null()),+ box_presence_host: None,queued_box_presence: None,document_is_decoded_svg: (false),active_layout_pass_depth: 0,@@ -1682,7 +1695,7 @@ impl LayoutNodeArena {rows,paintable_row_resets,arena_pinned_style_records,- style_engine: self.style_engine.get(),+ style_engine: self.style_engine.0,}}@@ -2677,10 +2690,10 @@ impl LayoutNodeArena {/// so do the boxes below them. Answers none where one of them follows another pseudo-element or styles a table/// wrapper, which only the host restyles.pub(crate) fn anonymous_child_samples(- &self,+ &mut self,row: NodeSlotId,sample: &DerivedStyleRecord,- host_record: impl Fn(NodeSlotId) -> u64,+ host_record: impl Fn(&Self, NodeSlotId) -> u64,) -> Option<smallvec::SmallVec<[(NodeSlotId, DerivedStyleRecord); 2]>> {let mut samples: smallvec::SmallVec<[(NodeSlotId, DerivedStyleRecord); 2]> = smallvec::SmallVec::new();let mut parents: smallvec::SmallVec<[(NodeSlotId, u64); 2]> = smallvec::smallvec![(row, sample.record)];@@ -2717,8 +2730,9 @@ impl LayoutNodeArena {.anonymous_box_column_source(child).filter(|source| *source == row).map(|_| sample.record);+ let child_host_record = host_record(self, child);let derived =- self.reinherit_anonymous_style_record(host_record(child), parent_record, column_source);+ self.reinherit_anonymous_style_record(child_host_record, parent_record, column_source);parents.push((child, derived.record));samples.push((child, derived));}@@ -2794,7 +2808,7 @@ 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_engine(|engine| {+ let Some(host_payloads) = self.with_style_store(|engine| {engine.style_record_payloads(host_record).map(|payloads| StylePayloadsRef::new(payloads.as_ptr().cast()))@@ -2815,7 +2829,7 @@ impl LayoutNodeArena {let sample = self.style_records[index];self.with_style_engine(|engine| engine.unpin_layout_style_record(sample));let HostStyle { record, pin } = host_style;- let payloads = self.with_style_engine(|engine| {+ 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")@@ -2940,7 +2954,7 @@ impl LayoutNodeArena {}).collect();fork.chunks_by_address.sort_unstable_by_key(|address| address.start);- fork.style_engine.set(engine);+ fork.style_engine = ArenaStyleEngine(engine);fork.svg_paint_resources.detach_enrolled_flag_for_fork();fork}@@ -3037,8 +3051,8 @@ impl LayoutNodeArena {self.style_records_pinned_by_host[id.slot_index() as usize]}- pub(crate) fn set_style_engine(&self, style_engine: crate::css::style::StyleEngineHandle) {- self.style_engine.set(style_engine);+ pub(crate) fn set_style_engine(&mut self, style_engine: crate::css::style::StyleEngineHandle) {+ self.style_engine = ArenaStyleEngine(style_engine);}pub(crate) fn set_document_is_decoded_svg(&mut self, is_decoded_svg: bool) {@@ -3199,7 +3213,7 @@ impl LayoutNodeArena {}fn style_engine(&self) -> crate::css::style::StyleEngineHandle {- let style_engine = self.style_engine.get();+ let style_engine = self.style_engine.0;assert!(!style_engine.is_null(), "layout node arena has no style engine");style_engine}@@ -3400,7 +3414,7 @@ impl LayoutNodeArena {/// element answering to it, and a reference to an id that is in no document has no such/// element.fn retain_published_reference_atoms(- &self,+ &mut self,retained: [u32; PUBLISHED_REFERENCE_ATOM_COUNT],released: [u32; PUBLISHED_REFERENCE_ATOM_COUNT],) {@@ -3429,7 +3443,9 @@ impl LayoutNodeArena {callback(&self.counter_styles)}- pub(crate) fn with_style_store<T>(&self, query: impl FnOnce(&StyleEngine) -> T) -> T {+ /// Reads the style engine's retained state, the part of the engine a shared arena reaches.+ pub(crate) fn with_style_store<T>(&self, query: impl FnOnce(&crate::css::style::RetainedState) -> T) -> T {+ // SAFETY: The engine outlives the arena's live nodes, and a mutable borrow of it needs the arena exclusively.query(unsafe { self.style_engine().get() })}@@ -3578,17 +3594,17 @@ impl LayoutNodeArena {/// Whether a style engine hosts this arena's records; a layout test's arena has none.pub(crate) fn has_style_engine(&self) -> bool {- !self.style_engine.get().is_null()+ !self.style_engine.0.is_null()}// The engine outlives the arena's live nodes. No host callback runs while this// native style-store borrow is active; shell notifications follow publication.- pub(crate) fn with_style_engine<T>(&self, callback: impl FnOnce(&mut StyleEngine) -> T) -> T {+ pub(crate) fn with_style_engine<T>(&mut self, callback: impl FnOnce(&mut StyleEngine) -> T) -> T {unsafe { callback(self.style_engine().get_mut()) }}pub(crate) fn derive_anonymous_style_record(- &self,+ &mut self,parent: u64,kind: AnonymousStyleKind,overrides: AnonymousStyleOverrides,@@ -3598,7 +3614,7 @@ impl LayoutNodeArena {/// `record` with its display replaced by `display`, pinned for a row of the arena.pub(crate) fn derive_style_record_with_display(- &self,+ &mut self,record: u64,display: crate::layout::FfiDisplay,) -> DerivedStyleRecord {@@ -3613,7 +3629,7 @@ impl LayoutNodeArena {}pub(crate) fn reinherit_anonymous_style_record(- &self,+ &mut self,record: u64,parent: u64,column_source: Option<u64>,@@ -3653,8 +3669,9 @@ impl LayoutNodeArena {node: NodeSlotId,update: impl FnOnce(&mut LayoutStyle),) {+ let record = self.node_style_record(node);let derived = self.with_style_engine(|engine| {- let mut style = LayoutStyle::from_record(engine, self.node_style_record(node));+ let mut style = LayoutStyle::from_record(engine, record);update(&mut style);if style.is_unchanged() {return None;@@ -4226,8 +4243,8 @@ impl LayoutNodeArena {self.set_node_flag(slot, NodeFlag::InsetsUseAnchorFunctions, insets_use_anchor_functions);}- pub(crate) fn set_box_presence_host(&self, host: Option<BoxPresenceHost>) {- self.box_presence_host.set(host);+ pub(crate) fn set_box_presence_host(&mut self, host: Option<BoxPresenceHost>) {+ self.box_presence_host = host;}/// What boxes the node bound to `row` has. An invalid row means the node has none.@@ -4248,7 +4265,7 @@ impl LayoutNodeArena {if let BoundNode::Identity(style_node) = node {self.gather_layout_style_snapshot_box_loss(style_node);}- if self.box_presence_host.get().is_none() {+ if self.box_presence_host.is_none() {return;}self.queued_box_presence@@ -4278,7 +4295,7 @@ impl LayoutNodeArena {/// bound again is told once per change, each time with its final state.pub(crate) fn take_queued_box_presence(&mut self) -> DueBoxPresence {let queued = self.queued_box_presence.take().expect("a change queued box presence");- let Some(host) = self.box_presence_host.get() else {+ let Some(host) = self.box_presence_host else {return DueBoxPresence::default();};let nodes = queueddiff --git a/Libraries/LibWeb/Rust/src/layout/style_snapshot.rs b/Libraries/LibWeb/Rust/src/layout/style_snapshot.rsindex 6f482a72fd7..1208ed525c5 100644--- a/Libraries/LibWeb/Rust/src/layout/style_snapshot.rs+++ b/Libraries/LibWeb/Rust/src/layout/style_snapshot.rs@@ -89,7 +89,7 @@ impl LayoutNodeArena {/// Hands the style engine the committed box of a node whose new style makes it a size/// container, which the last commit gathered no row for. Until the next commit, a size query/// on it reads that box, as the host's evaluation reads the box it holds.- pub(crate) fn publish_new_size_container_geometry(&self, node: NodeSlotId) {+ pub(crate) fn publish_new_size_container_geometry(&mut self, node: NodeSlotId) {if !node_is_size_container(self, node) {return;}diff --git a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs b/Libraries/LibWeb/Rust/src/layout/tree_builder.rsindex 1adb5594e23..cf0592e3d1b 100644--- a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs+++ b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs@@ -8,7 +8,7 @@ use super::*;use crate::css::css_enums::{content_visibility, float, positioning, white_space_collapse};use crate::css::style::RecordDemand;-use crate::css::style::StyleEngine;+use crate::css::style::RetainedState;use crate::css::style::bridge::{ElementBoxKind, FfiDemandedPseudoElement, FfiPseudoElementRecordDemand, answer_record_demand,element_adjustment_fact,@@ -78,13 +78,13 @@ impl Default for TreeBuilderState {impl TreeBuilderState {/// Holds `record` until the build ends.- fn pin_style_record_for_build(&mut self, arena: &LayoutNodeArena, record: u64) {+ fn pin_style_record_for_build(&mut self, arena: &mut LayoutNodeArena, record: u64) {arena.with_style_engine(|engine| engine.pin_layout_style_record(record));self.pinned_style_records.push(record);}/// Lets go of every record the build held, once the build is over.- pub(super) fn release_pinned_style_records(&mut self, arena: &LayoutNodeArena) {+ pub(super) fn release_pinned_style_records(&mut self, arena: &mut LayoutNodeArena) {let unused_document_style = self.document_style.take().map(|document_style| document_style.record);if self.pinned_style_records.is_empty() && unused_document_style.is_none() {return;@@ -512,7 +512,7 @@ enum SiblingDirection {/// arena. Every rejection is a shape the incremental insertion cannot produce the same tree for.struct ChildListInsertionReuse<'a, 'host> {layout: &'a TreeBuilderHost<'host>,- engine: &'a StyleEngine,+ engine: &'a RetainedState,element: StyleNodeID,layout_node: LayoutNode,/// Whether a `::first-letter` owner styles the first letter of this subtree, whose source@@ -586,7 +586,7 @@ pub(crate) fn build_keeps_box(arena: &mut LayoutNodeArena, element: StyleNodeID,/// tree around it, which only a full build resolves.fn may_update_pseudo_elements_in_place(layout: &TreeBuilderHost<'_>,- engine: &StyleEngine,+ engine: &RetainedState,kind: PrincipalNodeKind,element: StyleNodeID,) -> bool {@@ -671,7 +671,7 @@ fn may_update_pseudo_elements_in_place(/// See `DOM::Node::first_letter_owner_for_layout_subtree_from`.fn first_letter_owner_covers_subtree(layout: &TreeBuilderHost<'_>,- engine: &StyleEngine,+ engine: &RetainedState,element: StyleNodeID,layout_node: LayoutNode,) -> bool {@@ -696,7 +696,7 @@ fn first_letter_owner_covers_subtree(fn may_reuse_layout_node_for_child_list_insertion(layout: &TreeBuilderHost<'_>,- engine: &StyleEngine,+ engine: &RetainedState,kind: PrincipalNodeKind,element: StyleNodeID,) -> bool {@@ -1358,7 +1358,7 @@ impl TreeBuildJob {// build that may build the viewport is handed it before it starts.if let Some(record) = self.document_style_record {state.document_style = Some(- host.arena()+ host.arena_mut().with_style_engine(|engine| DerivedStyleRecord::pin(engine, record)),);}@@ -2434,7 +2434,7 @@ fn construct_principal_layout_node(return PrincipalBoxConstruction::none();};// The record the box is built from is held for the whole build.- update.state.pin_style_record_for_build(host.arena(), record);+ update.state.pin_style_record_for_build(host.arena_mut(), record);let display = host.published_display(update.style_node);let generation = principal_box_generation_decision(true,@@ -3195,7 +3195,7 @@ fn stamp_nested_list_marker_row(pseudo_element: FfiPseudoElement,list_item_box: NodeSlotId,) -> NodeSlotId {- let derived = host.arena().with_style_engine(|engine| {+ let derived = host.arena_mut().with_style_engine(|engine| {// The generator's own `::marker` record, which the engine derives for this read alone where the generator// holds none. It answers one for every list item; should it not, the marker takes the generator's style.let record = engine@@ -3265,8 +3265,9 @@ fn create_generated_content_item(};// https://drafts.csswg.org/css-content-3/#content-property// For <image>, this is an inline anonymous replaced element.- let derived = host.arena().derive_style_record_with_display(- host.arena().node_style_record(style_box),+ let style_box_record = host.arena().node_style_record(style_box);+ let derived = host.arena_mut().derive_style_record_with_display(+ style_box_record,FfiDisplay::outside_and_inside(crate::css::css_enums::display_outside::INLINE,crate::css::css_enums::display_inside::FLOW,@@ -3300,7 +3301,7 @@ fn create_pseudo_element(engine.pseudo_published_style_record(element_identity, pseudo_kind_of(generated_for_of(pseudo_element)))});if let Some(record) = record {- state.pin_style_record_for_build(host.arena(), record);+ state.pin_style_record_for_build(host.arena_mut(), record);}// The pseudo-element gives up the box it holds from an earlier build before the walk decides// whether it gets a new one.@@ -3828,7 +3829,7 @@ impl<'a> TreeBuilderHost<'a> {node_kind: NodeKind,) -> UnplacedLayoutNode {let derived = self- .arena()+ .arena_mut().derive_anonymous_style_record(parent_style_record, style_kind, overrides);let slot = self.arena.allocate_unbound();self.arena_mut().stamp_anonymous_box(slot, node_kind, derived);diff --git a/Libraries/LibWeb/Rust/src/layout/update_layout.rs b/Libraries/LibWeb/Rust/src/layout/update_layout.rsindex 4731cdd8da6..d6565abd723 100644--- a/Libraries/LibWeb/Rust/src/layout/update_layout.rs+++ b/Libraries/LibWeb/Rust/src/layout/update_layout.rs@@ -316,7 +316,7 @@ pub struct FfiStyleImageFacts {}impl FfiStyleImageFacts {- fn of(engine: &crate::css::style::StyleEngine, style_record: u64) -> Self {+ fn of(engine: &crate::css::style::RetainedState, style_record: u64) -> Self {Self {style_record,holds_image_values: engine.style_record_holds_image_values(style_record),@@ -587,7 +587,7 @@ impl OwedImage {) || arena.owe_style_image_resources_once(row))}).collect();- arena.with_style_engine(|engine| {+ arena.with_style_store(|engine| {owed.into_iter().map(|(row, owed)| Self {row,diff --git a/Libraries/LibWeb/Rust/src/layout/viewport_propagation.rs b/Libraries/LibWeb/Rust/src/layout/viewport_propagation.rsindex 3bde053266b..3b034610451 100644--- a/Libraries/LibWeb/Rust/src/layout/viewport_propagation.rs+++ b/Libraries/LibWeb/Rust/src/layout/viewport_propagation.rs@@ -12,7 +12,7 @@use crate::css::computed_value_views::ComputedValuesView;use crate::css::css_enums::{overflow, overscroll_behavior};-use crate::css::style::StyleEngine;+use crate::css::style::RetainedState;use crate::css::style::bridge::{element_adjustment_fact, element_construction_fact};use crate::css::style::tree::StyleNodeID;use crate::layout::LayoutNodeArena;@@ -45,7 +45,7 @@ pub(crate) struct ViewportPropagationFacts {}/// The published style record the style engine holds for an element.-fn published_style(engine: &StyleEngine, node: StyleNodeID) -> Option<ComputedValuesView<'_>> {+fn published_style(engine: &RetainedState, node: StyleNodeID) -> Option<ComputedValuesView<'_>> {engine.element_published_style_payloads(node).map(ComputedValuesView::new)@@ -67,7 +67,7 @@ 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: &StyleEngine, root_element: StyleNodeID) -> Option<StyleNodeID> {+fn first_html_body_child(engine: &RetainedState, root_element: StyleNodeID) -> Option<StyleNodeID> {engine.tree().dom_children(root_element)diff --git a/Libraries/LibWeb/Rust/src/painting/published_frame.rs b/Libraries/LibWeb/Rust/src/painting/published_frame.rsindex d07884876c5..5ce2c274acd 100644--- a/Libraries/LibWeb/Rust/src/painting/published_frame.rs+++ b/Libraries/LibWeb/Rust/src/painting/published_frame.rs@@ -232,7 +232,7 @@ impl LayoutNodeArena {rows,damage: self.paint_damage_for_frame(),paint_state: PublishedPaintState::new(&self.paint_state().borrow(), hit_test_item_capacity_hint),- _style_records: self.with_style_engine(|engine| engine.lease_style_records()),+ _style_records: self.with_style_store(|engine| engine.lease_style_records()),}}}diff --git a/Libraries/LibWeb/Rust/src/painting/selection.rs b/Libraries/LibWeb/Rust/src/painting/selection.rsindex 8a05cf9ad6b..10648e3aa74 100644--- a/Libraries/LibWeb/Rust/src/painting/selection.rs+++ b/Libraries/LibWeb/Rust/src/painting/selection.rs@@ -262,7 +262,7 @@ pub(crate) fn apply_spelling_errors(layout_arena: &mut PaintableRowsMut<'_>, err/// `style_record`, the element's record for that pseudo-element (zero for none), or `None` when/// that record styles nothing a highlight paints.fn highlight_pseudo_style_of_record(- engine: &crate::css::style::StyleEngine,+ engine: &crate::css::style::RetainedState,element: StyleNodeID,style_record: u64,) -> Option<SelectionStyleAnswer> {diff --git a/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs b/Libraries/LibWeb/Rust/src/render_state/clock/effects.rsindex 0218241eda1..06bc58362d6 100644--- a/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs+++ b/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs@@ -426,10 +426,14 @@ impl Lane {/// The record the host installed in the box `row`, which a tick may show a sample in meanwhile.fn host_record(&self, state: &RenderState, row: NodeSlotId) -> u64 {- self.ticked.iter().find(|(ticked, _)| *ticked == row).map_or_else(- || state.arena.arena().node_style_record(row),- |(_, host_style)| host_style.record(),- )+ self.host_record_in(state.arena.arena(), row)+ }++ fn host_record_in(&self, arena: &LayoutNodeArena, row: NodeSlotId) -> u64 {+ self.ticked+ .iter()+ .find(|(ticked, _)| *ticked == row)+ .map_or_else(|| arena.node_style_record(row), |(_, host_style)| host_style.record())}/// Shows `sample`, of the effects of the element `node` names, which animate `properties`, in its box `row`, with@@ -524,7 +528,7 @@ impl Lane {self.compose_pseudo_element_samples(state, &samples, overlay, bounds, &mut pseudo_element_samples);}// The anonymous boxes below a box show what they inherit of its sample beside it, as the host reinherits them.- let arena = state.arena.arena();+ let arena = state.arena.arena_mut();let mut anonymous: SmallVec<[(NodeSlotId, DerivedStyleRecord, &[u16]); 2]> = SmallVec::new();let mut takes = composed.is_ok();let box_samples = samples@@ -544,7 +548,7 @@ impl Lane {}takes = arena.takes_sample_beside_anonymous_boxes(row, kind)&& arena- .anonymous_child_samples(row, &sample, |child| self.host_record(state, child))+ .anonymous_child_samples(row, &sample, |arena, child| self.host_record_in(arena, child)).map(|children| {anonymous.extend(children.into_iter().map(|(child, sample)| (child, sample, properties)));})