mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Introduce ComputedUrl
Add web platform tests for computed URL styles Mark url with no original or resolved unreachable Update the WPT manifest for new url tests
This commit is contained in:
parent
f6aa17add9
commit
14c5a1b8d3
17 changed files with 197 additions and 46 deletions
|
@ -12,6 +12,7 @@ use std::fmt;
|
|||
// the threshold.
|
||||
use std::sync::Arc;
|
||||
use style_traits::{ToCss, ParseError};
|
||||
use values::computed::{Context, ToComputedValue, ComputedUrl};
|
||||
|
||||
/// A specified url() value for servo.
|
||||
///
|
||||
|
@ -126,3 +127,35 @@ impl ToCss for SpecifiedUrl {
|
|||
dest.write_str(")")
|
||||
}
|
||||
}
|
||||
|
||||
impl ToComputedValue for SpecifiedUrl {
|
||||
type ComputedValue = ComputedUrl;
|
||||
|
||||
// If we can't resolve the URL from the specified one, we fall back to the original
|
||||
// but still return it as a ComputedUrl::Invalid
|
||||
fn to_computed_value(&self, _: &Context) -> Self::ComputedValue {
|
||||
match self.resolved {
|
||||
Some(ref url) => ComputedUrl::Valid(url.clone()),
|
||||
None => match self.original {
|
||||
Some(ref url) => ComputedUrl::Invalid(url.clone()),
|
||||
None => {
|
||||
unreachable!("Found specified url with neither resolved or original URI!");
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn from_computed_value(computed: &ComputedUrl) -> Self {
|
||||
match *computed {
|
||||
ComputedUrl::Valid(ref url) => SpecifiedUrl {
|
||||
original: None,
|
||||
resolved: Some(url.clone()),
|
||||
},
|
||||
ComputedUrl::Invalid(ref url) => SpecifiedUrl {
|
||||
original: Some(url.clone()),
|
||||
resolved: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue