1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

LibWeb: Add Paintable::dom_node() convenience accessor

This commit is contained in:
Andreas Kling 2022-03-21 11:19:02 +01:00
parent b64b5fa8bd
commit f7cfd47b48
2 changed files with 9 additions and 6 deletions

View file

@ -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())

View file

@ -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();
}
}