Skip to content

Commit

Permalink
style: Change nscolor to StyleComplexColor.
Browse files Browse the repository at this point in the history
Bug: 1467622
Reviewed-by: xidorn
MozReview-Commit-ID: 1bbQzOoOuBe
  • Loading branch information
djg authored and emilio committed Jul 16, 2018
1 parent 6f9b47b commit a76f539
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
9 changes: 5 additions & 4 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -667,14 +667,14 @@ def set_gecko_property(ffi_name, expr):
SVGPaintKind::Color(color) => {
paint.mType = nsStyleSVGPaintType::eStyleSVGPaintType_Color;
unsafe {
*paint.mPaint.mColor.as_mut() = convert_rgba_to_nscolor(&color);
*paint.mPaint.mColor.as_mut() = color.into();
}
}
}

paint.mFallbackType = match fallback {
Some(Either::First(color)) => {
paint.mFallbackColor = convert_rgba_to_nscolor(&color);
paint.mFallbackColor = color.into();
nsStyleSVGFallbackType::eStyleSVGFallbackType_Color
},
Some(Either::Second(_)) => {
Expand Down Expand Up @@ -709,7 +709,7 @@ def set_gecko_property(ffi_name, expr):

let fallback = match paint.mFallbackType {
nsStyleSVGFallbackType::eStyleSVGFallbackType_Color => {
Some(Either::First(convert_nscolor_to_rgba(paint.mFallbackColor)))
Some(Either::First(paint.mFallbackColor.into()))
},
nsStyleSVGFallbackType::eStyleSVGFallbackType_None => {
Some(Either::Second(None_))
Expand All @@ -728,7 +728,8 @@ def set_gecko_property(ffi_name, expr):
})
}
nsStyleSVGPaintType::eStyleSVGPaintType_Color => {
unsafe { SVGPaintKind::Color(convert_nscolor_to_rgba(*paint.mPaint.mColor.as_ref())) }
let col = unsafe { *paint.mPaint.mColor.as_ref() };
SVGPaintKind::Color(col.into())
}
};
SVGPaint {
Expand Down
Expand Up @@ -29,7 +29,7 @@ use hash::FnvHashMap;
use super::ComputedValues;
use values::CSSFloat;
use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
use values::animated::color::RGBA as AnimatedRGBA;
use values::animated::color::Color as AnimatedColor;
use values::animated::effects::Filter as AnimatedFilter;
#[cfg(feature = "gecko")] use values::computed::TransitionProperty;
use values::computed::{Angle, CalcLengthOrPercentage};
Expand Down Expand Up @@ -2674,10 +2674,10 @@ impl ComputeSquaredDistance for ComputedTransform {
}

/// Animated SVGPaint
pub type IntermediateSVGPaint = SVGPaint<AnimatedRGBA, ComputedUrl>;
pub type IntermediateSVGPaint = SVGPaint<AnimatedColor, ComputedUrl>;

/// Animated SVGPaintKind
pub type IntermediateSVGPaintKind = SVGPaintKind<AnimatedRGBA, ComputedUrl>;
pub type IntermediateSVGPaintKind = SVGPaintKind<AnimatedColor, ComputedUrl>;

impl ToAnimatedZero for IntermediateSVGPaint {
#[inline]
Expand Down
7 changes: 4 additions & 3 deletions components/style/values/computed/svg.rs
Expand Up @@ -9,6 +9,7 @@ use values::RGBA;
use values::computed::{LengthOrPercentage, NonNegativeLength};
use values::computed::{NonNegativeLengthOrPercentage, NonNegativeNumber, Number};
use values::computed::Opacity;
use values::computed::color::Color;
use values::computed::url::ComputedUrl;
use values::generics::svg as generic;

Expand All @@ -17,9 +18,9 @@ pub use values::specified::SVGPaintOrder;
pub use values::specified::MozContextProperties;

/// Computed SVG Paint value
pub type SVGPaint = generic::SVGPaint<RGBA, ComputedUrl>;
pub type SVGPaint = generic::SVGPaint<Color, ComputedUrl>;
/// Computed SVG Paint Kind value
pub type SVGPaintKind = generic::SVGPaintKind<RGBA, ComputedUrl>;
pub type SVGPaintKind = generic::SVGPaintKind<Color, ComputedUrl>;

impl Default for SVGPaint {
fn default() -> Self {
Expand All @@ -33,7 +34,7 @@ impl Default for SVGPaint {
impl SVGPaint {
/// Opaque black color
pub fn black() -> Self {
let rgba = RGBA::from_floats(0., 0., 0., 1.);
let rgba = RGBA::from_floats(0., 0., 0., 1.).into();
SVGPaint {
kind: generic::SVGPaintKind::Color(rgba),
fallback: None,
Expand Down
6 changes: 3 additions & 3 deletions components/style/values/specified/svg.rs
Expand Up @@ -13,14 +13,14 @@ use values::CustomIdent;
use values::generics::svg as generic;
use values::specified::{LengthOrPercentage, NonNegativeLengthOrPercentage, NonNegativeNumber};
use values::specified::{Number, Opacity};
use values::specified::color::RGBAColor;
use values::specified::color::Color;
use values::specified::url::SpecifiedUrl;

/// Specified SVG Paint value
pub type SVGPaint = generic::SVGPaint<RGBAColor, SpecifiedUrl>;
pub type SVGPaint = generic::SVGPaint<Color, SpecifiedUrl>;

/// Specified SVG Paint Kind value
pub type SVGPaintKind = generic::SVGPaintKind<RGBAColor, SpecifiedUrl>;
pub type SVGPaintKind = generic::SVGPaintKind<Color, SpecifiedUrl>;

#[cfg(feature = "gecko")]
fn is_context_value_enabled() -> bool {
Expand Down

0 comments on commit a76f539

Please sign in to comment.