diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 1424f38caf..64247f96dd 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1060,10 +1060,8 @@ void Document::update_layout() // Broadcast the current viewport rect to any new paintables, so they know whether they're visible or not. inform_all_viewport_clients_about_the_current_viewport_rect(); - if (navigable()) { - navigable()->set_needs_to_resolve_paint_only_properties(); - navigable()->set_needs_display(); - } + navigable()->set_needs_display(); + set_needs_to_resolve_paint_only_properties(); if (navigable()->is_traversable()) { page().client().page_did_layout(); @@ -1145,6 +1143,15 @@ void Document::update_style() m_style_update_timer->stop(); } +void Document::update_paint_and_hit_testing_properties_if_needed() +{ + if (!m_needs_to_resolve_paint_only_properties) + return; + m_needs_to_resolve_paint_only_properties = false; + if (auto* paintable = this->paintable()) + paintable->resolve_paint_only_properties(); +} + void Document::set_link_color(Color color) { m_link_color = color; diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 315dc64d1a..a6cb496716 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -202,6 +202,7 @@ public: void update_style(); void update_layout(); + void update_paint_and_hit_testing_properties_if_needed(); void set_needs_layout(); @@ -562,6 +563,8 @@ public: Element const* element_from_point(double x, double y); + void set_needs_to_resolve_paint_only_properties() { m_needs_to_resolve_paint_only_properties = true; } + protected: virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; @@ -785,6 +788,8 @@ private: bool m_ready_to_run_scripts { false }; Vector m_form_associated_elements_with_form_attribute; + + bool m_needs_to_resolve_paint_only_properties { true }; }; template<> diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 9bc01bccfc..d321ee85c8 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -593,8 +593,8 @@ Element::RequiredInvalidationAfterStyleChange Element::recompute_style() m_computed_css_values = move(new_computed_css_values); computed_css_values_changed(); - if (invalidation.repaint && document().navigable()) - document().navigable()->set_needs_to_resolve_paint_only_properties(); + if (invalidation.repaint) + document().set_needs_to_resolve_paint_only_properties(); if (!invalidation.rebuild_layout_tree && layout_node()) { // If we're keeping the layout tree, we can just apply the new style to the existing layout tree. diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.cpp b/Userland/Libraries/LibWeb/HTML/Navigable.cpp index 72193ec832..502c3e37fe 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigable.cpp @@ -2106,10 +2106,7 @@ void Navigable::paint(Painting::RecordingPainter& recording_painter, PaintConfig context.set_should_paint_overlay(config.paint_overlay); context.set_has_focus(config.has_focus); - if (m_needs_to_resolve_paint_only_properties) { - document->paintable()->resolve_paint_only_properties(); - m_needs_to_resolve_paint_only_properties = false; - } + document->update_paint_and_hit_testing_properties_if_needed(); HashMap scroll_frames; if (is_traversable()) { diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.h b/Userland/Libraries/LibWeb/HTML/Navigable.h index d75c3b6de3..7c9554284f 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.h +++ b/Userland/Libraries/LibWeb/HTML/Navigable.h @@ -180,8 +180,6 @@ public: }; void paint(Painting::RecordingPainter&, PaintConfig); - void set_needs_to_resolve_paint_only_properties() { m_needs_to_resolve_paint_only_properties = true; } - protected: Navigable(); @@ -223,8 +221,6 @@ private: CSSPixelSize m_size; CSSPixelPoint m_viewport_scroll_offset; - - bool m_needs_to_resolve_paint_only_properties { true }; }; HashTable& all_navigables();