mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Auto merge of #18136 - upsuper:shadow-color, r=emilio
Use Option<RGBA> for color in shadow 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. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18136) <!-- Reviewable:end -->
This commit is contained in:
commit
0b45a4f651
5 changed files with 26 additions and 26 deletions
|
@ -1411,7 +1411,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
state.add_display_item(DisplayItem::BoxShadow(box BoxShadowDisplayItem {
|
state.add_display_item(DisplayItem::BoxShadow(box BoxShadowDisplayItem {
|
||||||
base: base,
|
base: base,
|
||||||
box_bounds: *absolute_bounds,
|
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),
|
offset: Vector2D::new(box_shadow.base.horizontal, box_shadow.base.vertical),
|
||||||
blur_radius: box_shadow.base.blur.0,
|
blur_radius: box_shadow.base.blur.0,
|
||||||
spread_radius: box_shadow.spread,
|
spread_radius: box_shadow.spread,
|
||||||
|
@ -2133,7 +2133,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
base: base.clone(),
|
base: base.clone(),
|
||||||
blur_radius: shadow.blur.0,
|
blur_radius: shadow.blur.0,
|
||||||
offset: Vector2D::new(shadow.horizontal, shadow.vertical),
|
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 app_units::Au;
|
||||||
use gecko::values::{convert_rgba_to_nscolor, convert_nscolor_to_rgba};
|
use gecko::values::{convert_rgba_to_nscolor, convert_nscolor_to_rgba};
|
||||||
use gecko_bindings::structs::nsCSSShadowItem;
|
use gecko_bindings::structs::nsCSSShadowItem;
|
||||||
use values::computed::Color;
|
use values::computed::RGBAColor;
|
||||||
use values::computed::effects::{BoxShadow, SimpleShadow};
|
use values::computed::effects::{BoxShadow, SimpleShadow};
|
||||||
|
|
||||||
impl nsCSSShadowItem {
|
impl nsCSSShadowItem {
|
||||||
|
@ -37,23 +37,23 @@ impl nsCSSShadowItem {
|
||||||
self.mRadius = shadow.blur.value();
|
self.mRadius = shadow.blur.value();
|
||||||
self.mSpread = 0;
|
self.mSpread = 0;
|
||||||
self.mInset = false;
|
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
|
// TODO handle currentColor
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=760345
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=760345
|
||||||
self.mHasColor = false;
|
self.mHasColor = false;
|
||||||
self.mColor = 0;
|
self.mColor = 0;
|
||||||
} else {
|
|
||||||
self.mHasColor = true;
|
|
||||||
self.mColor = convert_rgba_to_nscolor(&shadow.color.color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn extract_color(&self) -> Color {
|
fn extract_color(&self) -> Option<RGBAColor> {
|
||||||
if self.mHasColor {
|
if self.mHasColor {
|
||||||
Color::rgba(convert_nscolor_to_rgba(self.mColor))
|
Some(convert_nscolor_to_rgba(self.mColor))
|
||||||
} else {
|
} else {
|
||||||
Color::currentcolor()
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use std::cmp;
|
||||||
#[cfg(not(feature = "gecko"))]
|
#[cfg(not(feature = "gecko"))]
|
||||||
use values::Impossible;
|
use values::Impossible;
|
||||||
use values::animated::{ToAnimatedValue, ToAnimatedZero};
|
use values::animated::{ToAnimatedValue, ToAnimatedZero};
|
||||||
use values::animated::color::Color;
|
use values::animated::color::RGBA;
|
||||||
use values::computed::{Angle, NonNegativeNumber};
|
use values::computed::{Angle, NonNegativeNumber};
|
||||||
use values::computed::length::{Length, NonNegativeLength};
|
use values::computed::length::{Length, NonNegativeLength};
|
||||||
use values::distance::{ComputeSquaredDistance, SquaredDistance};
|
use values::distance::{ComputeSquaredDistance, SquaredDistance};
|
||||||
|
@ -34,7 +34,7 @@ pub type TextShadowList = ShadowList<SimpleShadow>;
|
||||||
pub struct ShadowList<Shadow>(Vec<Shadow>);
|
pub struct ShadowList<Shadow>(Vec<Shadow>);
|
||||||
|
|
||||||
/// An animated value for a single `box-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.
|
/// An animated value for the `filter` property.
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[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>;
|
pub type Filter = GenericFilter<Angle, NonNegativeNumber, NonNegativeLength, Impossible>;
|
||||||
|
|
||||||
/// An animated value for the `drop-shadow()` filter.
|
/// 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 {
|
impl ToAnimatedValue for ComputedBoxShadowList {
|
||||||
type AnimatedValue = BoxShadowList;
|
type AnimatedValue = BoxShadowList;
|
||||||
|
@ -245,7 +245,7 @@ impl ToAnimatedZero for SimpleShadow {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_animated_zero(&self) -> Result<Self, ()> {
|
fn to_animated_zero(&self) -> Result<Self, ()> {
|
||||||
Ok(SimpleShadow {
|
Ok(SimpleShadow {
|
||||||
color: Color::transparent(),
|
color: Some(RGBA::transparent()),
|
||||||
horizontal: self.horizontal.to_animated_zero()?,
|
horizontal: self.horizontal.to_animated_zero()?,
|
||||||
vertical: self.vertical.to_animated_zero()?,
|
vertical: self.vertical.to_animated_zero()?,
|
||||||
blur: self.blur.to_animated_zero()?,
|
blur: self.blur.to_animated_zero()?,
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
#[cfg(not(feature = "gecko"))]
|
#[cfg(not(feature = "gecko"))]
|
||||||
use values::Impossible;
|
use values::Impossible;
|
||||||
use values::computed::{Angle, NonNegativeNumber};
|
use values::computed::{Angle, NonNegativeNumber};
|
||||||
use values::computed::color::Color;
|
use values::computed::color::RGBAColor;
|
||||||
use values::computed::length::{Length, NonNegativeLength};
|
use values::computed::length::{Length, NonNegativeLength};
|
||||||
use values::generics::effects::BoxShadow as GenericBoxShadow;
|
use values::generics::effects::BoxShadow as GenericBoxShadow;
|
||||||
use values::generics::effects::Filter as GenericFilter;
|
use values::generics::effects::Filter as GenericFilter;
|
||||||
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
|
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
|
||||||
|
|
||||||
/// A computed value for a single shadow of the `box-shadow` property.
|
/// 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`.
|
/// A computed value for a single `filter`.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
@ -25,4 +25,4 @@ pub type Filter = GenericFilter<Angle, NonNegativeNumber, NonNegativeLength, Sim
|
||||||
pub type Filter = GenericFilter<Angle, NonNegativeNumber, NonNegativeLength, Impossible>;
|
pub type Filter = GenericFilter<Angle, NonNegativeNumber, NonNegativeLength, Impossible>;
|
||||||
|
|
||||||
/// A computed value for the `drop-shadow()` filter.
|
/// 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::Filter as GenericFilter;
|
||||||
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
|
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
|
||||||
use values::specified::{Angle, NumberOrPercentage};
|
use values::specified::{Angle, NumberOrPercentage};
|
||||||
use values::specified::color::Color;
|
use values::specified::color::RGBAColor;
|
||||||
use values::specified::length::{Length, NonNegativeLength};
|
use values::specified::length::{Length, NonNegativeLength};
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use values::specified::url::SpecifiedUrl;
|
use values::specified::url::SpecifiedUrl;
|
||||||
|
|
||||||
/// A specified value for a single shadow of the `box-shadow` property.
|
/// 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`.
|
/// A specified value for a single `filter`.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
@ -67,7 +68,7 @@ impl ToComputedValue for Factor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A specified value for the `drop-shadow()` filter.
|
/// 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 {
|
impl Parse for BoxShadow {
|
||||||
fn parse<'i, 't>(
|
fn parse<'i, 't>(
|
||||||
|
@ -104,7 +105,7 @@ impl Parse for BoxShadow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if color.is_none() {
|
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);
|
color = Some(value);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -184,11 +185,11 @@ impl Parse for SimpleShadow {
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>
|
input: &mut Parser<'i, 't>
|
||||||
) -> Result<Self, ParseError<'i>> {
|
) -> 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 horizontal = Length::parse(context, input)?;
|
||||||
let vertical = Length::parse(context, input)?;
|
let vertical = Length::parse(context, input)?;
|
||||||
let blur = input.try(|i| Length::parse_non_negative(context, i)).ok();
|
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 {
|
Ok(SimpleShadow {
|
||||||
color: color,
|
color: color,
|
||||||
horizontal: horizontal,
|
horizontal: horizontal,
|
||||||
|
@ -204,8 +205,7 @@ impl ToComputedValue for SimpleShadow {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||||
ComputedSimpleShadow {
|
ComputedSimpleShadow {
|
||||||
color:
|
color: self.color.to_computed_value(context),
|
||||||
self.color.as_ref().unwrap_or(&Color::CurrentColor).to_computed_value(context),
|
|
||||||
horizontal: self.horizontal.to_computed_value(context),
|
horizontal: self.horizontal.to_computed_value(context),
|
||||||
vertical: self.vertical.to_computed_value(context),
|
vertical: self.vertical.to_computed_value(context),
|
||||||
blur:
|
blur:
|
||||||
|
@ -216,7 +216,7 @@ impl ToComputedValue for SimpleShadow {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||||
SimpleShadow {
|
SimpleShadow {
|
||||||
color: Some(ToComputedValue::from_computed_value(&computed.color)),
|
color: ToComputedValue::from_computed_value(&computed.color),
|
||||||
horizontal: ToComputedValue::from_computed_value(&computed.horizontal),
|
horizontal: ToComputedValue::from_computed_value(&computed.horizontal),
|
||||||
vertical: ToComputedValue::from_computed_value(&computed.vertical),
|
vertical: ToComputedValue::from_computed_value(&computed.vertical),
|
||||||
blur: Some(ToComputedValue::from_computed_value(&computed.blur)),
|
blur: Some(ToComputedValue::from_computed_value(&computed.blur)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue