HTMLHyperlinkElementUtils.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #include <LibWeb/HTML/TokenizedFeatures.h>
  11. namespace Web::HTML {
  12. class HTMLHyperlinkElementUtils {
  13. public:
  14. virtual ~HTMLHyperlinkElementUtils();
  15. DeprecatedString origin() const;
  16. DeprecatedString href() const;
  17. void set_href(DeprecatedString);
  18. DeprecatedString protocol() const;
  19. void set_protocol(DeprecatedString);
  20. DeprecatedString username() const;
  21. void set_username(DeprecatedString);
  22. DeprecatedString password() const;
  23. void set_password(DeprecatedString);
  24. DeprecatedString host() const;
  25. void set_host(DeprecatedString);
  26. DeprecatedString hostname() const;
  27. void set_hostname(DeprecatedString);
  28. DeprecatedString port() const;
  29. void set_port(DeprecatedString);
  30. DeprecatedString pathname() const;
  31. void set_pathname(DeprecatedString);
  32. DeprecatedString search() const;
  33. void set_search(DeprecatedString);
  34. DeprecatedString hash() const;
  35. void set_hash(DeprecatedString);
  36. protected:
  37. virtual DOM::Document& hyperlink_element_utils_document() = 0;
  38. virtual DeprecatedString hyperlink_element_utils_href() const = 0;
  39. virtual void set_hyperlink_element_utils_href(DeprecatedString) = 0;
  40. virtual bool hyperlink_element_utils_is_html_anchor_element() const = 0;
  41. virtual bool hyperlink_element_utils_is_connected() const = 0;
  42. virtual DeprecatedString hyperlink_element_utils_target() const = 0;
  43. virtual DeprecatedString hyperlink_element_utils_rel() const = 0;
  44. virtual void hyperlink_element_utils_queue_an_element_task(HTML::Task::Source source, Function<void()> steps) = 0;
  45. void set_the_url();
  46. void follow_the_hyperlink(Optional<DeprecatedString> hyperlink_suffix);
  47. private:
  48. void reinitialize_url() const;
  49. void update_href();
  50. bool cannot_navigate() const;
  51. DeprecatedString get_an_elements_target() const;
  52. TokenizedFeature::NoOpener get_an_elements_noopener(StringView target) const;
  53. Optional<AK::URL> m_url;
  54. };
  55. }