From 330c47f78e9d4092a7fd2d727ecd8f71aa3d1dc3 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Mon, 2 May 2016 14:41:25 +1000 Subject: [PATCH] Support {flood,lighting,stop,text-decoration}-color in geckolib. --- components/style/properties/helpers.mako.rs | 1 + .../style/properties/longhand/svg.mako.rs | 15 +++++++++ .../style/properties/longhand/text.mako.rs | 5 +++ ports/geckolib/properties.mako.rs | 33 +++++++++++++++++++ 4 files changed, 54 insertions(+) diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index fcf30e83d87..eed9a686549 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -20,6 +20,7 @@ <%call expr="longhand(name, predefined_type=type, **kwargs)"> #[allow(unused_imports)] use app_units::Au; + use cssparser::{Color as CSSParserColor, RGBA}; pub type SpecifiedValue = specified::${type}; pub mod computed_value { pub use values::computed::${type} as T; diff --git a/components/style/properties/longhand/svg.mako.rs b/components/style/properties/longhand/svg.mako.rs index 4309926a99c..a9921e46d7d 100644 --- a/components/style/properties/longhand/svg.mako.rs +++ b/components/style/properties/longhand/svg.mako.rs @@ -15,12 +15,27 @@ ${helpers.single_keyword("vector-effect", "none non-scaling-stroke", products="g // Section 13 - Gradients and Patterns +${helpers.predefined_type( + "stop-color", "CSSColor", + "CSSParserColor::RGBA(RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0 })", + products="gecko")} + ${helpers.predefined_type("stop-opacity", "Opacity", "1.0", products="gecko")} // Section 15 - Filter Effects +${helpers.predefined_type( + "flood-color", "CSSColor", + "CSSParserColor::RGBA(RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0 })", + products="gecko")} + ${helpers.predefined_type("flood-opacity", "Opacity", "1.0", products="gecko")} +${helpers.predefined_type( + "lighting-color", "CSSColor", + "CSSParserColor::RGBA(RGBA { red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0 })", + products="gecko")} + // CSS Masking Module Level 1 // https://www.w3.org/TR/css-masking-1/ ${helpers.single_keyword("mask-type", "luminance alpha", products="gecko")} diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index 1fedba7d6cc..e56cf93597c 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/components/style/properties/longhand/text.mako.rs @@ -107,3 +107,8 @@ ${helpers.single_keyword("unicode-bidi", "normal embed isolate bidi-override iso ${helpers.single_keyword("text-decoration-style", "-moz-none solid double dotted dashed wavy", products="gecko")} + +${helpers.predefined_type( + "text-decoration-color", "CSSColor", + "CSSParserColor::RGBA(RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0 })", + products="gecko")} diff --git a/ports/geckolib/properties.mako.rs b/ports/geckolib/properties.mako.rs index 91400bc5b54..90f74f9eb15 100644 --- a/ports/geckolib/properties.mako.rs +++ b/ports/geckolib/properties.mako.rs @@ -546,6 +546,39 @@ fn static_assert() { +<%self:impl_trait style_struct_name="Text" + skip_longhands="text-decoration-color" + skip_additionals="*"> + + <% impl_color("text_decoration_color", "mTextDecorationColor", + color_flags_ffi_name="mTextDecorationStyle") %> + + fn has_underline(&self) -> bool { + use gecko_style_structs as gss; + (self.gecko.mTextDecorationStyle & (gss::NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE as u8)) != 0 + } + fn has_overline(&self) -> bool { + use gecko_style_structs as gss; + (self.gecko.mTextDecorationStyle & (gss::NS_STYLE_TEXT_DECORATION_LINE_OVERLINE as u8)) != 0 + } + fn has_line_through(&self) -> bool { + use gecko_style_structs as gss; + (self.gecko.mTextDecorationStyle & (gss::NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH as u8)) != 0 + } + + +<%self:impl_trait style_struct_name="SVG" + skip_longhands="flood-color lighting-color stop-color" + skip_additionals="*"> + + <% impl_color("flood_color", "mFloodColor") %> + + <% impl_color("lighting_color", "mLightingColor") %> + + <% impl_color("stop_color", "mStopColor") %> + + + <%def name="define_ffi_struct_accessor(style_struct)"> #[no_mangle] #[allow(non_snake_case, unused_variables)]