Truly independent web browser
LibWeb: Keep the image map and unique node id columns plain
Aliaksandr Kalenik962d0a5cbbf6
diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rsindex 37d99c92ca8..fc131fbd240 100644--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs@@ -1866,7 +1866,7 @@ impl LayoutNodeArena {// has no box and still has pseudo-elements.if let Some(generator) = generator.filter(|_| generated_for != 0) {let unique_node_id = self.with_style_store(|engine| engine.element_unique_node_id(generator));- self.unique_node_ids().publish(id, unique_node_id);+ self.unique_node_ids_mut().publish(id, unique_node_id);}}@@ -4093,7 +4093,7 @@ impl LayoutNodeArena {// The name the document knows the row's node by. The mirror publishes one for an// element; a text node's row answers for nothing, as its identity reads zero.let unique_node_id = self.with_style_store(|engine| engine.element_unique_node_id(style_node));- self.unique_node_ids().publish(slot, unique_node_id);+ self.unique_node_ids_mut().publish(slot, unique_node_id);// The spans a table cell or column takes from its attributes, which table fixup reads// before the build is over.let spans = self.with_style_store(|engine| engine.element_table_spans(style_node));diff --git a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs b/Libraries/LibWeb/Rust/src/layout/tree_builder.rsindex 2d7242383d6..1c8b9472bf8 100644--- a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs+++ b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs@@ -3798,7 +3798,7 @@ impl<'a> TreeBuilderHost<'a> {let unique_node_id = self.arena().with_style_store(|engine| engine.element_unique_node_id(document));- self.arena().unique_node_ids().publish(slot, unique_node_id);+ self.arena_mut().unique_node_ids_mut().publish(slot, unique_node_id);let host_calls = self.host_calls();self.arena_mut().apply_reinherited_style_record(host_calls, slot, document_style);diff --git a/Libraries/LibWeb/Rust/src/painting/image_map_areas.rs b/Libraries/LibWeb/Rust/src/painting/image_map_areas.rsindex bd7873ec63e..3823275f11f 100644--- a/Libraries/LibWeb/Rust/src/painting/image_map_areas.rs+++ b/Libraries/LibWeb/Rust/src/painting/image_map_areas.rs@@ -8,7 +8,6 @@ use crate::css::style::fast_hash::FastMap;use crate::layout::node_data::NodeSlotId;use libgfx_rust::path::Path;use libgfx_rust::{FloatPoint, WindingRule};-use std::cell::RefCell;use std::sync::Arc;/// The state an `<area>`'s `shape` attribute represents, as the HTML image map processing model@@ -185,7 +184,7 @@ fn rectangle_path(left: f32, top: f32, right: f32, bottom: f32) -> Path {#[derive(Clone, Default)]pub struct ImageMapAreaColumn {/// Shared with the rows published for the host, so a write copies the maps only while those hold them.- maps: RefCell<Arc<ImageMaps>>,+ maps: Arc<ImageMaps>,}/// The `<area>` elements of the image map of every image that has one, by the image's paintable row.@@ -193,40 +192,38 @@ pub type ImageMaps = FastMap<NodeSlotId, Arc<[PublishedImageMapArea]>>;impl ImageMapAreaColumn {/// Publishes the `<area>` elements of the image map an image is associated with, in tree order.- pub fn publish(&self, slot: NodeSlotId, areas: Box<[PublishedImageMapArea]>) {+ pub fn publish(&mut self, slot: NodeSlotId, areas: Box<[PublishedImageMapArea]>) {if slot.is_invalid() {return;}- let mut published = self.maps.borrow_mut();if areas.is_empty() {- if published.contains_key(&slot) {- Arc::make_mut(&mut published).remove(&slot);+ if self.maps.contains_key(&slot) {+ Arc::make_mut(&mut self.maps).remove(&slot);}} else {- Arc::make_mut(&mut published).insert(slot, areas.into());+ Arc::make_mut(&mut self.maps).insert(slot, areas.into());}}- pub fn forget(&self, slot: NodeSlotId) {- let mut published = self.maps.borrow_mut();- if published.contains_key(&slot) {- Arc::make_mut(&mut published).remove(&slot);+ pub fn forget(&mut self, slot: NodeSlotId) {+ if self.maps.contains_key(&slot) {+ Arc::make_mut(&mut self.maps).remove(&slot);}}/// Whether the image whose paintable row is `slot` has an image map.pub(crate) fn has_areas(&self, slot: NodeSlotId) -> bool {- self.maps.borrow().contains_key(&slot)+ self.maps.contains_key(&slot)}/// The maps as they are now, for the host to read.pub(crate) fn snapshot(&self) -> Arc<ImageMaps> {- self.maps.borrow().clone()+ 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.borrow()).addr()+ Arc::as_ptr(&self.maps).addr()}}diff --git a/Libraries/LibWeb/Rust/src/painting/paint_changes.rs b/Libraries/LibWeb/Rust/src/painting/paint_changes.rsindex 2868fc1b385..f08f29f2e45 100644--- a/Libraries/LibWeb/Rust/src/painting/paint_changes.rs+++ b/Libraries/LibWeb/Rust/src/painting/paint_changes.rs@@ -211,7 +211,7 @@ impl PaintChange {}Self::SetReplacedPaintFacts { target, facts } => arena.set_replaced_paint_facts(target, facts),Self::SupersededReplacedPaintFacts => {}- Self::PublishImageMapAreas { node, areas } => arena.image_map_areas().publish(node, areas),+ Self::PublishImageMapAreas { node, areas } => arena.image_map_areas_mut().publish(node, areas),Self::NoteVisualContextBoxDirty { node, kind } => {if arena.paintable_row_is_populated(node) {arena.note_visual_context_box_dirty(node, kind);diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rsindex 7291505e6f3..5cad1893f80 100644--- a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs+++ b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs@@ -289,27 +289,26 @@ impl PartialEq for CommittedFragmentLinkSlot {// for, so a slot that has been recycled since answers for the new row and not the old one.#[derive(Clone, Default)]pub(crate) struct UniqueNodeIdColumn {- ids: RefCell<Vec<(NodeSlotId, i64)>>,+ ids: Vec<(NodeSlotId, i64)>,}impl UniqueNodeIdColumn {pub(crate) fn id(&self, slot: NodeSlotId) -> i64 {- match self.ids.borrow().get(slot.slot_index() as usize) {+ match self.ids.get(slot.slot_index() as usize) {Some(&(stamped_for, id)) if !slot.is_invalid() && stamped_for == slot => id,_ => 0,}}- pub(crate) fn publish(&self, slot: NodeSlotId, id: i64) {+ pub(crate) fn publish(&mut self, slot: NodeSlotId, id: i64) {if slot.is_invalid() || self.id(slot) == id {return;}let index = slot.slot_index() as usize;- let mut ids = self.ids.borrow_mut();- if ids.len() <= index {- ids.resize(index + 1, (NodeSlotId::INVALID, 0));+ if self.ids.len() <= index {+ self.ids.resize(index + 1, (NodeSlotId::INVALID, 0));}- ids[index] = (slot, id);+ self.ids[index] = (slot, id);}}@@ -933,11 +932,19 @@ impl LayoutNodeArena {&self.paintable_rows.image_map_areas}+ pub(crate) fn image_map_areas_mut(&mut self) -> &mut crate::painting::image_map_areas::ImageMapAreaColumn {+ &mut self.paintable_rows.image_map_areas+ }+/// The unique node id of what each box is the box of, as the build stamped it.pub(crate) fn unique_node_ids(&self) -> &UniqueNodeIdColumn {&self.paintable_rows.unique_node_ids}+ pub(crate) fn unique_node_ids_mut(&mut self) -> &mut UniqueNodeIdColumn {+ &mut self.paintable_rows.unique_node_ids+ }+pub(crate) fn paintable_visual_context_record(&self, id: NodeSlotId) -> Option<&PaintableVisualContextRecord> {if !self.paintable_row_is_populated(id) {return None;