aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/layout/display_list_builder.rs2
-rw-r--r--components/script/dom/element.rs3
-rw-r--r--components/style/properties/gecko.mako.rs2
-rw-r--r--components/style/properties/longhand/background.mako.rs2
-rw-r--r--components/style/properties/longhand/box.mako.rs9
-rw-r--r--components/style/values.rs66
6 files changed, 64 insertions, 20 deletions
diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs
index 8d036dfc90e..58ff6d23e44 100644
--- a/components/layout/display_list_builder.rs
+++ b/components/layout/display_list_builder.rs
@@ -398,7 +398,7 @@ impl FragmentDisplayListBuilding for Fragment {
gradient,
style);
}
- Some(computed::Image::Url(ref image_url)) => {
+ Some(computed::Image::Url(ref image_url, ref _extra_data)) => {
self.build_display_list_for_background_image(state,
style,
display_list_section,
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index a4c1ed28583..ae3c31d151c 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -347,7 +347,8 @@ impl LayoutElementHelpers for LayoutJS<Element> {
if let Some(url) = background {
hints.push(from_declaration(
PropertyDeclaration::BackgroundImage(DeclaredValue::Value(
- background_image::SpecifiedValue(Some(specified::Image::Url(url)))))));
+ background_image::SpecifiedValue(Some(
+ specified::Image::Url(url, specified::UrlExtraData { })))))));
}
let color = if let Some(this) = self.downcast::<HTMLFontElement>() {
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index 56aa317d5ee..d4dfa3bc853 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -1097,7 +1097,7 @@ fn static_assert() {
Gecko_SetGradientImageValue(&mut geckoimage.mImage, gecko_gradient);
}
},
- Image::Url(_) => {
+ Image::Url(..) => {
// let utf8_bytes = url.as_bytes();
// Gecko_SetUrlImageValue(&mut self.gecko.mImage.mLayers.mFirstElement,
// utf8_bytes.as_ptr() as *const _,
diff --git a/components/style/properties/longhand/background.mako.rs b/components/style/properties/longhand/background.mako.rs
index f5708c5ede8..501a98fd7fa 100644
--- a/components/style/properties/longhand/background.mako.rs
+++ b/components/style/properties/longhand/background.mako.rs
@@ -28,7 +28,7 @@ ${helpers.predefined_type("background-color", "CSSColor",
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match self.0 {
None => dest.write_str("none"),
- Some(computed::Image::Url(ref url)) => url.to_css(dest),
+ Some(computed::Image::Url(ref url, ref _extra_data)) => url.to_css(dest),
Some(computed::Image::LinearGradient(ref gradient)) =>
gradient.to_css(dest)
}
diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs
index 87af34df33e..a00f0c01393 100644
--- a/components/style/properties/longhand/box.mako.rs
+++ b/components/style/properties/longhand/box.mako.rs
@@ -914,19 +914,12 @@ ${helpers.single_keyword("-moz-appearance",
use gecko_bindings::ptr::{GeckoArcPrincipal, GeckoArcURI};
use std::fmt::{self, Write};
use url::Url;
+ use values::specified::UrlExtraData;
use values::computed::ComputedValueAsSpecified;
use values::NoViewportPercentage;
#[derive(PartialEq, Clone, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
- pub struct UrlExtraData {
- pub base: GeckoArcURI,
- pub referrer: GeckoArcURI,
- pub principal: GeckoArcPrincipal,
- }
-
- #[derive(PartialEq, Clone, Debug)]
- #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue {
Url(Url, UrlExtraData),
None,
diff --git a/components/style/values.rs b/components/style/values.rs
index 35063977aa6..f3e7682de08 100644
--- a/components/style/values.rs
+++ b/components/style/values.rs
@@ -98,7 +98,9 @@ pub mod specified {
use app_units::Au;
use cssparser::{self, Parser, ToCss, Token};
use euclid::size::Size2D;
- use parser::ParserContext;
+ #[cfg(feature = "gecko")]
+ use gecko_bindings::ptr::{GeckoArcPrincipal, GeckoArcURI};
+ use parser::{ParserContext, ParserContextExtraData};
use std::ascii::AsciiExt;
use std::cmp;
use std::f32::consts::PI;
@@ -1317,11 +1319,47 @@ pub mod specified {
}
}
+ #[derive(PartialEq, Clone, Debug)]
+ #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
+ pub struct UrlExtraData {
+ #[cfg(feature = "gecko")]
+ pub base: GeckoArcURI,
+ #[cfg(feature = "gecko")]
+ pub referrer: GeckoArcURI,
+ #[cfg(feature = "gecko")]
+ pub principal: GeckoArcPrincipal,
+ }
+
+ impl UrlExtraData {
+ #[cfg(feature = "servo")]
+ pub fn make_from(content: &ParserContext) -> Option<UrlExtraData> {
+ Some(UrlExtraData { })
+ }
+
+ #[cfg(feature = "gecko")]
+ pub fn make_from(context: &ParserContext) -> Option<UrlExtraData> {
+ match context.extra_data {
+ ParserContextExtraData {
+ base: Some(ref base),
+ referrer: Some(ref referrer),
+ principal: Some(ref principal),
+ } => {
+ Some(UrlExtraData {
+ base: base.clone(),
+ referrer: referrer.clone(),
+ principal: principal.clone(),
+ })
+ },
+ _ => None,
+ }
+ }
+ }
+
/// Specified values for an image according to CSS-IMAGES.
#[derive(Clone, PartialEq, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum Image {
- Url(Url),
+ Url(Url, UrlExtraData),
LinearGradient(LinearGradient),
}
@@ -1329,7 +1367,7 @@ pub mod specified {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
use values::LocalToCss;
match *self {
- Image::Url(ref url) => {
+ Image::Url(ref url, ref _extra_data) => {
url.to_css(dest)
}
Image::LinearGradient(ref gradient) => gradient.to_css(dest)
@@ -1340,7 +1378,17 @@ pub mod specified {
impl Image {
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<Image, ()> {
if let Ok(url) = input.try(|input| input.expect_url()) {
- Ok(Image::Url(context.parse_url(&url)))
+ match UrlExtraData::make_from(context) {
+ Some(extra_data) => {
+ Ok(Image::Url(context.parse_url(&url), extra_data))
+ },
+ None => {
+ // FIXME(heycam) should ensure we always have a principal, etc., when
+ // parsing style attributes and re-parsing due to CSS Variables.
+ println!("stylo: skipping declaration without ParserContextExtraData");
+ Err(())
+ },
+ }
} else {
match_ignore_ascii_case! { try!(input.expect_function()),
"linear-gradient" => {
@@ -1664,7 +1712,7 @@ pub mod computed {
use super::{CSSFloat, specified};
use url::Url;
pub use cssparser::Color as CSSColor;
- pub use super::specified::{Angle, BorderStyle, Time};
+ pub use super::specified::{Angle, BorderStyle, Time, UrlExtraData};
pub struct Context<'a> {
pub is_root_element: bool,
@@ -2164,7 +2212,9 @@ pub mod computed {
#[inline]
fn to_computed_value(&self, context: &Context) -> Image {
match *self {
- specified::Image::Url(ref url) => Image::Url(url.clone()),
+ specified::Image::Url(ref url, ref extra_data) => {
+ Image::Url(url.clone(), extra_data.clone())
+ },
specified::Image::LinearGradient(ref linear_gradient) => {
Image::LinearGradient(linear_gradient.to_computed_value(context))
}
@@ -2177,14 +2227,14 @@ pub mod computed {
#[derive(Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum Image {
- Url(Url),
+ Url(Url, UrlExtraData),
LinearGradient(LinearGradient),
}
impl fmt::Debug for Image {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
- Image::Url(ref url) => write!(f, "url(\"{}\")", url),
+ Image::Url(ref url, ref _extra_data) => write!(f, "url(\"{}\")", url),
Image::LinearGradient(ref grad) => write!(f, "linear-gradient({:?})", grad),
}
}