mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:27:46 +00:00
Ladybird: Add IPC call for creating a new child tab
This will be used for choosing a navigable that requires opening a new tab or new window. Such as calls to window.open(), or specific WebDriver calls.
This commit is contained in:
parent
7245f6f11c
commit
677bdc2a4f
17 changed files with 144 additions and 19 deletions
|
@ -499,7 +499,7 @@ JS::GCPtr<DOM::Node> BrowsingContext::currently_focused_area()
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name
|
||||
BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_context(StringView name, TokenizedFeature::NoOpener no_opener, ActivateTab activate_tab)
|
||||
BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_context(StringView name, TokenizedFeature::NoOpener no_opener, ActivateTab)
|
||||
{
|
||||
// The rules for choosing a browsing context, given a browsing context name name, a browsing context current, and
|
||||
// a boolean noopener are as follows:
|
||||
|
@ -591,8 +591,8 @@ BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_contex
|
|||
|
||||
// 3. If noopener is true, then set chosen to the result of creating a new top-level browsing context.
|
||||
if (no_opener == TokenizedFeature::NoOpener::Yes) {
|
||||
auto handle = m_page->client().page_did_request_new_tab(activate_tab);
|
||||
chosen = RemoteBrowsingContext::create_a_new_remote_browsing_context(handle);
|
||||
// FIXME: This is completely wrong, but all of this should be removed in favor of choose_a_navigable
|
||||
chosen = this;
|
||||
}
|
||||
|
||||
// 4. Otherwise:
|
||||
|
|
43
Userland/Libraries/LibWeb/HTML/WebViewHints.cpp
Normal file
43
Userland/Libraries/LibWeb/HTML/WebViewHints.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Encoder.h>
|
||||
#include <LibWeb/HTML/WebViewHints.h>
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder& encoder, ::Web::HTML::WebViewHints const& data_holder)
|
||||
{
|
||||
TRY(encoder.encode(data_holder.popup));
|
||||
TRY(encoder.encode(data_holder.width));
|
||||
TRY(encoder.encode(data_holder.height));
|
||||
TRY(encoder.encode(data_holder.screen_x));
|
||||
TRY(encoder.encode(data_holder.screen_y));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<::Web::HTML::WebViewHints> decode(Decoder& decoder)
|
||||
{
|
||||
auto popup = TRY(decoder.decode<bool>());
|
||||
auto width = TRY(decoder.decode<Optional<Web::DevicePixels>>());
|
||||
auto height = TRY(decoder.decode<Optional<Web::DevicePixels>>());
|
||||
auto screen_x = TRY(decoder.decode<Optional<Web::DevicePixels>>());
|
||||
auto screen_y = TRY(decoder.decode<Optional<Web::DevicePixels>>());
|
||||
|
||||
return ::Web::HTML::WebViewHints {
|
||||
.popup = popup,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.screen_x = screen_x,
|
||||
.screen_y = screen_y,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
34
Userland/Libraries/LibWeb/HTML/WebViewHints.h
Normal file
34
Userland/Libraries/LibWeb/HTML/WebViewHints.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
#include <LibWeb/PixelUnits.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
struct WebViewHints {
|
||||
bool popup = false;
|
||||
Optional<DevicePixels> width = {};
|
||||
Optional<DevicePixels> height = {};
|
||||
Optional<DevicePixels> screen_x = {};
|
||||
Optional<DevicePixels> screen_y = {};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder&, Web::HTML::WebViewHints const&);
|
||||
|
||||
template<>
|
||||
ErrorOr<Web::HTML::WebViewHints> decode(Decoder&);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue