summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-03-21 12:16:50 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-21 13:03:33 +0100
commita779ace6a1685df6b627357b35022a0b798adbfd (patch)
tree0b97006f6734c4dcdb8e824497de6406cbc1a05c /Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
parent996f3228a2e518fb5562a4b2f91743ba435df9c3 (diff)
downloadserenity-a779ace6a1685df6b627357b35022a0b798adbfd.zip
LibWeb: Don't compute fragment absolute rect twice while hit testing
Diffstat (limited to 'Userland/Libraries/LibWeb/Painting/PaintableBox.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Painting/PaintableBox.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
index 4dbcf2349a..90bc55eb7b 100644
--- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
+++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
@@ -550,12 +550,13 @@ Optional<HitTestResult> PaintableWithLines::hit_test(const Gfx::FloatPoint& posi
for (auto& fragment : line_box.fragments()) {
if (is<Layout::Box>(fragment.layout_node()) && static_cast<Layout::Box const&>(fragment.layout_node()).paint_box()->stacking_context())
continue;
- if (fragment.absolute_rect().contains(position)) {
+ auto fragment_absolute_rect = fragment.absolute_rect();
+ if (fragment_absolute_rect.contains(position)) {
if (is<Layout::BlockContainer>(fragment.layout_node()) && fragment.layout_node().paintable())
return fragment.layout_node().paintable()->hit_test(position, type);
return HitTestResult { *fragment.layout_node().paintable(), fragment.text_index_at(position.x()) };
}
- if (fragment.absolute_rect().top() <= position.y())
+ if (fragment_absolute_rect.top() <= position.y())
last_good_candidate = HitTestResult { *fragment.layout_node().paintable(), fragment.text_index_at(position.x()) };
}
}