LibHTML: Detect hovering over links

HtmlView now calls Node::enclosing_link_element() to find the nearest
ancestor <a> element.

This patch also adds HTMLElement and HTMLAnchorElement.
This commit is contained in:
Andreas Kling 2019-09-29 11:59:38 +02:00
parent 88de955073
commit b477aff843
Notes: sideshowbarker 2024-07-19 11:53:50 +09:00
9 changed files with 60 additions and 0 deletions

View file

@ -1,6 +1,7 @@
#include <LibGUI/GPainter.h>
#include <LibGUI/GScrollBar.h>
#include <LibHTML/DOM/Element.h>
#include <LibHTML/DOM/HTMLAnchorElement.h>
#include <LibHTML/Dump.h>
#include <LibHTML/HtmlView.h>
#include <LibHTML/Layout/LayoutNode.h>
@ -93,6 +94,9 @@ void HtmlView::mousemove_event(GMouseEvent& event)
hovered_node_changed = node == m_document->hovered_node();
if (node) {
dbg() << "HtmlView: mousemove: " << node->tag_name() << "{" << node << "}";
if (auto* link = node->enclosing_link_element()) {
dbg() << "HtmlView: hovering over a link to " << link->href();
}
}
}
if (hovered_node_changed)