SessionHistoryEntry.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/GCPtr.h>
  10. #include <LibWeb/Forward.h>
  11. #include <LibWeb/HTML/PolicyContainers.h>
  12. namespace Web::HTML {
  13. // https://html.spec.whatwg.org/multipage/history.html#scroll-restoration-mode
  14. enum class ScrollRestorationMode {
  15. // https://html.spec.whatwg.org/multipage/history.html#dom-scrollrestoration-auto
  16. // The user agent is responsible for restoring the scroll position upon navigation.
  17. Auto,
  18. // https://html.spec.whatwg.org/multipage/history.html#dom-scrollrestoration-manual
  19. // The page is responsible for restoring the scroll position and the user agent does not attempt to do so automatically.
  20. Manual,
  21. };
  22. // https://html.spec.whatwg.org/multipage/history.html#session-history-entry
  23. struct SessionHistoryEntry {
  24. // URL, a URL
  25. AK::URL url;
  26. // document, a Document or null
  27. JS::GCPtr<DOM::Document> document;
  28. // serialized state, which is serialized state or null, initially null
  29. Optional<DeprecatedString> serialized_state;
  30. // policy container, a policy container or null
  31. Optional<PolicyContainer> policy_container;
  32. // scroll restoration mode, a scroll restoration mode, initially "auto"
  33. ScrollRestorationMode scroll_restoration_mode { ScrollRestorationMode::Auto };
  34. // FIXME: scroll position data, which is scroll position data for the document's restorable scrollable regions
  35. // browsing context name, a browsing context name or null, initially null
  36. Optional<DeprecatedString> browsing_context_name;
  37. // FIXME: persisted user state, which is implementation-defined, initially null
  38. // NOTE: This is where we could remember the state of form controls, for example.
  39. JS::GCPtr<BrowsingContext> original_source_browsing_context;
  40. };
  41. }