SessionHistoryEntry.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/URL.h>
  8. #include <AK/WeakPtr.h>
  9. #include <LibJS/Heap/Cell.h>
  10. #include <LibJS/Heap/GCPtr.h>
  11. #include <LibWeb/Forward.h>
  12. #include <LibWeb/HTML/PolicyContainers.h>
  13. namespace Web::HTML {
  14. // https://html.spec.whatwg.org/multipage/history.html#scroll-restoration-mode
  15. enum class ScrollRestorationMode {
  16. // https://html.spec.whatwg.org/multipage/history.html#dom-scrollrestoration-auto
  17. // The user agent is responsible for restoring the scroll position upon navigation.
  18. Auto,
  19. // https://html.spec.whatwg.org/multipage/history.html#dom-scrollrestoration-manual
  20. // The page is responsible for restoring the scroll position and the user agent does not attempt to do so automatically.
  21. Manual,
  22. };
  23. // https://html.spec.whatwg.org/multipage/history.html#session-history-entry
  24. struct SessionHistoryEntry final : public JS::Cell {
  25. JS_CELL(SessionHistoryEntry, JS::Cell);
  26. void visit_edges(Cell::Visitor&) override;
  27. // URL, a URL
  28. AK::URL url;
  29. // document, a Document or null
  30. // FIXME: this property is not present in the spec anymore and should be gone after introducing navigables
  31. JS::GCPtr<DOM::Document> document;
  32. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-document-state
  33. JS::GCPtr<HTML::DocumentState> document_state;
  34. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-serialized-state
  35. // serialized state, which is serialized state, initially StructuredSerializeForStorage(null).
  36. Optional<DeprecatedString> serialized_state;
  37. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-restoration-mode
  38. // scroll restoration mode, a scroll restoration mode, initially "auto"
  39. ScrollRestorationMode scroll_restoration_mode { ScrollRestorationMode::Auto };
  40. // policy container, a policy container or null
  41. Optional<PolicyContainer> policy_container;
  42. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-position
  43. // FIXME: scroll position data, which is scroll position data for the document's restorable scrollable regions
  44. // browsing context name, a browsing context name or null, initially null
  45. Optional<DeprecatedString> browsing_context_name;
  46. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-other
  47. // FIXME: persisted user state, which is implementation-defined, initially null
  48. // NOTE: This is where we could remember the state of form controls, for example.
  49. JS::GCPtr<BrowsingContext> original_source_browsing_context;
  50. };
  51. }