summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Page/EventHandler.cpp8
-rw-r--r--Userland/Libraries/LibWeb/Painting/Paintable.h13
2 files changed, 17 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp
index 2fa1606f9a..298efdb3e4 100644
--- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp
+++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp
@@ -301,7 +301,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
} else {
if (button == GUI::MouseButton::Primary) {
auto result = paint_root()->hit_test(position.to_type<float>(), Painting::HitTestType::TextCursor);
- if (result.has_value() && result->paintable->layout_node().dom_node()) {
+ if (result.has_value() && result->dom_node()) {
// See if we want to focus something.
bool did_focus_something = false;
@@ -316,7 +316,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
// If we didn't focus anything, place the document text cursor at the mouse position.
// FIXME: This is all rather strange. Find a better solution.
if (!did_focus_something) {
- m_browsing_context.set_cursor_position(DOM::Position(*result->paintable->layout_node().dom_node(), result->index_in_node));
+ m_browsing_context.set_cursor_position(DOM::Position(*result->dom_node(), result->index_in_node));
layout_root()->set_selection({ { result->paintable->layout_node(), result->index_in_node }, {} });
m_in_mouse_selection = true;
}
@@ -410,8 +410,8 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
}
if (m_in_mouse_selection) {
auto hit = paint_root()->hit_test(position.to_type<float>(), Painting::HitTestType::TextCursor);
- if (start_index.has_value() && hit.has_value() && hit->paintable->layout_node().dom_node()) {
- m_browsing_context.set_cursor_position(DOM::Position(*hit->paintable->layout_node().dom_node(), *start_index));
+ if (start_index.has_value() && hit.has_value() && hit->dom_node()) {
+ m_browsing_context.set_cursor_position(DOM::Position(*hit->dom_node(), *start_index));
layout_root()->set_selection_end({ hit->paintable->layout_node(), hit->index_in_node });
}
if (auto* page = m_browsing_context.page())
diff --git a/Userland/Libraries/LibWeb/Painting/Paintable.h b/Userland/Libraries/LibWeb/Painting/Paintable.h
index 3140c68c26..75c471d684 100644
--- a/Userland/Libraries/LibWeb/Painting/Paintable.h
+++ b/Userland/Libraries/LibWeb/Painting/Paintable.h
@@ -32,6 +32,9 @@ struct HitTestResult {
After,
};
InternalPosition internal_position { None };
+
+ DOM::Node* dom_node();
+ DOM::Node const* dom_node() const;
};
enum class HitTestType {
@@ -96,4 +99,14 @@ private:
Optional<Layout::BlockContainer*> mutable m_containing_block;
};
+inline DOM::Node* HitTestResult::dom_node()
+{
+ return paintable->layout_node().dom_node();
+}
+
+inline DOM::Node const* HitTestResult::dom_node() const
+{
+ return paintable->layout_node().dom_node();
+}
+
}