From 7bd257089c38489ded7d8d84493406c321c1f16f Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 23 Mar 2016 17:49:03 -0700 Subject: [PATCH] script: Make iframes know their pipeline IDs at all times, even after navigation. Since WebRender uses the pipeline ID stored in the iframe element to determine which pipeline to display, it had better be kept up to date! Closes #9919. --- components/compositing/constellation.rs | 5 ++- components/script/dom/htmliframeelement.rs | 10 ++++-- components/script/script_thread.rs | 13 +++++--- components/script_traits/lib.rs | 4 +-- tests/wpt/mozilla/meta/MANIFEST.json | 24 ++++++++++++++ .../css/iframe/mozbrowser_navigation.html.ini | 3 ++ .../css/iframe/mozbrowser_navigation.html | 33 +++++++++++++++++++ .../css/iframe/mozbrowser_navigation_ref.html | 19 +++++++++++ 8 files changed, 102 insertions(+), 9 deletions(-) create mode 100644 tests/wpt/mozilla/meta/css/iframe/mozbrowser_navigation.html.ini create mode 100644 tests/wpt/mozilla/tests/css/iframe/mozbrowser_navigation.html create mode 100644 tests/wpt/mozilla/tests/css/iframe/mozbrowser_navigation_ref.html diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 268ce926cbe..cf4673cd16b 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -1256,7 +1256,10 @@ impl Constellation Some((_, new_subpage_id)) => new_subpage_id, }, }; - let msg = ConstellationControlMsg::UpdateSubpageId(parent_pipeline_id, subpage_id, new_subpage_id); + let msg = ConstellationControlMsg::UpdateSubpageId(parent_pipeline_id, + subpage_id, + new_subpage_id, + next_pipeline_id); let result = match self.pipelines.get(&parent_pipeline_id) { None => return warn!("Pipeline {:?} child navigated after closure.", parent_pipeline_id), Some(pipeline) => pipeline.script_chan.send(msg), diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index a9d5471d468..ad172fabb99 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -24,7 +24,7 @@ use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers}; use dom::event::Event; use dom::eventtarget::EventTarget; use dom::htmlelement::HTMLElement; -use dom::node::{Node, UnbindContext, window_from_node, document_from_node}; +use dom::node::{Node, NodeDamage, UnbindContext, window_from_node, document_from_node}; use dom::urlhelper::UrlHelper; use dom::virtualmethods::VirtualMethods; use dom::window::{ReflowReason, Window}; @@ -177,8 +177,14 @@ impl HTMLIFrameElement { } } - pub fn update_subpage_id(&self, new_subpage_id: SubpageId) { + pub fn update_subpage_id(&self, new_subpage_id: SubpageId, new_pipeline_id: PipelineId) { self.subpage_id.set(Some(new_subpage_id)); + self.pipeline_id.set(Some(new_pipeline_id)); + + let mut blocker = self.load_blocker.borrow_mut(); + LoadBlocker::terminate(&mut blocker); + + self.upcast::().dirty(NodeDamage::OtherNodeDamage); } fn new_inherited(localName: Atom, diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index e725d9cbbf8..c0753f897a7 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -883,8 +883,12 @@ impl ScriptThread { event), ConstellationControlMsg::UpdateSubpageId(containing_pipeline_id, old_subpage_id, - new_subpage_id) => - self.handle_update_subpage_id(containing_pipeline_id, old_subpage_id, new_subpage_id), + new_subpage_id, + new_pipeline_id) => + self.handle_update_subpage_id(containing_pipeline_id, + old_subpage_id, + new_subpage_id, + new_pipeline_id), ConstellationControlMsg::FocusIFrame(containing_pipeline_id, subpage_id) => self.handle_focus_iframe_msg(containing_pipeline_id, subpage_id), ConstellationControlMsg::WebDriverScriptCommand(pipeline_id, msg) => @@ -1243,7 +1247,8 @@ impl ScriptThread { fn handle_update_subpage_id(&self, containing_pipeline_id: PipelineId, old_subpage_id: SubpageId, - new_subpage_id: SubpageId) { + new_subpage_id: SubpageId, + new_pipeline_id: PipelineId) { let borrowed_page = self.root_page(); let frame_element = borrowed_page.find(containing_pipeline_id).and_then(|page| { @@ -1251,7 +1256,7 @@ impl ScriptThread { doc.find_iframe(old_subpage_id) }); - frame_element.unwrap().update_subpage_id(new_subpage_id); + frame_element.unwrap().update_subpage_id(new_subpage_id, new_pipeline_id); } /// Window was resized, but this script was not active, so don't reflow yet diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 46c3e860643..523356e1e90 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -128,8 +128,8 @@ pub enum ConstellationControlMsg { Navigate(PipelineId, SubpageId, LoadData), /// Requests the script thread forward a mozbrowser event to an iframe it owns MozBrowserEvent(PipelineId, SubpageId, MozBrowserEvent), - /// Updates the current subpage id of a given iframe - UpdateSubpageId(PipelineId, SubpageId, SubpageId), + /// Updates the current subpage and pipeline IDs of a given iframe + UpdateSubpageId(PipelineId, SubpageId, SubpageId, PipelineId), /// Set an iframe to be focused. Used when an element in an iframe gains focus. FocusIFrame(PipelineId, SubpageId), /// Passes a webdriver command to the script thread for execution diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 4285757014f..c7a798e828f 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -1788,6 +1788,18 @@ "url": "/_mozilla/css/iframe/hide_layers2.html" } ], + "css/iframe/mozbrowser_navigation.html": [ + { + "path": "css/iframe/mozbrowser_navigation.html", + "references": [ + [ + "/_mozilla/css/iframe/mozbrowser_navigation_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/iframe/mozbrowser_navigation.html" + } + ], "css/iframe/multiple_external.html": [ { "path": "css/iframe/multiple_external.html", @@ -8516,6 +8528,18 @@ "url": "/_mozilla/css/iframe/hide_layers2.html" } ], + "css/iframe/mozbrowser_navigation.html": [ + { + "path": "css/iframe/mozbrowser_navigation.html", + "references": [ + [ + "/_mozilla/css/iframe/mozbrowser_navigation_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/iframe/mozbrowser_navigation.html" + } + ], "css/iframe/multiple_external.html": [ { "path": "css/iframe/multiple_external.html", diff --git a/tests/wpt/mozilla/meta/css/iframe/mozbrowser_navigation.html.ini b/tests/wpt/mozilla/meta/css/iframe/mozbrowser_navigation.html.ini new file mode 100644 index 00000000000..cf8719cfccf --- /dev/null +++ b/tests/wpt/mozilla/meta/css/iframe/mozbrowser_navigation.html.ini @@ -0,0 +1,3 @@ +[mozbrowser_navigation.html] + type: reftest + prefs: [dom.mozbrowser.enabled:true] diff --git a/tests/wpt/mozilla/tests/css/iframe/mozbrowser_navigation.html b/tests/wpt/mozilla/tests/css/iframe/mozbrowser_navigation.html new file mode 100644 index 00000000000..ea8ae85531d --- /dev/null +++ b/tests/wpt/mozilla/tests/css/iframe/mozbrowser_navigation.html @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/mozilla/tests/css/iframe/mozbrowser_navigation_ref.html b/tests/wpt/mozilla/tests/css/iframe/mozbrowser_navigation_ref.html new file mode 100644 index 00000000000..10e6dac4888 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/iframe/mozbrowser_navigation_ref.html @@ -0,0 +1,19 @@ + + + + + + + + + +