Skip to content

Commit

Permalink
Urlmageddon: Use refcounted urls more often.
Browse files Browse the repository at this point in the history
  • 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"

Expand Down
12 changes: 8 additions & 4 deletions components/gfx/font_cache_thread.rs
Expand Up @@ -15,6 +15,7 @@ use platform::font_list::last_resort_font_families;
use platform::font_list::system_default_family;
use platform::font_template::FontTemplateData;
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::mem;
Expand All @@ -23,7 +24,6 @@ use std::sync::{Arc, Mutex};
use std::u32;
use style::font_face::{EffectiveSources, Source};
use style::properties::longhands::font_family::computed_value::FontFamily;
use url::Url;
use util::thread::spawn_named;
use webrender_traits;

Expand Down Expand Up @@ -106,7 +106,7 @@ pub enum Command {
GetFontTemplate(FontFamily, FontTemplateDescriptor, IpcSender<Reply>),
GetLastResortFontTemplate(FontTemplateDescriptor, IpcSender<Reply>),
AddWebFont(LowercaseString, EffectiveSources, IpcSender<()>),
AddDownloadedWebFont(LowercaseString, Url, Vec<u8>, IpcSender<()>),
AddDownloadedWebFont(LowercaseString, ServoUrl, Vec<u8>, IpcSender<()>),
Exit(IpcSender<()>),
}

Expand Down Expand Up @@ -206,7 +206,11 @@ impl FontCache {
match src {
Source::Url(url_source) => {
// https://drafts.csswg.org/css-fonts/#font-fetching-requirements
let url = url_source.url;
let url = match url_source.url.url() {
Some(url) => url.clone(),
None => return,
};

let request = RequestInit {
url: url.clone(),
type_: RequestType::Font,
Expand Down Expand Up @@ -242,7 +246,7 @@ impl FontCache {
Err(_) => {
// FIXME(servo/fontsan#1): get an error message
debug!("Sanitiser rejected web font: \
family={:?} url={}", family_name, url);
family={:?} url={:?}", family_name, url);
let msg = Command::AddWebFont(family_name.clone(), sources.clone(), sender.clone());
channel_to_self.send(msg).unwrap();
return;
Expand Down
6 changes: 2 additions & 4 deletions components/gfx/lib.rs
Expand Up @@ -63,17 +63,15 @@ extern crate rustc_serialize;
extern crate serde;
#[macro_use]
extern crate serde_derive;

extern crate servo_url;
#[macro_use] extern crate servo_atoms;
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
extern crate simd;

#[macro_use] extern crate servo_atoms;
extern crate smallvec;
extern crate style;
extern crate style_traits;
extern crate time;
extern crate unicode_script;
extern crate url;
extern crate util;
extern crate webrender_traits;
extern crate xi_unicode;
Expand Down
6 changes: 3 additions & 3 deletions components/gfx/platform/macos/font_template.rs
Expand Up @@ -10,13 +10,13 @@ use core_text::font::CTFont;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::de::{Error, Visitor};
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::fs::File;
use std::io::{Read, Error as IoError};
use std::ops::Deref;
use std::sync::Mutex;
use url::Url;

/// Platform specific font representation for mac.
/// The identifier is a PostScript font name. The
Expand Down Expand Up @@ -86,13 +86,13 @@ impl FontTemplateData {
None => {}
}

let path = Url::parse(&*self.ctfont(0.0)
let path = ServoUrl::parse(&*self.ctfont(0.0)
.expect("No Core Text font available!")
.url()
.expect("No URL for Core Text font!")
.get_string()
.to_string()).expect("Couldn't parse Core Text font URL!")
.to_file_path()
.as_url().unwrap().to_file_path()
.expect("Core Text font didn't name a path!");
let mut bytes = Vec::new();
File::open(path).expect("Couldn't open font file!").read_to_end(&mut bytes).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion components/layout/Cargo.toml
Expand Up @@ -39,12 +39,12 @@ serde = "0.8"
serde_derive = "0.8"
serde_json = "0.8"
servo_atoms = {path = "../atoms"}
servo_url = {path = "../url"}
smallvec = "0.1"
style = {path = "../style"}
style_traits = {path = "../style_traits"}
unicode-bidi = "0.2"
unicode-script = {version = "0.1", features = ["harfbuzz"]}
url = {version = "1.2", features = ["heap_size"]}
util = {path = "../util"}

[dependencies.webrender_traits]
Expand Down

0 comments on commit 913c874

Please sign in to comment.