Auto merge of #14246 - emilio:servo-url, r=SimonSapin

Urlmageddon

<!-- Please describe your changes on the following line: -->

Still needs a bunch of code in net to be converted in order to get more
advantage of this for images and stuff, but meanwhile this should help quite a
bit with #13778.

Still wanted to get this in.

r? @SimonSapin

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14246)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-11-17 15:34:47 -06:00 committed by GitHub
commit 22aebdf5d4
161 changed files with 1044 additions and 718 deletions

View file

@ -69,6 +69,7 @@ script_traits = {path = "../script_traits"}
selectors = "0.14"
serde = "0.8"
servo_atoms = {path = "../atoms"}
servo_url = {path = "../url", features = ["servo"] }
smallvec = "0.1"
style = {path = "../style"}
style_traits = {path = "../style_traits"}

View file

@ -10,21 +10,21 @@ use dom::document::Document;
use ipc_channel::ipc::IpcSender;
use net_traits::{CoreResourceMsg, FetchResponseMsg, ResourceThreads, IpcSend};
use net_traits::request::RequestInit;
use servo_url::ServoUrl;
use std::thread;
use url::Url;
#[derive(JSTraceable, PartialEq, Clone, Debug, HeapSizeOf)]
pub enum LoadType {
Image(Url),
Script(Url),
Subframe(Url),
Stylesheet(Url),
PageSource(Url),
Media(Url),
Image(ServoUrl),
Script(ServoUrl),
Subframe(ServoUrl),
Stylesheet(ServoUrl),
PageSource(ServoUrl),
Media(ServoUrl),
}
impl LoadType {
fn url(&self) -> &Url {
fn url(&self) -> &ServoUrl {
match *self {
LoadType::Image(ref url) |
LoadType::Script(ref url) |
@ -67,7 +67,7 @@ impl LoadBlocker {
}
/// Return the url associated with this load.
pub fn url(&self) -> Option<&Url> {
pub fn url(&self) -> Option<&ServoUrl> {
self.load.as_ref().map(LoadType::url)
}
}
@ -93,7 +93,7 @@ impl DocumentLoader {
}
pub fn new_with_threads(resource_threads: ResourceThreads,
initial_load: Option<Url>) -> DocumentLoader {
initial_load: Option<ServoUrl>) -> DocumentLoader {
debug!("Initial blocking load {:?}.", initial_load);
let initial_loads = initial_load.into_iter().map(LoadType::PageSource).collect();

View file

@ -80,6 +80,7 @@ use script_traits::{TimerEventId, TimerSource, TouchpadPressurePhase};
use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType};
use serde::{Deserialize, Serialize};
use servo_atoms::Atom;
use servo_url::ServoUrl;
use smallvec::SmallVec;
use std::boxed::FnBox;
use std::cell::{Cell, UnsafeCell};
@ -100,7 +101,6 @@ use style::selector_impl::{PseudoElement, Snapshot};
use style::values::specified::Length;
use time::Duration;
use url::Origin as UrlOrigin;
use url::Url;
use uuid::Uuid;
use webrender_traits::{WebGLBufferId, WebGLError, WebGLFramebufferId, WebGLProgramId};
use webrender_traits::{WebGLRenderbufferId, WebGLShaderId, WebGLTextureId};
@ -302,7 +302,7 @@ impl<A: JSTraceable, B: JSTraceable, C: JSTraceable> JSTraceable for (A, B, C) {
}
}
no_jsmanaged_fields!(bool, f32, f64, String, Url, AtomicBool, AtomicUsize, UrlOrigin, Uuid, char);
no_jsmanaged_fields!(bool, f32, f64, String, ServoUrl, AtomicBool, AtomicUsize, UrlOrigin, Uuid, char);
no_jsmanaged_fields!(usize, u8, u16, u32, u64);
no_jsmanaged_fields!(isize, i8, i16, i32, i64);
no_jsmanaged_fields!(Sender<T>);

View file

@ -42,11 +42,11 @@ use net_traits::image::base::PixelFormat;
use net_traits::image_cache_thread::ImageResponse;
use num_traits::ToPrimitive;
use script_traits::ScriptMsg as ConstellationMsg;
use servo_url::ServoUrl;
use std::{cmp, fmt};
use std::cell::Cell;
use std::str::FromStr;
use unpremultiplytable::UNPREMULTIPLY_TABLE;
use url::Url;
#[must_root]
#[derive(JSTraceable, Clone, HeapSizeOf)]
@ -451,7 +451,7 @@ impl CanvasRenderingContext2D {
}
#[inline]
fn request_image_from_cache(&self, url: Url) -> ImageResponse {
fn request_image_from_cache(&self, url: ServoUrl) -> ImageResponse {
let window = window_from_node(&*self.canvas);
canvas_utils::request_image_from_cache(&window, url)
}

View file

@ -10,7 +10,7 @@ use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::str::{DOMString, USVString};
use dom::serviceworker::ServiceWorker;
use dom::window::Window;
use url::Url;
use servo_url::ServoUrl;
use uuid::Uuid;
#[dom_struct]
@ -24,7 +24,7 @@ pub struct Client {
}
impl Client {
fn new_inherited(url: Url) -> Client {
fn new_inherited(url: ServoUrl) -> Client {
Client {
reflector_: Reflector::new(),
active_worker: None,

View file

@ -33,12 +33,12 @@ use rand::random;
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, StackRootTLS, get_reports, new_rt_and_cx};
use script_runtime::ScriptThreadEventCategory::WorkerEvent;
use script_traits::{TimerEvent, TimerSource, WorkerGlobalScopeInit, WorkerScriptLoadOrigin};
use servo_url::ServoUrl;
use std::mem::replace;
use std::sync::{Arc, Mutex};
use std::sync::atomic::AtomicBool;
use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
use style::thread_state;
use url::Url;
use util::thread::spawn_named;
/// Set the `worker` field of a related DedicatedWorkerGlobalScope object to a particular
@ -92,7 +92,7 @@ pub struct DedicatedWorkerGlobalScope {
impl DedicatedWorkerGlobalScope {
fn new_inherited(init: WorkerGlobalScopeInit,
worker_url: Url,
worker_url: ServoUrl,
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
runtime: Runtime,
parent_sender: Box<ScriptChan + Send>,
@ -119,7 +119,7 @@ impl DedicatedWorkerGlobalScope {
#[allow(unsafe_code)]
pub fn new(init: WorkerGlobalScopeInit,
worker_url: Url,
worker_url: ServoUrl,
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
runtime: Runtime,
parent_sender: Box<ScriptChan + Send>,
@ -147,7 +147,7 @@ impl DedicatedWorkerGlobalScope {
#[allow(unsafe_code)]
pub fn run_worker_scope(init: WorkerGlobalScopeInit,
worker_url: Url,
worker_url: ServoUrl,
from_devtools_receiver: IpcReceiver<DevtoolScriptControlMsg>,
worker_rt_for_mainthread: Arc<Mutex<Option<SharedRt>>>,
worker: TrustedWorkerAddress,

View file

@ -108,6 +108,7 @@ use script_traits::{ScriptMsg as ConstellationMsg, TouchpadPressurePhase};
use script_traits::{TouchEventType, TouchId};
use script_traits::UntrustedNodeAddress;
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::boxed::FnBox;
@ -127,7 +128,6 @@ use style::selector_impl::{RestyleDamage, Snapshot};
use style::str::{split_html_space_chars, str_join};
use style::stylesheets::Stylesheet;
use time;
use url::Url;
use url::percent_encoding::percent_decode;
use util::prefs::PREFS;
@ -192,7 +192,7 @@ pub struct Document {
last_modified: Option<String>,
encoding: Cell<EncodingRef>,
is_html_document: bool,
url: Url,
url: ServoUrl,
quirks_mode: Cell<QuirksMode>,
/// Caches for the getElement methods
id_map: DOMRefCell<HashMap<Atom, Vec<JS<Element>>>>,
@ -398,12 +398,12 @@ impl Document {
}
// https://dom.spec.whatwg.org/#concept-document-url
pub fn url(&self) -> &Url {
pub fn url(&self) -> &ServoUrl {
&self.url
}
// https://html.spec.whatwg.org/multipage/#fallback-base-url
pub fn fallback_base_url(&self) -> Url {
pub fn fallback_base_url(&self) -> ServoUrl {
// Step 1: iframe srcdoc (#4767).
// Step 2: about:blank with a creator browsing context.
// Step 3.
@ -411,7 +411,7 @@ impl Document {
}
// https://html.spec.whatwg.org/multipage/#document-base-url
pub fn base_url(&self) -> Url {
pub fn base_url(&self) -> ServoUrl {
match self.base_element() {
// Step 1.
None => self.fallback_base_url(),
@ -1762,7 +1762,7 @@ impl LayoutDocumentHelpers for LayoutJS<Document> {
}
/// https://url.spec.whatwg.org/#network-scheme
fn url_has_network_scheme(url: &Url) -> bool {
fn url_has_network_scheme(url: &ServoUrl) -> bool {
match url.scheme() {
"ftp" | "http" | "https" => true,
_ => false,
@ -1772,7 +1772,7 @@ fn url_has_network_scheme(url: &Url) -> bool {
impl Document {
pub fn new_inherited(window: &Window,
browsing_context: Option<&BrowsingContext>,
url: Option<Url>,
url: Option<ServoUrl>,
is_html_document: IsHTMLDocument,
content_type: Option<DOMString>,
last_modified: Option<String>,
@ -1781,7 +1781,7 @@ impl Document {
referrer: Option<String>,
referrer_policy: Option<ReferrerPolicy>)
-> Document {
let url = url.unwrap_or_else(|| Url::parse("about:blank").unwrap());
let url = url.unwrap_or_else(|| ServoUrl::parse("about:blank").unwrap());
let (ready_state, domcontentloaded_dispatched) = if source == DocumentSource::FromParser {
(DocumentReadyState::Loading, false)
@ -1892,7 +1892,7 @@ impl Document {
pub fn new(window: &Window,
browsing_context: Option<&BrowsingContext>,
url: Option<Url>,
url: Option<ServoUrl>,
doctype: IsHTMLDocument,
content_type: Option<DOMString>,
last_modified: Option<String>,

View file

@ -383,7 +383,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
PropertyDeclaration::BackgroundImage(DeclaredValue::Value(
background_image::SpecifiedValue(vec![
background_image::single_value::SpecifiedValue(Some(
specified::Image::for_cascade(Some(Arc::new(url)), specified::url::UrlExtraData { })
specified::Image::for_cascade(Some(url.into()), specified::url::UrlExtraData { })
))
])))));
}

View file

@ -31,13 +31,13 @@ use net_traits::request::{RequestInit, RequestMode};
use network_listener::{NetworkListener, PreInvoke};
use script_thread::Runnable;
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::cell::Cell;
use std::mem;
use std::str::{Chars, FromStr};
use std::sync::{Arc, Mutex};
use task_source::TaskSource;
use timers::OneshotTimerCallback;
use url::Url;
header! { (LastEventId, "Last-Event-ID") => [String] }
@ -57,7 +57,7 @@ enum ReadyState {
#[dom_struct]
pub struct EventSource {
eventtarget: EventTarget,
url: Url,
url: ServoUrl,
request: DOMRefCell<Option<RequestInit>>,
last_event_id: DOMRefCell<DOMString>,
reconnection_time: Cell<u64>,
@ -309,7 +309,7 @@ impl PreInvoke for EventSourceContext {
}
impl EventSource {
fn new_inherited(url: Url, with_credentials: bool) -> EventSource {
fn new_inherited(url: ServoUrl, with_credentials: bool) -> EventSource {
EventSource {
eventtarget: EventTarget::new_inherited(),
url: url,
@ -323,7 +323,7 @@ impl EventSource {
}
}
fn new(global: &GlobalScope, url: Url, with_credentials: bool) -> Root<EventSource> {
fn new(global: &GlobalScope, url: ServoUrl, with_credentials: bool) -> Root<EventSource> {
reflect_dom_object(box EventSource::new_inherited(url, with_credentials),
global,
Wrap)

View file

@ -33,6 +33,7 @@ use js::jsapi::{CompileFunction, JS_GetFunctionObject, JSAutoCompartment};
use js::rust::{AutoObjectVectorWrapper, CompileOptionsWrapper};
use libc::{c_char, size_t};
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::default::Default;
@ -42,7 +43,6 @@ use std::mem;
use std::ops::{Deref, DerefMut};
use std::ptr;
use std::rc::Rc;
use url::Url;
#[derive(PartialEq, Clone, JSTraceable)]
pub enum CommonEventHandler {
@ -71,7 +71,7 @@ pub enum ListenerPhase {
#[derive(JSTraceable, Clone, PartialEq)]
pub struct InternalRawUncompiledHandler {
source: DOMString,
url: Url,
url: ServoUrl,
line: usize,
}
@ -348,7 +348,7 @@ impl EventTarget {
/// Store the raw uncompiled event handler for on-demand compilation later.
/// https://html.spec.whatwg.org/multipage/#event-handler-attributes:event-handler-content-attributes-3
pub fn set_event_handler_uncompiled(&self,
url: Url,
url: ServoUrl,
line: usize,
ty: &str,
source: DOMString) {

View file

@ -36,6 +36,7 @@ use script_runtime::{ScriptPort, maybe_take_panic_result};
use script_thread::{MainThreadScriptChan, RunnableWrapper, ScriptThread};
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEvent};
use script_traits::{TimerEventId, TimerEventRequest, TimerSource};
use servo_url::ServoUrl;
use std::cell::Cell;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
@ -46,7 +47,6 @@ use task_source::networking::NetworkingTaskSource;
use time::{Timespec, get_time};
use timers::{IsInterval, OneshotTimerCallback, OneshotTimerHandle};
use timers::{OneshotTimers, TimerCallback};
use url::Url;
#[dom_struct]
pub struct GlobalScope {
@ -239,7 +239,7 @@ impl GlobalScope {
/// Get the [base url](https://html.spec.whatwg.org/multipage/#api-base-url)
/// for this global scope.
pub fn api_base_url(&self) -> Url {
pub fn api_base_url(&self) -> ServoUrl {
if let Some(window) = self.downcast::<Window>() {
// https://html.spec.whatwg.org/multipage/#script-settings-for-browsing-contexts:api-base-url
return window.Document().base_url();
@ -252,7 +252,7 @@ impl GlobalScope {
}
/// Get the URL for this global scope.
pub fn get_url(&self) -> Url {
pub fn get_url(&self) -> ServoUrl {
if let Some(window) = self.downcast::<Window>() {
return window.get_url();
}

View file

@ -28,16 +28,16 @@ use html5ever_atoms::LocalName;
use net_traits::ReferrerPolicy;
use num_traits::ToPrimitive;
use script_traits::MozBrowserEvent;
use servo_url::ServoUrl;
use std::default::Default;
use style::attr::AttrValue;
use url::Url;
use util::prefs::PREFS;
#[dom_struct]
pub struct HTMLAnchorElement {
htmlelement: HTMLElement,
rel_list: MutNullableHeap<JS<DOMTokenList>>,
url: DOMRefCell<Option<Url>>,
url: DOMRefCell<Option<ServoUrl>>,
}
impl HTMLAnchorElement {

View file

@ -14,8 +14,8 @@ use dom::htmlelement::HTMLElement;
use dom::node::{Node, UnbindContext, document_from_node};
use dom::virtualmethods::VirtualMethods;
use html5ever_atoms::LocalName;
use servo_url::ServoUrl;
use style::attr::AttrValue;
use url::Url;
#[dom_struct]
pub struct HTMLBaseElement {
@ -39,7 +39,7 @@ impl HTMLBaseElement {
}
/// https://html.spec.whatwg.org/multipage/#frozen-base-url
pub fn frozen_base_url(&self) -> Url {
pub fn frozen_base_url(&self) -> ServoUrl {
let href = self.upcast::<Element>().get_attribute(&ns!(), &local_name!("href"))
.expect("The frozen base url is only defined for base elements \
that have a base url.");

View file

@ -19,9 +19,9 @@ use dom::node::{Node, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use html5ever_atoms::LocalName;
use script_traits::ScriptMsg as ConstellationMsg;
use servo_url::ServoUrl;
use style::attr::AttrValue;
use time;
use url::Url;
/// How long we should wait before performing the initial reflow after `<body>` is parsed, in
/// nanoseconds.
@ -85,7 +85,7 @@ impl HTMLBodyElementMethods for HTMLBodyElement {
pub trait HTMLBodyElementLayoutHelpers {
fn get_background_color(&self) -> Option<RGBA>;
fn get_color(&self) -> Option<RGBA>;
fn get_background(&self) -> Option<Url>;
fn get_background(&self) -> Option<ServoUrl>;
}
impl HTMLBodyElementLayoutHelpers for LayoutJS<HTMLBodyElement> {
@ -110,7 +110,7 @@ impl HTMLBodyElementLayoutHelpers for LayoutJS<HTMLBodyElement> {
}
#[allow(unsafe_code)]
fn get_background(&self) -> Option<Url> {
fn get_background(&self) -> Option<ServoUrl> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
.get_attr_for_layout(&ns!(), &local_name!("background"))

View file

@ -341,12 +341,12 @@ pub mod utils {
use dom::window::Window;
use ipc_channel::ipc;
use net_traits::image_cache_thread::{ImageCacheChan, ImageResponse};
use url::Url;
use servo_url::ServoUrl;
pub fn request_image_from_cache(window: &Window, url: Url) -> ImageResponse {
pub fn request_image_from_cache(window: &Window, url: ServoUrl) -> ImageResponse {
let image_cache = window.image_cache_thread();
let (response_chan, response_port) = ipc::channel().unwrap();
image_cache.request_image(url, ImageCacheChan(response_chan), None);
image_cache.request_image(url.into(), ImageCacheChan(response_chan), None);
let result = response_port.recv().unwrap();
result.image_response
}

View file

@ -380,10 +380,12 @@ impl HTMLFormElement {
fn mutate_action_url(&self, form_data: &mut Vec<FormDatum>, mut load_data: LoadData, encoding: EncodingRef) {
let charset = &*encoding.whatwg_name().unwrap();
load_data.url.query_pairs_mut().clear()
.encoding_override(Some(self.pick_encoding()))
.extend_pairs(form_data.into_iter()
.map(|field| (field.name.clone(), field.replace_value(charset))));
if let Some(ref mut url) = load_data.url.as_mut_url() {
url.query_pairs_mut().clear()
.encoding_override(Some(self.pick_encoding()))
.extend_pairs(form_data.into_iter()
.map(|field| (field.name.clone(), field.replace_value(charset))));
}
self.plan_to_navigate(load_data);
}
@ -394,16 +396,18 @@ impl HTMLFormElement {
let boundary = generate_boundary();
let bytes = match enctype {
FormEncType::UrlEncoded => {
let mut url = load_data.url.clone();
let charset = &*encoding.whatwg_name().unwrap();
load_data.headers.set(ContentType::form_url_encoded());
url.query_pairs_mut().clear()
.encoding_override(Some(self.pick_encoding()))
.extend_pairs(form_data.into_iter()
.map(|field| (field.name.clone(), field.replace_value(charset))));
url.query().unwrap_or("").to_string().into_bytes()
if let Some(ref mut url) = load_data.url.as_mut_url() {
url.query_pairs_mut().clear()
.encoding_override(Some(self.pick_encoding()))
.extend_pairs(form_data.into_iter()
.map(|field| (field.name.clone(), field.replace_value(charset))));
}
load_data.url.query().unwrap_or("").to_string().into_bytes()
}
FormEncType::FormDataEncoded => {
let mime = mime!(Multipart / FormData; Boundary =(&boundary));

View file

@ -46,10 +46,10 @@ use script_thread::ScriptThread;
use script_traits::{IFrameLoadInfo, LoadData, MozBrowserEvent, ScriptMsg as ConstellationMsg};
use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::cell::Cell;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use style::context::ReflowGoal;
use url::Url;
use util::prefs::PREFS;
use util::servo_version;
@ -84,7 +84,7 @@ impl HTMLIFrameElement {
/// <https://html.spec.whatwg.org/multipage/#otherwise-steps-for-iframe-or-frame-elements>,
/// step 1.
fn get_url(&self) -> Url {
fn get_url(&self) -> ServoUrl {
let element = self.upcast::<Element>();
element.get_attribute(&ns!(), &local_name!("src")).and_then(|src| {
let url = src.value();
@ -93,7 +93,7 @@ impl HTMLIFrameElement {
} else {
document_from_node(self).base_url().join(&url).ok()
}
}).unwrap_or_else(|| Url::parse("about:blank").unwrap())
}).unwrap_or_else(|| ServoUrl::parse("about:blank").unwrap())
}
pub fn generate_new_pipeline_id(&self) -> (Option<PipelineId>, PipelineId) {

View file

@ -27,11 +27,11 @@ use ipc_channel::router::ROUTER;
use net_traits::image::base::{Image, ImageMetadata};
use net_traits::image_cache_thread::{ImageResponder, ImageResponse};
use script_thread::Runnable;
use servo_url::ServoUrl;
use std::i32;
use std::sync::Arc;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use task_source::TaskSource;
use url::Url;
#[derive(JSTraceable, HeapSizeOf)]
#[allow(dead_code)]
@ -44,7 +44,7 @@ enum State {
#[derive(JSTraceable, HeapSizeOf)]
struct ImageRequest {
state: State,
parsed_url: Option<Url>,
parsed_url: Option<ServoUrl>,
source_url: Option<DOMString>,
#[ignore_heap_size_of = "Arc"]
image: Option<Arc<Image>>,
@ -58,7 +58,7 @@ pub struct HTMLImageElement {
}
impl HTMLImageElement {
pub fn get_url(&self) -> Option<Url> {
pub fn get_url(&self) -> Option<ServoUrl> {
self.current_request.borrow().parsed_url.clone()
}
}
@ -120,7 +120,7 @@ impl Runnable for ImageResponseHandlerRunnable {
impl HTMLImageElement {
/// Makes the local `image` member match the status of the `src` attribute and starts
/// prefetching the image. This method must be called after `src` is changed.
fn update_image(&self, value: Option<(DOMString, Url)>) {
fn update_image(&self, value: Option<(DOMString, ServoUrl)>) {
let document = document_from_node(self);
let window = document.window();
let image_cache = window.image_cache_thread();
@ -149,7 +149,7 @@ impl HTMLImageElement {
let _ = task_source.queue_with_wrapper(runnable, &wrapper);
});
image_cache.request_image_and_metadata(img_url,
image_cache.request_image_and_metadata(img_url.into(),
window.image_cache_chan(),
Some(ImageResponder::new(responder_sender)));
} else {
@ -241,7 +241,7 @@ pub trait LayoutHTMLImageElementHelpers {
unsafe fn image(&self) -> Option<Arc<Image>>;
#[allow(unsafe_code)]
unsafe fn image_url(&self) -> Option<Url>;
unsafe fn image_url(&self) -> Option<ServoUrl>;
fn get_width(&self) -> LengthOrPercentageOrAuto;
fn get_height(&self) -> LengthOrPercentageOrAuto;
@ -254,7 +254,7 @@ impl LayoutHTMLImageElementHelpers for LayoutJS<HTMLImageElement> {
}
#[allow(unsafe_code)]
unsafe fn image_url(&self) -> Option<Url> {
unsafe fn image_url(&self) -> Option<ServoUrl> {
(*self.unsafe_get()).current_request.borrow_for_layout().parsed_url.clone()
}

View file

@ -36,6 +36,7 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as Req
use network_listener::{NetworkListener, PreInvoke};
use script_layout_interface::message::Msg;
use script_traits::{MozBrowserEvent, ScriptMsg as ConstellationMsg};
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::cell::Cell;
@ -47,7 +48,6 @@ use style::media_queries::{MediaList, parse_media_query_list};
use style::parser::ParserContextExtraData;
use style::str::HTML_SPACE_CHARACTERS;
use style::stylesheets::{Stylesheet, Origin};
use url::Url;
no_jsmanaged_fields!(Stylesheet);
@ -318,7 +318,7 @@ struct StylesheetContext {
/// The response metadata received to date.
metadata: Option<Metadata>,
/// The initial URL requested.
url: Url,
url: ServoUrl,
}
impl PreInvoke for StylesheetContext {}

View file

@ -35,11 +35,11 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as Req
use network_listener::{NetworkListener, PreInvoke};
use script_thread::{Runnable, ScriptThread};
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::cell::Cell;
use std::sync::{Arc, Mutex};
use task_source::TaskSource;
use time::{self, Timespec, Duration};
use url::Url;
struct HTMLMediaElementContext {
/// The element that initiated the request.
@ -53,7 +53,7 @@ struct HTMLMediaElementContext {
/// Time of last progress notification.
next_progress_event: Timespec,
/// Url of resource requested.
url: Url,
url: ServoUrl,
/// Whether the media metadata has been completely received.
have_metadata: bool,
/// True if this response is invalid and should be ignored.
@ -164,7 +164,7 @@ impl PreInvoke for HTMLMediaElementContext {
}
impl HTMLMediaElementContext {
fn new(elem: &HTMLMediaElement, url: Url) -> HTMLMediaElementContext {
fn new(elem: &HTMLMediaElement, url: ServoUrl) -> HTMLMediaElementContext {
HTMLMediaElementContext {
elem: Trusted::new(elem),
data: vec![],
@ -437,7 +437,7 @@ impl HTMLMediaElement {
}
// https://html.spec.whatwg.org/multipage/#concept-media-load-algorithm
fn resource_selection_algorithm_sync(&self, base_url: Url) {
fn resource_selection_algorithm_sync(&self, base_url: ServoUrl) {
// TODO step 5 (populate pending text tracks)
// Step 6
@ -814,11 +814,11 @@ impl Runnable for FireSimpleEventTask {
struct ResourceSelectionTask {
elem: Trusted<HTMLMediaElement>,
base_url: Url,
base_url: ServoUrl,
}
impl ResourceSelectionTask {
fn new(elem: &HTMLMediaElement, url: Url) -> ResourceSelectionTask {
fn new(elem: &HTMLMediaElement, url: ServoUrl) -> ResourceSelectionTask {
ResourceSelectionTask {
elem: Trusted::new(elem),
base_url: url,
@ -885,5 +885,5 @@ enum ResourceSelectionMode {
enum Resource {
Object,
Url(Url),
Url(ServoUrl),
}

View file

@ -35,11 +35,11 @@ use net_traits::{FetchMetadata, FetchResponseListener, Metadata, NetworkError};
use net_traits::request::{CorsSettings, CredentialsMode, Destination, RequestInit, RequestMode, Type as RequestType};
use network_listener::{NetworkListener, PreInvoke};
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::cell::Cell;
use std::sync::{Arc, Mutex};
use style::str::{HTML_SPACE_CHARACTERS, StaticStringVec};
use url::Url;
#[dom_struct]
pub struct HTMLScriptElement {
@ -115,12 +115,12 @@ static SCRIPT_JS_MIMES: StaticStringVec = &[
#[derive(HeapSizeOf, JSTraceable)]
pub struct ScriptOrigin {
text: DOMString,
url: Url,
url: ServoUrl,
external: bool,
}
impl ScriptOrigin {
fn internal(text: DOMString, url: Url) -> ScriptOrigin {
fn internal(text: DOMString, url: ServoUrl) -> ScriptOrigin {
ScriptOrigin {
text: text,
url: url,
@ -128,7 +128,7 @@ impl ScriptOrigin {
}
}
fn external(text: DOMString, url: Url) -> ScriptOrigin {
fn external(text: DOMString, url: ServoUrl) -> ScriptOrigin {
ScriptOrigin {
text: text,
url: url,
@ -149,7 +149,7 @@ struct ScriptContext {
/// The response metadata received to date.
metadata: Option<Metadata>,
/// The initial URL requested.
url: Url,
url: ServoUrl,
/// Indicates whether the request failed, and why
status: Result<(), NetworkError>
}
@ -219,7 +219,7 @@ impl PreInvoke for ScriptContext {}
/// https://html.spec.whatwg.org/multipage/#fetch-a-classic-script
fn fetch_a_classic_script(script: &HTMLScriptElement,
url: Url,
url: ServoUrl,
cors_setting: Option<CorsSettings>,
character_encoding: EncodingRef) {
let doc = document_from_node(script);

View file

@ -10,7 +10,7 @@ use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::str::{DOMString, USVString};
use dom::urlhelper::UrlHelper;
use dom::window::Window;
use url::Url;
use servo_url::ServoUrl;
#[dom_struct]
pub struct Location {
@ -32,12 +32,12 @@ impl Location {
LocationBinding::Wrap)
}
fn get_url(&self) -> Url {
fn get_url(&self) -> ServoUrl {
self.window.get_url()
}
fn set_url_component(&self, value: USVString,
setter: fn(&mut Url, USVString)) {
setter: fn(&mut ServoUrl, USVString)) {
let mut url = self.window.get_url();
setter(&mut url, value);
self.window.load_url(url, false, None);

View file

@ -73,6 +73,7 @@ use script_traits::UntrustedNodeAddress;
use selectors::matching::{MatchingReason, matches};
use selectors::parser::Selector;
use selectors::parser::parse_author_origin_selector_list_from_str;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::cell::{Cell, UnsafeCell};
use std::cmp::max;
@ -85,7 +86,6 @@ use style::dom::OpaqueNode;
use style::selector_impl::ServoSelectorImpl;
use style::stylesheets::Stylesheet;
use style::thread_state;
use url::Url;
use uuid::Uuid;
//
@ -968,7 +968,7 @@ pub trait LayoutNodeHelpers {
fn text_content(&self) -> String;
fn selection(&self) -> Option<Range<usize>>;
fn image_url(&self) -> Option<Url>;
fn image_url(&self) -> Option<ServoUrl>;
fn canvas_data(&self) -> Option<HTMLCanvasData>;
fn svg_data(&self) -> Option<SVGSVGData>;
fn iframe_pipeline_id(&self) -> PipelineId;
@ -1103,7 +1103,7 @@ impl LayoutNodeHelpers for LayoutJS<Node> {
}
#[allow(unsafe_code)]
fn image_url(&self) -> Option<Url> {
fn image_url(&self) -> Option<ServoUrl> {
unsafe {
self.downcast::<HTMLImageElement>()
.expect("not an image!")

View file

@ -35,10 +35,10 @@ use net_traits::request::Referrer as NetTraitsRequestReferrer;
use net_traits::request::Request as NetTraitsRequest;
use net_traits::request::RequestMode as NetTraitsRequestMode;
use net_traits::request::Type as NetTraitsRequestType;
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::cell::{Cell, Ref};
use std::rc::Rc;
use url::Url;
#[dom_struct]
pub struct Request {
@ -53,7 +53,7 @@ pub struct Request {
impl Request {
fn new_inherited(global: &GlobalScope,
url: Url,
url: ServoUrl,
is_service_worker_global_scope: bool) -> Request {
Request {
reflector_: Reflector::new(),
@ -69,7 +69,7 @@ impl Request {
}
pub fn new(global: &GlobalScope,
url: Url,
url: ServoUrl,
is_service_worker_global_scope: bool) -> Root<Request> {
reflect_dom_object(box Request::new_inherited(global,
url,
@ -468,7 +468,7 @@ impl Request {
}
fn net_request_from_global(global: &GlobalScope,
url: Url,
url: ServoUrl,
is_service_worker_global_scope: bool) -> NetTraitsRequest {
let origin = Origin::Origin(global.get_url().origin());
let pipeline_id = global.pipeline_id();
@ -524,7 +524,7 @@ fn is_cors_safelisted_method(m: &HttpMethod) -> bool {
}
// https://url.spec.whatwg.org/#include-credentials
fn includes_credentials(input: &Url) -> bool {
fn includes_credentials(input: &ServoUrl) -> bool {
!input.username().is_empty() || input.password().is_some()
}

View file

@ -22,12 +22,12 @@ use hyper::header::Headers as HyperHeaders;
use hyper::status::StatusCode;
use hyper_serde::Serde;
use net_traits::response::{ResponseBody as NetTraitsResponseBody};
use servo_url::ServoUrl;
use std::cell::Ref;
use std::mem;
use std::rc::Rc;
use std::str::FromStr;
use url::Position;
use url::Url;
#[dom_struct]
pub struct Response {
@ -40,8 +40,8 @@ pub struct Response {
status: DOMRefCell<Option<StatusCode>>,
raw_status: DOMRefCell<Option<(u16, Vec<u8>)>>,
response_type: DOMRefCell<DOMResponseType>,
url: DOMRefCell<Option<Url>>,
url_list: DOMRefCell<Vec<Url>>,
url: DOMRefCell<Option<ServoUrl>>,
url_list: DOMRefCell<Vec<ServoUrl>>,
// For now use the existing NetTraitsResponseBody enum
body: DOMRefCell<NetTraitsResponseBody>,
#[ignore_heap_size_of = "Rc"]
@ -156,7 +156,7 @@ impl Response {
// Step 2
let url = match parsed_url {
Ok(url) => url,
Err(_) => return Err(Error::Type("Url could not be parsed".to_string())),
Err(_) => return Err(Error::Type("ServoUrl could not be parsed".to_string())),
};
// Step 3
@ -357,8 +357,8 @@ impl ResponseMethods for Response {
}
}
fn serialize_without_fragment(url: &Url) -> &str {
&url[..Position::AfterQuery]
fn serialize_without_fragment(url: &ServoUrl) -> &str {
&url.as_url().unwrap()[..Position::AfterQuery]
}
impl Response {
@ -377,7 +377,7 @@ impl Response {
*self.raw_status.borrow_mut() = status;
}
pub fn set_final_url(&self, final_url: Url) {
pub fn set_final_url(&self, final_url: ServoUrl) {
*self.url.borrow_mut() = Some(final_url);
}

View file

@ -18,8 +18,8 @@ use dom::globalscope::GlobalScope;
use js::jsapi::{HandleValue, JSContext};
use script_thread::Runnable;
use script_traits::{ScriptMsg, DOMMessage};
use servo_url::ServoUrl;
use std::cell::Cell;
use url::Url;
pub type TrustedServiceWorkerAddress = Trusted<ServiceWorker>;
@ -27,7 +27,7 @@ pub type TrustedServiceWorkerAddress = Trusted<ServiceWorker>;
pub struct ServiceWorker {
eventtarget: EventTarget,
script_url: DOMRefCell<String>,
scope_url: Url,
scope_url: ServoUrl,
state: Cell<ServiceWorkerState>,
skip_waiting: Cell<bool>
}
@ -35,7 +35,7 @@ pub struct ServiceWorker {
impl ServiceWorker {
fn new_inherited(script_url: &str,
skip_waiting: bool,
scope_url: Url) -> ServiceWorker {
scope_url: ServoUrl) -> ServiceWorker {
ServiceWorker {
eventtarget: EventTarget::new_inherited(),
script_url: DOMRefCell::new(String::from(script_url)),
@ -46,8 +46,8 @@ impl ServiceWorker {
}
pub fn install_serviceworker(global: &GlobalScope,
script_url: Url,
scope_url: Url,
script_url: ServoUrl,
scope_url: ServoUrl,
skip_waiting: bool) -> Root<ServiceWorker> {
reflect_dom_object(box ServiceWorker::new_inherited(script_url.as_str(),
skip_waiting,
@ -64,8 +64,8 @@ impl ServiceWorker {
self.upcast::<EventTarget>().fire_event(atom!("statechange"));
}
pub fn get_script_url(&self) -> Url {
Url::parse(&self.script_url.borrow().clone()).unwrap()
pub fn get_script_url(&self) -> ServoUrl {
ServoUrl::parse(&self.script_url.borrow().clone()).unwrap()
}
}

View file

@ -28,11 +28,11 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as Req
use rand::random;
use script_runtime::{CommonScriptMsg, StackRootTLS, get_reports, new_rt_and_cx, ScriptChan};
use script_traits::{TimerEvent, WorkerGlobalScopeInit, ScopeThings, ServiceWorkerMsg, WorkerScriptLoadOrigin};
use servo_url::ServoUrl;
use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
use std::thread;
use std::time::Duration;
use style::thread_state::{self, IN_WORKER, SCRIPT};
use url::Url;
use util::prefs::PREFS;
use util::thread::spawn_named;
@ -80,12 +80,12 @@ pub struct ServiceWorkerGlobalScope {
timer_event_port: Receiver<()>,
#[ignore_heap_size_of = "Defined in std"]
swmanager_sender: IpcSender<ServiceWorkerMsg>,
scope_url: Url,
scope_url: ServoUrl,
}
impl ServiceWorkerGlobalScope {
fn new_inherited(init: WorkerGlobalScopeInit,
worker_url: Url,
worker_url: ServoUrl,
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
runtime: Runtime,
own_sender: Sender<ServiceWorkerScriptMsg>,
@ -93,7 +93,7 @@ impl ServiceWorkerGlobalScope {
timer_event_chan: IpcSender<TimerEvent>,
timer_event_port: Receiver<()>,
swmanager_sender: IpcSender<ServiceWorkerMsg>,
scope_url: Url)
scope_url: ServoUrl)
-> ServiceWorkerGlobalScope {
ServiceWorkerGlobalScope {
workerglobalscope: WorkerGlobalScope::new_inherited(init,
@ -112,7 +112,7 @@ impl ServiceWorkerGlobalScope {
#[allow(unsafe_code)]
pub fn new(init: WorkerGlobalScopeInit,
worker_url: Url,
worker_url: ServoUrl,
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
runtime: Runtime,
own_sender: Sender<ServiceWorkerScriptMsg>,
@ -120,7 +120,7 @@ impl ServiceWorkerGlobalScope {
timer_event_chan: IpcSender<TimerEvent>,
timer_event_port: Receiver<()>,
swmanager_sender: IpcSender<ServiceWorkerMsg>,
scope_url: Url)
scope_url: ServoUrl)
-> Root<ServiceWorkerGlobalScope> {
let cx = runtime.cx();
let scope = box ServiceWorkerGlobalScope::new_inherited(init,
@ -144,7 +144,7 @@ impl ServiceWorkerGlobalScope {
receiver: Receiver<ServiceWorkerScriptMsg>,
devtools_receiver: IpcReceiver<DevtoolScriptControlMsg>,
swmanager_sender: IpcSender<ServiceWorkerMsg>,
scope_url: Url) {
scope_url: ServoUrl) {
let ScopeThings { script_url,
init,
worker_load_origin,

View file

@ -13,7 +13,7 @@ use dom::serviceworker::ServiceWorker;
use dom::serviceworkercontainer::Controllable;
use dom::workerglobalscope::prepare_workerscope_init;
use script_traits::{WorkerScriptLoadOrigin, ScopeThings};
use url::Url;
use servo_url::ServoUrl;
#[dom_struct]
pub struct ServiceWorkerRegistration {
@ -25,7 +25,7 @@ pub struct ServiceWorkerRegistration {
}
impl ServiceWorkerRegistration {
fn new_inherited(active_sw: &ServiceWorker, scope: Url) -> ServiceWorkerRegistration {
fn new_inherited(active_sw: &ServiceWorker, scope: ServoUrl) -> ServiceWorkerRegistration {
ServiceWorkerRegistration {
eventtarget: EventTarget::new_inherited(),
active: Some(JS::from_ref(active_sw)),
@ -36,8 +36,8 @@ impl ServiceWorkerRegistration {
}
#[allow(unrooted_must_root)]
pub fn new(global: &GlobalScope,
script_url: Url,
scope: Url,
script_url: ServoUrl,
scope: ServoUrl,
container: &Controllable) -> Root<ServiceWorkerRegistration> {
let active_worker = ServiceWorker::install_serviceworker(global, script_url.clone(), scope.clone(), true);
active_worker.set_transition_state(ServiceWorkerState::Installed);
@ -49,7 +49,7 @@ impl ServiceWorkerRegistration {
self.active.as_ref().unwrap()
}
pub fn create_scope_things(global: &GlobalScope, script_url: Url) -> ScopeThings {
pub fn create_scope_things(global: &GlobalScope, script_url: ServoUrl) -> ScopeThings {
let worker_load_origin = WorkerScriptLoadOrigin {
referrer_url: None,
referrer_policy: None,
@ -69,7 +69,7 @@ impl ServiceWorkerRegistration {
}
}
pub fn longest_prefix_match(stored_scope: &Url, potential_match: &Url) -> bool {
pub fn longest_prefix_match(stored_scope: &ServoUrl, potential_match: &ServoUrl) -> bool {
if stored_scope.origin() != potential_match.origin() {
return false;
}

View file

@ -31,10 +31,10 @@ use html5ever::tree_builder::{NodeOrText, QuirksMode};
use html5ever::tree_builder::{Tracer as HtmlTracer, TreeBuilder, TreeBuilderOpts, TreeSink};
use html5ever_atoms::QualName;
use js::jsapi::JSTracer;
use servo_url::ServoUrl;
use std::borrow::Cow;
use std::io::{self, Write};
use super::{FragmentContext, Sink};
use url::Url;
#[derive(HeapSizeOf, JSTraceable)]
#[must_root]
@ -48,7 +48,7 @@ pub struct Tokenizer {
impl Tokenizer {
pub fn new(
document: &Document,
url: Url,
url: ServoUrl,
fragment_context: Option<FragmentContext>)
-> Self {
let sink = Sink {

View file

@ -29,9 +29,9 @@ use network_listener::PreInvoke;
use profile_traits::time::{TimerMetadata, TimerMetadataFrameType};
use profile_traits::time::{TimerMetadataReflowType, ProfilerCategory, profile};
use script_thread::ScriptThread;
use servo_url::ServoUrl;
use std::cell::Cell;
use std::collections::VecDeque;
use url::Url;
use util::resource_files::read_resource_file;
mod html;
@ -65,7 +65,7 @@ impl ServoParser {
pub fn parse_html_document(
document: &Document,
input: DOMString,
url: Url,
url: ServoUrl,
owner: Option<PipelineId>) {
let parser = ServoParser::new(
document,
@ -122,7 +122,7 @@ impl ServoParser {
pub fn parse_xml_document(
document: &Document,
input: DOMString,
url: Url,
url: ServoUrl,
owner: Option<PipelineId>) {
let parser = ServoParser::new(
document,
@ -287,7 +287,7 @@ enum Tokenizer {
#[derive(JSTraceable, HeapSizeOf)]
#[must_root]
struct Sink {
pub base_url: Url,
pub base_url: ServoUrl,
pub document: JS<Document>,
}
@ -338,11 +338,11 @@ pub struct ParserContext {
/// The pipeline associated with this document.
id: PipelineId,
/// The URL for this document.
url: Url,
url: ServoUrl,
}
impl ParserContext {
pub fn new(id: PipelineId, url: Url) -> ParserContext {
pub fn new(id: PipelineId, url: ServoUrl) -> ParserContext {
ParserContext {
parser: None,
is_synthesized_document: false,

View file

@ -19,9 +19,9 @@ use dom::processinginstruction::ProcessingInstruction;
use dom::text::Text;
use html5ever_atoms::{Prefix, QualName};
use js::jsapi::JSTracer;
use servo_url::ServoUrl;
use std::borrow::Cow;
use super::Sink;
use url::Url;
use xml5ever::tendril::StrTendril;
use xml5ever::tokenizer::{Attribute, QName, XmlTokenizer};
use xml5ever::tree_builder::{NextParserState, NodeOrText};
@ -35,7 +35,7 @@ pub struct Tokenizer {
}
impl Tokenizer {
pub fn new(document: &Document, url: Url) -> Self {
pub fn new(document: &Document, url: ServoUrl) -> Self {
let sink = Sink {
base_url: url,
document: JS::from_ref(document),

View file

@ -18,8 +18,8 @@ use net_traits::IpcSend;
use net_traits::storage_thread::{StorageThreadMsg, StorageType};
use script_thread::{Runnable, ScriptThread};
use script_traits::ScriptMsg;
use servo_url::ServoUrl;
use task_source::TaskSource;
use url::Url;
#[dom_struct]
pub struct Storage {
@ -39,7 +39,7 @@ impl Storage {
reflect_dom_object(box Storage::new_inherited(storage_type), global, StorageBinding::Wrap)
}
fn get_url(&self) -> Url {
fn get_url(&self) -> ServoUrl {
self.global().get_url()
}
@ -158,7 +158,7 @@ impl Storage {
}
/// https://html.spec.whatwg.org/multipage/#send-a-storage-notification
pub fn queue_storage_event(&self, url: Url,
pub fn queue_storage_event(&self, url: ServoUrl,
key: Option<String>, old_value: Option<String>, new_value: Option<String>) {
let global = self.global();
let window = global.as_window();
@ -173,14 +173,14 @@ impl Storage {
pub struct StorageEventRunnable {
element: Trusted<Storage>,
url: Url,
url: ServoUrl,
key: Option<String>,
old_value: Option<String>,
new_value: Option<String>
}
impl StorageEventRunnable {
fn new(storage: Trusted<Storage>, url: Url,
fn new(storage: Trusted<Storage>, url: ServoUrl,
key: Option<String>, old_value: Option<String>, new_value: Option<String>) -> StorageEventRunnable {
StorageEventRunnable { element: storage, url: url, key: key, old_value: old_value, new_value: new_value }
}

View file

@ -17,8 +17,8 @@ use ipc_channel::ipc;
use net_traits::{CoreResourceMsg, IpcSend};
use net_traits::blob_url_store::{get_blob_origin, parse_blob_url};
use net_traits::filemanager_thread::FileManagerThreadMsg;
use servo_url::ServoUrl;
use std::default::Default;
use url::Url;
use uuid::Uuid;
// https://url.spec.whatwg.org/#url
@ -27,14 +27,14 @@ pub struct URL {
reflector_: Reflector,
// https://url.spec.whatwg.org/#concept-url-url
url: DOMRefCell<Url>,
url: DOMRefCell<ServoUrl>,
// https://url.spec.whatwg.org/#dom-url-searchparams
search_params: MutNullableHeap<JS<URLSearchParams>>,
}
impl URL {
fn new_inherited(url: Url) -> URL {
fn new_inherited(url: ServoUrl) -> URL {
URL {
reflector_: Reflector::new(),
url: DOMRefCell::new(url),
@ -42,18 +42,19 @@ impl URL {
}
}
pub fn new(global: &GlobalScope, url: Url) -> Root<URL> {
pub fn new(global: &GlobalScope, url: ServoUrl) -> Root<URL> {
reflect_dom_object(box URL::new_inherited(url),
global, URLBinding::Wrap)
}
pub fn query_pairs(&self) -> Vec<(String, String)> {
self.url.borrow().query_pairs().into_owned().collect()
self.url.borrow().as_url().unwrap().query_pairs().into_owned().collect()
}
pub fn set_query_pairs(&self, pairs: &[(String, String)]) {
let mut url = self.url.borrow_mut();
url.query_pairs_mut().clear().extend_pairs(pairs);
if let Some(ref mut url) = self.url.borrow_mut().as_mut_url() {
url.query_pairs_mut().clear().extend_pairs(pairs);
}
}
}
@ -69,7 +70,7 @@ impl URL {
},
Some(base) =>
// Step 2.1.
match Url::parse(&base.0) {
match ServoUrl::parse(&base.0) {
Ok(base) => Some(base),
Err(error) => {
// Step 2.2.
@ -78,7 +79,7 @@ impl URL {
}
};
// Step 3.
let parsed_url = match Url::options().base_url(parsed_base.as_ref()).parse(&url.0) {
let parsed_url = match ServoUrl::parse_with_base(parsed_base.as_ref(), &url.0) {
Ok(url) => url,
Err(error) => {
// Step 4.
@ -124,7 +125,7 @@ impl URL {
*/
let origin = get_blob_origin(&global.get_url());
if let Ok(url) = Url::parse(&url) {
if let Ok(url) = ServoUrl::parse(&url) {
if let Ok((id, _, _)) = parse_blob_url(&url) {
let resource_threads = global.resource_threads();
let (tx, rx) = ipc::channel().unwrap();
@ -192,7 +193,7 @@ impl URLMethods for URL {
// https://url.spec.whatwg.org/#dom-url-href
fn SetHref(&self, value: USVString) -> ErrorResult {
match Url::parse(&value.0) {
match ServoUrl::parse(&value.0) {
Ok(url) => {
*self.url.borrow_mut() = url;
self.search_params.set(None); // To be re-initialized in the SearchParams getter.
@ -258,7 +259,7 @@ impl URLMethods for URL {
fn SetSearch(&self, value: USVString) {
UrlHelper::SetSearch(&mut self.url.borrow_mut(), value);
if let Some(search_params) = self.search_params.get() {
search_params.set_list(self.url.borrow().query_pairs().into_owned().collect());
search_params.set_list(self.query_pairs());
}
}

View file

@ -3,32 +3,93 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::str::USVString;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use url::{Url, quirks};
use url::quirks;
#[derive(HeapSizeOf)]
pub struct UrlHelper;
impl UrlHelper {
pub fn SameOrigin(url_a: &Url, url_b: &Url) -> bool { url_a.origin() == url_b.origin() }
pub fn Origin(url: &Url) -> USVString { USVString(quirks::origin(url)) }
pub fn Href(url: &Url) -> USVString { USVString(quirks::href(url).to_owned()) }
pub fn Hash(url: &Url) -> USVString { USVString(quirks::hash(url).to_owned()) }
pub fn Host(url: &Url) -> USVString { USVString(quirks::host(url).to_owned()) }
pub fn Port(url: &Url) -> USVString { USVString(quirks::port(url).to_owned()) }
pub fn Search(url: &Url) -> USVString { USVString(quirks::search(url).to_owned()) }
pub fn Hostname(url: &Url) -> USVString { USVString(quirks::hostname(url).to_owned()) }
pub fn Password(url: &Url) -> USVString { USVString(quirks::password(url).to_owned()) }
pub fn Pathname(url: &Url) -> USVString { USVString(quirks::pathname(url).to_owned()) }
pub fn Protocol(url: &Url) -> USVString { USVString(quirks::protocol(url).to_owned()) }
pub fn Username(url: &Url) -> USVString { USVString(quirks::username(url).to_owned()) }
pub fn SetHash(url: &mut Url, value: USVString) { quirks::set_hash(url, &value.0) }
pub fn SetHost(url: &mut Url, value: USVString) { let _ = quirks::set_host(url, &value.0); }
pub fn SetPort(url: &mut Url, value: USVString) { let _ = quirks::set_port(url, &value.0); }
pub fn SetSearch(url: &mut Url, value: USVString) { quirks::set_search(url, &value.0) }
pub fn SetPathname(url: &mut Url, value: USVString) { quirks::set_pathname(url, &value.0) }
pub fn SetHostname(url: &mut Url, value: USVString) { let _ = quirks::set_hostname(url, &value.0); }
pub fn SetPassword(url: &mut Url, value: USVString) { let _ = quirks::set_password(url, &value.0); }
pub fn SetProtocol(url: &mut Url, value: USVString) { let _ = quirks::set_protocol(url, &value.0); }
pub fn SetUsername(url: &mut Url, value: USVString) { let _ = quirks::set_username(url, &value.0); }
pub fn SameOrigin(url_a: &ServoUrl, url_b: &ServoUrl) -> bool {
url_a.origin() == url_b.origin()
}
pub fn Origin(url: &ServoUrl) -> USVString {
USVString(quirks::origin(url.as_url().unwrap()).to_owned())
}
pub fn Href(url: &ServoUrl) -> USVString {
USVString(quirks::href(url.as_url().unwrap()).to_owned())
}
pub fn Hash(url: &ServoUrl) -> USVString {
USVString(quirks::hash(url.as_url().unwrap()).to_owned())
}
pub fn Host(url: &ServoUrl) -> USVString {
USVString(quirks::host(url.as_url().unwrap()).to_owned())
}
pub fn Port(url: &ServoUrl) -> USVString {
USVString(quirks::port(url.as_url().unwrap()).to_owned())
}
pub fn Search(url: &ServoUrl) -> USVString {
USVString(quirks::search(url.as_url().unwrap()).to_owned())
}
pub fn Hostname(url: &ServoUrl) -> USVString {
USVString(quirks::hostname(url.as_url().unwrap()).to_owned())
}
pub fn Password(url: &ServoUrl) -> USVString {
USVString(quirks::password(url.as_url().unwrap()).to_owned())
}
pub fn Pathname(url: &ServoUrl) -> USVString {
USVString(quirks::pathname(url.as_url().unwrap()).to_owned())
}
pub fn Protocol(url: &ServoUrl) -> USVString {
USVString(quirks::protocol(url.as_url().unwrap()).to_owned())
}
pub fn Username(url: &ServoUrl) -> USVString {
USVString(quirks::username(url.as_url().unwrap()).to_owned())
}
pub fn SetHash(url: &mut ServoUrl, value: USVString) {
if let Some(ref mut url) = url.as_mut_url() {
quirks::set_hash(url, &value.0)
}
}
pub fn SetHost(url: &mut ServoUrl, value: USVString) {
if let Some(ref mut url) = url.as_mut_url() {
let _ = quirks::set_host(url, &value.0);
}
}
pub fn SetPort(url: &mut ServoUrl, value: USVString) {
if let Some(ref mut url) = url.as_mut_url() {
let _ = quirks::set_port(url, &value.0);
}
}
pub fn SetSearch(url: &mut ServoUrl, value: USVString) {
if let Some(ref mut url) = url.as_mut_url() {
quirks::set_search(url, &value.0)
}
}
pub fn SetPathname(url: &mut ServoUrl, value: USVString) {
if let Some(ref mut url) = url.as_mut_url() {
quirks::set_pathname(url, &value.0)
}
}
pub fn SetHostname(url: &mut ServoUrl, value: USVString) {
if let Some(ref mut url) = url.as_mut_url() {
let _ = quirks::set_hostname(url, &value.0);
}
}
pub fn SetPassword(url: &mut ServoUrl, value: USVString) {
if let Some(ref mut url) = url.as_mut_url() {
let _ = quirks::set_password(url, &value.0);
}
}
pub fn SetProtocol(url: &mut ServoUrl, value: USVString) {
if let Some(ref mut url) = url.as_mut_url() {
let _ = quirks::set_protocol(url, &value.0);
}
}
pub fn SetUsername(url: &mut ServoUrl, value: USVString) {
if let Some(ref mut url) = url.as_mut_url() {
let _ = quirks::set_username(url, &value.0);
}
}
}

View file

@ -36,6 +36,7 @@ use net_traits::unwrap_websocket_protocol;
use script_runtime::CommonScriptMsg;
use script_runtime::ScriptThreadEventCategory::WebSocketEvent;
use script_thread::{Runnable, RunnableWrapper};
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::cell::Cell;
@ -43,7 +44,6 @@ use std::ptr;
use std::thread;
use task_source::TaskSource;
use task_source::networking::NetworkingTaskSource;
use websocket::client::request::Url;
use websocket::header::{Headers, WebSocketProtocol};
use websocket::ws::util::url::parse_url;
@ -171,7 +171,7 @@ pub fn fail_the_websocket_connection(address: Trusted<WebSocket>,
#[dom_struct]
pub struct WebSocket {
eventtarget: EventTarget,
url: Url,
url: ServoUrl,
ready_state: Cell<WebSocketRequestState>,
buffered_amount: Cell<u64>,
clearing_buffer: Cell<bool>, //Flag to tell if there is a running thread to clear buffered_amount
@ -182,7 +182,7 @@ pub struct WebSocket {
}
impl WebSocket {
fn new_inherited(url: Url) -> WebSocket {
fn new_inherited(url: ServoUrl) -> WebSocket {
WebSocket {
eventtarget: EventTarget::new_inherited(),
url: url,
@ -195,7 +195,7 @@ impl WebSocket {
}
}
fn new(global: &GlobalScope, url: Url) -> Root<WebSocket> {
fn new(global: &GlobalScope, url: ServoUrl) -> Root<WebSocket> {
reflect_dom_object(box WebSocket::new_inherited(url),
global, WebSocketBinding::Wrap)
}
@ -205,10 +205,10 @@ impl WebSocket {
protocols: Option<StringOrStringSequence>)
-> Fallible<Root<WebSocket>> {
// Step 1.
let resource_url = try!(Url::parse(&url).map_err(|_| Error::Syntax));
let resource_url = try!(ServoUrl::parse(&url).map_err(|_| Error::Syntax));
// Although we do this replace and parse operation again in the resource thread,
// we try here to be able to immediately throw a syntax error on failure.
let _ = try!(parse_url(&replace_hosts(&resource_url)).map_err(|_| Error::Syntax));
let _ = try!(parse_url(&replace_hosts(&resource_url).as_url().unwrap()).map_err(|_| Error::Syntax));
// Step 2: Disallow https -> ws connections.
// Step 3: Potentially block access to some ports.

View file

@ -76,6 +76,7 @@ use script_traits::{DocumentState, TimerEvent, TimerEventId};
use script_traits::{ScriptMsg as ConstellationMsg, TimerEventRequest, WindowSizeData, WindowSizeType};
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::cell::Cell;
@ -102,7 +103,6 @@ use time;
use timers::{IsInterval, TimerCallback};
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
use tinyfiledialogs::{self, MessageBoxIcon};
use url::Url;
use util::geometry::{self, max_rect};
use util::opts;
use util::prefs::PREFS;
@ -633,7 +633,7 @@ impl WindowMethods for Window {
// object, not self's.
Some(self.Document().origin().copy())
},
url => match Url::parse(&url) {
url => match ServoUrl::parse(&url) {
Ok(url) => Some(Origin::new(&url)),
Err(_) => return Err(Error::Syntax),
}
@ -869,7 +869,7 @@ impl WindowMethods for Window {
// check-tidy: no specs after this line
fn OpenURLInDefaultBrowser(&self, href: DOMString) -> ErrorResult {
let url = try!(Url::parse(&href).map_err(|e| {
let url = try!(ServoUrl::parse(&href).map_err(|e| {
Error::Type(format!("Couldn't parse URL: {}", e))
}));
match open::that(url.as_str()) {
@ -1331,7 +1331,7 @@ impl Window {
}
/// Commence a new URL load which will either replace this window or scroll to a fragment.
pub fn load_url(&self, url: Url, replace: bool, referrer_policy: Option<ReferrerPolicy>) {
pub fn load_url(&self, url: ServoUrl, replace: bool, referrer_policy: Option<ReferrerPolicy>) {
let doc = self.Document();
let referrer_policy = referrer_policy.or(doc.get_referrer_policy());
@ -1364,7 +1364,7 @@ impl Window {
self.window_size.get()
}
pub fn get_url(&self) -> Url {
pub fn get_url(&self) -> ServoUrl {
(*self.Document().url()).clone()
}

View file

@ -34,6 +34,7 @@ use script_runtime::{ScriptThreadEventCategory, PromiseJobQueue, EnqueuedPromise
use script_thread::{Runnable, RunnableWrapper};
use script_traits::{TimerEvent, TimerEventId};
use script_traits::WorkerGlobalScopeInit;
use servo_url::ServoUrl;
use std::default::Default;
use std::panic;
use std::rc::Rc;
@ -43,7 +44,6 @@ use std::sync::mpsc::Receiver;
use task_source::file_reading::FileReadingTaskSource;
use task_source::networking::NetworkingTaskSource;
use timers::{IsInterval, TimerCallback};
use url::Url;
pub fn prepare_workerscope_init(global: &GlobalScope,
devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>) -> WorkerGlobalScopeInit {
@ -68,7 +68,7 @@ pub struct WorkerGlobalScope {
globalscope: GlobalScope,
worker_id: WorkerId,
worker_url: Url,
worker_url: ServoUrl,
#[ignore_heap_size_of = "Arc"]
closing: Option<Arc<AtomicBool>>,
#[ignore_heap_size_of = "Defined in js"]
@ -91,7 +91,7 @@ pub struct WorkerGlobalScope {
impl WorkerGlobalScope {
pub fn new_inherited(init: WorkerGlobalScopeInit,
worker_url: Url,
worker_url: ServoUrl,
runtime: Runtime,
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
timer_event_chan: IpcSender<TimerEvent>,
@ -144,7 +144,7 @@ impl WorkerGlobalScope {
}
}
pub fn get_url(&self) -> &Url {
pub fn get_url(&self) -> &ServoUrl {
&self.worker_url
}

View file

@ -9,24 +9,24 @@ use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::str::{DOMString, USVString};
use dom::urlhelper::UrlHelper;
use dom::workerglobalscope::WorkerGlobalScope;
use url::Url;
use servo_url::ServoUrl;
// https://html.spec.whatwg.org/multipage/#worker-locations
#[dom_struct]
pub struct WorkerLocation {
reflector_: Reflector,
url: Url,
url: ServoUrl,
}
impl WorkerLocation {
fn new_inherited(url: Url) -> WorkerLocation {
fn new_inherited(url: ServoUrl) -> WorkerLocation {
WorkerLocation {
reflector_: Reflector::new(),
url: url,
}
}
pub fn new(global: &WorkerGlobalScope, url: Url) -> Root<WorkerLocation> {
pub fn new(global: &WorkerGlobalScope, url: ServoUrl) -> Root<WorkerLocation> {
reflect_dom_object(box WorkerLocation::new_inherited(url),
global,
WorkerLocationBinding::Wrap)

View file

@ -16,7 +16,7 @@ use dom::location::Location;
use dom::node::Node;
use dom::window::Window;
use js::jsapi::{JSContext, JSObject};
use url::Url;
use servo_url::ServoUrl;
// https://dom.spec.whatwg.org/#xmldocument
#[dom_struct]
@ -27,7 +27,7 @@ pub struct XMLDocument {
impl XMLDocument {
fn new_inherited(window: &Window,
browsing_context: Option<&BrowsingContext>,
url: Option<Url>,
url: Option<ServoUrl>,
is_html_document: IsHTMLDocument,
content_type: Option<DOMString>,
last_modified: Option<String>,
@ -49,7 +49,7 @@ impl XMLDocument {
pub fn new(window: &Window,
browsing_context: Option<&BrowsingContext>,
url: Option<Url>,
url: Option<ServoUrl>,
doctype: IsHTMLDocument,
content_type: Option<DOMString>,
last_modified: Option<String>,

View file

@ -55,6 +55,7 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit, RequestMode
use net_traits::trim_http_whitespace;
use network_listener::{NetworkListener, PreInvoke};
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::cell::Cell;
@ -64,7 +65,7 @@ use std::sync::{Arc, Mutex};
use task_source::networking::NetworkingTaskSource;
use time;
use timers::{OneshotTimerCallback, OneshotTimerHandle};
use url::{Position, Url};
use url::Position;
use util::prefs::PREFS;
#[derive(JSTraceable, PartialEq, Copy, Clone, HeapSizeOf)]
@ -137,7 +138,7 @@ pub struct XMLHttpRequest {
// Associated concepts
#[ignore_heap_size_of = "Defined in hyper"]
request_method: DOMRefCell<Method>,
request_url: DOMRefCell<Option<Url>>,
request_url: DOMRefCell<Option<ServoUrl>>,
#[ignore_heap_size_of = "Defined in hyper"]
request_headers: DOMRefCell<Headers>,
request_body_len: Cell<usize>,
@ -149,7 +150,7 @@ pub struct XMLHttpRequest {
fetch_time: Cell<i64>,
generation_id: Cell<GenerationId>,
response_status: Cell<Result<(), ()>>,
referrer_url: Option<Url>,
referrer_url: Option<ServoUrl>,
referrer_policy: Option<ReferrerPolicy>,
}
@ -169,7 +170,7 @@ impl XMLHttpRequest {
timeout: Cell::new(0u32),
with_credentials: Cell::new(false),
upload: JS::from_ref(&*XMLHttpRequestUpload::new(global)),
response_url: DOMRefCell::new(String::from("")),
response_url: DOMRefCell::new(String::new()),
status: Cell::new(0),
status_text: DOMRefCell::new(ByteString::new(vec!())),
response: DOMRefCell::new(ByteString::new(vec!())),
@ -272,7 +273,7 @@ impl XMLHttpRequest {
}
impl LoadOrigin for XMLHttpRequest {
fn referrer_url(&self) -> Option<Url> {
fn referrer_url(&self) -> Option<ServoUrl> {
return self.referrer_url.clone();
}
@ -860,7 +861,8 @@ impl XMLHttpRequest {
}
fn process_headers_available(&self,
gen_id: GenerationId, metadata: Result<FetchMetadata, NetworkError>)
gen_id: GenerationId,
metadata: Result<FetchMetadata, NetworkError>)
-> Result<(), Error> {
let metadata = match metadata {
Ok(meta) => match meta {
@ -876,7 +878,7 @@ impl XMLHttpRequest {
},
};
*self.response_url.borrow_mut() = metadata.final_url[..Position::AfterQuery].to_owned();
*self.response_url.borrow_mut() = metadata.final_url.as_url().unwrap()[..Position::AfterQuery].to_owned();
// XXXManishearth Clear cache entries in case of a network error
self.process_partial_response(XHRProgress::HeadersReceived(

View file

@ -24,10 +24,10 @@ use net_traits::CoreResourceMsg::Fetch as NetTraitsFetch;
use net_traits::request::Request as NetTraitsRequest;
use net_traits::request::RequestInit as NetTraitsRequestInit;
use network_listener::{NetworkListener, PreInvoke};
use servo_url::ServoUrl;
use std::mem;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use url::Url;
struct FetchContext {
fetch_promise: Option<TrustedPromise>,
@ -35,7 +35,7 @@ struct FetchContext {
body: Vec<u8>,
}
fn from_referrer_to_referrer_url(request: &NetTraitsRequest) -> Option<Url> {
fn from_referrer_to_referrer_url(request: &NetTraitsRequest) -> Option<ServoUrl> {
let referrer = request.referrer.borrow();
referrer.to_url().map(|url| url.clone())
}

View file

@ -51,6 +51,7 @@ use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayou
use selectors::matching::ElementFlags;
use selectors::parser::{AttrSelector, NamespaceConstraint};
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::fmt;
use std::marker::PhantomData;
use std::mem::transmute;
@ -69,7 +70,6 @@ use style::selector_impl::{NonTSPseudoClass, PseudoElement, RestyleDamage, Servo
use style::selector_matching::ApplicableDeclarationBlock;
use style::sink::Push;
use style::str::is_whitespace;
use url::Url;
#[derive(Copy, Clone)]
pub struct ServoLayoutNode<'a> {
@ -910,7 +910,7 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> {
})
}
fn image_url(&self) -> Option<Url> {
fn image_url(&self) -> Option<ServoUrl> {
let this = unsafe { self.get_jsmanaged() };
this.image_url()
}

View file

@ -82,6 +82,7 @@ extern crate script_traits;
extern crate selectors;
extern crate serde;
#[macro_use] extern crate servo_atoms;
extern crate servo_url;
extern crate smallvec;
#[macro_use]
extern crate style;

View file

@ -2,8 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use servo_url::ServoUrl;
use std::sync::Arc;
use url::{Host, Url};
use url::Host;
use url::Origin as UrlOrigin;
/// A representation of an [origin](https://html.spec.whatwg.org/multipage/#origin-2).
@ -22,7 +23,7 @@ impl Origin {
}
/// Create a new origin for the given URL.
pub fn new(url: &Url) -> Origin {
pub fn new(url: &ServoUrl) -> Origin {
Origin {
inner: Arc::new(url.origin()),
}

View file

@ -90,6 +90,7 @@ use script_traits::{TouchEventType, TouchId, UntrustedNodeAddress, WindowSizeDat
use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, ResizeEvent};
use script_traits::CompositorEvent::{TouchEvent, TouchpadPressureEvent};
use script_traits::webdriver_msg::WebDriverScriptCommand;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::cell::Cell;
use std::collections::{hash_map, HashMap, HashSet};
@ -110,7 +111,7 @@ use task_source::history_traversal::HistoryTraversalTaskSource;
use task_source::networking::NetworkingTaskSource;
use task_source::user_interaction::{UserInteractionTask, UserInteractionTaskSource};
use time::Tm;
use url::{Position, Url};
use url::Position;
use util::opts;
use util::thread;
use webdriver_handlers;
@ -150,7 +151,7 @@ struct InProgressLoad {
/// Window is visible.
is_visible: bool,
/// The requested URL of the load.
url: Url,
url: ServoUrl,
}
impl InProgressLoad {
@ -160,7 +161,7 @@ impl InProgressLoad {
parent_info: Option<(PipelineId, FrameType)>,
layout_chan: Sender<message::Msg>,
window_size: Option<WindowSizeData>,
url: Url) -> InProgressLoad {
url: ServoUrl) -> InProgressLoad {
InProgressLoad {
pipeline_id: id,
frame_id: frame_id,
@ -397,7 +398,7 @@ pub struct ScriptThread {
/// A list of data pertaining to loads that have not yet received a network response
incomplete_loads: DOMRefCell<Vec<InProgressLoad>>,
/// A map to store service worker registrations for a given origin
registration_map: DOMRefCell<HashMap<Url, JS<ServiceWorkerRegistration>>>,
registration_map: DOMRefCell<HashMap<ServoUrl, JS<ServiceWorkerRegistration>>>,
/// A handle to the image cache thread.
image_cache_thread: ImageCacheThread,
/// A handle to the resource thread. This is an `Arc` to avoid running out of file descriptors if
@ -563,7 +564,7 @@ impl ScriptThread {
}
// stores a service worker registration
pub fn set_registration(scope_url: Url, registration:&ServiceWorkerRegistration, pipeline_id: PipelineId) {
pub fn set_registration(scope_url: ServoUrl, registration:&ServiceWorkerRegistration, pipeline_id: PipelineId) {
SCRIPT_THREAD_ROOT.with(|root| {
let script_thread = unsafe { &*root.get().unwrap() };
script_thread.handle_serviceworker_registration(scope_url, registration, pipeline_id);
@ -1448,7 +1449,7 @@ impl ScriptThread {
}
fn handle_serviceworker_registration(&self,
scope: Url,
scope: ServoUrl,
registration: &ServiceWorkerRegistration,
pipeline_id: PipelineId) {
{
@ -1580,7 +1581,7 @@ impl ScriptThread {
}
/// Notify a window of a storage event
fn handle_storage_event(&self, pipeline_id: PipelineId, storage_type: StorageType, url: Url,
fn handle_storage_event(&self, pipeline_id: PipelineId, storage_type: StorageType, url: ServoUrl,
key: Option<String>, old_value: Option<String>, new_value: Option<String>) {
let storage = match self.documents.borrow().find_window(pipeline_id) {
None => return warn!("Storage event sent to closed pipeline {}.", pipeline_id),
@ -1752,7 +1753,7 @@ impl ScriptThread {
// Start with the scheme data of the parsed URL;
// append question mark and query component, if any;
// append number sign and fragment component if any.
let encoded = &incomplete.url[Position::BeforePath..];
let encoded = &incomplete.url.as_url().unwrap()[Position::BeforePath..];
// Percent-decode (8.) and UTF-8 decode (9.)
let script_source = percent_decode(encoded.as_bytes()).decode_utf8_lossy();
@ -1812,7 +1813,7 @@ impl ScriptThread {
document.get_current_parser().unwrap()
}
fn notify_devtools(&self, title: DOMString, url: Url, ids: (PipelineId, Option<WorkerId>)) {
fn notify_devtools(&self, title: DOMString, url: ServoUrl, ids: (PipelineId, Option<WorkerId>)) {
if let Some(ref chan) = self.devtools_chan {
let page_info = DevtoolsPageInfo {
title: String::from(title),
@ -1994,11 +1995,13 @@ impl ScriptThread {
Some(document) => document,
None => return warn!("Message sent to closed pipeline {}.", parent_pipeline_id),
};
let url = document.url();
if &url[..Position::AfterQuery] == &nurl[..Position::AfterQuery] &&
load_data.method == Method::Get {
self.check_and_scroll_fragment(fragment, parent_pipeline_id, &document);
return;
let nurl = nurl.as_url().unwrap();
if let Some(url) = document.url().as_url() {
if &url[..Position::AfterQuery] == &nurl[..Position::AfterQuery] &&
load_data.method == Method::Get {
self.check_and_scroll_fragment(fragment, parent_pipeline_id, &document);
return;
}
}
}
}
@ -2068,7 +2071,7 @@ impl ScriptThread {
});
if load_data.url.scheme() == "javascript" {
load_data.url = Url::parse("about:blank").unwrap();
load_data.url = ServoUrl::parse("about:blank").unwrap();
}
let request = RequestInit {

View file

@ -16,9 +16,9 @@ use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER;
use net_traits::{CustomResponseMediator, CoreResourceMsg};
use script_traits::{ServiceWorkerMsg, ScopeThings, SWManagerMsg, SWManagerSenders, DOMMessage};
use servo_url::ServoUrl;
use std::collections::HashMap;
use std::sync::mpsc::{channel, Sender, Receiver, RecvError};
use url::Url;
use util::prefs::PREFS;
use util::thread::spawn_named;
@ -29,9 +29,9 @@ enum Message {
pub struct ServiceWorkerManager {
// map of registered service worker descriptors
registered_workers: HashMap<Url, ScopeThings>,
registered_workers: HashMap<ServoUrl, ScopeThings>,
// map of active service worker descriptors
active_workers: HashMap<Url, Sender<ServiceWorkerScriptMsg>>,
active_workers: HashMap<ServoUrl, Sender<ServiceWorkerScriptMsg>>,
// own sender to send messages here
own_sender: IpcSender<ServiceWorkerMsg>,
// receiver to receive messages from constellation
@ -67,7 +67,7 @@ impl ServiceWorkerManager {
});
}
pub fn get_matching_scope(&self, load_url: &Url) -> Option<Url> {
pub fn get_matching_scope(&self, load_url: &ServoUrl) -> Option<ServoUrl> {
for scope in self.registered_workers.keys() {
if longest_prefix_match(&scope, load_url) {
return Some(scope.clone());
@ -76,7 +76,7 @@ impl ServiceWorkerManager {
None
}
pub fn wakeup_serviceworker(&mut self, scope_url: Url) -> Option<Sender<ServiceWorkerScriptMsg>> {
pub fn wakeup_serviceworker(&mut self, scope_url: ServoUrl) -> Option<Sender<ServiceWorkerScriptMsg>> {
let scope_things = self.registered_workers.get(&scope_url);
if let Some(scope_things) = scope_things {
let (sender, receiver) = channel();

View file

@ -36,7 +36,7 @@ use net_traits::IpcSend;
use script_thread::Documents;
use script_traits::webdriver_msg::{WebDriverFrameId, WebDriverJSError, WebDriverJSResult, WebDriverJSValue};
use script_traits::webdriver_msg::WebDriverCookieError;
use url::Url;
use servo_url::ServoUrl;
fn find_node_by_unique_id(documents: &Documents,
pipeline: PipelineId,
@ -361,11 +361,11 @@ pub fn handle_get_css(documents: &Documents,
pub fn handle_get_url(documents: &Documents,
pipeline: PipelineId,
reply: IpcSender<Url>) {
reply: IpcSender<ServoUrl>) {
// TODO: Return an error if the pipeline doesn't exist.
let url = documents.find_document(pipeline)
.map(|document| document.url().clone())
.unwrap_or_else(|| Url::parse("about:blank").expect("infallible"));
.unwrap_or_else(|| ServoUrl::parse("about:blank").expect("infallible"));
reply.send(url).unwrap();
}