From 74897c38512793455f4c1622e2b454b274aa8cec Mon Sep 17 00:00:00 2001 From: "Ngo Iok Ui (Wu Yu Wei)" Date: Mon, 29 Apr 2024 16:59:52 +0900 Subject: [PATCH] Update WebView variants of ConstellationMsg (#32163) * Add ConstellationMsg::WebViewOpened * Remove unused variants * Send the message on first webview as well --- components/compositing/compositor.rs | 8 +++ components/constellation/constellation.rs | 56 +++---------------- components/constellation/tracing.rs | 5 +- .../shared/compositing/constellation_msg.rs | 15 +---- 4 files changed, 21 insertions(+), 63 deletions(-) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 48752bd44bd..19cecbcf55d 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -369,6 +369,10 @@ impl IOCompositor { }, ) .expect("Infallible with a new WebViewManager"); + let msg = ConstellationMsg::WebViewOpened(top_level_browsing_context_id); + if let Err(e) = state.constellation_chan.send(msg) { + warn!("Sending event to constellation failed ({:?}).", e); + } webviews .show(top_level_browsing_context_id) .expect("Infallible due to add"); @@ -1183,6 +1187,10 @@ impl IOCompositor { error!("{webview_id}: Creating webview that already exists"); return; } + let msg = ConstellationMsg::WebViewOpened(top_level_browsing_context_id); + if let Err(e) = self.constellation_chan.send(msg) { + warn!("Sending event to constellation failed ({:?}).", e); + } } self.send_root_pipeline_display_list(); diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 70d4452534d..53b0ae8d412 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -1459,6 +1459,15 @@ where FromCompositorMsg::NewWebView(url, top_level_browsing_context_id) => { self.handle_new_top_level_browsing_context(url, top_level_browsing_context_id); }, + // A top level browsing context is created and opened in both constellation and + // compositor. + FromCompositorMsg::WebViewOpened(top_level_browsing_context_id) => { + let msg = ( + Some(top_level_browsing_context_id), + EmbedderMsg::WebViewOpened(top_level_browsing_context_id), + ); + self.embedder_proxy.send(msg); + }, // Close a top level browsing context. FromCompositorMsg::CloseWebView(top_level_browsing_context_id) => { self.handle_close_top_level_browsing_context(top_level_browsing_context_id); @@ -1471,48 +1480,6 @@ where } self.handle_panic(top_level_browsing_context_id, error, None); }, - FromCompositorMsg::MoveResizeWebView(top_level_browsing_context_id, rect) => { - if self.webviews.get(top_level_browsing_context_id).is_none() { - return warn!( - "{}: MoveResizeWebView on unknown top-level browsing context", - top_level_browsing_context_id - ); - } - self.compositor_proxy.send(CompositorMsg::MoveResizeWebView( - top_level_browsing_context_id, - rect, - )); - }, - FromCompositorMsg::ShowWebView(webview_id, hide_others) => { - if self.webviews.get(webview_id).is_none() { - return warn!( - "{}: ShowWebView on unknown top-level browsing context", - webview_id - ); - } - self.compositor_proxy - .send(CompositorMsg::ShowWebView(webview_id, hide_others)); - }, - FromCompositorMsg::HideWebView(webview_id) => { - if self.webviews.get(webview_id).is_none() { - return warn!( - "{}: HideWebView on unknown top-level browsing context", - webview_id - ); - } - self.compositor_proxy - .send(CompositorMsg::HideWebView(webview_id)); - }, - FromCompositorMsg::RaiseWebViewToTop(webview_id, hide_others) => { - if self.webviews.get(webview_id).is_none() { - return warn!( - "{}: RaiseWebViewToTop on unknown top-level browsing context", - webview_id - ); - } - self.compositor_proxy - .send(CompositorMsg::RaiseWebViewToTop(webview_id, hide_others)); - }, FromCompositorMsg::FocusWebView(top_level_browsing_context_id) => { if self.webviews.get(top_level_browsing_context_id).is_none() { return warn!("{top_level_browsing_context_id}: FocusWebView on unknown top-level browsing context"); @@ -2975,11 +2942,6 @@ where ) { let window_size = self.window_size.initial_viewport; let pipeline_id = PipelineId::new(); - let msg = ( - Some(top_level_browsing_context_id), - EmbedderMsg::WebViewOpened(top_level_browsing_context_id), - ); - self.embedder_proxy.send(msg); let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id); let load_data = LoadData::new( LoadOrigin::Constellation, diff --git a/components/constellation/tracing.rs b/components/constellation/tracing.rs index 040a8bd3269..509b6aa404f 100644 --- a/components/constellation/tracing.rs +++ b/components/constellation/tracing.rs @@ -76,12 +76,9 @@ mod from_compositor { Self::Reload(..) => target!("Reload"), Self::LogEntry(..) => target!("LogEntry"), Self::NewWebView(..) => target!("NewWebView"), + Self::WebViewOpened(..) => target!("WebViewOpened"), Self::CloseWebView(..) => target!("CloseWebView"), Self::SendError(..) => target!("SendError"), - Self::MoveResizeWebView(..) => target!("MoveResizeWebView"), - Self::ShowWebView(..) => target!("ShowWebView"), - Self::HideWebView(..) => target!("HideWebView"), - Self::RaiseWebViewToTop(..) => target!("RaiseWebViewToTop"), Self::FocusWebView(..) => target!("FocusWebView"), Self::BlurWebView => target!("BlurWebView"), Self::ForwardEvent(_, event) => event.log_target(), diff --git a/components/shared/compositing/constellation_msg.rs b/components/shared/compositing/constellation_msg.rs index 64d593ee08c..dac141b61b4 100644 --- a/components/shared/compositing/constellation_msg.rs +++ b/components/shared/compositing/constellation_msg.rs @@ -57,18 +57,12 @@ pub enum ConstellationMsg { LogEntry(Option, Option, LogEntry), /// Create a new top level browsing context. NewWebView(ServoUrl, TopLevelBrowsingContextId), + /// A top level browsing context is created in both constellation and compositor. + WebViewOpened(TopLevelBrowsingContextId), /// Close a top level browsing context. CloseWebView(TopLevelBrowsingContextId), /// Panic a top level browsing context. SendError(Option, String), - /// Move and/or resize a webview to the given rect. - MoveResizeWebView(TopLevelBrowsingContextId, DeviceRect), - /// Start painting a webview, and optionally stop painting all others. - ShowWebView(TopLevelBrowsingContextId, bool), - /// Stop painting a webview. - HideWebView(TopLevelBrowsingContextId), - /// Start painting a webview on top of all others, and optionally stop painting all others. - RaiseWebViewToTop(TopLevelBrowsingContextId, bool), /// Make a webview focused. FocusWebView(TopLevelBrowsingContextId), /// Make none of the webviews focused. @@ -121,11 +115,8 @@ impl ConstellationMsg { Reload(..) => "Reload", LogEntry(..) => "LogEntry", NewWebView(..) => "NewWebView", + WebViewOpened(..) => "WebViewOpened", CloseWebView(..) => "CloseWebView", - MoveResizeWebView(..) => "MoveResizeWebView", - ShowWebView(..) => "ShowWebView", - HideWebView(..) => "HideWebView", - RaiseWebViewToTop(..) => "RaiseWebViewToTop", FocusWebView(..) => "FocusWebView", BlurWebView => "BlurWebView", SendError(..) => "SendError",