diff options
author | Andreas Kling <kling@serenityos.org> | 2022-03-21 11:19:02 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-21 13:03:33 +0100 |
commit | f7cfd47b48fdaa9629d762e7204cfdd8e21a0596 (patch) | |
tree | f4195b11bcc4b0f38d1c198d3ac4136fd3afc6bb /Userland/Libraries | |
parent | b64b5fa8bdb70dd95342660464d9a861abef1e6a (diff) | |
download | serenity-f7cfd47b48fdaa9629d762e7204cfdd8e21a0596.zip |
LibWeb: Add Paintable::dom_node() convenience accessor
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/Page/EventHandler.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Painting/Paintable.h | 7 |
2 files changed, 9 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 298efdb3e4..b3da68ed98 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -182,7 +182,7 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button if (paintable) { RefPtr<DOM::Node> node = paintable->mouse_event_target(); if (!node) - node = paintable->layout_node().dom_node(); + node = paintable->dom_node(); if (node) { if (is<HTML::HTMLIFrameElement>(*node)) { @@ -235,7 +235,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt node = paintable->mouse_event_target(); if (!node) - node = paintable->layout_node().dom_node(); + node = paintable->dom_node(); document->set_hovered_node(node); if (paintable->wants_mouse_events()) { @@ -357,7 +357,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt const HTML::HTMLAnchorElement* hovered_link_element = nullptr; if (paintable) { if (paintable->wants_mouse_events()) { - document.set_hovered_node(paintable->layout_node().dom_node()); + document.set_hovered_node(paintable->dom_node()); if (paintable->handle_mousemove({}, position, buttons, modifiers) == Painting::Paintable::DispatchEventOfSameName::No) return false; @@ -368,7 +368,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt RefPtr<DOM::Node> node = paintable->mouse_event_target(); if (!node) - node = paintable->layout_node().dom_node(); + node = paintable->dom_node(); if (node && is<HTML::HTMLIFrameElement>(*node)) { if (auto* nested_browsing_context = static_cast<HTML::HTMLIFrameElement&>(*node).nested_browsing_context()) diff --git a/Userland/Libraries/LibWeb/Painting/Paintable.h b/Userland/Libraries/LibWeb/Painting/Paintable.h index 75c471d684..d272fa185d 100644 --- a/Userland/Libraries/LibWeb/Painting/Paintable.h +++ b/Userland/Libraries/LibWeb/Painting/Paintable.h @@ -74,6 +74,9 @@ public: Layout::Node const& layout_node() const { return m_layout_node; } Layout::Node& layout_node() { return const_cast<Layout::Node&>(m_layout_node); } + DOM::Node* dom_node() { return layout_node().dom_node(); } + DOM::Node const* dom_node() const { return layout_node().dom_node(); } + auto const& computed_values() const { return m_layout_node.computed_values(); } HTML::BrowsingContext const& browsing_context() const { return m_layout_node.browsing_context(); } @@ -101,12 +104,12 @@ private: inline DOM::Node* HitTestResult::dom_node() { - return paintable->layout_node().dom_node(); + return paintable->dom_node(); } inline DOM::Node const* HitTestResult::dom_node() const { - return paintable->layout_node().dom_node(); + return paintable->dom_node(); } } |