aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
authorPaul Rouget <me@paulrouget.com>2016-01-25 16:26:50 +0100
committerPaul Rouget <me@paulrouget.com>2016-01-25 16:31:59 +0100
commita2c931e4df812669513625cfb54656db2a67a332 (patch)
tree6f315432fb48b0eaba4d47aa3e8ee52536e532ab /components/script/script_thread.rs
parentc80fa3386459efd27b64c8b6cab33794e66d082b (diff)
downloadservo-a2c931e4df812669513625cfb54656db2a67a332.tar.gz
servo-a2c931e4df812669513625cfb54656db2a67a332.zip
Check if root page exist before handling DOM events
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index d4339cb2b05..663d87f46ee 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -835,6 +835,10 @@ impl ScriptThread {
self.page.borrow().as_ref().unwrap().clone()
}
+ fn root_page_exists(&self) -> bool {
+ self.page.borrow().is_some()
+ }
+
/// Find a child page of the root page by pipeline id. Returns `None` if the root page does
/// not exist or the subpage cannot be found.
fn find_subpage(&self, pipeline_id: PipelineId) -> Option<Rc<Page>> {
@@ -1651,10 +1655,6 @@ impl ScriptThread {
}
debug!("ScriptThread: loading {} on page {:?}", incomplete.url.serialize(), incomplete.pipeline_id);
- // We should either be initializing a root page or loading a child page of an
- // existing one.
- let root_page_exists = self.page.borrow().is_some();
-
let frame_element = incomplete.parent_info.and_then(|(parent_id, subpage_id)| {
// The root page may not exist yet, if the parent of this frame
// exists in a different script thread.
@@ -1677,7 +1677,7 @@ impl ScriptThread {
// Create a new frame tree entry.
let page = Rc::new(Page::new(incomplete.pipeline_id));
- if !root_page_exists {
+ if !self.root_page_exists() {
// We have a new root frame tree.
*self.page.borrow_mut() = Some(page.clone());
} else if let Some((parent, _)) = incomplete.parent_info {
@@ -1725,7 +1725,7 @@ impl ScriptThread {
}
}
- let page_to_remove = if !root_page_exists {
+ let page_to_remove = if !self.root_page_exists() {
PageToRemove::Root
} else {
PageToRemove::Child(incomplete.pipeline_id)
@@ -1922,6 +1922,11 @@ impl ScriptThread {
/// TODO: Actually perform DOM event dispatch.
fn handle_event(&self, pipeline_id: PipelineId, event: CompositorEvent) {
+ // DOM events can only be handled if there's a root page.
+ if !self.root_page_exists() {
+ return;
+ }
+
match event {
ResizeEvent(new_size) => {
self.handle_resize_event(pipeline_id, new_size);