BrowsingContextGroup.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. static JS::NonnullGCPtr<BrowsingContextGroup> create_a_new_browsing_context_group(Page&);
  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(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(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. WeakPtr<Page> m_page;
  34. };
  35. }