/* * Copyright (c) 2020-2023, Andreas Kling * Copyright (c) 2021-2022, Linus Groh * Copyright (c) 2023, Andrew Kaster * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include namespace WebContent { PageHost::PageHost(ConnectionFromClient& client) : m_client(client) { auto& first_page = create_page(); Web::HTML::TraversableNavigable::create_a_fresh_top_level_traversable(first_page.page(), URL::URL("about:blank")).release_value_but_fixme_should_propagate_errors(); } PageClient& PageHost::create_page() { m_pages.set(m_next_id, PageClient::create(Web::Bindings::main_thread_vm(), *this, m_next_id)); ++m_next_id; return *m_pages.get(m_next_id - 1).value(); } void PageHost::remove_page(Badge, u64 index) { m_pages.remove(index); } Optional PageHost::page(u64 index) { return m_pages.get(index).map([](auto& value) -> PageClient& { return *value; }); } PageHost::~PageHost() = default; }