HTMLAnchorElement.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. public:
  14. using WrapperType = Bindings::HTMLAnchorElementWrapper;
  15. HTMLAnchorElement(DOM::Document&, DOM::QualifiedName);
  16. virtual ~HTMLAnchorElement() override;
  17. String target() const { return attribute(HTML::AttributeNames::target); }
  18. String download() const { return attribute(HTML::AttributeNames::download); }
  19. virtual bool is_focusable() const override { return has_attribute(HTML::AttributeNames::href); }
  20. virtual bool is_html_anchor_element() const override { return true; }
  21. private:
  22. void run_activation_behavior(Web::DOM::Event const&);
  23. // ^DOM::Element
  24. virtual void parse_attribute(FlyString const& name, String const& value) override;
  25. // ^HTML::HTMLHyperlinkElementUtils
  26. virtual DOM::Document& hyperlink_element_utils_document() override { return document(); }
  27. virtual String hyperlink_element_utils_href() const override;
  28. virtual void set_hyperlink_element_utils_href(String) override;
  29. virtual bool hyperlink_element_utils_is_html_anchor_element() const final { return true; }
  30. virtual bool hyperlink_element_utils_is_connected() const final { return is_connected(); }
  31. virtual String hyperlink_element_utils_target() const final { return target(); }
  32. virtual void hyperlink_element_utils_queue_an_element_task(HTML::Task::Source source, Function<void()> steps) override
  33. {
  34. queue_an_element_task(source, move(steps));
  35. }
  36. };
  37. }
  38. namespace Web::DOM {
  39. template<>
  40. inline bool Node::fast_is<HTML::HTMLAnchorElement>() const { return is_html_anchor_element(); }
  41. }