From 7fae87d687a4d4a13b9cb31d6ed9db2b15cc5176 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 28 Aug 2016 11:28:14 +0530 Subject: [PATCH] stylo: Support text-shadow --- components/style/properties/gecko.mako.rs | 45 ++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 0676df08c57..37dc430a182 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1211,12 +1211,55 @@ fn static_assert() { <%self:impl_trait style_struct_name="InheritedText" - skip_longhands="text-align line-height word-spacing"> + skip_longhands="text-align text-shadow line-height word-spacing"> <% text_align_keyword = Keyword("text-align", "start end left right center justify -moz-center -moz-left " + "-moz-right match-parent") %> ${impl_keyword('text_align', 'mTextAlign', text_align_keyword, need_clone=False)} + pub fn set_text_shadow(&mut self, v: longhands::text_shadow::computed_value::T) { + use cssparser::Color; + self.gecko.mTextShadow.replace_with_new(v.0.len() as u32); + + for (servo, gecko_shadow) in v.0.into_iter() + .zip(self.gecko.mTextShadow.iter_mut()) { + + gecko_shadow.mXOffset = servo.offset_x.0; + gecko_shadow.mYOffset = servo.offset_y.0; + gecko_shadow.mRadius = servo.blur_radius.0; + gecko_shadow.mHasColor = false; + gecko_shadow.mColor = match servo.color { + Color::RGBA(rgba) => { + gecko_shadow.mHasColor = true; + convert_rgba_to_nscolor(&rgba) + }, + // TODO handle currentColor + // https://bugzilla.mozilla.org/show_bug.cgi?id=760345 + Color::CurrentColor => 0, + } + + } + } + + pub fn copy_text_shadow_from(&mut self, other: &Self) { + self.gecko.mTextShadow.copy_from(&other.gecko.mTextShadow); + } + + pub fn clone_text_shadow(&self) -> longhands::text_shadow::computed_value::T { + use cssparser::Color; + + let buf = self.gecko.mTextShadow.iter().map(|shadow| { + longhands::text_shadow::computed_value::TextShadow { + offset_x: Au(shadow.mXOffset), + offset_y: Au(shadow.mYOffset), + blur_radius: Au(shadow.mRadius), + color: Color::RGBA(convert_nscolor_to_rgba(shadow.mColor)), + } + + }).collect(); + longhands::text_shadow::computed_value::T(buf) + } + pub fn set_line_height(&mut self, v: longhands::line_height::computed_value::T) { use properties::longhands::line_height::computed_value::T; // FIXME: Align binary representations and ditch |match| for cast + static_asserts