Use a UrlExtraData type alias to unify url handling logic.

This commit is contained in:
Xidorn Quan 2017-04-03 21:17:13 +10:00
parent a097a293b5
commit 37585309e9
24 changed files with 166 additions and 272 deletions

View file

@ -19,7 +19,6 @@ use dom_struct::dom_struct;
use servo_atoms::Atom;
use std::sync::Arc;
use style::keyframes::{Keyframe, KeyframeSelector};
use style::parser::ParserContextExtraData;
use style::shared_lock::{Locked, ToCssWithGuard};
use style::stylesheets::KeyframesRule;
@ -83,8 +82,7 @@ impl CSSKeyframesRuleMethods for CSSKeyframesRule {
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-appendrule
fn AppendRule(&self, rule: DOMString) {
let rule = Keyframe::parse(&rule, self.cssrule.parent_stylesheet().style_stylesheet(),
ParserContextExtraData::default());
let rule = Keyframe::parse(&rule, self.cssrule.parent_stylesheet().style_stylesheet());
if let Ok(rule) = rule {
let mut guard = self.cssrule.shared_lock().write();
self.keyframesrule.write_with(&mut guard).keyframes.push(rule);

View file

@ -18,7 +18,6 @@ use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::sync::Arc;
use style::attr::AttrValue;
use style::parser::ParserContextExtraData;
use style::properties::{Importance, PropertyDeclarationBlock, PropertyId, LonghandId, ShorthandId};
use style::properties::{parse_one_declaration, parse_style_attribute};
use style::selector_parser::PseudoElement;
@ -147,7 +146,7 @@ impl CSSStyleOwner {
match *self {
CSSStyleOwner::Element(ref el) => window_from_node(&**el).Document().base_url(),
CSSStyleOwner::CSSRule(ref rule, _) => {
rule.parent_stylesheet().style_stylesheet().base_url.clone()
rule.parent_stylesheet().style_stylesheet().url_data.clone()
}
}
}
@ -258,8 +257,7 @@ impl CSSStyleDeclaration {
let window = self.owner.window();
let result =
parse_one_declaration(id, &value, &self.owner.base_url(),
window.css_error_reporter(),
ParserContextExtraData::default());
window.css_error_reporter());
// Step 7
let parsed = match result {
@ -439,8 +437,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
// Step 3
*pdb = parse_style_attribute(&value,
&self.owner.base_url(),
window.css_error_reporter(),
ParserContextExtraData::default());
window.css_error_reporter());
});
Ok(())

View file

@ -101,7 +101,6 @@ use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use style::context::{QuirksMode, ReflowGoal};
use style::element_state::*;
use style::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
use style::parser::ParserContextExtraData;
use style::properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute};
use style::properties::longhands::{self, background_image, border_spacing, font_family, font_size, overflow_x};
use style::restyle_hints::RESTYLE_SELF;
@ -2197,8 +2196,7 @@ impl VirtualMethods for Element {
Arc::new(doc.style_shared_lock().wrap(parse_style_attribute(
&attr.value(),
&doc.base_url(),
win.css_error_reporter(),
ParserContextExtraData::default())))
win.css_error_reporter())))
};
Some(block)

View file

@ -105,7 +105,7 @@ impl HTMLMetaElement {
rules: CssRules::new(vec![rule], shared_lock),
origin: Origin::Author,
shared_lock: shared_lock.clone(),
base_url: window_from_node(self).get_url(),
url_data: window_from_node(self).get_url(),
namespaces: Default::default(),
media: Arc::new(shared_lock.wrap(Default::default())),
// Viewport constraints are always recomputed on resize; they don't need to

View file

@ -25,7 +25,6 @@ use script_layout_interface::message::Msg;
use std::cell::Cell;
use std::sync::Arc;
use style::media_queries::parse_media_query_list;
use style::parser::ParserContextExtraData;
use style::stylesheets::{Stylesheet, Origin};
use stylesheet_loader::{StylesheetLoader, StylesheetOwner};
@ -88,8 +87,7 @@ impl HTMLStyleElement {
let loader = StylesheetLoader::for_element(self.upcast());
let sheet = Stylesheet::from_str(&data, url, Origin::Author, mq,
shared_lock, Some(&loader),
win.css_error_reporter(),
ParserContextExtraData::default());
win.css_error_reporter());
let sheet = Arc::new(sheet);

View file

@ -27,7 +27,6 @@ use servo_url::ServoUrl;
use std::mem;
use std::sync::{Arc, Mutex};
use style::media_queries::MediaList;
use style::parser::ParserContextExtraData;
use style::shared_lock::Locked as StyleLocked;
use style::stylesheets::{ImportRule, Stylesheet, Origin};
use style::stylesheets::StylesheetLoader as StyleStylesheetLoader;
@ -146,8 +145,7 @@ impl FetchResponseListener for StylesheetContext {
media.take().unwrap(),
shared_lock,
Some(&loader),
win.css_error_reporter(),
ParserContextExtraData::default()));
win.css_error_reporter()));
if link.is_alternate() {
sheet.set_disabled(true);
@ -164,8 +162,7 @@ impl FetchResponseListener for StylesheetContext {
protocol_encoding_label,
Some(environment_encoding),
Some(&loader),
win.css_error_reporter(),
ParserContextExtraData::default());
win.css_error_reporter());
}
}