diff options
author | Andreas Kling <kling@serenityos.org> | 2022-03-11 00:03:28 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-11 00:21:49 +0100 |
commit | 5779a910e5186fbf6bf2d26203312271073dcfce (patch) | |
tree | 7f1aae3a61dd35c8dfc391ca0dcc64be7a38a59a /Userland/Libraries/LibWeb/Layout/BlockContainer.cpp | |
parent | ba606d90570f2a57cc094c19cf4fd35a43e22102 (diff) | |
download | serenity-5779a910e5186fbf6bf2d26203312271073dcfce.zip |
LibWeb: Move hit testing to the painting tree
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/BlockContainer.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/BlockContainer.cpp | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/BlockContainer.cpp b/Userland/Libraries/LibWeb/Layout/BlockContainer.cpp index 4871d6e477..4723d8bb09 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockContainer.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockContainer.cpp @@ -29,31 +29,6 @@ BlockContainer::~BlockContainer() { } -HitTestResult BlockContainer::hit_test(const Gfx::IntPoint& position, HitTestType type) const -{ - if (!children_are_inline()) - return Box::hit_test(position, type); - - HitTestResult last_good_candidate; - for (auto& line_box : paint_box()->line_boxes()) { - for (auto& fragment : line_box.fragments()) { - if (is<Box>(fragment.layout_node()) && verify_cast<Box>(fragment.layout_node()).paint_box()->stacking_context()) - continue; - if (enclosing_int_rect(fragment.absolute_rect()).contains(position)) { - if (is<BlockContainer>(fragment.layout_node())) - return verify_cast<BlockContainer>(fragment.layout_node()).hit_test(position, type); - return { fragment.layout_node().paintable(), fragment.text_index_at(position.x()) }; - } - if (fragment.absolute_rect().top() <= position.y()) - last_good_candidate = { fragment.layout_node().paintable(), fragment.text_index_at(position.x()) }; - } - } - - if (type == HitTestType::TextCursor && last_good_candidate.paintable) - return last_good_candidate; - return { paint_box()->absolute_border_box_rect().contains(position.x(), position.y()) ? paintable() : nullptr }; -} - bool BlockContainer::is_scrollable() const { // FIXME: Support horizontal scroll as well (overflow-x) |