BrowsingContextGroup.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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/HashMap.h>
  8. #include <AK/NonnullRefPtr.h>
  9. #include <AK/WeakPtr.h>
  10. #include <LibJS/Heap/Cell.h>
  11. #include <LibWeb/Forward.h>
  12. namespace Web::HTML {
  13. class BrowsingContextGroup final : public JS::Cell {
  14. JS_CELL(BrowsingContextGroup, JS::Cell);
  15. JS_DECLARE_ALLOCATOR(BrowsingContextGroup);
  16. public:
  17. struct BrowsingContextGroupAndDocument {
  18. JS::NonnullGCPtr<HTML::BrowsingContextGroup> browsing_context;
  19. JS::NonnullGCPtr<DOM::Document> document;
  20. };
  21. static WebIDL::ExceptionOr<BrowsingContextGroupAndDocument> create_a_new_browsing_context_group_and_document(JS::NonnullGCPtr<Page>);
  22. ~BrowsingContextGroup();
  23. Page& page() { return m_page; }
  24. Page const& page() const { return m_page; }
  25. auto& browsing_context_set() { return m_browsing_context_set; }
  26. auto const& browsing_context_set() const { return m_browsing_context_set; }
  27. void append(BrowsingContext&);
  28. private:
  29. explicit BrowsingContextGroup(JS::NonnullGCPtr<Web::Page>);
  30. virtual void visit_edges(Cell::Visitor&) override;
  31. // https://html.spec.whatwg.org/multipage/browsers.html#browsing-context-group-set
  32. OrderedHashTable<JS::NonnullGCPtr<BrowsingContext>> m_browsing_context_set;
  33. JS::NonnullGCPtr<Page> m_page;
  34. };
  35. }