2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2019-09-29 11:59:38 +02:00
|
|
|
#pragma once
|
|
|
|
|
2020-07-26 15:08:16 +02:00
|
|
|
#include <LibWeb/HTML/HTMLElement.h>
|
2021-10-03 19:39:12 +02:00
|
|
|
#include <LibWeb/HTML/HTMLHyperlinkElementUtils.h>
|
2019-09-29 11:59:38 +02:00
|
|
|
|
2020-07-28 18:20:36 +02:00
|
|
|
namespace Web::HTML {
|
2020-03-07 10:27:02 +01:00
|
|
|
|
2021-10-03 19:39:12 +02:00
|
|
|
class HTMLAnchorElement final
|
|
|
|
: public HTMLElement
|
|
|
|
, public HTMLHyperlinkElementUtils {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(HTMLAnchorElement, HTMLElement);
|
2020-07-27 05:04:26 +01:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
public:
|
2019-09-29 11:59:38 +02:00
|
|
|
virtual ~HTMLAnchorElement() override;
|
|
|
|
|
2020-06-03 20:51:28 +02:00
|
|
|
String target() const { return attribute(HTML::AttributeNames::target); }
|
2022-03-15 14:37:58 +00:00
|
|
|
String download() const { return attribute(HTML::AttributeNames::download); }
|
2020-08-14 19:40:37 +02:00
|
|
|
|
2022-03-26 18:05:48 +00:00
|
|
|
// ^EventTarget
|
|
|
|
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-a-element
|
2020-08-14 19:40:37 +02:00
|
|
|
virtual bool is_focusable() const override { return has_attribute(HTML::AttributeNames::href); }
|
2021-10-03 19:39:12 +02:00
|
|
|
|
2022-03-02 15:14:38 +01:00
|
|
|
virtual bool is_html_anchor_element() const override { return true; }
|
|
|
|
|
2021-10-03 19:39:12 +02:00
|
|
|
private:
|
2022-08-28 13:42:07 +02:00
|
|
|
HTMLAnchorElement(DOM::Document&, DOM::QualifiedName);
|
|
|
|
|
2022-03-15 14:37:58 +00:00
|
|
|
void run_activation_behavior(Web::DOM::Event const&);
|
|
|
|
|
2021-10-03 19:39:12 +02:00
|
|
|
// ^DOM::Element
|
|
|
|
virtual void parse_attribute(FlyString const& name, String const& value) override;
|
|
|
|
|
|
|
|
// ^HTML::HTMLHyperlinkElementUtils
|
2022-03-15 14:37:58 +00:00
|
|
|
virtual DOM::Document& hyperlink_element_utils_document() override { return document(); }
|
2021-10-03 19:39:12 +02:00
|
|
|
virtual String hyperlink_element_utils_href() const override;
|
|
|
|
virtual void set_hyperlink_element_utils_href(String) override;
|
2022-03-15 14:37:58 +00:00
|
|
|
virtual bool hyperlink_element_utils_is_html_anchor_element() const final { return true; }
|
|
|
|
virtual bool hyperlink_element_utils_is_connected() const final { return is_connected(); }
|
|
|
|
virtual String hyperlink_element_utils_target() const final { return target(); }
|
|
|
|
virtual void hyperlink_element_utils_queue_an_element_task(HTML::Task::Source source, Function<void()> steps) override
|
|
|
|
{
|
|
|
|
queue_an_element_task(source, move(steps));
|
|
|
|
}
|
2019-09-29 11:59:38 +02:00
|
|
|
};
|
2019-10-06 20:37:39 +02:00
|
|
|
|
|
|
|
}
|
2022-03-02 15:14:38 +01:00
|
|
|
|
|
|
|
namespace Web::DOM {
|
|
|
|
template<>
|
|
|
|
inline bool Node::fast_is<HTML::HTMLAnchorElement>() const { return is_html_anchor_element(); }
|
|
|
|
}
|