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