1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 17:55:07 +00:00

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
9 changed files with 60 additions and 0 deletions

View file

@ -1,5 +1,6 @@
#include <LibHTML/DOM/Node.h>
#include <LibHTML/DOM/Element.h>
#include <LibHTML/DOM/HTMLAnchorElement.h>
#include <LibHTML/CSS/StyleResolver.h>
#include <LibHTML/Layout/LayoutNode.h>
#include <LibHTML/Layout/LayoutBlock.h>
@ -73,3 +74,10 @@ RefPtr<LayoutNode> Node::create_layout_tree(const StyleResolver& resolver, const
}
return layout_node;
}
const HTMLAnchorElement* Node::enclosing_link_element() const
{
if (is_element() && tag_name().to_lowercase() == "a")
return static_cast<const HTMLAnchorElement*>(this);
return parent() ? parent()->enclosing_link_element() : nullptr;
}