Update WebView variants of ConstellationMsg (#32163)

* Add ConstellationMsg::WebViewOpened

* Remove unused variants

* Send the message on first webview as well
This commit is contained in:
Ngo Iok Ui (Wu Yu Wei) 2024-04-29 16:59:52 +09:00 committed by GitHub
parent 1d6be62454
commit 74897c3851
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 63 deletions

View file

@ -369,6 +369,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
}, },
) )
.expect("Infallible with a new WebViewManager"); .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 webviews
.show(top_level_browsing_context_id) .show(top_level_browsing_context_id)
.expect("Infallible due to add"); .expect("Infallible due to add");
@ -1183,6 +1187,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
error!("{webview_id}: Creating webview that already exists"); error!("{webview_id}: Creating webview that already exists");
return; 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(); self.send_root_pipeline_display_list();

View file

@ -1459,6 +1459,15 @@ where
FromCompositorMsg::NewWebView(url, top_level_browsing_context_id) => { FromCompositorMsg::NewWebView(url, top_level_browsing_context_id) => {
self.handle_new_top_level_browsing_context(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. // Close a top level browsing context.
FromCompositorMsg::CloseWebView(top_level_browsing_context_id) => { FromCompositorMsg::CloseWebView(top_level_browsing_context_id) => {
self.handle_close_top_level_browsing_context(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); 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) => { FromCompositorMsg::FocusWebView(top_level_browsing_context_id) => {
if self.webviews.get(top_level_browsing_context_id).is_none() { 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"); 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 window_size = self.window_size.initial_viewport;
let pipeline_id = PipelineId::new(); 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 browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
let load_data = LoadData::new( let load_data = LoadData::new(
LoadOrigin::Constellation, LoadOrigin::Constellation,

View file

@ -76,12 +76,9 @@ mod from_compositor {
Self::Reload(..) => target!("Reload"), Self::Reload(..) => target!("Reload"),
Self::LogEntry(..) => target!("LogEntry"), Self::LogEntry(..) => target!("LogEntry"),
Self::NewWebView(..) => target!("NewWebView"), Self::NewWebView(..) => target!("NewWebView"),
Self::WebViewOpened(..) => target!("WebViewOpened"),
Self::CloseWebView(..) => target!("CloseWebView"), Self::CloseWebView(..) => target!("CloseWebView"),
Self::SendError(..) => target!("SendError"), 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::FocusWebView(..) => target!("FocusWebView"),
Self::BlurWebView => target!("BlurWebView"), Self::BlurWebView => target!("BlurWebView"),
Self::ForwardEvent(_, event) => event.log_target(), Self::ForwardEvent(_, event) => event.log_target(),

View file

@ -57,18 +57,12 @@ pub enum ConstellationMsg {
LogEntry(Option<TopLevelBrowsingContextId>, Option<String>, LogEntry), LogEntry(Option<TopLevelBrowsingContextId>, Option<String>, LogEntry),
/// Create a new top level browsing context. /// Create a new top level browsing context.
NewWebView(ServoUrl, TopLevelBrowsingContextId), NewWebView(ServoUrl, TopLevelBrowsingContextId),
/// A top level browsing context is created in both constellation and compositor.
WebViewOpened(TopLevelBrowsingContextId),
/// Close a top level browsing context. /// Close a top level browsing context.
CloseWebView(TopLevelBrowsingContextId), CloseWebView(TopLevelBrowsingContextId),
/// Panic a top level browsing context. /// Panic a top level browsing context.
SendError(Option<TopLevelBrowsingContextId>, String), SendError(Option<TopLevelBrowsingContextId>, 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. /// Make a webview focused.
FocusWebView(TopLevelBrowsingContextId), FocusWebView(TopLevelBrowsingContextId),
/// Make none of the webviews focused. /// Make none of the webviews focused.
@ -121,11 +115,8 @@ impl ConstellationMsg {
Reload(..) => "Reload", Reload(..) => "Reload",
LogEntry(..) => "LogEntry", LogEntry(..) => "LogEntry",
NewWebView(..) => "NewWebView", NewWebView(..) => "NewWebView",
WebViewOpened(..) => "WebViewOpened",
CloseWebView(..) => "CloseWebView", CloseWebView(..) => "CloseWebView",
MoveResizeWebView(..) => "MoveResizeWebView",
ShowWebView(..) => "ShowWebView",
HideWebView(..) => "HideWebView",
RaiseWebViewToTop(..) => "RaiseWebViewToTop",
FocusWebView(..) => "FocusWebView", FocusWebView(..) => "FocusWebView",
BlurWebView => "BlurWebView", BlurWebView => "BlurWebView",
SendError(..) => "SendError", SendError(..) => "SendError",