Auto merge of #18084 - hiikezoe:currentcolor-for-box-shadow-animation, r=xidorn

Currentcolor for box shadow animation

<!-- Please describe your changes on the following line: -->
https://bugzilla.mozilla.org/show_bug.cgi?id=1388220
---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors

<!-- 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/18084)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-08-15 04:37:44 -05:00 committed by GitHub
commit 526d573e07

View file

@ -23,12 +23,7 @@ impl nsCSSShadowItem {
#[inline]
pub fn to_box_shadow(&self) -> BoxShadow {
BoxShadow {
base: SimpleShadow {
color: Color::rgba(convert_nscolor_to_rgba(self.mColor)),
horizontal: Au(self.mXOffset),
vertical: Au(self.mYOffset),
blur: Au(self.mRadius).into(),
},
base: self.extract_simple_shadow(),
spread: Au(self.mSpread),
inset: self.mInset,
}
@ -53,16 +48,31 @@ impl nsCSSShadowItem {
}
}
/// Returns this item as a simple shadow.
#[inline]
pub fn to_simple_shadow(&self) -> SimpleShadow {
debug_assert_eq!(self.mSpread, 0);
debug_assert_eq!(self.mInset, false);
fn extract_color(&self) -> Color {
if self.mHasColor {
Color::rgba(convert_nscolor_to_rgba(self.mColor))
} else {
Color::currentcolor()
}
}
/// Gets a simple shadow from this item.
#[inline]
fn extract_simple_shadow(&self) -> SimpleShadow {
SimpleShadow {
color: Color::rgba(convert_nscolor_to_rgba(self.mColor)),
color: self.extract_color(),
horizontal: Au(self.mXOffset),
vertical: Au(self.mYOffset),
blur: Au(self.mRadius).into(),
}
}
/// Returns this item as a simple shadow.
#[inline]
pub fn to_simple_shadow(&self) -> SimpleShadow {
debug_assert_eq!(self.mSpread, 0);
debug_assert_eq!(self.mInset, false);
self.extract_simple_shadow()
}
}