Rewild Your Web
at main 50 lines 2.0 kB view raw
1--- original 2+++ modified 3@@ -6,6 +6,7 @@ 4 use std::sync::Arc; 5 use std::time::{SystemTime, UNIX_EPOCH}; 6 7+use constellation_traits::{EmbeddedWebViewEventType, ScriptToConstellationMessage}; 8 use dom_struct::dom_struct; 9 use embedder_traits::{ 10 EmbedderMsg, Notification as EmbedderNotification, 11@@ -270,11 +271,22 @@ 12 if !shown { 13 // TODO: step 6.1: Append notification to the list of notifications. 14 // step 6.2: Display notification on the device 15- self.global() 16- .send_to_embedder(EmbedderMsg::ShowNotification( 17- self.global().webview_id(), 18- self.to_embedder_notification(), 19- )); 20+ let notification = self.to_embedder_notification(); 21+ if self.global().is_embedded_webview() { 22+ // For embedded webviews, route through constellation to parent iframe 23+ self.global() 24+ .script_to_constellation_chan() 25+ .send(ScriptToConstellationMessage::EmbeddedWebViewNotification( 26+ EmbeddedWebViewEventType::NotificationShow(notification), 27+ )) 28+ .unwrap(); 29+ } else { 30+ self.global() 31+ .send_to_embedder(EmbedderMsg::ShowNotification( 32+ self.global().webview_id(), 33+ notification, 34+ )); 35+ } 36 } 37 38 // TODO: step 7: If shown is false or oldNotification is non-null, 39@@ -857,6 +869,11 @@ 40 for (request, resource_type) in pending_requests { 41 self.fetch_and_show_when_ready(request, resource_type); 42 } 43+ 44+ // If there are no resources to fetch, show the notification immediately 45+ if self.pending_request_ids.borrow().is_empty() { 46+ self.show(); 47+ } 48 } 49 50 fn fetch_and_show_when_ready(&self, request: RequestBuilder, resource_type: ResourceType) {