HTMLHyperlinkElementUtils.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/URL.h>
  8. #include <LibWeb/Forward.h>
  9. #include <LibWeb/HTML/EventLoop/Task.h>
  10. namespace Web::HTML {
  11. class HTMLHyperlinkElementUtils {
  12. public:
  13. virtual ~HTMLHyperlinkElementUtils();
  14. DeprecatedString origin() const;
  15. DeprecatedString href() const;
  16. void set_href(DeprecatedString);
  17. DeprecatedString protocol() const;
  18. void set_protocol(DeprecatedString);
  19. DeprecatedString username() const;
  20. void set_username(DeprecatedString);
  21. DeprecatedString password() const;
  22. void set_password(DeprecatedString);
  23. DeprecatedString host() const;
  24. void set_host(DeprecatedString);
  25. DeprecatedString hostname() const;
  26. void set_hostname(DeprecatedString);
  27. DeprecatedString port() const;
  28. void set_port(DeprecatedString);
  29. DeprecatedString pathname() const;
  30. void set_pathname(DeprecatedString);
  31. DeprecatedString search() const;
  32. void set_search(DeprecatedString);
  33. DeprecatedString hash() const;
  34. void set_hash(DeprecatedString);
  35. protected:
  36. virtual DOM::Document& hyperlink_element_utils_document() = 0;
  37. virtual DeprecatedString hyperlink_element_utils_href() const = 0;
  38. virtual void set_hyperlink_element_utils_href(DeprecatedString) = 0;
  39. virtual bool hyperlink_element_utils_is_html_anchor_element() const = 0;
  40. virtual bool hyperlink_element_utils_is_connected() const = 0;
  41. virtual DeprecatedString hyperlink_element_utils_target() const = 0;
  42. virtual void hyperlink_element_utils_queue_an_element_task(HTML::Task::Source source, Function<void()> steps) = 0;
  43. void set_the_url();
  44. void follow_the_hyperlink(Optional<DeprecatedString> hyperlink_suffix);
  45. private:
  46. void reinitialize_url() const;
  47. void update_href();
  48. bool cannot_navigate() const;
  49. DeprecatedString get_an_elements_target() const;
  50. bool get_an_elements_noopener(StringView target) const;
  51. Optional<AK::URL> m_url;
  52. };
  53. }