Skip to content

Commit

Permalink
Auto merge of #10606 - servo:remove-url-plugin, r=nox
Browse files Browse the repository at this point in the history
Remove the url! plugin.

In rust-url 1.0 the `Url` struct is going to have private fields, and there is no way to to create an aribitrary one without going through the parser.

The plugin never had a clear demonstrated performance benefit, it was made mostly because it was possible and relatively easy at the time.

This commit was originally part of #9840, but it’s taking a while to land and I keep removing new uses of `url!` when rebasing.

r? @nox

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10606)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Apr 14, 2016
2 parents 87d5424 + 6889f37 commit 3368565
Show file tree
Hide file tree
Showing 27 changed files with 84 additions and 296 deletions.
4 changes: 2 additions & 2 deletions components/compositing/constellation.rs
Expand Up @@ -868,7 +868,7 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
parent_info,
window_size,
None,
LoadData::new(url!("about:failure")));
LoadData::new(Url::parse("about:failure").unwrap()));

self.push_pending_frame(new_pipeline_id, Some(pipeline_id));

Expand Down Expand Up @@ -951,7 +951,7 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
// If no url is specified, reload.
let new_url = load_info.url.clone()
.or_else(|| old_pipeline.map(|old_pipeline| old_pipeline.url.clone()))
.unwrap_or_else(|| url!("about:blank"));
.unwrap_or_else(|| Url::parse("about:blank").unwrap());

// Compare the pipeline's url to the new url. If the origin is the same,
// then reuse the script thread in creating the new pipeline
Expand Down
1 change: 0 additions & 1 deletion components/plugins/Cargo.toml
Expand Up @@ -16,7 +16,6 @@ optional = true

[dependencies]
tenacious = "0.1.2"
url = {version = "0.5.7", features = ["heap_size"]}

[features]
default = []
5 changes: 0 additions & 5 deletions components/plugins/lib.rs
Expand Up @@ -28,8 +28,6 @@ extern crate syntax;
extern crate syntax_ext;
extern crate tenacious;

extern crate url;

use rustc_plugin::Registry;
use syntax::ext::base::*;
use syntax::feature_gate::AttributeType::Whitelisted;
Expand All @@ -41,8 +39,6 @@ pub mod jstraceable;
pub mod lints;
/// Autogenerates implementations of Reflectable on DOM structs
pub mod reflector;
/// The `url!` plugin.
mod url_plugin;
/// Utilities for writing plugins
pub mod utils;

Expand All @@ -51,7 +47,6 @@ pub fn plugin_registrar(reg: &mut Registry) {
reg.register_syntax_extension(intern("dom_struct"), MultiModifier(box jstraceable::expand_dom_struct));
reg.register_syntax_extension(intern("derive_JSTraceable"), MultiDecorator(box jstraceable::expand_jstraceable));
reg.register_syntax_extension(intern("_generate_reflector"), MultiDecorator(box reflector::expand_reflector));
reg.register_macro("url", url_plugin::expand_url);
reg.register_late_lint_pass(box lints::transmute_type::TransmutePass);
reg.register_late_lint_pass(box lints::unrooted_must_root::UnrootedPass::new());
reg.register_late_lint_pass(box lints::privatize::PrivatizePass);
Expand Down
146 changes: 0 additions & 146 deletions components/plugins/url_plugin.rs

This file was deleted.

2 changes: 1 addition & 1 deletion components/script/dom/document.rs
Expand Up @@ -1603,7 +1603,7 @@ impl Document {
source: DocumentSource,
doc_loader: DocumentLoader)
-> Document {
let url = url.unwrap_or_else(|| url!("about:blank"));
let url = url.unwrap_or_else(|| Url::parse("about:blank").unwrap());

let (ready_state, domcontentloaded_dispatched) = if source == DocumentSource::FromParser {
(DocumentReadyState::Loading, false)
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/htmliframeelement.rs
Expand Up @@ -146,7 +146,7 @@ impl HTMLIFrameElement {
pub fn process_the_iframe_attributes(&self) {
let url = match self.get_url() {
Some(url) => url.clone(),
None => url!("about:blank"),
None => Url::parse("about:blank").unwrap(),
};

self.navigate_or_reload_child_browsing_context(Some(url));
Expand Down
2 changes: 1 addition & 1 deletion components/script/script_thread.rs
Expand Up @@ -1880,7 +1880,7 @@ impl ScriptThread {
};

if load_data.url.scheme == "javascript" {
load_data.url = url!("about:blank");
load_data.url = Url::parse("about:blank").unwrap();
}

resource_thread.send(ControlMsg::Load(NetLoadData {
Expand Down
10 changes: 0 additions & 10 deletions components/servo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions components/servo/Cargo.toml
Expand Up @@ -33,9 +33,6 @@ path = "../../tests/unit/net"
[dev-dependencies.net_traits_tests]
path = "../../tests/unit/net_traits"

[dev-dependencies.plugin_tests]
path = "../../tests/unit/plugin"

[dev-dependencies.script_tests]
path = "../../tests/unit/script"

Expand Down
2 changes: 1 addition & 1 deletion components/style/font_face.rs
Expand Up @@ -102,7 +102,7 @@ fn parse_one_src(context: &ParserContext, input: &mut Parser) -> Result<Source,
}
let url = try!(input.expect_url());
let url = context.base_url.join(&url).unwrap_or_else(
|_error| url!("about:invalid"));
|_error| Url::parse("about:invalid").unwrap());

// Parsing optional format()
let format_hints = if input.try(|input| input.expect_function_matching("format")).is_ok() {
Expand Down
2 changes: 1 addition & 1 deletion components/style/parser.rs
Expand Up @@ -34,7 +34,7 @@ impl<'a> ParserContext<'a> {
impl<'a> ParserContext<'a> {
pub fn parse_url(&self, input: &str) -> Url {
self.base_url.join(input)
.unwrap_or_else(|_| url!("about:invalid"))
.unwrap_or_else(|_| Url::parse("about:invalid").unwrap())
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/style/selector_matching.rs
Expand Up @@ -69,7 +69,7 @@ lazy_static! {
Ok(res) => {
Stylesheet::from_bytes(
&res,
url!("chrome:///quirks-mode.css"),
Url::parse("chrome:///quirks-mode.css").unwrap(),
None,
None,
Origin::UserAgent,
Expand Down
2 changes: 1 addition & 1 deletion components/util/opts.rs
Expand Up @@ -463,7 +463,7 @@ const DEFAULT_USER_AGENT: UserAgent = UserAgent::Desktop;
pub fn default_opts() -> Opts {
Opts {
is_running_problem_test: false,
url: Some(url!("about:blank")),
url: Some(Url::parse("about:blank").unwrap()),
paint_threads: 1,
gpu_painting: false,
tile_size: 512,
Expand Down
1 change: 0 additions & 1 deletion ports/cef/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ports/geckolib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ports/gonk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions tests/unit/net/cookie.rs
Expand Up @@ -7,6 +7,7 @@ extern crate cookie as cookie_rs;
use net::cookie::Cookie;
use net::cookie_storage::CookieStorage;
use net_traits::CookieSource;
use url::Url;

#[test]
fn test_domain_match() {
Expand Down Expand Up @@ -56,9 +57,9 @@ fn test_default_path() {
fn fn_cookie_constructor() {
use net_traits::CookieSource;

let url = &url!("http://example.com/foo");
let url = &Url::parse("http://example.com/foo").unwrap();

let gov_url = &url!("http://gov.ac/foo");
let gov_url = &Url::parse("http://gov.ac/foo").unwrap();
// cookie name/value test
assert!(cookie_rs::Cookie::parse(" baz ").is_err());
assert!(cookie_rs::Cookie::parse(" = bar ").is_err());
Expand Down Expand Up @@ -94,7 +95,7 @@ fn fn_cookie_constructor() {
assert!(&cookie.cookie.domain.as_ref().unwrap()[..] == "example.com");
assert!(cookie.host_only);

let u = &url!("http://example.com/foobar");
let u = &Url::parse("http://example.com/foobar").unwrap();
let cookie = cookie_rs::Cookie::parse("foobar=value;path=/").unwrap();
assert!(Cookie::new_wrapped(cookie, u, CookieSource::HTTP).is_some());
}
Expand All @@ -117,7 +118,7 @@ fn delay_to_ensure_different_timestamp() {
fn test_sort_order() {
use std::cmp::Ordering;

let url = &url!("http://example.com/foo");
let url = &Url::parse("http://example.com/foo").unwrap();
let a_wrapped = cookie_rs::Cookie::parse("baz=bar; Path=/foo/bar/").unwrap();
let a = Cookie::new_wrapped(a_wrapped.clone(), url, CookieSource::HTTP).unwrap();
delay_to_ensure_different_timestamp();
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/net/hsts.rs
Expand Up @@ -6,6 +6,7 @@ use net::hsts::{HSTSList, HSTSEntry};
use net::hsts::{secure_url, preload_hsts_domains};
use net_traits::IncludeSubdomains;
use time;
use url::Url;

#[test]
fn test_hsts_entry_is_not_expired_when_it_has_no_timestamp() {
Expand Down Expand Up @@ -255,23 +256,23 @@ fn test_preload_hsts_domains_well_formed() {

#[test]
fn test_secure_url_does_not_change_explicit_port() {
let url = url!("http://mozilla.org:8080/");
let url = Url::parse("http://mozilla.org:8080/").unwrap();
let secure = secure_url(&url);

assert!(secure.port().unwrap() == 8080u16);
}

#[test]
fn test_secure_url_does_not_affect_non_http_schemas() {
let url = url!("file://mozilla.org");
let url = Url::parse("file://mozilla.org").unwrap();
let secure = secure_url(&url);

assert_eq!(&secure.scheme, "file");
}

#[test]
fn test_secure_url_forces_an_http_host_in_list_to_https() {
let url = url!("http://mozilla.org");
let url = Url::parse("http://mozilla.org").unwrap();
let secure = secure_url(&url);

assert_eq!(&secure.scheme, "https");
Expand Down

0 comments on commit 3368565

Please sign in to comment.