Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Urlmageddon: Use refcounted urls more often.
  • Loading branch information
emilio committed Nov 17, 2016
1 parent f14e733 commit 913c874
Show file tree
Hide file tree
Showing 161 changed files with 1,044 additions and 718 deletions.
2 changes: 1 addition & 1 deletion components/compositing/Cargo.toml
Expand Up @@ -23,9 +23,9 @@ profile_traits = {path = "../profile_traits"}
script_traits = {path = "../script_traits"}
serde = "0.8"
serde_derive = "0.8"
servo_url = {path = "../url", features = ["servo"]}
style_traits = {path = "../style_traits"}
time = "0.1.17"
url = {version = "1.2", features = ["heap_size"]}
util = {path = "../util"}

[dependencies.webrender]
Expand Down
6 changes: 3 additions & 3 deletions components/compositing/compositor.rs
Expand Up @@ -26,6 +26,7 @@ use script_traits::{ConstellationMsg, LayoutControlMsg, LoadData, MouseButton};
use script_traits::{MouseEventType, StackingContextScrollState};
use script_traits::{TouchpadPressurePhase, TouchEventType, TouchId, WindowSizeData, WindowSizeType};
use script_traits::CompositorEvent::{self, MouseMoveEvent, MouseButtonEvent, TouchEvent, TouchpadPressureEvent};
use servo_url::ServoUrl;
use std::collections::HashMap;
use std::fs::File;
use std::rc::Rc;
Expand All @@ -34,7 +35,6 @@ use style_traits::{PagePx, ViewportPx};
use style_traits::viewport::ViewportConstraints;
use time::{precise_time_ns, precise_time_s};
use touch::{TouchHandler, TouchAction};
use url::Url;
use util::geometry::ScreenPx;
use util::opts;
use util::prefs::PREFS;
Expand Down Expand Up @@ -697,7 +697,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
}

fn change_page_url(&mut self, _: PipelineId, url: Url) {
fn change_page_url(&mut self, _: PipelineId, url: ServoUrl) {
self.window.set_page_url(url);
}

Expand Down Expand Up @@ -881,7 +881,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn on_load_url_window_event(&mut self, url_string: String) {
debug!("osmain: loading URL `{}`", url_string);
self.got_load_complete_message = false;
match Url::parse(&url_string) {
match ServoUrl::parse(&url_string) {
Ok(url) => {
self.window.set_page_url(url.clone());
let msg = match self.root_pipeline {
Expand Down
6 changes: 3 additions & 3 deletions components/compositing/compositor_thread.rs
Expand Up @@ -14,11 +14,11 @@ use net_traits::image::base::Image;
use profile_traits::mem;
use profile_traits::time;
use script_traits::{AnimationState, ConstellationMsg, EventResult};
use servo_url::ServoUrl;
use std::fmt::{Debug, Error, Formatter};
use std::sync::mpsc::{Receiver, Sender};
use style_traits::cursor::Cursor;
use style_traits::viewport::ViewportConstraints;
use url::Url;
use webrender;
use webrender_traits;

Expand Down Expand Up @@ -76,7 +76,7 @@ pub enum Msg {
/// Alerts the compositor that the current page has changed its title.
ChangePageTitle(PipelineId, Option<String>),
/// Alerts the compositor that the current page has changed its URL.
ChangePageUrl(PipelineId, Url),
ChangePageUrl(PipelineId, ServoUrl),
/// Alerts the compositor that the given pipeline has changed whether it is running animations.
ChangeRunningAnimationsState(PipelineId, AnimationState),
/// Replaces the current frame tree, typically called during main frame navigation.
Expand All @@ -102,7 +102,7 @@ pub enum Msg {
/// A reply to the compositor asking if the output image is stable.
IsReadyToSaveImageReply(bool),
/// A favicon was detected
NewFavicon(Url),
NewFavicon(ServoUrl),
/// <head> tag finished parsing
HeadParsed,
/// A status message to be displayed by the browser chrome.
Expand Down
2 changes: 1 addition & 1 deletion components/compositing/lib.rs
Expand Up @@ -23,9 +23,9 @@ extern crate profile_traits;
extern crate script_traits;
#[macro_use]
extern crate serde_derive;
extern crate servo_url;
extern crate style_traits;
extern crate time;
extern crate url;
#[macro_use]
extern crate util;
extern crate webrender;
Expand Down
6 changes: 3 additions & 3 deletions components/compositing/windowing.rs
Expand Up @@ -13,9 +13,9 @@ use gfx_traits::DevicePixel;
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
use net_traits::net_error_list::NetError;
use script_traits::{MouseButton, TouchEventType, TouchId, TouchpadPressurePhase};
use servo_url::ServoUrl;
use std::fmt::{Debug, Error, Formatter};
use style_traits::cursor::Cursor;
use url::Url;
use util::geometry::ScreenPx;

#[derive(Clone)]
Expand Down Expand Up @@ -123,7 +123,7 @@ pub trait WindowMethods {
/// Sets the page title for the current page.
fn set_page_title(&self, title: Option<String>);
/// Sets the load data for the current page.
fn set_page_url(&self, url: Url);
fn set_page_url(&self, url: ServoUrl);
/// Called when the browser chrome should display a status message.
fn status(&self, Option<String>);
/// Called when the browser has started loading a frame.
Expand Down Expand Up @@ -160,5 +160,5 @@ pub trait WindowMethods {
fn supports_clipboard(&self) -> bool;

/// Add a favicon
fn set_favicon(&self, url: Url);
fn set_favicon(&self, url: ServoUrl);
}
2 changes: 1 addition & 1 deletion components/constellation/Cargo.toml
Expand Up @@ -33,7 +33,7 @@ script_traits = {path = "../script_traits"}
serde = "0.8"
serde_derive = "0.8"
style_traits = {path = "../style_traits"}
url = {version = "1.2", features = ["heap_size"]}
servo_url = {path = "../url", features = ["servo"]}
util = {path = "../util"}

[dependencies.webrender_traits]
Expand Down
12 changes: 6 additions & 6 deletions components/constellation/constellation.rs
Expand Up @@ -46,6 +46,7 @@ use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, Scri
use script_traits::{LogEntry, ServiceWorkerMsg, webdriver_msg};
use script_traits::{MozBrowserErrorType, MozBrowserEvent, WebDriverCommandMsg, WindowSizeData};
use script_traits::{SWManagerMsg, ScopeThings, WindowSizeType};
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::collections::{HashMap, VecDeque};
use std::io::Error as IOError;
Expand All @@ -62,7 +63,6 @@ use style_traits::PagePx;
use style_traits::cursor::Cursor;
use style_traits::viewport::ViewportConstraints;
use timer_scheduler::TimerScheduler;
use url::Url;
use util::opts;
use util::prefs::PREFS;
use util::remutex::ReentrantMutex;
Expand Down Expand Up @@ -1047,15 +1047,15 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
}

fn handle_register_serviceworker(&self, scope_things: ScopeThings, scope: Url) {
fn handle_register_serviceworker(&self, scope_things: ScopeThings, scope: ServoUrl) {
if let Some(ref mgr) = self.swmanager_chan {
let _ = mgr.send(ServiceWorkerMsg::RegisterServiceWorker(scope_things, scope));
} else {
warn!("sending scope info to service worker manager failed");
}
}

fn handle_broadcast_storage_event(&self, pipeline_id: PipelineId, storage: StorageType, url: Url,
fn handle_broadcast_storage_event(&self, pipeline_id: PipelineId, storage: StorageType, url: ServoUrl,
key: Option<String>, old_value: Option<String>, new_value: Option<String>) {
let origin = url.origin();
for pipeline in self.pipelines.values() {
Expand Down Expand Up @@ -1204,7 +1204,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
self.close_pipeline(pending_pipeline_id, ExitPipelineMode::Force);
}

let failure_url = Url::parse("about:failure").expect("infallible");
let failure_url = ServoUrl::parse("about:failure").expect("infallible");

if let Some(pipeline_url) = pipeline_url {
if pipeline_url == failure_url {
Expand Down Expand Up @@ -1245,7 +1245,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
}

fn handle_init_load(&mut self, url: Url) {
fn handle_init_load(&mut self, url: ServoUrl) {
let window_size = self.window_size.visible_viewport;
let root_pipeline_id = PipelineId::new();
let root_frame_id = self.root_frame_id;
Expand Down Expand Up @@ -1331,7 +1331,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
let load_data = load_info.load_data.unwrap_or_else(|| {
let url = match old_pipeline {
Some(old_pipeline) => old_pipeline.url.clone(),
None => Url::parse("about:blank").expect("infallible"),
None => ServoUrl::parse("about:blank").expect("infallible"),
};

// TODO - loaddata here should have referrer info (not None, None)
Expand Down
2 changes: 1 addition & 1 deletion components/constellation/lib.rs
Expand Up @@ -36,8 +36,8 @@ extern crate script_traits;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate servo_url;
extern crate style_traits;
extern crate url;
#[macro_use]
extern crate util;
extern crate webrender_traits;
Expand Down
6 changes: 3 additions & 3 deletions components/constellation/pipeline.rs
Expand Up @@ -26,6 +26,7 @@ use script_traits::{ConstellationControlMsg, InitialScriptState};
use script_traits::{LayoutControlMsg, LayoutMsg, LoadData, MozBrowserEvent};
use script_traits::{NewLayoutInfo, SWManagerMsg, SWManagerSenders, ScriptMsg};
use script_traits::{ScriptThreadFactory, TimerEventRequest, WindowSizeData};
use servo_url::ServoUrl;
use std::collections::HashMap;
use std::env;
use std::ffi::OsStr;
Expand All @@ -34,7 +35,6 @@ use std::process;
use std::rc::Rc;
use std::sync::mpsc::Sender;
use style_traits::{PagePx, ViewportPx};
use url::Url;
use util::opts::{self, Opts};
use util::prefs::{PREFS, Pref};
use webrender_traits;
Expand All @@ -58,7 +58,7 @@ pub struct Pipeline {
/// A channel to the compositor.
pub compositor_proxy: Box<CompositorProxy + 'static + Send>,
/// URL corresponding to the most recently-loaded page.
pub url: Url,
pub url: ServoUrl,
/// The title of the most recently-loaded page.
pub title: Option<String>,
pub size: Option<TypedSize2D<f32, PagePx>>,
Expand Down Expand Up @@ -264,7 +264,7 @@ impl Pipeline {
layout_chan: IpcSender<LayoutControlMsg>,
compositor_proxy: Box<CompositorProxy + 'static + Send>,
is_private: bool,
url: Url,
url: ServoUrl,
size: Option<TypedSize2D<f32, PagePx>>,
visible: bool)
-> Pipeline {
Expand Down
2 changes: 1 addition & 1 deletion components/devtools_traits/Cargo.toml
Expand Up @@ -19,5 +19,5 @@ ipc-channel = "0.5"
msg = {path = "../msg"}
serde = "0.8"
serde_derive = "0.8"
servo_url = {path = "../url"}
time = "0.1"
url = {version = "1.2", features = ["heap_size"]}
8 changes: 4 additions & 4 deletions components/devtools_traits/lib.rs
Expand Up @@ -24,24 +24,24 @@ extern crate ipc_channel;
extern crate msg;
extern crate serde;
#[macro_use] extern crate serde_derive;
extern crate servo_url;
extern crate time;
extern crate url;

use hyper::header::Headers;
use hyper::method::Method;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::PipelineId;
use servo_url::ServoUrl;
use std::net::TcpStream;
use time::Duration;
use time::Tm;
use url::Url;

// Information would be attached to NewGlobal to be received and show in devtools.
// Extend these fields if we need more information.
#[derive(Debug, Deserialize, Serialize)]
pub struct DevtoolsPageInfo {
pub title: String,
pub url: Url
pub url: ServoUrl,
}

#[derive(Debug, Deserialize, HeapSizeOf, Serialize, Clone)]
Expand Down Expand Up @@ -292,7 +292,7 @@ pub enum CachedConsoleMessage {

#[derive(Debug, PartialEq)]
pub struct HttpRequest {
pub url: Url,
pub url: ServoUrl,
pub method: Method,
pub headers: Headers,
pub body: Option<Vec<u8>>,
Expand Down
2 changes: 1 addition & 1 deletion components/gfx/Cargo.toml
Expand Up @@ -32,13 +32,13 @@ range = {path = "../range"}
rustc-serialize = "0.3"
serde = "0.8"
servo_atoms = {path = "../atoms"}
servo_url = {path = "../url"}
serde_derive = "0.8"
smallvec = "0.1"
style = {path = "../style"}
style_traits = {path = "../style_traits"}
time = "0.1.12"
unicode-script = {version = "0.1", features = ["harfbuzz"]}
url = {version = "1.2", features = ["heap_size"]}
util = {path = "../util"}
xi-unicode = "0.0.1"