BrowsingContextGroup.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. public:
  16. struct BrowsingContextGroupAndDocument {
  17. JS::NonnullGCPtr<HTML::BrowsingContextGroup> browsing_context;
  18. JS::NonnullGCPtr<DOM::Document> document;
  19. };
  20. static WebIDL::ExceptionOr<BrowsingContextGroupAndDocument> create_a_new_browsing_context_group_and_document(Page&);
  21. ~BrowsingContextGroup();
  22. Page* page() { return m_page; }
  23. Page const* page() const { return m_page; }
  24. auto& browsing_context_set() { return m_browsing_context_set; }
  25. auto const& browsing_context_set() const { return m_browsing_context_set; }
  26. void append(BrowsingContext&);
  27. private:
  28. explicit BrowsingContextGroup(Web::Page&);
  29. virtual void visit_edges(Cell::Visitor&) override;
  30. // https://html.spec.whatwg.org/multipage/browsers.html#browsing-context-group-set
  31. OrderedHashTable<JS::NonnullGCPtr<BrowsingContext>> m_browsing_context_set;
  32. WeakPtr<Page> m_page;
  33. };
  34. }