mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 02:10:26 +00:00
LibWeb: Account for scroll and transforms in to_top_level_position()
This change means the right click context menu is displayed in the right place when clicking inside an iframe on a scrolled page, including when the iframe has CSS transforms applied to it.
This commit is contained in:
parent
e77167f2f4
commit
7fc945d524
Notes:
github-actions[bot]
2026-03-01 08:32:44 +00:00
Author: https://github.com/tcl3
Commit: 7fc945d524
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7898
Reviewed-by: https://github.com/kalenikaliaksandr
1 changed files with 14 additions and 3 deletions
|
|
@ -54,6 +54,7 @@
|
|||
#include <LibWeb/Painting/DisplayListPlayerSkia.h>
|
||||
#include <LibWeb/Painting/NavigableContainerViewportPaintable.h>
|
||||
#include <LibWeb/Painting/Paintable.h>
|
||||
#include <LibWeb/Painting/PaintableBox.h>
|
||||
#include <LibWeb/Painting/ViewportPaintable.h>
|
||||
#include <LibWeb/Platform/EventLoopPlugin.h>
|
||||
#include <LibWeb/Selection/Selection.h>
|
||||
|
|
@ -2581,10 +2582,20 @@ CSSPixelPoint Navigable::to_top_level_position(CSSPixelPoint a_position)
|
|||
break;
|
||||
if (!ancestor->container())
|
||||
return {};
|
||||
if (!ancestor->container()->paintable())
|
||||
auto const* paintable = ancestor->container()->paintable();
|
||||
if (!paintable)
|
||||
return {};
|
||||
// FIXME: Handle CSS transforms that might affect the ancestor.
|
||||
position.translate_by(ancestor->container()->paintable()->box_type_agnostic_position());
|
||||
|
||||
if (auto const* paintable_box = as_if<Painting::PaintableBox>(*paintable); paintable_box && paintable_box->accumulated_visual_context()) {
|
||||
auto const& accumulated_visual_context = *paintable_box->accumulated_visual_context();
|
||||
auto const& viewport_paintable = *paintable_box->document().paintable();
|
||||
auto const& scroll_state = viewport_paintable.scroll_state_snapshot();
|
||||
auto point = paintable_box->absolute_position();
|
||||
point.translate_by(position);
|
||||
position = accumulated_visual_context.transform_rect_to_viewport({ point, { 0, 0 } }, scroll_state).location();
|
||||
} else {
|
||||
position.translate_by(paintable->box_type_agnostic_position());
|
||||
}
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue