SessionHistoryEntry.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. enum class Pending {
  28. Tag,
  29. };
  30. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-step
  31. // step, a non-negative integer or "pending", initially "pending".
  32. Variant<int, Pending> step { Pending::Tag };
  33. // URL, a URL
  34. AK::URL url;
  35. // document, a Document or null
  36. // FIXME: this property is not present in the spec anymore and should be gone after introducing navigables
  37. JS::GCPtr<DOM::Document> document;
  38. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-document-state
  39. JS::GCPtr<HTML::DocumentState> document_state;
  40. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-serialized-state
  41. // serialized state, which is serialized state, initially StructuredSerializeForStorage(null).
  42. Optional<DeprecatedString> serialized_state;
  43. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-restoration-mode
  44. // scroll restoration mode, a scroll restoration mode, initially "auto"
  45. ScrollRestorationMode scroll_restoration_mode { ScrollRestorationMode::Auto };
  46. // policy container, a policy container or null
  47. Optional<PolicyContainer> policy_container;
  48. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-position
  49. // FIXME: scroll position data, which is scroll position data for the document's restorable scrollable regions
  50. // browsing context name, a browsing context name or null, initially null
  51. Optional<DeprecatedString> browsing_context_name;
  52. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-other
  53. // FIXME: persisted user state, which is implementation-defined, initially null
  54. // NOTE: This is where we could remember the state of form controls, for example.
  55. JS::GCPtr<BrowsingContext> original_source_browsing_context;
  56. };
  57. }