mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:18:12 +00:00
LibHTML: Implement basic HTMLElement.title support
We now show a tooltip for the hovered node's enclosing HTML element's title attribute, if one is present. This patch also adds HTMLHeadingElement. The tags h1-h6 will now create the right kind of objects.
This commit is contained in:
parent
92aae72025
commit
f38b0f667e
4 changed files with 28 additions and 3 deletions
|
@ -6,4 +6,9 @@ class HTMLElement : public Element {
|
|||
public:
|
||||
HTMLElement(Document&, const String& tag_name);
|
||||
virtual ~HTMLElement() override;
|
||||
|
||||
String title() const { return attribute("title"); }
|
||||
|
||||
private:
|
||||
virtual bool is_html_element() const final { return true; }
|
||||
};
|
||||
|
|
|
@ -81,3 +81,10 @@ const HTMLAnchorElement* Node::enclosing_link_element() const
|
|||
return static_cast<const HTMLAnchorElement*>(this);
|
||||
return parent() ? parent()->enclosing_link_element() : nullptr;
|
||||
}
|
||||
|
||||
const HTMLElement* Node::enclosing_html_element() const
|
||||
{
|
||||
if (is_html_element())
|
||||
return static_cast<const HTMLElement*>(this);
|
||||
return parent() ? parent()->enclosing_html_element() : nullptr;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ enum class NodeType : unsigned {
|
|||
};
|
||||
|
||||
class Document;
|
||||
class HTMLElement;
|
||||
class HTMLAnchorElement;
|
||||
class ParentNode;
|
||||
class LayoutNode;
|
||||
|
@ -39,6 +40,9 @@ public:
|
|||
const Document& document() const { return m_document; }
|
||||
|
||||
const HTMLAnchorElement* enclosing_link_element() const;
|
||||
const HTMLElement* enclosing_html_element() const;
|
||||
|
||||
virtual bool is_html_element() const { return false; }
|
||||
|
||||
protected:
|
||||
Node(Document&, NodeType);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue