SessionHistoryEntry.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. #include <LibWeb/HTML/StructuredSerialize.h>
  14. namespace Web::HTML {
  15. // https://html.spec.whatwg.org/multipage/history.html#scroll-restoration-mode
  16. enum class ScrollRestorationMode {
  17. // https://html.spec.whatwg.org/multipage/history.html#dom-scrollrestoration-auto
  18. // The user agent is responsible for restoring the scroll position upon navigation.
  19. Auto,
  20. // https://html.spec.whatwg.org/multipage/history.html#dom-scrollrestoration-manual
  21. // The page is responsible for restoring the scroll position and the user agent does not attempt to do so automatically.
  22. Manual,
  23. };
  24. // https://html.spec.whatwg.org/multipage/history.html#session-history-entry
  25. struct SessionHistoryEntry final : public JS::Cell {
  26. JS_CELL(SessionHistoryEntry, JS::Cell);
  27. SessionHistoryEntry();
  28. void visit_edges(Cell::Visitor&) override;
  29. enum class Pending {
  30. Tag,
  31. };
  32. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-step
  33. // step, a non-negative integer or "pending", initially "pending".
  34. Variant<int, Pending> step { Pending::Tag };
  35. // URL, a URL
  36. AK::URL url;
  37. // document, a Document or null
  38. // FIXME: this property is not present in the spec anymore and should be gone after introducing navigables
  39. JS::GCPtr<DOM::Document> document;
  40. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-document-state
  41. JS::GCPtr<HTML::DocumentState> document_state;
  42. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-classic-history-api-state
  43. // classic history API state, which is serialized state, initially StructuredSerializeForStorage(null).
  44. SerializationRecord classic_history_api_state;
  45. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-state
  46. // navigation API state, which is a serialized state, initially StructuredSerializeForStorage(undefined).
  47. SerializationRecord navigation_api_state;
  48. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-key
  49. // navigation API key, which is a string, initially set to the result of generating a random UUID.
  50. String navigation_api_key;
  51. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-id
  52. // navigation API ID, which is a string, initially set to the result of generating a random UUID.
  53. String navigation_api_id;
  54. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-restoration-mode
  55. // scroll restoration mode, a scroll restoration mode, initially "auto"
  56. ScrollRestorationMode scroll_restoration_mode { ScrollRestorationMode::Auto };
  57. // policy container, a policy container or null
  58. Optional<PolicyContainer> policy_container;
  59. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-position
  60. // FIXME: scroll position data, which is scroll position data for the document's restorable scrollable regions
  61. // browsing context name, a browsing context name or null, initially null
  62. Optional<DeprecatedString> browsing_context_name;
  63. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-other
  64. // FIXME: persisted user state, which is implementation-defined, initially null
  65. // NOTE: This is where we could remember the state of form controls, for example.
  66. JS::GCPtr<BrowsingContext> original_source_browsing_context;
  67. };
  68. }