Serenity Operating System
at master 64 lines 2.4 kB view raw
1/* 2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <LibWeb/HTML/HTMLElement.h> 10#include <LibWeb/HTML/HTMLHyperlinkElementUtils.h> 11 12namespace Web::HTML { 13 14class HTMLAnchorElement final 15 : public HTMLElement 16 , public HTMLHyperlinkElementUtils { 17 WEB_PLATFORM_OBJECT(HTMLAnchorElement, HTMLElement); 18 19public: 20 virtual ~HTMLAnchorElement() override; 21 22 DeprecatedString rel() const { return attribute(HTML::AttributeNames::rel); } 23 DeprecatedString target() const { return attribute(HTML::AttributeNames::target); } 24 DeprecatedString download() const { return attribute(HTML::AttributeNames::download); } 25 26 // ^EventTarget 27 // https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-a-element 28 virtual bool is_focusable() const override { return has_attribute(HTML::AttributeNames::href); } 29 30 virtual bool is_html_anchor_element() const override { return true; } 31 32private: 33 HTMLAnchorElement(DOM::Document&, DOM::QualifiedName); 34 35 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; 36 37 void run_activation_behavior(Web::DOM::Event const&); 38 39 // ^DOM::Element 40 virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override; 41 virtual i32 default_tab_index_value() const override; 42 43 // ^HTML::HTMLHyperlinkElementUtils 44 virtual DOM::Document& hyperlink_element_utils_document() override { return document(); } 45 virtual DeprecatedString hyperlink_element_utils_href() const override; 46 virtual void set_hyperlink_element_utils_href(DeprecatedString) override; 47 virtual bool hyperlink_element_utils_is_html_anchor_element() const final { return true; } 48 virtual bool hyperlink_element_utils_is_connected() const final { return is_connected(); } 49 virtual DeprecatedString hyperlink_element_utils_target() const final { return target(); } 50 virtual DeprecatedString hyperlink_element_utils_rel() const final { return rel(); } 51 virtual void hyperlink_element_utils_queue_an_element_task(HTML::Task::Source source, Function<void()> steps) override 52 { 53 queue_an_element_task(source, move(steps)); 54 } 55 56 virtual Optional<ARIA::Role> default_role() const override; 57}; 58 59} 60 61namespace Web::DOM { 62template<> 63inline bool Node::fast_is<HTML::HTMLAnchorElement>() const { return is_html_anchor_element(); } 64}