diff options
author | Gregory Terzian <gterzian@users.noreply.github.com> | 2019-09-05 16:12:52 +0800 |
---|---|---|
committer | Gregory Terzian <gterzian@users.noreply.github.com> | 2019-09-22 12:46:40 +0800 |
commit | 45ec250b0a989643865880734ff898de4b15bd7d (patch) | |
tree | 361580237392c5e1aecafd722f9de3265736e702 /components/script/script_thread.rs | |
parent | 4fe8238b14d535f7ca94a36effda06624b73ecbe (diff) | |
download | servo-45ec250b0a989643865880734ff898de4b15bd7d.tar.gz servo-45ec250b0a989643865880734ff898de4b15bd7d.zip |
improve spec compliance of discarding BCs
do not handle compositor input events when BC is being discarded
prevent firing of timers for discarded BCs
return null for opener is BC has been discarded
bundle discard BC steps into window method
return null in window.opener, if BC has already been discarded
move the window closed check pre-event to script-thread
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 440de991ceb..b4363f5ada3 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1973,7 +1973,15 @@ impl ScriptThread { let window = self.documents.borrow().find_window(pipeline_id); let window = match window { - Some(w) => w, + Some(w) => { + if w.Closed() { + return warn!( + "Received fire timer msg for a discarded browsing context whose pipeline is pending exit {}.", + pipeline_id + ); + } + w + }, None => { return warn!( "Received fire timer msg for a closed pipeline {}.", @@ -2848,7 +2856,7 @@ impl ScriptThread { // to avoid running layout on detached iframes. let window = document.window(); if discard_bc == DiscardBrowsingContext::Yes { - window.window_proxy().discard_browsing_context(); + window.discard_browsing_context(); } window.clear_js_runtime(); } @@ -3378,9 +3386,26 @@ impl ScriptThread { /// /// TODO: Actually perform DOM event dispatch. fn handle_event(&self, pipeline_id: PipelineId, event: CompositorEvent) { + // Do not handle events if the pipeline exited. + let window = match { self.documents.borrow().find_window(pipeline_id) } { + Some(win) => win, + None => { + return warn!( + "Compositor event sent to a pipeline that already exited {}.", + pipeline_id + ) + }, + }; + // Do not handle events if the BC has been, or is being, discarded + if window.Closed() { + return warn!( + "Compositor event sent to a pipeline with a closed window {}.", + pipeline_id + ); + } + // Assuming all CompositionEvent are generated by user interactions. ScriptThread::set_user_interacting(true); - match event { ResizeEvent(new_size, size_type) => { self.handle_resize_event(pipeline_id, new_size, size_type); |