Initial internal support for multiple webviews (#31417)

* Add multiple concurrent top-level browsing contexts

Co-authored-by: Delan Azabani <dazabani@igalia.com>

* Rename variables and comments

There are some variable and comments still use browser as names.
This commit renames them to webview.

* Update log message from web view to webview

* Revert offscreen_framebuffer_id rename

* Rename all web view to webview

* Cargo fmt

* Fix viewport/event/clear coordinates when multiview is disabled

* Only deprecate things when multiview is enabled

* Update WebViewManger with shown and invisible sets

Replace visible_webviews and native_window_is_visible with shown_webviews
and invisible_webviews. Add 4 more methods to set them accordingly. The
behavior of is_effectively_visible will return true if the wbview is in
shown_webviews set but not in invisible_webviews.

* Update variant behaviors

* Rename WebViewVisibilityChanged to MarkWebViewInvisible

* Fix unit test by marking id 3 visible again

* Update MarkWebViewInvisible and add UnmarkWebViewInvisible

* Update format and doc comments

* Clean up doc comments

* Address style and naming changes

* Rename UpdateWebView to UpdateFrameTreeForWebView

* constellation: send frame tree unconditionally over focus and feature

* Clarify shown and invisible sets in constellation WebViewManager

* Eliminate forward_to_constellation!()

* Actually remove the unused macro

* Don’t gate compositor changes on multiview feature flag

* Update todo in mouse event dispatch

* Pass all visible webview ids in a single ReadyToPresent message

* Fix compile and lint errors

* servoshell: fix gap between minibrowser toolbar and webview

* Fix failure in /_mozilla/mozilla/window_resizeTo.html

* Fix compile warnings

* Remove stray dbg!()

* Remove confusing “effectively visible” logic (see #31815, #31816)

* Allow embedder to show/hide/raise webviews without ipc

* Update root pipeline only when painting order actually changes

* Stop gating old focus and SetFrameTree behaviour behind Cargo feature

* Use webview_id and WebViewId in webview-related code

* Improve logging of webview-related embedder events

* Allow webview Show and Raise events to optionally hide all others

* Don’t do anything in response to WebViewPaintingOrder

* Remove WebViewPaintingOrder, since its payload is unreliable

* On MoveResizeWebView, only update root pipeline if rect changed

* Rename IOCompositor methods for clarity

* compositor: add event tracing; log webview ops even without ipc

* Add temporary debug logging

* Add more temporary debug logging

* Remove temporary logging in compositor

* Remove temporary debug logging

* Add temporary debug logging, but defer I/O until panic

* Capture a backtrace with each crash log entry

* Proper error handling without panicking in WebViewManager

* Clean up imports in constellation

---------

Co-authored-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Ngo Iok Ui (Wu Yu Wei) 2024-04-03 20:06:28 +09:00 committed by GitHub
parent 18b37e676b
commit 66878fb834
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 1142 additions and 434 deletions

View file

@ -1471,6 +1471,48 @@ 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");
@ -1480,9 +1522,6 @@ where
Some(top_level_browsing_context_id),
EmbedderMsg::WebViewFocused(top_level_browsing_context_id),
));
if !cfg!(feature = "multiview") {
self.update_frame_tree_if_focused(top_level_browsing_context_id);
}
},
FromCompositorMsg::BlurWebView => {
self.webviews.unfocus();
@ -1539,11 +1578,9 @@ where
FromCompositorMsg::SetWebViewThrottled(webview_id, throttled) => {
self.set_webview_throttled(webview_id, throttled);
},
FromCompositorMsg::ReadyToPresent(top_level_browsing_context_id) => {
self.embedder_proxy.send((
Some(top_level_browsing_context_id),
EmbedderMsg::ReadyToPresent,
));
FromCompositorMsg::ReadyToPresent(webview_ids) => {
self.embedder_proxy
.send((None, EmbedderMsg::ReadyToPresent(webview_ids)));
},
FromCompositorMsg::Gamepad(gamepad_event) => {
self.handle_gamepad_msg(gamepad_event);
@ -3016,7 +3053,8 @@ where
.send((None, EmbedderMsg::WebViewBlurred));
}
self.webviews.remove(top_level_browsing_context_id);
// TODO Send the compositor a RemoveWebView event.
self.compositor_proxy
.send(CompositorMsg::RemoveWebView(top_level_browsing_context_id));
self.embedder_proxy.send((
Some(top_level_browsing_context_id),
EmbedderMsg::WebViewClosed(top_level_browsing_context_id),
@ -3804,7 +3842,7 @@ where
self.notify_history_changed(top_level_browsing_context_id);
self.trim_history(top_level_browsing_context_id);
self.update_frame_tree_if_focused(top_level_browsing_context_id);
self.update_webview_in_compositor(top_level_browsing_context_id);
}
fn update_browsing_context(
@ -4763,7 +4801,7 @@ where
}
self.notify_history_changed(change.top_level_browsing_context_id);
self.update_frame_tree_if_focused(change.top_level_browsing_context_id);
self.update_webview_in_compositor(change.top_level_browsing_context_id);
}
fn focused_browsing_context_is_descendant_of(
@ -5376,24 +5414,15 @@ where
}
/// Send the frame tree for the given webview to the compositor.
fn update_frame_tree_if_focused(
&mut self,
top_level_browsing_context_id: TopLevelBrowsingContextId,
) {
// Only send the frame tree if the given webview is focused.
if let Some(focused_webview_id) = self.webviews.focused_webview().map(|(id, _)| id) {
if top_level_browsing_context_id != focused_webview_id {
return;
}
}
fn update_webview_in_compositor(&mut self, webview_id: WebViewId) {
// Note that this function can panic, due to ipc-channel creation failure.
// avoiding this panic would require a mechanism for dealing
// with low-resource scenarios.
let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
let browsing_context_id = BrowsingContextId::from(webview_id);
if let Some(frame_tree) = self.browsing_context_to_sendable(browsing_context_id) {
debug!("{}: Sending frame tree", browsing_context_id);
self.compositor_proxy
.send(CompositorMsg::SetFrameTree(frame_tree));
.send(CompositorMsg::CreateOrUpdateWebView(frame_tree));
}
}

View file

@ -59,37 +59,41 @@ mod from_compositor {
fn log_target(&self) -> &'static str {
match self {
Self::Exit => target!("Exit"),
Self::GetBrowsingContext(_, _) => target!("GetBrowsingContext"),
Self::GetPipeline(_, _) => target!("GetPipeline"),
Self::GetFocusTopLevelBrowsingContext(_) => {
Self::GetBrowsingContext(..) => target!("GetBrowsingContext"),
Self::GetPipeline(..) => target!("GetPipeline"),
Self::GetFocusTopLevelBrowsingContext(..) => {
target!("GetFocusTopLevelBrowsingContext")
},
Self::IsReadyToSaveImage(_) => target!("IsReadyToSaveImage"),
Self::Keyboard(_) => target!("Keyboard"),
Self::AllowNavigationResponse(_, _) => target!("AllowNavigationResponse"),
Self::LoadUrl(_, _) => target!("LoadUrl"),
Self::IsReadyToSaveImage(..) => target!("IsReadyToSaveImage"),
Self::Keyboard(..) => target!("Keyboard"),
Self::AllowNavigationResponse(..) => target!("AllowNavigationResponse"),
Self::LoadUrl(..) => target!("LoadUrl"),
Self::ClearCache => target!("ClearCache"),
Self::TraverseHistory(_, _) => target!("TraverseHistory"),
Self::WindowSize(_, _, _) => target!("WindowSize"),
Self::TickAnimation(_, _) => target!("TickAnimation"),
Self::WebDriverCommand(_) => target!("WebDriverCommand"),
Self::Reload(_) => target!("Reload"),
Self::LogEntry(_, _, _) => target!("LogEntry"),
Self::NewWebView(_, _) => target!("NewWebView"),
Self::CloseWebView(_) => target!("CloseWebView"),
Self::SendError(_, _) => target!("SendError"),
Self::FocusWebView(_) => target!("FocusWebView"),
Self::TraverseHistory(..) => target!("TraverseHistory"),
Self::WindowSize(..) => target!("WindowSize"),
Self::TickAnimation(..) => target!("TickAnimation"),
Self::WebDriverCommand(..) => target!("WebDriverCommand"),
Self::Reload(..) => target!("Reload"),
Self::LogEntry(..) => target!("LogEntry"),
Self::NewWebView(..) => target!("NewWebView"),
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(),
Self::SetCursor(_) => target!("SetCursor"),
Self::EnableProfiler(_, _) => target!("EnableProfiler"),
Self::SetCursor(..) => target!("SetCursor"),
Self::EnableProfiler(..) => target!("EnableProfiler"),
Self::DisableProfiler => target!("DisableProfiler"),
Self::ExitFullScreen(_) => target!("ExitFullScreen"),
Self::MediaSessionAction(_) => target!("MediaSessionAction"),
Self::SetWebViewThrottled(_, _) => target!("SetWebViewThrottled"),
Self::IMEDismissed => target!("IMEDismissed"),
Self::ReadyToPresent(_) => target!("ReadyToPresent"),
Self::Gamepad(_) => target!("Gamepad"),
Self::ReadyToPresent(..) => target!("ReadyToPresent"),
Self::Gamepad(..) => target!("Gamepad"),
}
}
}
@ -102,15 +106,15 @@ mod from_compositor {
};
}
match self {
Self::ResizeEvent(_, _) => target_variant!("ResizeEvent"),
Self::MouseButtonEvent(_, _, _, _, _, _) => target_variant!("MouseButtonEvent"),
Self::MouseMoveEvent(_, _, _) => target_variant!("MouseMoveEvent"),
Self::TouchEvent(_, _, _, _) => target_variant!("TouchEvent"),
Self::WheelEvent(_, _, _) => target_variant!("WheelEvent"),
Self::KeyboardEvent(_) => target_variant!("KeyboardEvent"),
Self::CompositionEvent(_) => target_variant!("CompositionEvent"),
Self::ResizeEvent(..) => target_variant!("ResizeEvent"),
Self::MouseButtonEvent(..) => target_variant!("MouseButtonEvent"),
Self::MouseMoveEvent(..) => target_variant!("MouseMoveEvent"),
Self::TouchEvent(..) => target_variant!("TouchEvent"),
Self::WheelEvent(..) => target_variant!("WheelEvent"),
Self::KeyboardEvent(..) => target_variant!("KeyboardEvent"),
Self::CompositionEvent(..) => target_variant!("CompositionEvent"),
Self::IMEDismissedEvent => target_variant!("IMEDismissedEvent"),
Self::GamepadEvent(_) => target_variant!("GamepadEvent"),
Self::GamepadEvent(..) => target_variant!("GamepadEvent"),
}
}
}
@ -128,65 +132,65 @@ mod from_script {
impl LogTarget for script_traits::ScriptMsg {
fn log_target(&self) -> &'static str {
match self {
Self::CompleteMessagePortTransfer(_, _) => target!("CompleteMessagePortTransfer"),
Self::MessagePortTransferResult(_, _, _) => target!("MessagePortTransferResult"),
Self::NewMessagePort(_, _) => target!("NewMessagePort"),
Self::NewMessagePortRouter(_, _) => target!("NewMessagePortRouter"),
Self::RemoveMessagePortRouter(_) => target!("RemoveMessagePortRouter"),
Self::RerouteMessagePort(_, _) => target!("RerouteMessagePort"),
Self::MessagePortShipped(_) => target!("MessagePortShipped"),
Self::RemoveMessagePort(_) => target!("RemoveMessagePort"),
Self::EntanglePorts(_, _) => target!("EntanglePorts"),
Self::NewBroadcastChannelRouter(_, _, _) => target!("NewBroadcastChannelRouter"),
Self::RemoveBroadcastChannelRouter(_, _) => target!("RemoveBroadcastChannelRouter"),
Self::NewBroadcastChannelNameInRouter(_, _, _) => {
Self::CompleteMessagePortTransfer(..) => target!("CompleteMessagePortTransfer"),
Self::MessagePortTransferResult(..) => target!("MessagePortTransferResult"),
Self::NewMessagePort(..) => target!("NewMessagePort"),
Self::NewMessagePortRouter(..) => target!("NewMessagePortRouter"),
Self::RemoveMessagePortRouter(..) => target!("RemoveMessagePortRouter"),
Self::RerouteMessagePort(..) => target!("RerouteMessagePort"),
Self::MessagePortShipped(..) => target!("MessagePortShipped"),
Self::RemoveMessagePort(..) => target!("RemoveMessagePort"),
Self::EntanglePorts(..) => target!("EntanglePorts"),
Self::NewBroadcastChannelRouter(..) => target!("NewBroadcastChannelRouter"),
Self::RemoveBroadcastChannelRouter(..) => target!("RemoveBroadcastChannelRouter"),
Self::NewBroadcastChannelNameInRouter(..) => {
target!("NewBroadcastChannelNameInRouter")
},
Self::RemoveBroadcastChannelNameInRouter(_, _, _) => {
Self::RemoveBroadcastChannelNameInRouter(..) => {
target!("RemoveBroadcastChannelNameInRouter")
},
Self::ScheduleBroadcast(_, _) => target!("ScheduleBroadcast"),
Self::ScheduleBroadcast(..) => target!("ScheduleBroadcast"),
Self::ForwardToEmbedder(msg) => msg.log_target(),
Self::InitiateNavigateRequest(_, _) => target!("InitiateNavigateRequest"),
Self::BroadcastStorageEvent(_, _, _, _, _) => target!("BroadcastStorageEvent"),
Self::ChangeRunningAnimationsState(_) => target!("ChangeRunningAnimationsState"),
Self::CreateCanvasPaintThread(_, _) => target!("CreateCanvasPaintThread"),
Self::InitiateNavigateRequest(..) => target!("InitiateNavigateRequest"),
Self::BroadcastStorageEvent(..) => target!("BroadcastStorageEvent"),
Self::ChangeRunningAnimationsState(..) => target!("ChangeRunningAnimationsState"),
Self::CreateCanvasPaintThread(..) => target!("CreateCanvasPaintThread"),
Self::Focus => target!("Focus"),
Self::GetTopForBrowsingContext(_, _) => target!("GetTopForBrowsingContext"),
Self::GetBrowsingContextInfo(_, _) => target!("GetBrowsingContextInfo"),
Self::GetChildBrowsingContextId(_, _, _) => target!("GetChildBrowsingContextId"),
Self::GetTopForBrowsingContext(..) => target!("GetTopForBrowsingContext"),
Self::GetBrowsingContextInfo(..) => target!("GetBrowsingContextInfo"),
Self::GetChildBrowsingContextId(..) => target!("GetChildBrowsingContextId"),
Self::LoadComplete => target!("LoadComplete"),
Self::LoadUrl(_, _) => target!("LoadUrl"),
Self::LoadUrl(..) => target!("LoadUrl"),
Self::AbortLoadUrl => target!("AbortLoadUrl"),
Self::PostMessage { .. } => target!("PostMessage"),
Self::NavigatedToFragment(_, _) => target!("NavigatedToFragment"),
Self::TraverseHistory(_) => target!("TraverseHistory"),
Self::PushHistoryState(_, _) => target!("PushHistoryState"),
Self::ReplaceHistoryState(_, _) => target!("ReplaceHistoryState"),
Self::JointSessionHistoryLength(_) => target!("JointSessionHistoryLength"),
Self::RemoveIFrame(_, _) => target!("RemoveIFrame"),
Self::SetThrottledComplete(_) => target!("SetThrottledComplete"),
Self::ScriptLoadedURLInIFrame(_) => target!("ScriptLoadedURLInIFrame"),
Self::ScriptNewIFrame(_) => target!("ScriptNewIFrame"),
Self::ScriptNewAuxiliary(_) => target!("ScriptNewAuxiliary"),
Self::NavigatedToFragment(..) => target!("NavigatedToFragment"),
Self::TraverseHistory(..) => target!("TraverseHistory"),
Self::PushHistoryState(..) => target!("PushHistoryState"),
Self::ReplaceHistoryState(..) => target!("ReplaceHistoryState"),
Self::JointSessionHistoryLength(..) => target!("JointSessionHistoryLength"),
Self::RemoveIFrame(..) => target!("RemoveIFrame"),
Self::SetThrottledComplete(..) => target!("SetThrottledComplete"),
Self::ScriptLoadedURLInIFrame(..) => target!("ScriptLoadedURLInIFrame"),
Self::ScriptNewIFrame(..) => target!("ScriptNewIFrame"),
Self::ScriptNewAuxiliary(..) => target!("ScriptNewAuxiliary"),
Self::ActivateDocument => target!("ActivateDocument"),
Self::SetDocumentState(_) => target!("SetDocumentState"),
Self::SetLayoutEpoch(_, _) => target!("SetLayoutEpoch"),
Self::SetFinalUrl(_) => target!("SetFinalUrl"),
Self::TouchEventProcessed(_) => target!("TouchEventProcessed"),
Self::LogEntry(_, _) => target!("LogEntry"),
Self::SetDocumentState(..) => target!("SetDocumentState"),
Self::SetLayoutEpoch(..) => target!("SetLayoutEpoch"),
Self::SetFinalUrl(..) => target!("SetFinalUrl"),
Self::TouchEventProcessed(..) => target!("TouchEventProcessed"),
Self::LogEntry(..) => target!("LogEntry"),
Self::DiscardDocument => target!("DiscardDocument"),
Self::DiscardTopLevelBrowsingContext => target!("DiscardTopLevelBrowsingContext"),
Self::PipelineExited => target!("PipelineExited"),
Self::ForwardDOMMessage(_, _) => target!("ForwardDOMMessage"),
Self::ScheduleJob(_) => target!("ScheduleJob"),
Self::GetClientWindow(_) => target!("GetClientWindow"),
Self::GetScreenSize(_) => target!("GetScreenSize"),
Self::GetScreenAvailSize(_) => target!("GetScreenAvailSize"),
Self::MediaSessionEvent(_, _) => target!("MediaSessionEvent"),
Self::RequestAdapter(_, _, _) => target!("RequestAdapter"),
Self::GetWebGPUChan(_) => target!("GetWebGPUChan"),
Self::TitleChanged(_, _) => target!("TitleChanged"),
Self::ForwardDOMMessage(..) => target!("ForwardDOMMessage"),
Self::ScheduleJob(..) => target!("ScheduleJob"),
Self::GetClientWindow(..) => target!("GetClientWindow"),
Self::GetScreenSize(..) => target!("GetScreenSize"),
Self::GetScreenAvailSize(..) => target!("GetScreenAvailSize"),
Self::MediaSessionEvent(..) => target!("MediaSessionEvent"),
Self::RequestAdapter(..) => target!("RequestAdapter"),
Self::GetWebGPUChan(..) => target!("GetWebGPUChan"),
Self::TitleChanged(..) => target!("TitleChanged"),
}
}
}
@ -199,43 +203,43 @@ mod from_script {
};
}
match self {
Self::Status(_) => target_variant!("Status"),
Self::ChangePageTitle(_) => target_variant!("ChangePageTitle"),
Self::MoveTo(_) => target_variant!("MoveTo"),
Self::ResizeTo(_) => target_variant!("ResizeTo"),
Self::Prompt(_, _) => target_variant!("Prompt"),
Self::ShowContextMenu(_, _, _) => target_variant!("ShowContextMenu"),
Self::AllowNavigationRequest(_, _) => target_variant!("AllowNavigationRequest"),
Self::AllowOpeningWebView(_) => target_variant!("AllowOpeningWebView"),
Self::WebViewOpened(_) => target_variant!("WebViewOpened"),
Self::WebViewClosed(_) => target_variant!("WebViewClosed"),
Self::WebViewFocused(_) => target_variant!("WebViewFocused"),
Self::Status(..) => target_variant!("Status"),
Self::ChangePageTitle(..) => target_variant!("ChangePageTitle"),
Self::MoveTo(..) => target_variant!("MoveTo"),
Self::ResizeTo(..) => target_variant!("ResizeTo"),
Self::Prompt(..) => target_variant!("Prompt"),
Self::ShowContextMenu(..) => target_variant!("ShowContextMenu"),
Self::AllowNavigationRequest(..) => target_variant!("AllowNavigationRequest"),
Self::AllowOpeningWebView(..) => target_variant!("AllowOpeningWebView"),
Self::WebViewOpened(..) => target_variant!("WebViewOpened"),
Self::WebViewClosed(..) => target_variant!("WebViewClosed"),
Self::WebViewFocused(..) => target_variant!("WebViewFocused"),
Self::WebViewBlurred => target_variant!("WebViewBlurred"),
Self::AllowUnload(_) => target_variant!("AllowUnload"),
Self::Keyboard(_) => target_variant!("Keyboard"),
Self::GetClipboardContents(_) => target_variant!("GetClipboardContents"),
Self::SetClipboardContents(_) => target_variant!("SetClipboardContents"),
Self::SetCursor(_) => target_variant!("SetCursor"),
Self::NewFavicon(_) => target_variant!("NewFavicon"),
Self::AllowUnload(..) => target_variant!("AllowUnload"),
Self::Keyboard(..) => target_variant!("Keyboard"),
Self::GetClipboardContents(..) => target_variant!("GetClipboardContents"),
Self::SetClipboardContents(..) => target_variant!("SetClipboardContents"),
Self::SetCursor(..) => target_variant!("SetCursor"),
Self::NewFavicon(..) => target_variant!("NewFavicon"),
Self::HeadParsed => target_variant!("HeadParsed"),
Self::HistoryChanged(_, _) => target_variant!("HistoryChanged"),
Self::SetFullscreenState(_) => target_variant!("SetFullscreenState"),
Self::HistoryChanged(..) => target_variant!("HistoryChanged"),
Self::SetFullscreenState(..) => target_variant!("SetFullscreenState"),
Self::LoadStart => target_variant!("LoadStart"),
Self::LoadComplete => target_variant!("LoadComplete"),
Self::Panic(_, _) => target_variant!("Panic"),
Self::GetSelectedBluetoothDevice(_, _) => {
Self::Panic(..) => target_variant!("Panic"),
Self::GetSelectedBluetoothDevice(..) => {
target_variant!("GetSelectedBluetoothDevice")
},
Self::SelectFiles(_, _, _) => target_variant!("SelectFiles"),
Self::PromptPermission(_, _) => target_variant!("PromptPermission"),
Self::ShowIME(_, _, _, _) => target_variant!("ShowIME"),
Self::SelectFiles(..) => target_variant!("SelectFiles"),
Self::PromptPermission(..) => target_variant!("PromptPermission"),
Self::ShowIME(..) => target_variant!("ShowIME"),
Self::HideIME => target_variant!("HideIME"),
Self::Shutdown => target_variant!("Shutdown"),
Self::ReportProfile(_) => target_variant!("ReportProfile"),
Self::MediaSessionEvent(_) => target_variant!("MediaSessionEvent"),
Self::OnDevtoolsStarted(_, _) => target_variant!("OnDevtoolsStarted"),
Self::ReadyToPresent => target_variant!("ReadyToPresent"),
Self::EventDelivered(_) => target_variant!("EventDelivered"),
Self::ReportProfile(..) => target_variant!("ReportProfile"),
Self::MediaSessionEvent(..) => target_variant!("MediaSessionEvent"),
Self::OnDevtoolsStarted(..) => target_variant!("OnDevtoolsStarted"),
Self::ReadyToPresent(..) => target_variant!("ReadyToPresent"),
Self::EventDelivered(..) => target_variant!("EventDelivered"),
}
}
}
@ -253,8 +257,8 @@ mod from_layout {
impl LogTarget for script_traits::LayoutMsg {
fn log_target(&self) -> &'static str {
match self {
Self::IFrameSizes(_) => target!("IFrameSizes"),
Self::PendingPaintMetric(_, _) => target!("PendingPaintMetric"),
Self::IFrameSizes(..) => target!("IFrameSizes"),
Self::PendingPaintMetric(..) => target!("PendingPaintMetric"),
}
}
}

View file

@ -101,12 +101,12 @@ mod test {
use msg::constellation_msg::{
BrowsingContextId, BrowsingContextIndex, PipelineNamespace, PipelineNamespaceId,
TopLevelBrowsingContextId,
TopLevelBrowsingContextId, WebViewId,
};
use crate::webview::WebViewManager;
fn top_level_id(namespace_id: u32, index: u32) -> TopLevelBrowsingContextId {
fn id(namespace_id: u32, index: u32) -> WebViewId {
TopLevelBrowsingContextId(BrowsingContextId {
namespace_id: PipelineNamespaceId(namespace_id),
index: BrowsingContextIndex(NonZeroU32::new(index).expect("Incorrect test case")),
@ -115,7 +115,7 @@ mod test {
fn webviews_sorted<WebView: Clone>(
webviews: &WebViewManager<WebView>,
) -> Vec<(TopLevelBrowsingContextId, WebView)> {
) -> Vec<(WebViewId, WebView)> {
let mut keys = webviews.webviews.keys().collect::<Vec<_>>();
keys.sort();
keys.iter()
@ -138,59 +138,59 @@ mod test {
let mut webviews = WebViewManager::default();
// add() adds the webview to the map, but does not focus it.
webviews.add(TopLevelBrowsingContextId::new(), 'a');
webviews.add(TopLevelBrowsingContextId::new(), 'b');
webviews.add(TopLevelBrowsingContextId::new(), 'c');
webviews.add(WebViewId::new(), 'a');
webviews.add(WebViewId::new(), 'b');
webviews.add(WebViewId::new(), 'c');
assert_eq!(
webviews_sorted(&webviews),
vec![
(top_level_id(0, 1), 'a'),
(top_level_id(0, 2), 'b'),
(top_level_id(0, 3), 'c'),
]
vec![(id(0, 1), 'a'), (id(0, 2), 'b'), (id(0, 3), 'c'),]
);
assert!(webviews.focus_order.is_empty());
assert_eq!(webviews.is_focused, false);
// focus() makes the given webview the latest in focus order.
webviews.focus(top_level_id(0, 2));
assert_eq!(webviews.focus_order, vec![top_level_id(0, 2)]);
webviews.focus(id(0, 2));
assert_eq!(webviews.focus_order, vec![id(0, 2)]);
assert_eq!(webviews.is_focused, true);
webviews.focus(top_level_id(0, 1));
assert_eq!(
webviews.focus_order,
vec![top_level_id(0, 2), top_level_id(0, 1)]
);
webviews.focus(id(0, 1));
assert_eq!(webviews.focus_order, vec![id(0, 2), id(0, 1)]);
assert_eq!(webviews.is_focused, true);
webviews.focus(top_level_id(0, 3));
assert_eq!(
webviews.focus_order,
vec![top_level_id(0, 2), top_level_id(0, 1), top_level_id(0, 3)]
);
webviews.focus(id(0, 3));
assert_eq!(webviews.focus_order, vec![id(0, 2), id(0, 1), id(0, 3)]);
assert_eq!(webviews.is_focused, true);
// unfocus() clears the “is focused” flag, but does not touch the focus order.
webviews.unfocus();
assert_eq!(
webviews.focus_order,
vec![top_level_id(0, 2), top_level_id(0, 1), top_level_id(0, 3)]
);
assert_eq!(webviews.focus_order, vec![id(0, 2), id(0, 1), id(0, 3)]);
assert_eq!(webviews.is_focused, false);
// focus() avoids duplicates in focus order, when the given webview has been focused before.
webviews.focus(top_level_id(0, 1));
assert_eq!(
webviews.focus_order,
vec![top_level_id(0, 2), top_level_id(0, 3), top_level_id(0, 1)]
);
webviews.focus(id(0, 1));
assert_eq!(webviews.focus_order, vec![id(0, 2), id(0, 3), id(0, 1)]);
assert_eq!(webviews.is_focused, true);
// remove() clears the “is focused” flag iff the given webview was focused.
webviews.remove(top_level_id(0, 2));
webviews.remove(id(1, 1));
assert_eq!(webviews.is_focused, true);
webviews.remove(top_level_id(0, 1));
webviews.remove(id(1, 2));
assert_eq!(webviews.is_focused, true);
webviews.remove(id(2, 1));
assert_eq!(webviews.is_focused, true);
webviews.remove(id(2, 2));
assert_eq!(webviews.is_focused, true);
webviews.remove(id(2, 3));
assert_eq!(webviews.is_focused, true);
webviews.remove(id(2, 4));
assert_eq!(webviews.is_focused, true);
webviews.remove(id(3, 1));
assert_eq!(webviews.is_focused, true);
webviews.remove(id(4, 1));
assert_eq!(webviews.is_focused, true);
webviews.remove(id(0, 2));
assert_eq!(webviews.is_focused, true);
webviews.remove(id(0, 1));
assert_eq!(webviews.is_focused, false);
webviews.remove(top_level_id(0, 3));
webviews.remove(id(0, 3));
assert_eq!(webviews.is_focused, false);
// remove() removes the given webview from both the map and the focus order.