Urlmageddon: Use refcounted urls more often.

This commit is contained in:
Emilio Cobos Álvarez 2016-11-16 11:57:39 +01:00
parent f14e7339b5
commit 913c874cb5
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
161 changed files with 1044 additions and 718 deletions

View file

@ -21,5 +21,5 @@ html5ever-atoms = "0.1"
servo_atoms = {path = "../../../components/atoms"}
style = {path = "../../../components/style"}
style_traits = {path = "../../../components/style_traits"}
url = {version = "1.2", features = ["heap_size"]}
servo_url = {path = "../../../components/url"}
util = {path = "../../../components/util"}

View file

@ -15,9 +15,9 @@ extern crate parking_lot;
extern crate rustc_serialize;
extern crate selectors;
#[macro_use] extern crate servo_atoms;
extern crate servo_url;
extern crate style;
extern crate style_traits;
extern crate url;
extern crate util;
mod atomic_refcell;

View file

@ -5,6 +5,7 @@
use app_units::Au;
use cssparser::{Parser, SourcePosition};
use euclid::size::TypedSize2D;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use style::Atom;
use style::error_reporting::ParseErrorReporter;
@ -12,7 +13,6 @@ use style::media_queries::*;
use style::parser::ParserContextExtraData;
use style::stylesheets::{Stylesheet, Origin, CssRule};
use style::values::specified;
use url::Url;
pub struct CSSErrorReporterTest;
@ -25,7 +25,7 @@ impl ParseErrorReporter for CSSErrorReporterTest {
}
fn test_media_rule<F>(css: &str, callback: F) where F: Fn(&MediaList, &str) {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let stylesheet = Stylesheet::from_str(css, url, Origin::Author, Box::new(CSSErrorReporterTest),
ParserContextExtraData::default());
let mut rule_count = 0;
@ -48,7 +48,7 @@ fn media_queries<F>(rules: &[CssRule], f: &mut F) where F: FnMut(&MediaList) {
}
fn media_query_test(device: &Device, css: &str, expected_rule_count: usize) {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let ss = Stylesheet::from_str(css, url, Origin::Author, Box::new(CSSErrorReporterTest),
ParserContextExtraData::default());
let mut rule_count = 0;

View file

@ -4,16 +4,16 @@
use cssparser::Parser;
use media_queries::CSSErrorReporterTest;
use servo_url::ServoUrl;
use style::parser::ParserContext;
use style::properties::longhands::{border_image_outset, border_image_repeat, border_image_slice};
use style::properties::longhands::{border_image_source, border_image_width};
use style::properties::shorthands::border_image;
use style::stylesheets::Origin;
use url::Url;
#[test]
fn border_image_shorhand_should_parse_when_all_properties_specified() {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill / 20px 40px / 10px \
round stretch");
@ -29,7 +29,7 @@ fn border_image_shorhand_should_parse_when_all_properties_specified() {
#[test]
fn border_image_shorhand_should_parse_without_width() {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill / / 10px round stretch");
let result = border_image::parse_value(&context, &mut parser).unwrap();
@ -44,7 +44,7 @@ fn border_image_shorhand_should_parse_without_width() {
#[test]
fn border_image_shorhand_should_parse_without_outset() {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill / 20px 40px round");
let result = border_image::parse_value(&context, &mut parser).unwrap();
@ -59,7 +59,7 @@ fn border_image_shorhand_should_parse_without_outset() {
#[test]
fn border_image_shorhand_should_parse_without_width_or_outset() {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill round");
let result = border_image::parse_value(&context, &mut parser).unwrap();
@ -74,7 +74,7 @@ fn border_image_shorhand_should_parse_without_width_or_outset() {
#[test]
fn border_image_shorhand_should_parse_with_just_source() {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
let mut parser = Parser::new("linear-gradient(red, blue)");
let result = border_image::parse_value(&context, &mut parser).unwrap();

View file

@ -4,13 +4,13 @@
use cssparser::Parser;
use media_queries::CSSErrorReporterTest;
use servo_url::ServoUrl;
use style::parser::ParserContext;
use style::properties::longhands::font_feature_settings;
use style::properties::longhands::font_feature_settings::computed_value;
use style::properties::longhands::font_feature_settings::computed_value::FeatureTagValue;
use style::stylesheets::Origin;
use style_traits::ToCss;
use url::Url;
#[test]
fn font_feature_settings_should_parse_properly() {
@ -52,7 +52,7 @@ fn font_feature_settings_should_parse_properly() {
#[test]
fn font_feature_settings_should_throw_on_bad_input() {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
let mut empty = Parser::new("");

View file

@ -8,7 +8,6 @@ use style::parser::ParserContext;
use style::stylesheets::Origin;
use style::values::specified::image::*;
use style_traits::ToCss;
use url::Url;
#[test]
fn test_linear_gradient() {

View file

@ -6,7 +6,6 @@ use cssparser::Parser;
use media_queries::CSSErrorReporterTest;
use style::parser::ParserContext;
use style::stylesheets::Origin;
use url::Url;
#[test]
fn text_emphasis_style_longhand_should_parse_properly() {

View file

@ -4,16 +4,16 @@
use cssparser::Parser;
use media_queries::CSSErrorReporterTest;
use servo_url::ServoUrl;
use style::parser::ParserContext;
use style::properties::longhands::{mask_clip, mask_composite, mask_image, mask_mode};
use style::properties::longhands::{mask_origin, mask_position, mask_repeat, mask_size};
use style::properties::shorthands::mask;
use style::stylesheets::Origin;
use url::Url;
#[test]
fn mask_shorthand_should_parse_all_available_properties_when_specified() {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
let mut parser = Parser::new("url(\"http://servo/test.png\") luminance 7px 4px / 70px 50px \
repeat-x padding-box border-box subtract");
@ -31,7 +31,7 @@ fn mask_shorthand_should_parse_all_available_properties_when_specified() {
#[test]
fn mask_shorthand_should_parse_when_some_fields_set() {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
let mut parser = Parser::new("14px 40px repeat-y");
let result = mask::parse_value(&context, &mut parser).unwrap();
@ -59,7 +59,7 @@ fn mask_shorthand_should_parse_when_some_fields_set() {
#[test]
fn mask_shorthand_should_parse_position_and_size_correctly() {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
let mut parser = Parser::new("7px 4px");
let result = mask::parse_value(&context, &mut parser).unwrap();
@ -81,7 +81,7 @@ fn mask_shorthand_should_parse_position_and_size_correctly() {
#[test]
fn mask_shorthand_should_parse_origin_and_clip_correctly() {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
let mut parser = Parser::new("padding-box content-box");
let result = mask::parse_value(&context, &mut parser).unwrap();
@ -104,7 +104,7 @@ fn mask_shorthand_should_parse_origin_and_clip_correctly() {
#[test]
fn mask_shorthand_should_not_parse_when_mode_specified_but_image_not() {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
let mut parser = Parser::new("luminance 7px 4px repeat-x padding");
assert!(mask::parse_value(&context, &mut parser).is_err());

View file

@ -36,7 +36,7 @@ macro_rules! assert_roundtrip_with_context {
assert_roundtrip_with_context!($fun, $string, $string);
};
($fun:expr,$input:expr, $output:expr) => {
let url = Url::parse("http://localhost").unwrap();
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
let mut parser = Parser::new($input);
let parsed = $fun(&context, &mut parser)
@ -55,7 +55,7 @@ macro_rules! assert_roundtrip_with_context {
macro_rules! parse_longhand {
($name:ident, $s:expr) => {{
let url = Url::parse("http://localhost").unwrap();
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
$name::parse(&context, &mut Parser::new($s)).unwrap()
}};

View file

@ -8,6 +8,7 @@ use media_queries::CSSErrorReporterTest;
use parking_lot::RwLock;
use selectors::parser::*;
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::sync::Arc;
use std::sync::Mutex;
@ -19,7 +20,6 @@ use style::properties::Importance;
use style::properties::longhands::animation_play_state;
use style::stylesheets::{Stylesheet, NamespaceRule, CssRule, StyleRule, KeyframesRule, Origin};
use style::values::specified::{LengthOrPercentageOrAuto, Percentage};
use url::Url;
#[test]
fn test_parse_stylesheet() {
@ -48,7 +48,7 @@ fn test_parse_stylesheet() {
animation-play-state: running; /* … except animation-play-state */
}
}";
let url = Url::parse("about::test").unwrap();
let url = ServoUrl::parse("about::test").unwrap();
let stylesheet = Stylesheet::from_str(css, url, Origin::UserAgent,
Box::new(CSSErrorReporterTest),
ParserContextExtraData::default());
@ -315,7 +315,7 @@ fn test_report_error_stylesheet() {
invalid: true;
}
";
let url = Url::parse("about::test").unwrap();
let url = ServoUrl::parse("about::test").unwrap();
let error_reporter = Box::new(CSSInvalidErrorReporterTest::new());
let errors = error_reporter.errors.clone();

View file

@ -6,6 +6,7 @@ use cssparser::Parser;
use euclid::scale_factor::ScaleFactor;
use euclid::size::TypedSize2D;
use media_queries::CSSErrorReporterTest;
use servo_url::ServoUrl;
use style::error_reporting::ParseErrorReporter;
use style::media_queries::{Device, MediaType};
use style::parser::{ParserContext, ParserContextExtraData};
@ -15,13 +16,12 @@ use style::values::specified::LengthOrPercentageOrAuto::{self, Auto};
use style::values::specified::ViewportPercentageLength::Vw;
use style::viewport::*;
use style_traits::viewport::*;
use url::Url;
macro_rules! stylesheet {
($css:expr, $origin:ident, $error_reporter:expr) => {
Box::new(Stylesheet::from_str(
$css,
Url::parse("http://localhost").unwrap(),
ServoUrl::parse("http://localhost").unwrap(),
Origin::$origin,
$error_reporter,
ParserContextExtraData::default()
@ -279,7 +279,7 @@ fn multiple_stylesheets_cascading() {
#[test]
fn constrain_viewport() {
let url = Url::parse("http://localhost").unwrap();
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
macro_rules! from_css {