1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 06:20:46 +00:00

LibWeb: Force scroll offsets update in Internals::hit_test()

Since we might enter Internals::hit_test() before the enclosing scroll
offsets are updated in the paintables tree during pre-paint, this
update need to be enforced.
This commit is contained in:
Aliaksandr Kalenik 2024-01-29 06:07:32 +01:00 committed by Andreas Kling
parent 66959bcc09
commit beb1c85b6b

View File

@ -16,6 +16,7 @@
#include <LibWeb/Internals/Internals.h>
#include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/PaintableBox.h>
#include <LibWeb/Painting/ViewportPaintable.h>
namespace Web::Internals {
@ -51,6 +52,9 @@ JS::Object* Internals::hit_test(double x, double y)
// for stacking context traversal, might not exist if this call occurs between the tear_down_layout_tree()
// and update_layout() calls
active_document->update_layout();
HashMap<Painting::PaintableBox const*, Painting::ViewportPaintable::ScrollFrame> scroll_frames;
// NOTE: Make sure that paintables have updated scroll offsets
active_document->paintable()->assign_scroll_frame_ids(scroll_frames);
auto result = active_document->paintable_box()->hit_test({ x, y }, Painting::HitTestType::Exact);
if (result.has_value()) {
auto hit_tеsting_result = JS::Object::create(realm(), nullptr);