style: Change nscolor to StyleComplexColor in nsStyleGradientStop.

Bug: 1467379
Reviewed-by: xidorn
MozReview-Commit-ID: D9KQcv9uQ4S
This commit is contained in:
Dan Glastonbury 2018-06-07 15:55:26 +10:00 committed by Emilio Cobos Álvarez
parent 74189514fd
commit 4d255392f7
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
3 changed files with 14 additions and 22 deletions

View file

@ -9,7 +9,7 @@
#![allow(unsafe_code)] #![allow(unsafe_code)]
use app_units::Au; use app_units::Au;
use gecko::values::{convert_rgba_to_nscolor, GeckoStyleCoordConvertible}; use gecko::values::GeckoStyleCoordConvertible;
use gecko_bindings::bindings; use gecko_bindings::bindings;
use gecko_bindings::structs::{self, nsCSSUnit, nsStyleCoord_CalcValue}; use gecko_bindings::structs::{self, nsCSSUnit, nsStyleCoord_CalcValue};
use gecko_bindings::structs::{nsresult, SheetType, nsStyleImage}; use gecko_bindings::structs::{nsresult, SheetType, nsStyleImage};
@ -358,7 +358,7 @@ impl nsStyleImage {
match *item { match *item {
GradientItem::ColorStop(ref stop) => { GradientItem::ColorStop(ref stop) => {
gecko_stop.mColor = convert_rgba_to_nscolor(&stop.color); gecko_stop.mColor = stop.color.into();
gecko_stop.mIsInterpolationHint = false; gecko_stop.mIsInterpolationHint = false;
coord.set(stop.position); coord.set(stop.position);
}, },
@ -433,7 +433,6 @@ impl nsStyleImage {
} }
unsafe fn get_gradient(self: &nsStyleImage) -> Box<Gradient> { unsafe fn get_gradient(self: &nsStyleImage) -> Box<Gradient> {
use gecko::values::convert_nscolor_to_rgba;
use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_CORNER as CLOSEST_CORNER; use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_CORNER as CLOSEST_CORNER;
use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE as CLOSEST_SIDE; use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE as CLOSEST_SIDE;
use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER as FARTHEST_CORNER; use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER as FARTHEST_CORNER;
@ -601,7 +600,7 @@ impl nsStyleImage {
) )
} else { } else {
GradientItem::ColorStop(ColorStop { GradientItem::ColorStop(ColorStop {
color: convert_nscolor_to_rgba(stop.mColor), color: stop.mColor.into(),
position: LengthOrPercentage::from_gecko_style_coord(&stop.mLocation), position: LengthOrPercentage::from_gecko_style_coord(&stop.mLocation),
}) })
} }

View file

@ -7,12 +7,11 @@
//! //!
//! [image]: https://drafts.csswg.org/css-images/#image-values //! [image]: https://drafts.csswg.org/css-images/#image-values
use cssparser::RGBA;
use std::f32::consts::PI; use std::f32::consts::PI;
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss}; use style_traits::{CssWriter, ToCss};
use values::{Either, None_}; use values::{Either, None_};
use values::computed::{Angle, Context}; use values::computed::{Angle, Color, Context};
use values::computed::{Length, LengthOrPercentage, NumberOrPercentage, ToComputedValue}; use values::computed::{Length, LengthOrPercentage, NumberOrPercentage, ToComputedValue};
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use values::computed::Percentage; use values::computed::Percentage;
@ -32,7 +31,7 @@ pub type Image = generic::Image<Gradient, MozImageRect, ComputedImageUrl>;
/// Computed values for a CSS gradient. /// Computed values for a CSS gradient.
/// <https://drafts.csswg.org/css-images/#gradients> /// <https://drafts.csswg.org/css-images/#gradients>
pub type Gradient = pub type Gradient =
generic::Gradient<LineDirection, Length, LengthOrPercentage, Position, RGBA, Angle>; generic::Gradient<LineDirection, Length, LengthOrPercentage, Position, Color, Angle>;
/// A computed gradient kind. /// A computed gradient kind.
pub type GradientKind = pub type GradientKind =
@ -58,10 +57,10 @@ pub enum LineDirection {
pub type EndingShape = generic::EndingShape<Length, LengthOrPercentage>; pub type EndingShape = generic::EndingShape<Length, LengthOrPercentage>;
/// A computed gradient item. /// A computed gradient item.
pub type GradientItem = generic::GradientItem<RGBA, LengthOrPercentage>; pub type GradientItem = generic::GradientItem<Color, LengthOrPercentage>;
/// A computed color stop. /// A computed color stop.
pub type ColorStop = generic::ColorStop<RGBA, LengthOrPercentage>; pub type ColorStop = generic::ColorStop<Color, LengthOrPercentage>;
/// Computed values for `-moz-image-rect(...)`. /// Computed values for `-moz-image-rect(...)`.
pub type MozImageRect = generic::MozImageRect<NumberOrPercentage, ComputedImageUrl>; pub type MozImageRect = generic::MozImageRect<NumberOrPercentage, ComputedImageUrl>;

View file

@ -26,7 +26,7 @@ use values::generics::image::{self as generic, Circle, CompatMode, Ellipse, Shap
use values::generics::image::PaintWorklet; use values::generics::image::PaintWorklet;
use values::generics::position::Position as GenericPosition; use values::generics::position::Position as GenericPosition;
use values::specified::{Angle, Color, Length, LengthOrPercentage}; use values::specified::{Angle, Color, Length, LengthOrPercentage};
use values::specified::{Number, NumberOrPercentage, Percentage, RGBAColor}; use values::specified::{Number, NumberOrPercentage, Percentage};
use values::specified::position::{LegacyPosition, Position, PositionComponent, Side, X, Y}; use values::specified::position::{LegacyPosition, Position, PositionComponent, Side, X, Y};
use values::specified::url::SpecifiedImageUrl; use values::specified::url::SpecifiedImageUrl;
@ -41,19 +41,13 @@ pub type Image = generic::Image<Gradient, MozImageRect, SpecifiedImageUrl>;
/// <https://drafts.csswg.org/css-images/#gradients> /// <https://drafts.csswg.org/css-images/#gradients>
#[cfg(not(feature = "gecko"))] #[cfg(not(feature = "gecko"))]
pub type Gradient = pub type Gradient =
generic::Gradient<LineDirection, Length, LengthOrPercentage, Position, RGBAColor, Angle>; generic::Gradient<LineDirection, Length, LengthOrPercentage, Position, Color, Angle>;
/// Specified values for a CSS gradient. /// Specified values for a CSS gradient.
/// <https://drafts.csswg.org/css-images/#gradients> /// <https://drafts.csswg.org/css-images/#gradients>
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub type Gradient = generic::Gradient< pub type Gradient =
LineDirection, generic::Gradient<LineDirection, Length, LengthOrPercentage, GradientPosition, Color, Angle>;
Length,
LengthOrPercentage,
GradientPosition,
RGBAColor,
Angle,
>;
impl SpecifiedValueInfo for Gradient { impl SpecifiedValueInfo for Gradient {
const SUPPORTED_TYPES: u8 = CssType::GRADIENT; const SUPPORTED_TYPES: u8 = CssType::GRADIENT;
@ -121,10 +115,10 @@ pub enum GradientPosition {
pub type EndingShape = generic::EndingShape<Length, LengthOrPercentage>; pub type EndingShape = generic::EndingShape<Length, LengthOrPercentage>;
/// A specified gradient item. /// A specified gradient item.
pub type GradientItem = generic::GradientItem<RGBAColor, LengthOrPercentage>; pub type GradientItem = generic::GradientItem<Color, LengthOrPercentage>;
/// A computed color stop. /// A computed color stop.
pub type ColorStop = generic::ColorStop<RGBAColor, LengthOrPercentage>; pub type ColorStop = generic::ColorStop<Color, LengthOrPercentage>;
/// Specified values for `moz-image-rect` /// Specified values for `moz-image-rect`
/// -moz-image-rect(<uri>, top, right, bottom, left); /// -moz-image-rect(<uri>, top, right, bottom, left);
@ -957,7 +951,7 @@ impl Parse for ColorStop {
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
Ok(ColorStop { Ok(ColorStop {
color: RGBAColor::parse(context, input)?, color: Color::parse(context, input)?,
position: input.try(|i| LengthOrPercentage::parse(context, i)).ok(), position: input.try(|i| LengthOrPercentage::parse(context, i)).ok(),
}) })
} }