mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 18:57:34 +00:00
LibWeb: Ensure scroll offsets and clip rects updated before hit-testing
Hit-testing relies on updated clip rectangles and containing scroll offsets, so it's necessary to ensure that paintables have these elements updated. This also removes the enclosing scroll offsets update from `Internals::hit_test()`, as it is no longer needed.
This commit is contained in:
parent
d27b376699
commit
d3b983b201
2 changed files with 5 additions and 4 deletions
|
@ -52,9 +52,6 @@ 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()
|
// for stacking context traversal, might not exist if this call occurs between the tear_down_layout_tree()
|
||||||
// and update_layout() calls
|
// and update_layout() calls
|
||||||
active_document->update_layout();
|
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);
|
auto result = active_document->paintable_box()->hit_test({ x, y }, Painting::HitTestType::Exact);
|
||||||
if (result.has_value()) {
|
if (result.has_value()) {
|
||||||
auto hit_tеsting_result = JS::Object::create(realm(), nullptr);
|
auto hit_tеsting_result = JS::Object::create(realm(), nullptr);
|
||||||
|
|
|
@ -684,7 +684,11 @@ Optional<HitTestResult> PaintableBox::hit_test(CSSPixelPoint position, HitTestTy
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
if (layout_box().is_viewport()) {
|
if (layout_box().is_viewport()) {
|
||||||
const_cast<ViewportPaintable&>(static_cast<ViewportPaintable const&>(*this)).build_stacking_context_tree_if_needed();
|
auto& viewport_paintable = const_cast<ViewportPaintable&>(static_cast<ViewportPaintable const&>(*this));
|
||||||
|
viewport_paintable.build_stacking_context_tree_if_needed();
|
||||||
|
HashMap<Painting::PaintableBox const*, Painting::ViewportPaintable::ScrollFrame> scroll_frames;
|
||||||
|
viewport_paintable.assign_scroll_frame_ids(scroll_frames);
|
||||||
|
viewport_paintable.assign_clip_rectangles();
|
||||||
return stacking_context()->hit_test(position, type);
|
return stacking_context()->hit_test(position, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue