mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
servo: Merge #18136 - Use Option<RGBA> for color in shadow (from upsuper:shadow-color); r=emilio
This fixes [bug 1390697](https://bugzilla.mozilla.org/show_bug.cgi?id=1390697) by downgrading the support of currentcolor in shadow to what Gecko currently supports. Source-Repo: https://github.com/servo/servo Source-Revision: 0b45a4f65174a436986c9bfd0ef99a629ab569b3 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : b8857843ec4f8c44237e77d0d772b0352bbd913d
This commit is contained in:
parent
a7240d8532
commit
5576112e59
@ -1411,7 +1411,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||
state.add_display_item(DisplayItem::BoxShadow(box BoxShadowDisplayItem {
|
||||
base: base,
|
||||
box_bounds: *absolute_bounds,
|
||||
color: style.resolve_color(box_shadow.base.color).to_gfx_color(),
|
||||
color: box_shadow.base.color.unwrap_or(style.get_color().color).to_gfx_color(),
|
||||
offset: Vector2D::new(box_shadow.base.horizontal, box_shadow.base.vertical),
|
||||
blur_radius: box_shadow.base.blur.0,
|
||||
spread_radius: box_shadow.spread,
|
||||
@ -2133,7 +2133,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||
base: base.clone(),
|
||||
blur_radius: shadow.blur.0,
|
||||
offset: Vector2D::new(shadow.horizontal, shadow.vertical),
|
||||
color: self.style().resolve_color(shadow.color).to_gfx_color(),
|
||||
color: shadow.color.unwrap_or(self.style().get_color().color).to_gfx_color(),
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
use app_units::Au;
|
||||
use gecko::values::{convert_rgba_to_nscolor, convert_nscolor_to_rgba};
|
||||
use gecko_bindings::structs::nsCSSShadowItem;
|
||||
use values::computed::Color;
|
||||
use values::computed::RGBAColor;
|
||||
use values::computed::effects::{BoxShadow, SimpleShadow};
|
||||
|
||||
impl nsCSSShadowItem {
|
||||
@ -37,23 +37,23 @@ impl nsCSSShadowItem {
|
||||
self.mRadius = shadow.blur.value();
|
||||
self.mSpread = 0;
|
||||
self.mInset = false;
|
||||
if shadow.color.is_currentcolor() {
|
||||
if let Some(color) = shadow.color {
|
||||
self.mHasColor = true;
|
||||
self.mColor = convert_rgba_to_nscolor(&color);
|
||||
} else {
|
||||
// TODO handle currentColor
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=760345
|
||||
self.mHasColor = false;
|
||||
self.mColor = 0;
|
||||
} else {
|
||||
self.mHasColor = true;
|
||||
self.mColor = convert_rgba_to_nscolor(&shadow.color.color);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn extract_color(&self) -> Color {
|
||||
fn extract_color(&self) -> Option<RGBAColor> {
|
||||
if self.mHasColor {
|
||||
Color::rgba(convert_nscolor_to_rgba(self.mColor))
|
||||
Some(convert_nscolor_to_rgba(self.mColor))
|
||||
} else {
|
||||
Color::currentcolor()
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ use std::cmp;
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
use values::Impossible;
|
||||
use values::animated::{ToAnimatedValue, ToAnimatedZero};
|
||||
use values::animated::color::Color;
|
||||
use values::animated::color::RGBA;
|
||||
use values::computed::{Angle, NonNegativeNumber};
|
||||
use values::computed::length::{Length, NonNegativeLength};
|
||||
use values::distance::{ComputeSquaredDistance, SquaredDistance};
|
||||
@ -34,7 +34,7 @@ pub type TextShadowList = ShadowList<SimpleShadow>;
|
||||
pub struct ShadowList<Shadow>(Vec<Shadow>);
|
||||
|
||||
/// An animated value for a single `box-shadow`.
|
||||
pub type BoxShadow = GenericBoxShadow<Color, Length, NonNegativeLength, Length>;
|
||||
pub type BoxShadow = GenericBoxShadow<Option<RGBA>, Length, NonNegativeLength, Length>;
|
||||
|
||||
/// An animated value for the `filter` property.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
@ -50,7 +50,7 @@ pub type Filter = GenericFilter<Angle, NonNegativeNumber, NonNegativeLength, Sim
|
||||
pub type Filter = GenericFilter<Angle, NonNegativeNumber, NonNegativeLength, Impossible>;
|
||||
|
||||
/// An animated value for the `drop-shadow()` filter.
|
||||
pub type SimpleShadow = GenericSimpleShadow<Color, Length, NonNegativeLength>;
|
||||
pub type SimpleShadow = GenericSimpleShadow<Option<RGBA>, Length, NonNegativeLength>;
|
||||
|
||||
impl ToAnimatedValue for ComputedBoxShadowList {
|
||||
type AnimatedValue = BoxShadowList;
|
||||
@ -245,7 +245,7 @@ impl ToAnimatedZero for SimpleShadow {
|
||||
#[inline]
|
||||
fn to_animated_zero(&self) -> Result<Self, ()> {
|
||||
Ok(SimpleShadow {
|
||||
color: Color::transparent(),
|
||||
color: Some(RGBA::transparent()),
|
||||
horizontal: self.horizontal.to_animated_zero()?,
|
||||
vertical: self.vertical.to_animated_zero()?,
|
||||
blur: self.blur.to_animated_zero()?,
|
||||
|
@ -7,14 +7,14 @@
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
use values::Impossible;
|
||||
use values::computed::{Angle, NonNegativeNumber};
|
||||
use values::computed::color::Color;
|
||||
use values::computed::color::RGBAColor;
|
||||
use values::computed::length::{Length, NonNegativeLength};
|
||||
use values::generics::effects::BoxShadow as GenericBoxShadow;
|
||||
use values::generics::effects::Filter as GenericFilter;
|
||||
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
|
||||
|
||||
/// A computed value for a single shadow of the `box-shadow` property.
|
||||
pub type BoxShadow = GenericBoxShadow<Color, Length, NonNegativeLength, Length>;
|
||||
pub type BoxShadow = GenericBoxShadow<Option<RGBAColor>, Length, NonNegativeLength, Length>;
|
||||
|
||||
/// A computed value for a single `filter`.
|
||||
#[cfg(feature = "gecko")]
|
||||
@ -25,4 +25,4 @@ pub type Filter = GenericFilter<Angle, NonNegativeNumber, NonNegativeLength, Sim
|
||||
pub type Filter = GenericFilter<Angle, NonNegativeNumber, NonNegativeLength, Impossible>;
|
||||
|
||||
/// A computed value for the `drop-shadow()` filter.
|
||||
pub type SimpleShadow = GenericSimpleShadow<Color, Length, NonNegativeLength>;
|
||||
pub type SimpleShadow = GenericSimpleShadow<Option<RGBAColor>, Length, NonNegativeLength>;
|
||||
|
@ -17,13 +17,14 @@ use values::generics::effects::BoxShadow as GenericBoxShadow;
|
||||
use values::generics::effects::Filter as GenericFilter;
|
||||
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
|
||||
use values::specified::{Angle, NumberOrPercentage};
|
||||
use values::specified::color::Color;
|
||||
use values::specified::color::RGBAColor;
|
||||
use values::specified::length::{Length, NonNegativeLength};
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
/// A specified value for a single shadow of the `box-shadow` property.
|
||||
pub type BoxShadow = GenericBoxShadow<Option<Color>, Length, Option<NonNegativeLength>, Option<Length>>;
|
||||
pub type BoxShadow = GenericBoxShadow<Option<RGBAColor>, Length,
|
||||
Option<NonNegativeLength>, Option<Length>>;
|
||||
|
||||
/// A specified value for a single `filter`.
|
||||
#[cfg(feature = "gecko")]
|
||||
@ -67,7 +68,7 @@ impl ToComputedValue for Factor {
|
||||
}
|
||||
|
||||
/// A specified value for the `drop-shadow()` filter.
|
||||
pub type SimpleShadow = GenericSimpleShadow<Option<Color>, Length, Option<NonNegativeLength>>;
|
||||
pub type SimpleShadow = GenericSimpleShadow<Option<RGBAColor>, Length, Option<NonNegativeLength>>;
|
||||
|
||||
impl Parse for BoxShadow {
|
||||
fn parse<'i, 't>(
|
||||
@ -104,7 +105,7 @@ impl Parse for BoxShadow {
|
||||
}
|
||||
}
|
||||
if color.is_none() {
|
||||
if let Ok(value) = input.try(|i| Color::parse(context, i)) {
|
||||
if let Ok(value) = input.try(|i| RGBAColor::parse(context, i)) {
|
||||
color = Some(value);
|
||||
continue;
|
||||
}
|
||||
@ -184,11 +185,11 @@ impl Parse for SimpleShadow {
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let color = input.try(|i| Color::parse(context, i)).ok();
|
||||
let color = input.try(|i| RGBAColor::parse(context, i)).ok();
|
||||
let horizontal = Length::parse(context, input)?;
|
||||
let vertical = Length::parse(context, input)?;
|
||||
let blur = input.try(|i| Length::parse_non_negative(context, i)).ok();
|
||||
let color = color.or_else(|| input.try(|i| Color::parse(context, i)).ok());
|
||||
let color = color.or_else(|| input.try(|i| RGBAColor::parse(context, i)).ok());
|
||||
Ok(SimpleShadow {
|
||||
color: color,
|
||||
horizontal: horizontal,
|
||||
@ -204,8 +205,7 @@ impl ToComputedValue for SimpleShadow {
|
||||
#[inline]
|
||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||
ComputedSimpleShadow {
|
||||
color:
|
||||
self.color.as_ref().unwrap_or(&Color::CurrentColor).to_computed_value(context),
|
||||
color: self.color.to_computed_value(context),
|
||||
horizontal: self.horizontal.to_computed_value(context),
|
||||
vertical: self.vertical.to_computed_value(context),
|
||||
blur:
|
||||
@ -216,7 +216,7 @@ impl ToComputedValue for SimpleShadow {
|
||||
#[inline]
|
||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||
SimpleShadow {
|
||||
color: Some(ToComputedValue::from_computed_value(&computed.color)),
|
||||
color: ToComputedValue::from_computed_value(&computed.color),
|
||||
horizontal: ToComputedValue::from_computed_value(&computed.horizontal),
|
||||
vertical: ToComputedValue::from_computed_value(&computed.vertical),
|
||||
blur: Some(ToComputedValue::from_computed_value(&computed.blur)),
|
||||
|
Loading…
Reference in New Issue
Block a user