diff options
author | Ms2ger <ms2ger@gmail.com> | 2014-05-11 22:34:03 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2014-05-12 21:21:03 +0200 |
commit | d095c42eaf4b18be93f199ed886f93e5657234d7 (patch) | |
tree | 202dcf68f3c0897224b6f35a45c6c262e20e980f /src/components/script/script_task.rs | |
parent | c6274f9793cf3bab74b58a697961680567dea97b (diff) | |
download | servo-d095c42eaf4b18be93f199ed886f93e5657234d7.tar.gz servo-d095c42eaf4b18be93f199ed886f93e5657234d7.zip |
Move the loading of documents in iframes into HTMLIFrameElement.
Right now, the load is kicked off inside the parser glue. This is unfortunate
for several reasons:
1) we'd like to replace the current parser (libhubbub) by our own parser,
written in Rust, so code intertwined with the parser will have to be
rewritten;
2) it is impossible to support dynamically (i.e. from script) created iframes
in this way;
3) the code flow around loading subdocuments is complicated needlessly.
This commit adds the constellation channel (on which the message to actually
load the document is sent) as a field on the Page, to allow HTMLIFrameElement
to access it.
In rewriting the code, support for dynamically created iframes is added, and
a task failure is avoided when the value of the src attribute can not be
parsed.
Diffstat (limited to 'src/components/script/script_task.rs')
-rw-r--r-- | src/components/script/script_task.rs | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index c1e01bbc3bc..4bd981a5291 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -22,7 +22,7 @@ use dom::node; use dom::node::{Node, NodeHelpers}; use dom::window::{TimerId, Window}; use html::hubbub_html_parser::HtmlParserResult; -use html::hubbub_html_parser::{HtmlDiscoveredStyle, HtmlDiscoveredIFrame, HtmlDiscoveredScript}; +use html::hubbub_html_parser::{HtmlDiscoveredStyle, HtmlDiscoveredScript}; use html::hubbub_html_parser; use layout_interface::{AddStylesheetMsg, DocumentDamage}; use layout_interface::{DocumentDamageLevel, HitTestQuery, HitTestResponse, LayoutQuery, MouseOverQuery, MouseOverResponse}; @@ -43,8 +43,7 @@ use js::rust::with_compartment; use js; use servo_msg::compositor_msg::{FinishedLoading, LayerId, Loading, PerformingLayout}; use servo_msg::compositor_msg::{ScriptListener}; -use servo_msg::constellation_msg::{ConstellationChan, IFrameSandboxed, IFrameUnsandboxed}; -use servo_msg::constellation_msg::{LoadIframeUrlMsg, LoadCompleteMsg, LoadUrlMsg, NavigationDirection}; +use servo_msg::constellation_msg::{ConstellationChan, LoadCompleteMsg, LoadUrlMsg, NavigationDirection}; use servo_msg::constellation_msg::{PipelineId, SubpageId, Failure, FailureMsg}; use servo_msg::constellation_msg; use servo_net::image_cache_task::ImageCacheTask; @@ -157,6 +156,9 @@ pub struct Page { /// Associated resource task for use by DOM objects like XMLHttpRequest pub resource_task: Untraceable<ResourceTask>, + + /// A handle for communicating messages to the constellation task. + pub constellation_chan: Untraceable<ConstellationChan>, } pub struct PageTree { @@ -171,6 +173,7 @@ pub struct PageTreeIterator<'a> { impl PageTree { fn new(id: PipelineId, layout_chan: LayoutChan, window_size: Size2D<uint>, resource_task: ResourceTask, + constellation_chan: ConstellationChan, js_context: Rc<Cx>) -> PageTree { let js_info = JSPageInfo { dom_static: GlobalStaticData(), @@ -190,7 +193,8 @@ impl PageTree { resize_event: Untraceable::new(Cell::new(None)), fragment_node: Traceable::new(RefCell::new(None)), last_reflow_id: Traceable::new(Cell::new(0)), - resource_task: Untraceable::new(resource_task) + resource_task: Untraceable::new(resource_task), + constellation_chan: Untraceable::new(constellation_chan), }), inner: vec!(), } @@ -287,6 +291,13 @@ impl Page { self.frame.deref().borrow_mut() } + pub fn get_next_subpage_id(&self) -> SubpageId { + let subpage_id = self.next_subpage_id.deref().get(); + let SubpageId(id_num) = subpage_id; + self.next_subpage_id.deref().set(SubpageId(id_num + 1)); + subpage_id + } + /// Adds the given damage. pub fn damage(&self, level: DocumentDamageLevel) { let root = match *self.frame() { @@ -595,7 +606,9 @@ impl ScriptTask { -> Rc<ScriptTask> { let (js_runtime, js_context) = ScriptTask::new_rt_and_cx(); let page_tree = PageTree::new(id, layout_chan, window_size, - resource_task.clone(), js_context.clone()); + resource_task.clone(), + constellation_chan.clone(), + js_context.clone()); Rc::new(ScriptTask { page_tree: RefCell::new(page_tree), @@ -781,6 +794,7 @@ impl ScriptTask { let window_size = parent_page_tree.page().window_size.deref().get(); PageTree::new(new_id, layout_chan, window_size, parent_page_tree.page().resource_task.deref().clone(), + self.constellation_chan.clone(), self.js_context.borrow().get_ref().clone()) }; parent_page_tree.inner.push(new_page_tree); @@ -973,20 +987,6 @@ impl ScriptTask { let LayoutChan(ref chan) = *page.layout_chan; chan.send(AddStylesheetMsg(sheet)); } - Some(HtmlDiscoveredIFrame((iframe_url, subpage_id, sandboxed))) => { - let SubpageId(num) = subpage_id; - page.next_subpage_id.deref().set(SubpageId(num + 1)); - let sandboxed = if sandboxed { - IFrameSandboxed - } else { - IFrameUnsandboxed - }; - let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(LoadIframeUrlMsg(iframe_url, - pipeline_id, - subpage_id, - sandboxed)); - } None => break } } |