Truly independent web browser
LibWeb: Write a recommitted row once instead of resetting it first
Aliaksandr Kalenik437d77632cab
diff --git a/Libraries/LibWeb/Rust/src/layout/commit.rs b/Libraries/LibWeb/Rust/src/layout/commit.rsindex 4f7bae2dd82..779f98def51 100644--- a/Libraries/LibWeb/Rust/src/layout/commit.rs+++ b/Libraries/LibWeb/Rust/src/layout/commit.rs@@ -258,11 +258,14 @@ fn commit_subtree(line_root_changes_for_children.fragment_changed |= change.content_changed;line_root_changes_for_children.inline_content_changed |= change.content_changed;line_root_changes_for_children.inline_item_order_changed |= change.item_order_changed;+ } else {+ paintables.clear_line_data(node);}}}if entry.is_none() && prepared.has_paintable_row {paintables.set_box_fragments(node, fragments);+ paintables.clear_line_data(node);paintables.schedule_scrollable_overflow_recalculation(node);}diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_build.rs b/Libraries/LibWeb/Rust/src/painting/paintable_build.rsindex 430448f0d03..8289adbd319 100644--- a/Libraries/LibWeb/Rust/src/painting/paintable_build.rs+++ b/Libraries/LibWeb/Rust/src/painting/paintable_build.rs@@ -468,6 +468,7 @@ impl<'a> PaintableCommit<'a> {previous_fragmented_content: Option<std::sync::Arc<crate::layout::inline_content::InlineContent>>,) -> LineDataChange {if !node_painting::has_lines(self.arena(), slot) {+ self.clear_line_data(slot);return LineDataChange::default();}let writing_mode = line_data.writing_mode;@@ -500,6 +501,13 @@ impl<'a> PaintableCommit<'a> {}}+ /// Clears the inline content of a row whose new fragment has none.+ pub(crate) fn clear_line_data(&mut self, slot: NodeSlotId) {+ if self.arena().committed_side_data(slot).inline_content.is_some() {+ self.arena_mut().committed_side_data_mut(slot).inline_content = None;+ }+ }+pub(crate) fn schedule_scrollable_overflow_recalculation(&mut self, mut node: NodeSlotId) {// NB: Commit visits changed boxes before their descendants. Invalidate each containing// block once, including blocks outside the committed layout subtree.diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_data.rs b/Libraries/LibWeb/Rust/src/painting/paintable_data.rsindex a2aadc6ceef..32abc86a655 100644--- a/Libraries/LibWeb/Rust/src/painting/paintable_data.rs+++ b/Libraries/LibWeb/Rust/src/painting/paintable_data.rs@@ -255,10 +255,6 @@ impl CommittedSideData {self.order_inputs.is_initialized().then_some(self.order_inputs)}- pub(crate) fn clear_committed_records(&mut self) {- self.inline_content = None;- }-pub(crate) fn box_fragments(&self) -> &[CommittedBoxFragment] {self.box_fragments.as_deref().map_or(&[], Vec::as_slice)}diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rsindex c5c99f0df83..1376ba145ee 100644--- a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs+++ b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs@@ -6,8 +6,8 @@use crate::cow_column::{CowColumn, RowMut};use crate::layout::LayoutNodeArena;+use crate::layout::fragment_tree;use crate::layout::node_data::{NodeFlag, NodeSlotId};-use crate::layout::{fragment_tree, used_values};use crate::painting::node_painting;use crate::painting::paint_read::{GeometryRead, PaintRead};use crate::painting::paintable_data::*;@@ -539,18 +539,11 @@ wheredata}+ /// Starts committing a row anew. The commit writes its geometry and inline content over what it committed last, so+ /// that a row it commits as it was copies no chunk a published generation shares.pub(crate) fn begin_paintable_row_recommit(&mut self, id: NodeSlotId) {- {- let mut data = self.paintable_data_mut(id);- data.offset = used_values::FfiCssPixelPoint::default();- data.content_size = used_values::FfiCssPixelSize::default();- }// The row's damage is deliberately kept; the commit diff pushes what actually changed.- let filter = {- let mut committed = self.arena.committed_side_data_mut(id);- committed.clear_committed_records();- committed.fragment_ownership.take()- };+ let filter = self.arena.committed_side_data_mut(id).fragment_ownership.take();let side = self.arena.paintable_side_data_mut(id);side.overflow_measured_this_commit = false;if filter.is_some() {