aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/servo/url.rs
diff options
context:
space:
mode:
authorXidorn Quan <me@upsuper.org>2018-03-08 21:31:09 +1100
committerXidorn Quan <me@upsuper.org>2018-03-08 23:34:34 +1100
commitfa5d76c395684e0569e6512b0f1037f02da3e85c (patch)
tree840ff7a4ceaf53dc2bac8587151ef7e0e5a1e4e4 /components/style/servo/url.rs
parent0090fbb3c8278b2616e9dd164dd932740d879d91 (diff)
downloadservo-fa5d76c395684e0569e6512b0f1037f02da3e85c.tar.gz
servo-fa5d76c395684e0569e6512b0f1037f02da3e85c.zip
Split CssUrl from SpecifiedUrl for non-value URLs.
Diffstat (limited to 'components/style/servo/url.rs')
-rw-r--r--components/style/servo/url.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/components/style/servo/url.rs b/components/style/servo/url.rs
index fc461955cea..67b884c2bea 100644
--- a/components/style/servo/url.rs
+++ b/components/style/servo/url.rs
@@ -15,7 +15,7 @@ use std::sync::Arc;
use style_traits::{CssWriter, ParseError, ToCss};
use values::computed::{Context, ToComputedValue};
-/// A specified url() value for servo.
+/// A CSS url() value for servo.
///
/// Servo eagerly resolves SpecifiedUrls, which it can then take advantage of
/// when computing values. In contrast, Gecko uses a different URL backend, so
@@ -24,7 +24,7 @@ use values::computed::{Context, ToComputedValue};
/// However, this approach is still not necessarily optimal: See
/// <https://bugzilla.mozilla.org/show_bug.cgi?id=1347435#c6>
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
-pub struct SpecifiedUrl {
+pub struct CssUrl {
/// The original URI. This might be optional since we may insert computed
/// values of images into the cascade directly, and we don't bother to
/// convert their serialization.
@@ -38,7 +38,7 @@ pub struct SpecifiedUrl {
resolved: Option<ServoUrl>,
}
-impl SpecifiedUrl {
+impl CssUrl {
/// Try to parse a URL from a string value that is a valid CSS token for a
/// URL. Never fails - the API is only fallible to be compatible with the
/// gecko version.
@@ -47,7 +47,7 @@ impl SpecifiedUrl {
-> Result<Self, ParseError<'a>> {
let serialization = Arc::new(url);
let resolved = context.url_data.join(&serialization).ok();
- Ok(SpecifiedUrl {
+ Ok(CssUrl {
original: Some(serialization),
resolved: resolved,
})
@@ -88,7 +88,7 @@ impl SpecifiedUrl {
/// Creates an already specified url value from an already resolved URL
/// for insertion in the cascade.
pub fn for_cascade(url: ServoUrl) -> Self {
- SpecifiedUrl {
+ CssUrl {
original: None,
resolved: Some(url),
}
@@ -96,21 +96,21 @@ impl SpecifiedUrl {
/// Gets a new url from a string for unit tests.
pub fn new_for_testing(url: &str) -> Self {
- SpecifiedUrl {
+ CssUrl {
original: Some(Arc::new(url.into())),
resolved: ServoUrl::parse(url).ok(),
}
}
}
-impl Parse for SpecifiedUrl {
+impl Parse for CssUrl {
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
let url = input.expect_url()?;
Self::parse_from_string(url.as_ref().to_owned(), context)
}
}
-impl PartialEq for SpecifiedUrl {
+impl PartialEq for CssUrl {
fn eq(&self, other: &Self) -> bool {
// TODO(emilio): maybe we care about equality of the specified values if
// present? Seems not.
@@ -118,9 +118,9 @@ impl PartialEq for SpecifiedUrl {
}
}
-impl Eq for SpecifiedUrl {}
+impl Eq for CssUrl {}
-impl ToCss for SpecifiedUrl {
+impl ToCss for CssUrl {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
@@ -142,6 +142,9 @@ impl ToCss for SpecifiedUrl {
}
}
+/// A specified url() value for servo.
+pub type SpecifiedUrl = CssUrl;
+
impl ToComputedValue for SpecifiedUrl {
type ComputedValue = ComputedUrl;
@@ -174,7 +177,7 @@ impl ToComputedValue for SpecifiedUrl {
}
/// A specified image url() value for servo.
-pub type SpecifiedImageUrl = SpecifiedUrl;
+pub type SpecifiedImageUrl = CssUrl;
/// The computed value of a CSS `url()`, resolved relative to the stylesheet URL.
#[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]