diff options
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/document.rs | 2 | ||||
-rw-r--r-- | components/script/script_thread.rs | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index b59f9502d63..b3f08964502 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -3211,7 +3211,7 @@ impl Document { let window = self.window(); // Step 8 - let event = EmbedderMsg::SetFullscreenState(true); + let event = EmbedderMsg::SetFullscreenState(false); self.send_to_embedder(event); // Step 9 diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 41a7192e70a..78b7a8606b0 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1304,6 +1304,10 @@ impl ScriptThread { // An event came-in from a document that is not fully-active, it has been stored by the task-queue. // Continue without adding it to "sequential". }, + FromConstellation(ConstellationControlMsg::ExitFullScreen(id)) => self + .profile_event(ScriptThreadEventCategory::ExitFullscreen, Some(id), || { + self.handle_exit_fullscreen(id); + }), _ => { sequential.push(event); }, @@ -1500,6 +1504,7 @@ impl ScriptThread { Reload(id, ..) => Some(id), WebVREvents(id, ..) => Some(id), PaintMetric(..) => None, + ExitFullScreen(id, ..) => Some(id), } }, MixedMessage::FromDevtools(_) => None, @@ -1731,6 +1736,7 @@ impl ScriptThread { msg @ ConstellationControlMsg::Viewport(..) | msg @ ConstellationControlMsg::SetScrollState(..) | msg @ ConstellationControlMsg::Resize(..) | + msg @ ConstellationControlMsg::ExitFullScreen(..) | msg @ ConstellationControlMsg::ExitScriptThread => { panic!("should have handled {:?} already", msg) }, @@ -1953,6 +1959,19 @@ impl ScriptThread { warn!("resize sent to nonexistent pipeline"); } + // exit_fullscreen creates a new JS promise object, so we need to have entered a compartment + fn handle_exit_fullscreen(&self, id: PipelineId) { + let document = self.documents.borrow().find_document(id); + if let Some(document) = document { + let _ac = JSAutoCompartment::new( + document.global().get_cx(), + document.reflector().get_jsobject().get(), + ); + document.exit_fullscreen(); + return; + } + } + fn handle_viewport(&self, id: PipelineId, rect: Rect<f32>) { let document = self.documents.borrow().find_document(id); if let Some(document) = document { |