HTMLAnchorElement.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/HTML/HTMLElement.h>
  8. #include <LibWeb/HTML/HTMLHyperlinkElementUtils.h>
  9. namespace Web::HTML {
  10. class HTMLAnchorElement final
  11. : public HTMLElement
  12. , public HTMLHyperlinkElementUtils {
  13. WEB_PLATFORM_OBJECT(HTMLAnchorElement, HTMLElement);
  14. public:
  15. virtual ~HTMLAnchorElement() override;
  16. DeprecatedString target() const { return attribute(HTML::AttributeNames::target); }
  17. DeprecatedString download() const { return attribute(HTML::AttributeNames::download); }
  18. // ^EventTarget
  19. // https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-a-element
  20. virtual bool is_focusable() const override { return has_attribute(HTML::AttributeNames::href); }
  21. virtual bool is_html_anchor_element() const override { return true; }
  22. private:
  23. HTMLAnchorElement(DOM::Document&, DOM::QualifiedName);
  24. void run_activation_behavior(Web::DOM::Event const&);
  25. // ^DOM::Element
  26. virtual void parse_attribute(FlyString const& name, DeprecatedString const& value) override;
  27. virtual i32 default_tab_index_value() const override;
  28. // ^HTML::HTMLHyperlinkElementUtils
  29. virtual DOM::Document& hyperlink_element_utils_document() override { return document(); }
  30. virtual DeprecatedString hyperlink_element_utils_href() const override;
  31. virtual void set_hyperlink_element_utils_href(DeprecatedString) override;
  32. virtual bool hyperlink_element_utils_is_html_anchor_element() const final { return true; }
  33. virtual bool hyperlink_element_utils_is_connected() const final { return is_connected(); }
  34. virtual DeprecatedString hyperlink_element_utils_target() const final { return target(); }
  35. virtual void hyperlink_element_utils_queue_an_element_task(HTML::Task::Source source, Function<void()> steps) override
  36. {
  37. queue_an_element_task(source, move(steps));
  38. }
  39. };
  40. }
  41. namespace Web::DOM {
  42. template<>
  43. inline bool Node::fast_is<HTML::HTMLAnchorElement>() const { return is_html_anchor_element(); }
  44. }