diff options
-rw-r--r-- | Cargo.lock | 1 | ||||
-rw-r--r-- | components/compositing/compositor.rs | 4 | ||||
-rw-r--r-- | components/compositing/constellation.rs | 24 | ||||
-rw-r--r-- | components/compositing/pipeline.rs | 17 | ||||
-rw-r--r-- | components/msg/Cargo.toml | 4 | ||||
-rw-r--r-- | components/msg/constellation_msg.rs | 26 | ||||
-rw-r--r-- | components/msg/lib.rs | 1 | ||||
-rw-r--r-- | components/script/html/hubbub_html_parser.rs | 14 | ||||
-rw-r--r-- | components/script/script_task.rs | 14 | ||||
-rw-r--r-- | components/script_traits/lib.rs | 5 |
10 files changed, 75 insertions, 35 deletions
diff --git a/Cargo.lock b/Cargo.lock index 6e05b1e2a25..6202dd3faf3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -322,6 +322,7 @@ dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure#b357751c04a89a87e6ef1f0cebe5f20957dd112d)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a)", "geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)", + "http 0.1.0-pre (git+https://github.com/servo/rust-http?ref=servo#92019011b0cdf1bffc8c584830de1bf330d79d0d)", "io_surface 0.1.0 (git+https://github.com/servo/rust-io-surface#7038341220bd7e86e21118fac2cbc6bd50890e47)", "layers 0.1.0 (git+https://github.com/servo/rust-layers#180d3ff2f28d239e32d01982c76be5c97d5763a8)", "url 0.1.0 (git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243)", diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 954fc072d4b..af19496be88 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -39,7 +39,7 @@ use png; use servo_msg::compositor_msg::{Blank, Epoch, FinishedLoading, IdleRenderState, LayerId}; use servo_msg::compositor_msg::{ReadyState, RenderingRenderState, RenderState, Scrollable}; use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, LoadUrlMsg, NavigateMsg}; -use servo_msg::constellation_msg::{PipelineId, ResizedWindowMsg, WindowSizeData}; +use servo_msg::constellation_msg::{LoadData, PipelineId, ResizedWindowMsg, WindowSizeData}; use servo_msg::constellation_msg; use servo_util::geometry::{PagePx, ScreenPx, ViewportPx}; use servo_util::memory::MemoryProfilerChan; @@ -726,7 +726,7 @@ impl IOCompositor { layers"), }; - let msg = LoadUrlMsg(root_pipeline_id, Url::parse(url_string.as_slice()).unwrap()); + let msg = LoadUrlMsg(root_pipeline_id, LoadData::new(Url::parse(url_string.as_slice()).unwrap())); let ConstellationChan(ref chan) = self.constellation_chan; chan.send(msg); } diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 4cc8915f456..0dc7428f96a 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -17,7 +17,7 @@ use servo_msg::compositor_msg::LayerId; use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, FailureMsg, Failure, FrameRectMsg}; use servo_msg::constellation_msg::{IFrameSandboxState, IFrameUnsandboxed, InitLoadUrlMsg}; use servo_msg::constellation_msg::{LoadCompleteMsg, LoadIframeUrlMsg, LoadUrlMsg, Msg, NavigateMsg}; -use servo_msg::constellation_msg::{NavigationType, PipelineId, RendererReadyMsg, ResizedWindowMsg}; +use servo_msg::constellation_msg::{LoadData, NavigationType, PipelineId, RendererReadyMsg, ResizedWindowMsg}; use servo_msg::constellation_msg::{SubpageId, WindowSizeData}; use servo_msg::constellation_msg; use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient}; @@ -292,7 +292,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { id: PipelineId, subpage_id: Option<SubpageId>, script_pipeline: Option<Rc<Pipeline>>, - url: Url) + load_data: LoadData) -> Rc<Pipeline> { let pipe = Pipeline::create::<LTF, STF>(id, subpage_id, @@ -306,7 +306,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { self.window_size, self.opts.clone(), script_pipeline, - url); + load_data); pipe.load(); Rc::new(pipe) } @@ -364,9 +364,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { // Load a new page, usually -- but not always -- from a mouse click or typed url // If there is already a pending page (self.pending_frames), it will not be overridden; // However, if the id is not encompassed by another change, it will be. - LoadUrlMsg(source_id, url) => { + LoadUrlMsg(source_id, load_data) => { debug!("constellation got URL load message"); - self.handle_load_url_msg(source_id, url); + self.handle_load_url_msg(source_id, load_data); } // A page loaded through one of several methods above has completed all parsing, // script, and reflow messages have been sent. @@ -449,7 +449,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { let new_id = self.get_next_pipeline_id(); let pipeline = self.new_pipeline(new_id, subpage_id, None, - Url::parse("about:failure").unwrap()); + LoadData::new(Url::parse("about:failure").unwrap())); self.pending_frames.push(FrameChange{ before: Some(pipeline_id), @@ -466,7 +466,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { fn handle_init_load(&mut self, url: Url) { let next_pipeline_id = self.get_next_pipeline_id(); - let pipeline = self.new_pipeline(next_pipeline_id, None, None, url); + let pipeline = self.new_pipeline(next_pipeline_id, None, None, LoadData::new(url)); self.pending_frames.push(FrameChange { before: None, @@ -573,7 +573,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { source Id of LoadIframeUrlMsg does have an associated pipeline in constellation. This should be impossible.").clone(); - let source_url = source_pipeline.url.clone(); + let source_url = source_pipeline.load_data.url.clone(); let same_script = (source_url.host() == url.host() && source_url.port() == url.port()) && sandbox == IFrameUnsandboxed; @@ -591,7 +591,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { next_pipeline_id, Some(subpage_id), new_pipeline, - url + LoadData::new(url) ); let rect = self.pending_sizes.pop(&(source_pipeline_id, subpage_id)); @@ -608,8 +608,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { self.pipelines.insert(pipeline.id, pipeline); } - fn handle_load_url_msg(&mut self, source_id: PipelineId, url: Url) { - debug!("Constellation: received message to load {:s}", url.to_string()); + fn handle_load_url_msg(&mut self, source_id: PipelineId, load_data: LoadData) { + debug!("Constellation: received message to load {:s}", load_data.url.to_string()); // Make sure no pending page would be overridden. let source_frame = self.current_frame().as_ref().unwrap().find(source_id).expect( "Constellation: received a LoadUrlMsg from a pipeline_id associated @@ -635,7 +635,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { let subpage_id = source_frame.pipeline.subpage_id; let next_pipeline_id = self.get_next_pipeline_id(); - let pipeline = self.new_pipeline(next_pipeline_id, subpage_id, None, url); + let pipeline = self.new_pipeline(next_pipeline_id, subpage_id, None, load_data); self.pending_frames.push(FrameChange{ before: Some(source_id), diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index 41ae22b13f7..9f888a3e19f 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -11,14 +11,13 @@ use devtools_traits::DevtoolsControlChan; use gfx::render_task::{PaintPermissionGranted, PaintPermissionRevoked}; use gfx::render_task::{RenderChan, RenderTask}; use servo_msg::constellation_msg::{ConstellationChan, Failure, PipelineId, SubpageId}; -use servo_msg::constellation_msg::WindowSizeData; +use servo_msg::constellation_msg::{LoadData, WindowSizeData}; use servo_net::image_cache_task::ImageCacheTask; use gfx::font_cache_task::FontCacheTask; use servo_net::resource_task::ResourceTask; use servo_util::opts::Opts; use servo_util::time::TimeProfilerChan; use std::rc::Rc; -use url::Url; /// A uniquely-identifiable pipeline of script task, layout task, and render task. pub struct Pipeline { @@ -29,8 +28,8 @@ pub struct Pipeline { pub render_chan: RenderChan, pub layout_shutdown_port: Receiver<()>, pub render_shutdown_port: Receiver<()>, - /// The most recently loaded url - pub url: Url, + /// The most recently loaded page + pub load_data: LoadData, } /// The subset of the pipeline that is needed for layer composition. @@ -58,7 +57,7 @@ impl Pipeline { window_size: WindowSizeData, opts: Opts, script_pipeline: Option<Rc<Pipeline>>, - url: Url) + load_data: LoadData) -> Pipeline { let layout_pair = ScriptTaskFactory::create_layout_channel(None::<&mut STF>); let (render_port, render_chan) = RenderChan::new(); @@ -134,7 +133,7 @@ impl Pipeline { render_chan, layout_shutdown_port, render_shutdown_port, - url) + load_data) } pub fn new(id: PipelineId, @@ -144,7 +143,7 @@ impl Pipeline { render_chan: RenderChan, layout_shutdown_port: Receiver<()>, render_shutdown_port: Receiver<()>, - url: Url) + load_data: LoadData) -> Pipeline { Pipeline { id: id, @@ -154,13 +153,13 @@ impl Pipeline { render_chan: render_chan, layout_shutdown_port: layout_shutdown_port, render_shutdown_port: render_shutdown_port, - url: url, + load_data: load_data, } } pub fn load(&self) { let ScriptControlChan(ref chan) = self.script_chan; - chan.send(LoadMsg(self.id, self.url.clone())); + chan.send(LoadMsg(self.id, self.load_data.clone())); } pub fn grant_paint_permission(&self) { diff --git a/components/msg/Cargo.toml b/components/msg/Cargo.toml index a09372a13f8..9f77add758e 100644 --- a/components/msg/Cargo.toml +++ b/components/msg/Cargo.toml @@ -17,6 +17,10 @@ git = "https://github.com/servo/rust-azure" [dependencies.geom] git = "https://github.com/servo/rust-geom" +[dependencies.http] +git = "https://github.com/servo/rust-http" +branch = "servo" + [dependencies.layers] git = "https://github.com/servo/rust-layers" diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 500f996aa79..737ef3f4d98 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -8,6 +8,8 @@ use geom::rect::Rect; use geom::size::TypedSize2D; use geom::scale_factor::ScaleFactor; +use http::headers::request::HeaderCollection as RequestHeaderCollection; +use http::method::{Method, Get}; use layers::geometry::DevicePixel; use servo_util::geometry::{PagePx, ViewportPx}; use std::comm::{channel, Sender, Receiver}; @@ -55,13 +57,35 @@ pub enum Msg { InitLoadUrlMsg(Url), LoadCompleteMsg(PipelineId, Url), FrameRectMsg(PipelineId, SubpageId, Rect<f32>), - LoadUrlMsg(PipelineId, Url), + LoadUrlMsg(PipelineId, LoadData), LoadIframeUrlMsg(Url, PipelineId, SubpageId, IFrameSandboxState), NavigateMsg(NavigationDirection), RendererReadyMsg(PipelineId), ResizedWindowMsg(WindowSizeData), } +/// Similar to net::resource_task::LoadData +/// can be passed to LoadUrlMsg to load a page with GET/POST +/// parameters or headers +#[deriving(Clone)] +pub struct LoadData { + pub url: Url, + pub method: Method, + pub headers: RequestHeaderCollection, + pub data: Option<Vec<u8>>, +} + +impl LoadData { + pub fn new(url: Url) -> LoadData { + LoadData { + url: url, + method: Get, + headers: RequestHeaderCollection::new(), + data: None, + } + } +} + /// Represents the two different ways to which a page can be navigated #[deriving(Clone, PartialEq, Hash)] pub enum NavigationType { diff --git a/components/msg/lib.rs b/components/msg/lib.rs index 9fd61ed5a8d..15e06b55060 100644 --- a/components/msg/lib.rs +++ b/components/msg/lib.rs @@ -6,6 +6,7 @@ extern crate azure; extern crate geom; +extern crate http; extern crate layers; extern crate serialize; extern crate "util" as servo_util; diff --git a/components/script/html/hubbub_html_parser.rs b/components/script/html/hubbub_html_parser.rs index 36d39562938..409bfa01a9a 100644 --- a/components/script/html/hubbub_html_parser.rs +++ b/components/script/html/hubbub_html_parser.rs @@ -25,6 +25,7 @@ use encoding::types::{Encoding, DecodeReplace}; use hubbub::hubbub; use hubbub::hubbub::{NullNs, HtmlNs, MathMlNs, SvgNs, XLinkNs, XmlNs, XmlNsNs}; use servo_net::resource_task::{Load, LoadData, Payload, Done, ResourceTask, load_whole_resource}; +use servo_msg::constellation_msg::LoadData as MsgLoadData; use servo_util::str::DOMString; use servo_util::task::spawn_named; use std::ascii::StrAsciiExt; @@ -283,10 +284,12 @@ pub fn build_element_from_tag(tag: DOMString, ns: Namespace, prefix: Option<DOMS return ElementCast::from_temporary(HTMLUnknownElement::new(tag, prefix, document)); } +// The url from msg_load_data is ignored here pub fn parse_html(page: &Page, document: JSRef<Document>, input: HTMLInput, - resource_task: ResourceTask) + resource_task: ResourceTask, + msg_load_data: Option<MsgLoadData>) -> HtmlParserResult { debug!("Hubbub: parsing {:?}", input); @@ -303,7 +306,14 @@ pub fn parse_html(page: &Page, InputUrl(ref url) => { // Wait for the LoadResponse so that the parser knows the final URL. let (input_chan, input_port) = channel(); - resource_task.send(Load(LoadData::new(url.clone()), input_chan)); + let mut load_data = LoadData::new(url.clone()); + msg_load_data.map(|m| { + load_data.headers = m.headers; + load_data.method = m.method; + load_data.data = m.data; + }); + resource_task.send(Load(load_data, input_chan)); + let load_response = input_port.recv(); debug!("Fetched page; metadata is {:?}", load_response.metadata); diff --git a/components/script/script_task.rs b/components/script/script_task.rs index f3168e3e325..d5cef0e8b17 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -47,7 +47,7 @@ use script_traits::ReflowCompleteMsg; use servo_msg::compositor_msg::{FinishedLoading, LayerId, Loading}; use servo_msg::compositor_msg::{ScriptListener}; use servo_msg::constellation_msg::{ConstellationChan, LoadCompleteMsg, LoadUrlMsg, NavigationDirection}; -use servo_msg::constellation_msg::{PipelineId, Failure, FailureMsg, WindowSizeData}; +use servo_msg::constellation_msg::{LoadData, PipelineId, Failure, FailureMsg, WindowSizeData}; use servo_msg::constellation_msg; use servo_net::image_cache_task::ImageCacheTask; use servo_net::resource_task::ResourceTask; @@ -484,7 +484,7 @@ impl ScriptTask { match msg { // TODO(tkuehn) need to handle auxiliary layouts for iframes FromConstellation(AttachLayoutMsg(_)) => fail!("should have handled AttachLayoutMsg already"), - FromConstellation(LoadMsg(id, url)) => self.load(id, url), + FromConstellation(LoadMsg(id, load_data)) => self.load(id, load_data), FromScript(TriggerLoadMsg(id, url)) => self.trigger_load(id, url), FromScript(TriggerFragmentMsg(id, url)) => self.trigger_fragment(id, url), FromConstellation(SendEventMsg(id, event)) => self.handle_event(id, event), @@ -698,7 +698,8 @@ impl ScriptTask { /// The entry point to document loading. Defines bindings, sets up the window and document /// objects, parses HTML and CSS, and kicks off initial layout. - fn load(&self, pipeline_id: PipelineId, url: Url) { + fn load(&self, pipeline_id: PipelineId, load_data: LoadData) { + let url = load_data.url.clone(); debug!("ScriptTask: loading {} on page {:?}", url, pipeline_id); let mut page = self.page.borrow_mut(); @@ -750,7 +751,7 @@ impl ScriptTask { let parser_input = if !is_javascript { InputUrl(url.clone()) } else { - let evalstr = url.non_relative_scheme_data().unwrap(); + let evalstr = load_data.url.non_relative_scheme_data().unwrap(); let jsval = window.evaluate_js_with_result(evalstr); let strval = FromJSValConvertible::from_jsval(self.get_cx(), jsval, Empty); InputString(strval.unwrap_or("".to_string())) @@ -763,7 +764,8 @@ impl ScriptTask { hubbub_html_parser::parse_html(&*page, *document, parser_input, - self.resource_task.clone()); + self.resource_task.clone(), + Some(load_data)); let HtmlParserResult { discovery_port @@ -1038,7 +1040,7 @@ impl ScriptTask { /// for the given pipeline. fn trigger_load(&self, pipeline_id: PipelineId, url: Url) { let ConstellationChan(ref const_chan) = self.constellation_chan; - const_chan.send(LoadUrlMsg(pipeline_id, url)); + const_chan.send(LoadUrlMsg(pipeline_id, LoadData::new(url))); } /// The entry point for content to notify that a fragment url has been requested diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index d5efa73af0f..2960fb7ea74 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -21,12 +21,11 @@ extern crate serialize; use devtools_traits::DevtoolsControlChan; use servo_msg::constellation_msg::{ConstellationChan, PipelineId, Failure, WindowSizeData}; -use servo_msg::constellation_msg::SubpageId; +use servo_msg::constellation_msg::{LoadData, SubpageId}; use servo_msg::compositor_msg::ScriptListener; use servo_net::image_cache_task::ImageCacheTask; use servo_net::resource_task::ResourceTask; use std::any::Any; -use url::Url; use geom::point::Point2D; @@ -42,7 +41,7 @@ pub struct NewLayoutInfo { /// Messages sent from the constellation to the script task pub enum ConstellationControlMsg { /// Loads a new URL on the specified pipeline. - LoadMsg(PipelineId, Url), + LoadMsg(PipelineId, LoadData), /// Gives a channel and ID to a layout task, as well as the ID of that layout's parent AttachLayoutMsg(NewLayoutInfo), /// Window resized. Sends a DOM event eventually, but first we combine events. |