Skip to content

Truly independent web browser

LibWeb: Write highlight and image map facts where they are read

Aliaksandr Kalenik209ded4629b9
diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp
index f7a6594b805..08c34f341df 100644
--- a/Libraries/LibWeb/DOM/Document.cpp
+++ b/Libraries/LibWeb/DOM/Document.cpp
@@ -3164,14 +3164,11 @@ void Document::prepare_for_rendering(Layout::BegunRead const& read)
void Document::update_paint_and_hit_testing_properties_if_needed()
{
Layout::ForcedReadScope read { *this };
- // NB: Called during paint property resolution.
- // Everything that reads paint state comes through here, so the states it holds stale are written first.
- update_highlight_states_if_needed(read);
// Nothing was written to the render state since the properties were prepared from it: every pass below would find
// nothing to do, so none is sent to the render owner.
auto* host = m_layout_node_arena ? m_layout_node_arena->host() : nullptr;
- if (host && Layout::RustFFI::document_host_paint_preparation_is_current(host) && !m_needs_accumulated_visual_contexts_update && !m_image_map_areas_need_publication)
+ if (host && Layout::RustFFI::document_host_paint_preparation_is_current(host) && !m_needs_accumulated_visual_contexts_update)
return;
// What the passes prepare stays current until something is written to the render state, from here on as well.
@@ -3179,7 +3176,6 @@ void Document::update_paint_and_hit_testing_properties_if_needed()
Layout::RustFFI::document_host_note_paint_preparation_is_current(host);
prepare_for_rendering(read);
- Painting::publish_image_map_area_facts_if_needed(read, *this);
if (m_needs_accumulated_visual_contexts_update) {
m_needs_accumulated_visual_contexts_update = false;
if (has_committed_viewport_box())
@@ -12213,6 +12209,8 @@ Painting::DisplayListRecording Document::commit_display_list_recording(Layout::B
Optional<Painting::DisplayListRecording> Document::start_recording(Layout::BegunRead const& read, HTML::PaintConfig config, Painting::PaintCommandCacheMode cache_mode, Optional<Compositor::FlightPresentation>&& committed)
{
+ update_highlight_states_if_needed(read);
+ Painting::publish_image_map_area_facts_if_needed(read, *this);
update_paint_and_hit_testing_properties_if_needed();
VERIFY(has_committed_viewport_box());
@@ -12283,6 +12281,7 @@ Painting::HitTestListAdoption Document::adopt_published_recording(Optional<Layou
bool Document::hit_test_display_list_is_current(Layout::BegunRead const& read)
{
+ Painting::publish_image_map_area_facts_if_needed(read, *this);
update_paint_and_hit_testing_properties_if_needed();
if (!has_committed_viewport_box())
return false;
diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h
index a921aa07b97..6cc7f8b9688 100644
--- a/Libraries/LibWeb/DOM/Document.h
+++ b/Libraries/LibWeb/DOM/Document.h
@@ -662,8 +662,8 @@ public:
[[nodiscard]] bool is_running_update_layout() const;
// The selection changed, or lost its range, so the selection states of the boxes it paints through are stale. They
- // are found again at the next read of the paint state: the selection may change beside a frame in flight, which
- // holds the boxes.
+ // are found again before the next recording: the selection may change beside a frame in flight, which holds the
+ // boxes.
void note_selection_changed();
// Writes the selection and find-in-page match states left stale to the paint state.
void update_highlight_states_if_needed(Layout::BegunRead const&);
diff --git a/Libraries/LibWeb/HTML/LocalNavigable.cpp b/Libraries/LibWeb/HTML/LocalNavigable.cpp
index 82148df7875..75d86fd8935 100644
--- a/Libraries/LibWeb/HTML/LocalNavigable.cpp
+++ b/Libraries/LibWeb/HTML/LocalNavigable.cpp
@@ -92,6 +92,7 @@
#include <LibWeb/Painting/BoxViews.h>
#include <LibWeb/Painting/ChromeWidget.h>
#include <LibWeb/Painting/DocumentPaintState.h>
+#include <LibWeb/Painting/PaintFacts.h>
#include <LibWeb/Painting/PaintableTypes.h>
#include <LibWeb/Painting/PaintingRustBridge.h>
#include <LibWeb/Painting/ScrollSnap.h>
@@ -6973,6 +6974,8 @@ bool LocalNavigable::commit_frame(PaintConfig paint_config)
Layout::ForcedReadScope read { *document };
adopt_pending_async_scroll_offsets();
+ document->update_highlight_states_if_needed(read);
+ Painting::publish_image_map_area_facts_if_needed(read, *document);
document->update_paint_and_hit_testing_properties_if_needed();
document->update_compositor_animations(read);