servoshell: Port desktop servoshell to use delegate API (#35284)

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Martin Robinson 2025-02-06 08:33:31 +01:00 committed by GitHub
parent 6b12499077
commit 5f08e4fa76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 1109 additions and 1258 deletions

View file

@ -1089,7 +1089,11 @@ impl Servo {
webview.delegate().notify_ready_to_show(webview);
}
},
EmbedderMsg::WebViewClosed(_) => {},
EmbedderMsg::WebViewClosed(webview_id) => {
if let Some(webview) = self.get_webview_handle(webview_id) {
webview.delegate().notify_closed(webview);
}
},
EmbedderMsg::WebViewFocused(webview_id) => {
for id in self.webviews.borrow().keys() {
if let Some(webview) = self.get_webview_handle(*id) {

View file

@ -117,6 +117,10 @@ pub trait WebViewDelegate {
/// The history state has changed.
// changed pattern; maybe wasteful if embedder doesnt care?
fn notify_history_changed(&self, _webview: WebView, _: Vec<Url>, _: usize) {}
/// Page content has closed this [`WebView`] via `window.close()`. It's the embedder's
/// responsibility to remove the [`WebView`] from the interface when this notification
/// occurs.
fn notify_closed(&self, _webview: WebView) {}
/// A keyboard event has been sent to Servo, but remains unprocessed. This allows the
/// embedding application to handle key events while first letting the [`WebView`]
@ -144,10 +148,6 @@ pub trait WebViewDelegate {
fn request_open_auxiliary_webview(&self, _parent_webview: WebView) -> Option<WebView> {
None
}
/// Page content has requested that this [`WebView`] be closed. It's the embedder's
/// responsibility to either ignore this request or to remove the [`WebView`] from the
/// interface.
fn request_close(&self, _webview: WebView) {}
/// Open interface to request permission specified by prompt.
fn request_permission(
&self,