mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Split CssUrl from SpecifiedUrl for non-value URLs.
This commit is contained in:
parent
0090fbb3c8
commit
fa5d76c395
10 changed files with 86 additions and 47 deletions
|
@ -17,7 +17,7 @@ use std::fmt::{self, Write};
|
|||
use str::CssStringWriter;
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use stylesheets::CssRules;
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
use values::CssUrl;
|
||||
|
||||
#[derive(Debug)]
|
||||
/// A @-moz-document rule
|
||||
|
@ -75,7 +75,7 @@ impl DeepCloneWithLock for DocumentRule {
|
|||
pub enum UrlMatchingFunction {
|
||||
/// Exact URL matching function. It evaluates to true whenever the
|
||||
/// URL of the document being styled is exactly the URL given.
|
||||
Url(SpecifiedUrl),
|
||||
Url(CssUrl),
|
||||
/// URL prefix matching function. It evaluates to true whenever the
|
||||
/// URL of the document being styled has the argument to the
|
||||
/// function as an initial substring (which is true when the two
|
||||
|
@ -130,7 +130,7 @@ impl UrlMatchingFunction {
|
|||
input.parse_nested_block(|input| {
|
||||
Ok(UrlMatchingFunction::Regexp(input.expect_string()?.as_ref().to_owned()))
|
||||
})
|
||||
} else if let Ok(url) = input.try(|input| SpecifiedUrl::parse(context, input)) {
|
||||
} else if let Ok(url) = input.try(|input| CssUrl::parse(context, input)) {
|
||||
Ok(UrlMatchingFunction::Url(url))
|
||||
} else {
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::fmt::{self, Write};
|
|||
use str::CssStringWriter;
|
||||
use style_traits::{CssWriter, ToCss};
|
||||
use stylesheets::{StylesheetContents, StylesheetInDocument};
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
use values::CssUrl;
|
||||
|
||||
/// A sheet that is held from an import rule.
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -80,7 +80,7 @@ impl DeepCloneWithLock for ImportSheet {
|
|||
#[derive(Debug)]
|
||||
pub struct ImportRule {
|
||||
/// The `<url>` this `@import` rule is loading.
|
||||
pub url: SpecifiedUrl,
|
||||
pub url: CssUrl,
|
||||
|
||||
/// The stylesheet is always present.
|
||||
///
|
||||
|
|
|
@ -11,7 +11,7 @@ use parser::ParserContext;
|
|||
use servo_arc::Arc;
|
||||
use shared_lock::{Locked, SharedRwLock};
|
||||
use stylesheets::import_rule::ImportRule;
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
use values::CssUrl;
|
||||
|
||||
/// The stylesheet loader is the abstraction used to trigger network requests
|
||||
/// for `@import` rules.
|
||||
|
@ -20,7 +20,7 @@ pub trait StylesheetLoader {
|
|||
/// the constructed `@import` rule.
|
||||
fn request_stylesheet(
|
||||
&self,
|
||||
url: SpecifiedUrl,
|
||||
url: CssUrl,
|
||||
location: SourceLocation,
|
||||
context: &ParserContext,
|
||||
lock: &SharedRwLock,
|
||||
|
|
|
@ -28,10 +28,8 @@ use stylesheets::keyframes_rule::parse_keyframe_list;
|
|||
use stylesheets::stylesheet::Namespaces;
|
||||
use stylesheets::supports_rule::SupportsCondition;
|
||||
use stylesheets::viewport_rule;
|
||||
use values::CustomIdent;
|
||||
use values::KeyframesName;
|
||||
use values::{CssUrl, CustomIdent, KeyframesName};
|
||||
use values::computed::font::FamilyName;
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
/// The parser for the top-level rules in a stylesheet.
|
||||
pub struct TopLevelRuleParser<'a, R: 'a> {
|
||||
|
@ -134,7 +132,7 @@ pub enum AtRuleBlockPrelude {
|
|||
/// A rule prelude for at-rule without block.
|
||||
pub enum AtRuleNonBlockPrelude {
|
||||
/// A @import rule prelude.
|
||||
Import(SpecifiedUrl, Arc<Locked<MediaList>>, SourceLocation),
|
||||
Import(CssUrl, Arc<Locked<MediaList>>, SourceLocation),
|
||||
/// A @namespace rule prelude.
|
||||
Namespace(Option<Prefix>, Namespace, SourceLocation),
|
||||
}
|
||||
|
@ -174,13 +172,13 @@ impl<'a, 'i, R: ParseErrorReporter> AtRuleParser<'i> for TopLevelRuleParser<'a,
|
|||
}
|
||||
|
||||
let url_string = input.expect_url_or_string()?.as_ref().to_owned();
|
||||
let specified_url = SpecifiedUrl::parse_from_string(url_string, &self.context)?;
|
||||
let url = CssUrl::parse_from_string(url_string, &self.context)?;
|
||||
|
||||
let media = parse_media_query_list(&self.context, input,
|
||||
self.error_context.error_reporter);
|
||||
let media = Arc::new(self.shared_lock.wrap(media));
|
||||
|
||||
let prelude = AtRuleNonBlockPrelude::Import(specified_url, media, location);
|
||||
let prelude = AtRuleNonBlockPrelude::Import(url, media, location);
|
||||
return Ok(AtRuleType::WithoutBlock(prelude));
|
||||
},
|
||||
"namespace" => {
|
||||
|
@ -228,12 +226,12 @@ impl<'a, 'i, R: ParseErrorReporter> AtRuleParser<'i> for TopLevelRuleParser<'a,
|
|||
#[inline]
|
||||
fn rule_without_block(&mut self, prelude: AtRuleNonBlockPrelude) -> CssRule {
|
||||
match prelude {
|
||||
AtRuleNonBlockPrelude::Import(specified_url, media, location) => {
|
||||
AtRuleNonBlockPrelude::Import(url, media, location) => {
|
||||
let loader =
|
||||
self.loader.expect("Expected a stylesheet loader for @import");
|
||||
|
||||
let import_rule = loader.request_stylesheet(
|
||||
specified_url,
|
||||
url,
|
||||
location,
|
||||
&self.context,
|
||||
&self.shared_lock,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue