1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:08:10 +00:00
serenity/Userland/Services/WebContent/PageHost.cpp
Andrew Kaster fbfb70f81a LibWeb+WebContent: Plumb ability for WebContent process to hold N pages
In order for same-origin NavigableContainers (iframe, frame, embed, ...)
and window.open() WindowProxies to have the proper JS access to their
embedder/opener, we need to host multiple top level traversables in the
same WebContent process. As a first step, make WebContent::PageHost hold
a HashMap of PageClient objects, each holding their own Web::Page that
represents a TraversableNavigable's API surface with the UI process.
2023-12-01 20:47:44 +01:00

48 lines
1.5 KiB
C++

/*
* Copyright (c) 2020-2023, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "PageHost.h"
#include "ConnectionFromClient.h"
#include "PageClient.h"
#include <LibGfx/ShareableBitmap.h>
#include <LibGfx/SystemTheme.h>
#include <LibWeb/CSS/SystemColor.h>
#include <LibWeb/Cookie/ParsedCookie.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/TraversableNavigable.h>
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/PaintableBox.h>
#include <LibWeb/Painting/PaintingCommandExecutorCPU.h>
#include <LibWeb/Painting/ViewportPaintable.h>
#include <LibWeb/Platform/Timer.h>
#include <WebContent/WebContentClientEndpoint.h>
#include <WebContent/WebDriverConnection.h>
#ifdef HAS_ACCELERATED_GRAPHICS
# include <LibWeb/Painting/PaintingCommandExecutorGPU.h>
#endif
namespace WebContent {
PageHost::PageHost(ConnectionFromClient& client)
: m_client(client)
{
auto& first_page = create_page();
first_page.page().set_top_level_traversable(Web::HTML::TraversableNavigable::create_a_fresh_top_level_traversable(first_page.page(), AK::URL("about:blank")).release_value_but_fixme_should_propagate_errors());
}
PageClient& PageHost::create_page()
{
m_pages.set(m_next_id, make<PageClient>(*this, m_next_id));
++m_next_id;
return *m_pages.get(m_next_id - 1).value();
}
PageHost::~PageHost() = default;
}