Rewild Your Web
web browser dweb

constellation: ensure non embedded iframes are not considered as top-level BC

+18 -13
+18 -13
patches/components/constellation/constellation.rs.patch
··· 88 let new_pipeline_info = NewPipelineInfo { 89 parent_info: parent_pipeline_id, 90 new_pipeline_id, 91 - @@ -1051,6 +1085,8 @@ 92 viewport_details: initial_viewport_details, 93 user_content_manager_id, 94 theme, 95 - + is_embedded_webview: self.embedded_webview_to_iframe.contains_key(&webview_id), 96 + hide_focus, 97 }; 98 let pipeline = match Pipeline::spawn(new_pipeline_info, event_loop, self, throttled) { 99 Ok(pipeline) => pipeline, 100 - @@ -1522,11 +1558,7 @@ 101 } 102 }, 103 EmbedderToConstellationMessage::PreferencesUpdated(updates) => { ··· 110 let _ = event_loop.send(ScriptThreadMessage::PreferencesUpdated( 111 updates 112 .iter() 113 - @@ -1550,6 +1582,18 @@ 114 EmbedderToConstellationMessage::UpdatePinchZoomInfos(pipeline_id, pinch_zoom) => { 115 self.handle_update_pinch_zoom_infos(pipeline_id, pinch_zoom); 116 }, ··· 129 } 130 } 131 132 - @@ -1773,6 +1817,12 @@ 133 self.broadcast_channels 134 .remove_broadcast_channel_router(router_id); 135 }, ··· 142 ScriptToConstellationMessage::ScheduleBroadcast(router_id, message) => { 143 if self 144 .check_origin_against_pipeline(&source_pipeline_id, &message.origin) 145 - @@ -1803,6 +1853,12 @@ 146 ScriptToConstellationMessage::CreateAuxiliaryWebView(load_info) => { 147 self.handle_script_new_auxiliary(load_info); 148 }, ··· 155 ScriptToConstellationMessage::ChangeRunningAnimationsState(animation_state) => { 156 self.handle_change_running_animations_state(source_pipeline_id, animation_state) 157 }, 158 - @@ -1969,6 +2025,23 @@ 159 new_value, 160 ); 161 }, ··· 179 ScriptToConstellationMessage::MediaSessionEvent(pipeline_id, event) => { 180 // Unlikely at this point, but we may receive events coming from 181 // different media sessions, so we set the active media session based 182 - @@ -2037,6 +2110,129 @@ 183 ScriptToConstellationMessage::RespondToScreenshotReadinessRequest(response) => { 184 self.handle_screenshot_readiness_response(source_pipeline_id, response); 185 }, ··· 309 } 310 } 311 312 - @@ -3135,6 +3331,13 @@ 313 /// <https://html.spec.whatwg.org/multipage/#destroy-a-top-level-traversable> 314 fn handle_close_top_level_browsing_context(&mut self, webview_id: WebViewId) { 315 debug!("{webview_id}: Closing"); ··· 323 let browsing_context_id = BrowsingContextId::from(webview_id); 324 // Step 5. Remove traversable from the user agent's top-level traversable set. 325 let browsing_context = 326 - @@ -3411,8 +3614,27 @@ 327 opener_webview_id, 328 opener_pipeline_id, 329 response_sender, ··· 351 let Some((webview_id_sender, webview_id_receiver)) = generic_channel::channel() else { 352 warn!("Failed to create channel"); 353 let _ = response_sender.send(None); 354 - @@ -3510,6 +3732,359 @@ 355 }); 356 } 357 ··· 711 #[servo_tracing::instrument(skip_all)] 712 fn handle_refresh_cursor(&self, pipeline_id: PipelineId) { 713 let Some(pipeline) = self.pipelines.get(&pipeline_id) else { 714 - @@ -4632,7 +5207,7 @@ 715 } 716 717 #[servo_tracing::instrument(skip_all)] ··· 720 // Send a flat projection of the history to embedder. 721 // The final vector is a concatenation of the URLs of the past 722 // entries, the current entry and the future entries. 723 - @@ -4735,9 +5310,23 @@ 724 ); 725 self.embedder_proxy.send(EmbedderMsg::HistoryChanged( 726 webview_id,
··· 88 let new_pipeline_info = NewPipelineInfo { 89 parent_info: parent_pipeline_id, 90 new_pipeline_id, 91 + @@ -1051,6 +1085,13 @@ 92 viewport_details: initial_viewport_details, 93 user_content_manager_id, 94 theme, 95 + + // Only set is_embedded_webview=true if this browsing context IS the embedded webview itself, 96 + + // not for regular iframes inside the embedded webview that happen to share the same webview_id 97 + + is_embedded_webview: self 98 + + .embedded_webview_to_iframe 99 + + .get(&webview_id) 100 + + .is_some_and(|(embedded_bc_id, _)| *embedded_bc_id == browsing_context_id), 101 + hide_focus, 102 }; 103 let pipeline = match Pipeline::spawn(new_pipeline_info, event_loop, self, throttled) { 104 Ok(pipeline) => pipeline, 105 + @@ -1522,11 +1563,7 @@ 106 } 107 }, 108 EmbedderToConstellationMessage::PreferencesUpdated(updates) => { ··· 115 let _ = event_loop.send(ScriptThreadMessage::PreferencesUpdated( 116 updates 117 .iter() 118 + @@ -1550,6 +1587,18 @@ 119 EmbedderToConstellationMessage::UpdatePinchZoomInfos(pipeline_id, pinch_zoom) => { 120 self.handle_update_pinch_zoom_infos(pipeline_id, pinch_zoom); 121 }, ··· 134 } 135 } 136 137 + @@ -1773,6 +1822,12 @@ 138 self.broadcast_channels 139 .remove_broadcast_channel_router(router_id); 140 }, ··· 147 ScriptToConstellationMessage::ScheduleBroadcast(router_id, message) => { 148 if self 149 .check_origin_against_pipeline(&source_pipeline_id, &message.origin) 150 + @@ -1803,6 +1858,12 @@ 151 ScriptToConstellationMessage::CreateAuxiliaryWebView(load_info) => { 152 self.handle_script_new_auxiliary(load_info); 153 }, ··· 160 ScriptToConstellationMessage::ChangeRunningAnimationsState(animation_state) => { 161 self.handle_change_running_animations_state(source_pipeline_id, animation_state) 162 }, 163 + @@ -1969,6 +2030,23 @@ 164 new_value, 165 ); 166 }, ··· 184 ScriptToConstellationMessage::MediaSessionEvent(pipeline_id, event) => { 185 // Unlikely at this point, but we may receive events coming from 186 // different media sessions, so we set the active media session based 187 + @@ -2037,6 +2115,129 @@ 188 ScriptToConstellationMessage::RespondToScreenshotReadinessRequest(response) => { 189 self.handle_screenshot_readiness_response(source_pipeline_id, response); 190 }, ··· 314 } 315 } 316 317 + @@ -3135,6 +3336,13 @@ 318 /// <https://html.spec.whatwg.org/multipage/#destroy-a-top-level-traversable> 319 fn handle_close_top_level_browsing_context(&mut self, webview_id: WebViewId) { 320 debug!("{webview_id}: Closing"); ··· 328 let browsing_context_id = BrowsingContextId::from(webview_id); 329 // Step 5. Remove traversable from the user agent's top-level traversable set. 330 let browsing_context = 331 + @@ -3411,8 +3619,27 @@ 332 opener_webview_id, 333 opener_pipeline_id, 334 response_sender, ··· 356 let Some((webview_id_sender, webview_id_receiver)) = generic_channel::channel() else { 357 warn!("Failed to create channel"); 358 let _ = response_sender.send(None); 359 + @@ -3510,6 +3737,359 @@ 360 }); 361 } 362 ··· 716 #[servo_tracing::instrument(skip_all)] 717 fn handle_refresh_cursor(&self, pipeline_id: PipelineId) { 718 let Some(pipeline) = self.pipelines.get(&pipeline_id) else { 719 + @@ -4632,7 +5212,7 @@ 720 } 721 722 #[servo_tracing::instrument(skip_all)] ··· 725 // Send a flat projection of the history to embedder. 726 // The final vector is a concatenation of the URLs of the past 727 // entries, the current entry and the future entries. 728 + @@ -4735,9 +5315,23 @@ 729 ); 730 self.embedder_proxy.send(EmbedderMsg::HistoryChanged( 731 webview_id,