Skip to content

Truly independent web browser

LibWeb: Decide the relayout of a style change in Rust

Aliaksandr Kalenikf69471a077d6
diff --git a/Libraries/LibWeb/CSS/UpdateStyle.cpp b/Libraries/LibWeb/CSS/UpdateStyle.cpp
index 1335df1763d..adc50fa0598 100644
--- a/Libraries/LibWeb/CSS/UpdateStyle.cpp
+++ b/Libraries/LibWeb/CSS/UpdateStyle.cpp
@@ -5,6 +5,7 @@
*/
#include <AK/AnyOf.h>
+#include <AK/Debug.h>
#include <AK/Format.h>
#include <AK/HashTable.h>
#include <AK/ScopeGuard.h>
@@ -29,7 +30,6 @@
#include <LibWeb/HTML/HTMLSlotElement.h>
#include <LibWeb/HTML/LocalNavigable.h>
#include <LibWeb/HTML/NavigableContainer.h>
-#include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/NodeArena.h>
#include <LibWeb/Painting/BoxViews.h>
#include <LibWeb/Selection/Selection.h>
@@ -121,33 +121,10 @@ static void apply_element_style_invalidation_after_style_change(Layout::BegunRea
// layout as it was for what reads it next.
if (auto parent = element.element_to_inherit_style_from({}); !installed_by_render_state && parent && has_flag(parent->installed_style().dependency_flags(), StyleRecordDependencyFlag::InDisplayNoneSubtree) && !element.unsafe_layout_node(read))
return;
- bool const needs_relayout = invalidation.needs_relayout() && !installed_by_render_state;
-
- // Only a full layout pass applies viewport propagation again, so a relayout of an element the viewport takes its
- // overflow, writing mode, or direction from must not finish as a partial relayout of that element.
- bool const element_is_viewport_propagation_source = element.is_viewport_propagation_source();
- if (needs_relayout && element_is_viewport_propagation_source)
- element.document().record_partial_relayout_escape(DOM::PartialRelayoutEscapeReason::ViewportPropagationSourceChangedByStyleChange);
-
- if (needs_relayout) {
- // A relayout-only style change on an absolutely positioned partial relayout boundary
- // stays confined to it: the box contributes nothing to ancestor layout, and partial
- // relayout re-resolves the boundary's own size and position. A rendered ::backdrop
- // disqualifies the element, because pseudo-element style diffs are merged into the
- // element's invalidation while the ::backdrop box is a sibling of the element's box,
- // outside the subtree a boundary-self relayout covers.
- auto* box = as_if<Layout::Box>(element.unsafe_layout_node(read));
- if (!invalidation.needs_layout_tree_rebuild()
- && !element_is_viewport_propagation_source
- && box
- && box->is_absolutely_positioned()
- && box->is_partial_relayout_boundary()
- && !element.pseudo_element_unsafe_layout_node(read, CSS::PseudoElement::Backdrop)) {
- box->set_needs_own_geometry_update();
- element.set_needs_layout_update(DOM::SetNeedsLayoutReason::StyleChange, Layout::LayoutUpdatePropagation::BoundarySelfOnly);
- } else {
- element.set_needs_layout_update(DOM::SetNeedsLayoutReason::StyleChange);
- }
+ if (auto* arena = element.document().layout_node_arena_if_created(); arena && invalidation.needs_relayout() && !installed_by_render_state) {
+ dbgln_if(UPDATE_LAYOUT_DEBUG, "NEED LAYOUT {}", DOM::to_string(DOM::SetNeedsLayoutReason::StyleChange));
+ Layout::RustFFI::render_state_relayout_element_after_style_change(arena->host(), element.style_node_id().value(), invalidation.needs_layout_tree_rebuild());
+ Painting::request_document_repaint(element.document(), InvalidateDisplayList::No);
}
if (invalidation.needs_layout_tree_rebuild()) {
if (installed_by_render_state) {
diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h
index e331d987e8d..3e7e91ca44f 100644
--- a/Libraries/LibWeb/DOM/Document.h
+++ b/Libraries/LibWeb/DOM/Document.h
@@ -255,8 +255,7 @@ enum class UpdateLayoutReason {
#define ENUMERATE_PARTIAL_RELAYOUT_ESCAPE_REASONS(X) \
X(AnchorNamesUnregisteredByElementRemoval) \
- X(AnchorNamesUnregisteredByStyleChange) \
- X(ViewportPropagationSourceChangedByStyleChange)
+ X(AnchorNamesUnregisteredByStyleChange)
enum class PartialRelayoutEscapeReason {
#define ENUMERATE_PARTIAL_RELAYOUT_ESCAPE_REASON(e) e,
diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp
index c0284c32d06..e82d63683f9 100644
--- a/Libraries/LibWeb/DOM/Node.cpp
+++ b/Libraries/LibWeb/DOM/Node.cpp
@@ -4102,16 +4102,10 @@ void Node::publish_dom_paint_facts()
}
void Node::set_needs_layout_update(SetNeedsLayoutReason reason)
-{
- set_needs_layout_update(reason, Layout::LayoutUpdatePropagation::ThroughAncestors);
-}
-
-void Node::set_needs_layout_update(SetNeedsLayoutReason reason, Layout::LayoutUpdatePropagation propagation)
{
dbgln_if(UPDATE_LAYOUT_DEBUG, "NEED LAYOUT {}", to_string(reason));
Layout::RustFFI::FfiBoxMarks marks {};
marks.layout_update = true;
- marks.layout_update_through_ancestors = propagation == Layout::LayoutUpdatePropagation::ThroughAncestors;
mark_box(marks);
}
diff --git a/Libraries/LibWeb/DOM/Node.h b/Libraries/LibWeb/DOM/Node.h
index ce994f098b5..2cafd353e63 100644
--- a/Libraries/LibWeb/DOM/Node.h
+++ b/Libraries/LibWeb/DOM/Node.h
@@ -43,12 +43,6 @@ enum class UserSelect : u8;
}
-namespace Web::Layout {
-
-enum class LayoutUpdatePropagation : u8;
-
-}
-
namespace Web::Layout::RustFFI {
struct FfiBoxMarks;
@@ -490,7 +484,6 @@ public:
// The facts about this node that a box built for it paints (inertness, editability, and so on) may have changed.
void publish_dom_paint_facts();
void set_needs_layout_update(SetNeedsLayoutReason);
- void set_needs_layout_update(SetNeedsLayoutReason, Layout::LayoutUpdatePropagation);
// Whether the node's layout subtree can leave the parent's box without restructuring the
// anonymous boxes around it, so the parent's subtree keeps its layout tree.
diff --git a/Libraries/LibWeb/Layout/Box.cpp b/Libraries/LibWeb/Layout/Box.cpp
index 4b6acc651a1..d245041bc25 100644
--- a/Libraries/LibWeb/Layout/Box.cpp
+++ b/Libraries/LibWeb/Layout/Box.cpp
@@ -62,9 +62,4 @@ void Box::set_owned_image_provider(NonnullOwnPtr<ImageProvider> image_provider)
RustFFI::document_host_set_owned_image_provider(document_host(), Node::slot_id(this), image_provider.leak_ptr());
}
-bool Box::is_partial_relayout_boundary() const
-{
- return RustFFI::render_state_node_is_partial_relayout_boundary(document_host(), Node::slot_id(this));
-}
-
}
diff --git a/Libraries/LibWeb/Layout/Box.h b/Libraries/LibWeb/Layout/Box.h
index 431b7bc904e..c2dc5c9b517 100644
--- a/Libraries/LibWeb/Layout/Box.h
+++ b/Libraries/LibWeb/Layout/Box.h
@@ -16,11 +16,6 @@ namespace Web::Layout {
class WEB_API Box : public NodeWithStyle {
public:
- // A partial relayout boundary is a box whose subtree can be re-laid out in
- // isolation: its own used size and position are guaranteed not to change
- // when layout is invalidated somewhere inside its subtree.
- bool is_partial_relayout_boundary() const;
-
ImageProvider const& image_provider() const;
// The provider of the image the box shows: the one it owns once it is handed it, else its element's, which a box
// that owns a provider it has yet to be handed may not have.
diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cpp
index ddaab27929a..c114dbcac1a 100644
--- a/Libraries/LibWeb/Layout/Node.cpp
+++ b/Libraries/LibWeb/Layout/Node.cpp
@@ -847,7 +847,7 @@ CSS::UserSelect Node::user_select_used_value() const
return CSS::UserSelect::Text;
}
-void Node::set_needs_layout_update(DOM::SetNeedsLayoutReason reason, LayoutUpdatePropagation propagation)
+void Node::set_needs_layout_update(DOM::SetNeedsLayoutReason reason)
{
if constexpr (UPDATE_LAYOUT_DEBUG) {
// NOTE: We check some conditions here to avoid debug spam in documents that don't do layout.
@@ -857,8 +857,7 @@ void Node::set_needs_layout_update(DOM::SetNeedsLayoutReason reason, LayoutUpdat
dbgln_if(UPDATE_LAYOUT_DEBUG, "NEED LAYOUT {}", DOM::to_string(reason));
}
}
- RustFFI::render_state_set_needs_layout_update(document_host(), slot_id(this),
- propagation == LayoutUpdatePropagation::ThroughAncestors);
+ RustFFI::render_state_set_needs_layout_update(document_host(), slot_id(this));
}
}
diff --git a/Libraries/LibWeb/Layout/Node.h b/Libraries/LibWeb/Layout/Node.h
index e6d4390cbac..fda1cb75c93 100644
--- a/Libraries/LibWeb/Layout/Node.h
+++ b/Libraries/LibWeb/Layout/Node.h
@@ -44,11 +44,6 @@ static_assert(offsetof(Compositing::RustFFI::NodeSlotId, index) == 0);
static_assert(sizeof(RustFFI::NodeKind) == sizeof(u8));
static_assert(sizeof(RustFFI::NodeFlag) == sizeof(u32));
-enum class LayoutUpdatePropagation : u8 {
- ThroughAncestors,
- BoundarySelfOnly,
-};
-
enum class BindToPreparedArenaSlot {
Yes,
};
@@ -172,10 +167,7 @@ public:
bool needs_compositor_background_color_frame() const { return has_compositor_animation_frame(RustFFI::CompositorAnimationFrameKind::BackgroundColor); }
void set_needs_compositor_background_color_frame(bool value) { set_needs_compositor_animation_frame(RustFFI::CompositorAnimationFrameKind::BackgroundColor, value); }
- // Set when a style change altered geometry-determining properties of this node itself, so
- // a partial relayout must re-resolve its own size and position instead of reusing them.
- void set_needs_own_geometry_update() { set_flag(RustFFI::NodeFlag::NeedsOwnGeometryUpdate, true); }
- void set_needs_layout_update(DOM::SetNeedsLayoutReason, LayoutUpdatePropagation = LayoutUpdatePropagation::ThroughAncestors);
+ void set_needs_layout_update(DOM::SetNeedsLayoutReason);
bool is_generated_for_pseudo_element() const { return generated_for() != 0; }
Optional<CSS::PseudoElement> generated_for_pseudo_element() const
diff --git a/Libraries/LibWeb/Rust/src/layout/layout_changes.rs b/Libraries/LibWeb/Rust/src/layout/layout_changes.rs
index 7da94dd2191..2b3187da358 100644
--- a/Libraries/LibWeb/Rust/src/layout/layout_changes.rs
+++ b/Libraries/LibWeb/Rust/src/layout/layout_changes.rs
@@ -25,7 +25,10 @@ use smallvec::SmallVec;
pub(crate) enum LayoutChange {
SetNeedsLayoutUpdate {
node: NodeSlotId,
- propagate_through_ancestors: bool,
+ },
+ RelayoutElementAfterStyleChange {
+ element: StyleNodeID,
+ rebuilds_layout_tree: bool,
},
/// The whole layout tree is built again.
SetNeedsFullLayoutTreeUpdate,
@@ -174,6 +177,7 @@ impl LayoutChange {
Self::SetNodeFlag { flag, .. } if *flag as u32 & NodeFlag::IDENTITY != 0 => RowWrite::Identities,
Self::SetNodeStyle { .. } => RowWrite::NamedStyles,
Self::SetNeedsLayoutUpdate { .. }
+ | Self::RelayoutElementAfterStyleChange { .. }
| Self::SetNeedsFullLayoutTreeUpdate
| Self::RelayoutUsersOfFontLists { .. }
| Self::MarkBox { .. }
@@ -234,14 +238,15 @@ impl LayoutChange {
/// left to change.
pub(crate) fn apply(self, arena: &mut LayoutNodeArena) {
match self {
- Self::SetNeedsLayoutUpdate {
- node,
- propagate_through_ancestors,
- } => {
+ Self::SetNeedsLayoutUpdate { node } => {
if arena.slot_is_live(node) {
- arena.set_needs_layout_update(node, propagate_through_ancestors);
+ arena.set_needs_layout_update(node, true);
}
}
+ Self::RelayoutElementAfterStyleChange {
+ element,
+ rebuilds_layout_tree,
+ } => arena.mark_element_for_relayout_after_style_change(element, rebuilds_layout_tree),
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),
@@ -465,16 +470,24 @@ pub(crate) fn queue(host: &DocumentHost, change: LayoutChange) {
}
#[unsafe(no_mangle)]
-pub extern "C" fn render_state_set_needs_layout_update(
+pub extern "C" fn render_state_set_needs_layout_update(host: &DocumentHost, node: NodeSlotId) {
+ queue(host, LayoutChange::SetNeedsLayoutUpdate { node });
+}
+
+#[unsafe(no_mangle)]
+pub extern "C" fn render_state_relayout_element_after_style_change(
host: &DocumentHost,
- node: NodeSlotId,
- propagate_through_ancestors: bool,
+ style_node: u32,
+ rebuilds_layout_tree: bool,
) {
+ let Some(element) = StyleNodeID::from_raw(style_node) else {
+ return;
+ };
queue(
host,
- LayoutChange::SetNeedsLayoutUpdate {
- node,
- propagate_through_ancestors,
+ LayoutChange::RelayoutElementAfterStyleChange {
+ element,
+ rebuilds_layout_tree,
},
);
}
@@ -740,11 +753,7 @@ mod tests {
arena
.free_subtree(freed)
.destroy_shells_and_invoke_callbacks(&crate::stage::MainThread::for_test());
- LayoutChange::SetNeedsLayoutUpdate {
- node: freed,
- propagate_through_ancestors: true,
- }
- .apply(&mut arena);
+ LayoutChange::SetNeedsLayoutUpdate { node: freed }.apply(&mut arena);
assert!(!arena.slot_is_live(freed));
}
@@ -755,11 +764,7 @@ mod tests {
arena.write_shape(node).set_kind(NodeKind::BlockContainer);
arena.reset_layout_update_flags_in_subtree(node);
assert!(!arena.node_needs_layout_update(node));
- LayoutChange::SetNeedsLayoutUpdate {
- node,
- propagate_through_ancestors: false,
- }
- .apply(&mut arena);
+ LayoutChange::SetNeedsLayoutUpdate { node }.apply(&mut arena);
assert!(arena.node_needs_layout_update(node));
arena
.free_subtree(node)
diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
index 1fd888fa031..428492beeda 100644
--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
@@ -2830,18 +2830,41 @@ impl LayoutNodeArena {
}
}
- /// Marks `slot`, the box of the element `style_node` names, for the relayout a style change asks for, as the host
- /// does. Only a full layout pass propagates the viewport's overflow, writing mode and direction from their elements
- /// again, so the relayout of one of them does not finish as a partial relayout. A relayout of an absolutely
- /// positioned partial relayout boundary stays confined to it, as the box contributes nothing to ancestor layout;
- /// a rendered ::backdrop keeps it from being confined, as its box is the element box's sibling.
- fn mark_row_for_relayout_after_style_change(&mut self, style_node: StyleNodeID, slot: NodeSlotId) {
+ /// Marks the box of the element `element` names for the relayout a style change asks for. Only a full layout pass
+ /// propagates the viewport's overflow, writing mode and direction from their elements again, so the relayout of one
+ /// of them does not finish as a partial relayout, even where the element has no box.
+ pub(crate) fn mark_element_for_relayout_after_style_change(
+ &mut self,
+ element: StyleNodeID,
+ rebuilds_layout_tree: bool,
+ ) {
let viewport_propagation_source =
- self.data(slot).flags.get() & (NodeFlag::IsDocumentElement as u32 | NodeFlag::IsBody as u32) != 0;
+ super::viewport_propagation::element_is_viewport_propagation_source(self, element);
if viewport_propagation_source {
self.record_partial_relayout_escape();
}
- let confined = !viewport_propagation_source
+ let slot = self.bound_row(element);
+ if !slot.is_invalid() {
+ self.mark_row_for_relayout(element, slot, !viewport_propagation_source && !rebuilds_layout_tree);
+ }
+ }
+
+ /// Marks `slot`, the box of the element `style_node` names or of one of its pseudo-elements, for the relayout a style
+ /// change that builds no box again asks for.
+ fn mark_row_for_relayout_after_style_change(&mut self, style_node: StyleNodeID, slot: NodeSlotId) {
+ if slot == self.bound_row(style_node) {
+ self.mark_element_for_relayout_after_style_change(style_node, false);
+ } else {
+ self.mark_row_for_relayout(style_node, slot, true);
+ }
+ }
+
+ /// A relayout of an absolutely positioned partial relayout boundary stays confined to it, as the box contributes
+ /// nothing to ancestor layout; a rendered ::backdrop keeps it from being confined, as its box is the element box's
+ /// sibling.
+ fn mark_row_for_relayout(&mut self, style_node: StyleNodeID, slot: NodeSlotId, may_be_confined_to_boundary: bool) {
+ let confined = may_be_confined_to_boundary
+ && super::node_facts::kind_is_box(self.data(slot).kind.get())
&& self
.style_view(slot)
.is_some_and(|payloads| payloads.is_absolutely_positioned())
diff --git a/Libraries/LibWeb/Rust/src/layout/mod.rs b/Libraries/LibWeb/Rust/src/layout/mod.rs
index 69aab01a056..18c87d505a5 100644
--- a/Libraries/LibWeb/Rust/src/layout/mod.rs
+++ b/Libraries/LibWeb/Rust/src/layout/mod.rs
@@ -103,7 +103,6 @@ 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;
pub(crate) use rendered_text::{PublishedTextSlot, RenderedText, RenderedTextBoundary, TextFragments};
pub(crate) use run_state::RunState;
use std::cell::Cell;
diff --git a/Libraries/LibWeb/Rust/src/layout/node_data.rs b/Libraries/LibWeb/Rust/src/layout/node_data.rs
index 4704e82a694..4a7769be607 100644
--- a/Libraries/LibWeb/Rust/src/layout/node_data.rs
+++ b/Libraries/LibWeb/Rust/src/layout/node_data.rs
@@ -183,6 +183,8 @@ pub enum NodeFlag {
HasScrollOffset = 1 << 5,
IsBody = 1 << 6,
NeedsLayoutUpdate = 1 << 7,
+ /// A style change altered geometry-determining properties of this node itself, so a partial relayout must re-resolve
+ /// its own size and position instead of reusing them.
NeedsOwnGeometryUpdate = 1 << 8,
AbsposDescendantEscapes = 1 << 9,
CompensatesForHorizontalScroll = 1 << 10,
diff --git a/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs b/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs
index 586247839f8..2297f3af5d9 100644
--- a/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs
+++ b/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs
@@ -35,8 +35,6 @@ impl PartialRelayoutBoundaryRoots {
}
}
-crate::render_state::held_node_entries!();
-
pub(crate) struct LayoutTreeUpdateClassification {
pub(crate) marks_partial_relayout_boundary_self_only: bool,
/// The node a rebuild escalates to past anonymous parents, if it does, named the way a commit
@@ -130,6 +128,8 @@ impl LayoutNodeArena {
false
}
+ /// A partial relayout boundary is a box whose subtree can be re-laid out in isolation: its own used size and position
+ /// are guaranteed not to change when layout is invalidated somewhere inside its subtree.
pub(crate) fn node_is_partial_relayout_boundary(&self, node: NodeSlotId) -> bool {
let data = self.data(node);
@@ -845,16 +845,6 @@ impl LayoutNodeArena {
}
}
-#[unsafe(no_mangle)]
-pub extern "C" fn render_state_node_is_partial_relayout_boundary(
- host: &crate::render_state::DocumentHost,
- node: NodeSlotId,
-) -> bool {
- super::shell_reads::read_arena(host, node_read(), node, |arena, node| {
- arena.node_is_partial_relayout_boundary(node)
- })
-}
-
/// The facts the host owns that take an update off the partial relayout path.
#[derive(Clone, Copy)]
pub(crate) struct FfiPartialRelayoutHostFacts {
diff --git a/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs b/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs
index b8a138369cb..cba968b29e3 100644
--- a/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs
+++ b/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs
@@ -430,9 +430,8 @@ pub extern "C" fn render_state_apply_layout_tree_update_mark(
#[repr(C)]
#[derive(Clone, Copy, Default)]
pub struct FfiBoxMarks {
- /// The box lays out again, and its ancestors with it where `layout_update_through_ancestors`.
+ /// The box lays out again, and its ancestors with it.
pub layout_update: bool,
- pub layout_update_through_ancestors: bool,
/// The box paints again, and is hit-tested again where `repaint_hit_testing`. A text box repaints its containing
/// block.
pub repaint: bool,
@@ -498,7 +497,6 @@ impl FfiBoxMarks {
/// later DOM paint facts replace the earlier ones.
pub(crate) fn merge(&mut self, later: Self) {
self.layout_update |= later.layout_update;
- self.layout_update_through_ancestors |= later.layout_update_through_ancestors;
self.repaint |= later.repaint;
self.repaint_hit_testing |= later.repaint_hit_testing;
self.repaint_subtree |= later.repaint_subtree;
@@ -530,7 +528,6 @@ impl FfiBoxMarks {
pub(crate) fn is_empty(&self) -> bool {
let Self {
layout_update,
- layout_update_through_ancestors: _,
repaint,
repaint_hit_testing,
repaint_subtree,
@@ -602,7 +599,7 @@ impl FfiBoxMarks {
}
}
if self.layout_update {
- arena.set_needs_layout_update(row, self.layout_update_through_ancestors);
+ arena.set_needs_layout_update(row, true);
}
if self.has_dom_paint_facts {
arena.set_node_dom_paint_facts(row, self.dom_paint_facts);
diff --git a/Libraries/LibWeb/Rust/src/layout/viewport_propagation.rs b/Libraries/LibWeb/Rust/src/layout/viewport_propagation.rs
index 465dc77c1e6..0f851fb0213 100644
--- a/Libraries/LibWeb/Rust/src/layout/viewport_propagation.rs
+++ b/Libraries/LibWeb/Rust/src/layout/viewport_propagation.rs
@@ -71,6 +71,19 @@ fn first_html_body_child(engine: &RetainedState, root_element: StyleNodeID) -> O
.find(|&child| engine.element_adjustment_facts(child) & element_adjustment_fact::IS_HTML_BODY_ELEMENT != 0)
}
+pub(crate) fn element_is_viewport_propagation_source(arena: &LayoutNodeArena, element: StyleNodeID) -> bool {
+ let Some(root_element) = document_element(arena) else {
+ return false;
+ };
+ root_element == element
+ || arena.with_style_store(|engine| {
+ engine.element_adjustment_facts(element) & element_adjustment_fact::IS_HTML_BODY_ELEMENT != 0
+ && engine.element_construction_facts(root_element) & element_construction_fact::IS_HTML_HTML_ELEMENT
+ != 0
+ && first_html_body_child(engine, root_element) == Some(element)
+ })
+}
+
/// The inputs of the propagation: the document element and its first HTML body child element, as
/// their own published style records have them.
pub(crate) fn viewport_propagation_facts(arena: &LayoutNodeArena) -> ViewportPropagationFacts {
diff --git a/Libraries/LibWeb/Rust/src/render_state/document_host.rs b/Libraries/LibWeb/Rust/src/render_state/document_host.rs
index 5a921c1a02e..ed6e46e7346 100644
--- a/Libraries/LibWeb/Rust/src/render_state/document_host.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/document_host.rs
@@ -1769,7 +1769,6 @@ mod tests {
host.queue_change(ArenaChange::Layout(LayoutChange::SetNeedsLayoutUpdate {
node: viewport,
- propagate_through_ancestors: false,
}));
assert_eq!(host.known_layout_up_to_date_unless_built(), None);
}
diff --git a/Libraries/LibWeb/Rust/src/render_state/wait.rs b/Libraries/LibWeb/Rust/src/render_state/wait.rs
index a243a42bcc8..fbddb840c00 100644
--- a/Libraries/LibWeb/Rust/src/render_state/wait.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/wait.rs
@@ -254,7 +254,6 @@ macro_rules! held_node_entry {
// The modules whose host entries read or write the row of a layout node the host holds.
held_node_entry!(crate::layout::shell_reads::HeldNode);
held_node_entry!(crate::layout::ArenaHeldNode);
-held_node_entry!(crate::layout::PartialRelayoutHeldNode);
held_node_entry!(crate::layout::text_queries::HeldNode);
held_node_entry!(crate::painting::ffi::HeldNode);
held_node_entry!(crate::painting::layout_tree_dump::HeldNode);