libservo: Add WebView immediately to the Compositor (#35662)

When creating a `WebView`, let the Compositor know synchronously that
it exists. This allows the embedder to immediately call methods like
`WebView::focus()`. In addition remove messages associated with the
`WebViewDelegate::notify_ready_to_show()` method (and the method
itself), as now `WebView`s can be shown immediately.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-02-26 17:16:48 +01:00 committed by GitHub
parent de66f72197
commit 9d5171f3c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 46 additions and 89 deletions

View file

@ -109,6 +109,10 @@ impl RunningAppState {
pub(crate) fn new_toplevel_webview(self: &Rc<Self>, url: Url) {
let webview = self.servo().new_webview(url);
webview.set_delegate(self.clone());
webview.focus();
webview.raise_to_top(true);
self.add(webview);
}
@ -464,13 +468,12 @@ impl WebViewDelegate for RunningAppState {
) -> Option<servo::WebView> {
let webview = self.servo.new_auxiliary_webview();
webview.set_delegate(parent_webview.delegate());
self.add(webview.clone());
Some(webview)
}
fn notify_ready_to_show(&self, webview: servo::WebView) {
webview.focus();
webview.raise_to_top(true);
self.add(webview.clone());
Some(webview)
}
fn notify_closed(&self, webview: servo::WebView) {

View file

@ -127,10 +127,6 @@ impl WebViewDelegate for RunningAppState {
.notify_load_status_changed(load_status);
}
fn notify_ready_to_show(&self, webview: WebView) {
webview.focus();
}
fn notify_closed(&self, webview: WebView) {
{
let mut inner_mut = self.inner_mut();
@ -308,6 +304,7 @@ impl RunningAppState {
pub(crate) fn new_toplevel_webview(self: &Rc<Self>, url: Url) {
let webview = self.servo.new_webview(url);
webview.set_delegate(self.clone());
webview.focus();
self.add(webview.clone());
}