mirror of
https://github.com/servo/servo.git
synced 2025-08-14 18:05:36 +01:00
Make text-shadow and box-shadow use SimpleShadow
This commit is contained in:
parent
65ff4a399c
commit
201d7e79e7
14 changed files with 414 additions and 434 deletions
|
@ -7,37 +7,30 @@
|
|||
use app_units::Au;
|
||||
use gecko::values::{convert_rgba_to_nscolor, convert_nscolor_to_rgba};
|
||||
use gecko_bindings::structs::nsCSSShadowItem;
|
||||
use values::computed::{Color, Shadow};
|
||||
use values::computed::effects::SimpleShadow;
|
||||
use values::computed::Color;
|
||||
use values::computed::effects::{BoxShadow, SimpleShadow};
|
||||
|
||||
impl nsCSSShadowItem {
|
||||
/// Set this item to the given shadow value.
|
||||
pub fn set_from_shadow(&mut self, other: Shadow) {
|
||||
self.mXOffset = other.offset_x.0;
|
||||
self.mYOffset = other.offset_y.0;
|
||||
self.mRadius = other.blur_radius.0;
|
||||
self.mSpread = other.spread_radius.0;
|
||||
self.mInset = other.inset;
|
||||
if other.color.is_currentcolor() {
|
||||
// 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(&other.color.color);
|
||||
}
|
||||
/// Sets this item from the given box shadow.
|
||||
#[inline]
|
||||
pub fn set_from_box_shadow(&mut self, shadow: BoxShadow) {
|
||||
self.set_from_simple_shadow(shadow.base);
|
||||
self.mSpread = shadow.spread.0;
|
||||
self.mInset = shadow.inset;
|
||||
}
|
||||
|
||||
/// Generate shadow value from this shadow item.
|
||||
pub fn to_shadow(&self) -> Shadow {
|
||||
Shadow {
|
||||
offset_x: Au(self.mXOffset),
|
||||
offset_y: Au(self.mYOffset),
|
||||
blur_radius: Au(self.mRadius),
|
||||
spread_radius: Au(self.mSpread),
|
||||
/// Returns this item as a box shadow.
|
||||
#[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),
|
||||
},
|
||||
spread: Au(self.mSpread),
|
||||
inset: self.mInset,
|
||||
color: Color::rgba(convert_nscolor_to_rgba(self.mColor)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue