Bug 1338936 - Part 8: stylo: Support quirksmode text-decoration color override; r?emilio draft
authorManish Goregaokar <manishearth@gmail.com>
Sun, 12 Feb 2017 16:02:29 -0800
changeset 485642 0026fcef352a7600765d0da8d2e998c53678ec6f
parent 485641 4c152778adfd3f01c82e0a229a93e04805a70946
child 485643 8a4401944dc01de4d338a8d668c84880009e8025
push id45797
push userbmo:manishearth@gmail.com
push dateThu, 16 Feb 2017 23:47:53 +0000
reviewersemilio
bugs1338936
milestone54.0a1
Bug 1338936 - Part 8: stylo: Support quirksmode text-decoration color override; r?emilio MozReview-Commit-ID: 6wg32flypt7
servo/components/style/properties/gecko.mako.rs
servo/components/style/properties/longhand/text.mako.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -2377,16 +2377,19 @@ fn static_assert() {
             bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_OVERLINE as u8;
         }
         if v.line_through {
             bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH as u8;
         }
         if v.blink {
             bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_BLINK as u8;
         }
+        if v.color_override {
+            bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL as u8;
+        }
         self.gecko.mTextDecorationLine = bits;
     }
 
     ${impl_simple_copy('text_decoration_line', 'mTextDecorationLine')}
 
 
     fn clear_overflow_sides_if_string(&mut self) {
         use gecko_bindings::structs::nsStyleTextOverflowSide;
--- a/servo/components/style/properties/longhand/text.mako.rs
+++ b/servo/components/style/properties/longhand/text.mako.rs
@@ -116,16 +116,26 @@
 
     #[derive(PartialEq, Eq, Copy, Clone, Debug)]
     #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
     pub struct SpecifiedValue {
         pub underline: bool,
         pub overline: bool,
         pub line_through: bool,
         pub blink: bool,
+        % if product == "gecko":
+            /// Only set by presentation attributes
+            ///
+            /// Setting this will mean that text-decorations use the color
+            /// specified by `color` in quirks mode.
+            ///
+            /// For example, this gives <a href=foo><font color="red">text</font></a>
+            /// a red text decoration
+            pub color_override: bool,
+        % endif
     }
 
     impl ToCss for SpecifiedValue {
         fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
             let mut has_any = false;
             macro_rules! write_value {
                 ($line:ident => $css:expr) => {
                     if self.$line {
@@ -146,26 +156,32 @@
             }
             Ok(())
         }
     }
     pub mod computed_value {
         pub type T = super::SpecifiedValue;
         #[allow(non_upper_case_globals)]
         pub const none: T = super::SpecifiedValue {
-            underline: false, overline: false, line_through: false, blink: false
+            underline: false, overline: false, line_through: false, blink: false,
+            % if product == "gecko":
+                color_override: false,
+            % endif
         };
     }
     #[inline] pub fn get_initial_value() -> computed_value::T {
         computed_value::none
     }
     /// none | [ underline || overline || line-through || blink ]
     pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
         let mut result = SpecifiedValue {
-            underline: false, overline: false, line_through: false, blink: false
+            underline: false, overline: false, line_through: false, blink: false,
+            % if product == "gecko":
+                color_override: false,
+            % endif
         };
         if input.try(|input| input.expect_ident_matching("none")).is_ok() {
             return Ok(result)
         }
         let mut empty = true;
 
         while input.try(|input| {
                 if let Ok(ident) = input.expect_ident() {
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -1221,19 +1221,26 @@ pub extern "C" fn Servo_DeclarationBlock
         if parser.is_exhausted() {
             let decl = PropertyDeclaration::FontFamily(DeclaredValue::Value(family));
             declarations.write().declarations.push((decl, Default::default()));
         }
     }
 }
 
 #[no_mangle]
-pub extern "C" fn Servo_DeclarationBlock_SetTextDecorationColorOverride(_:
-                                                        RawServoDeclarationBlockBorrowed) {
-    error!("stylo: Don't know how to handle quirks-mode text-decoration color overrides");
+pub extern "C" fn Servo_DeclarationBlock_SetTextDecorationColorOverride(declarations:
+                                                                RawServoDeclarationBlockBorrowed) {
+    use style::properties::{DeclaredValue, PropertyDeclaration};
+    use style::properties::longhands::text_decoration_line;
+
+    let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
+    let mut decoration = text_decoration_line::computed_value::none;
+    decoration.color_override = true;
+    let decl = PropertyDeclaration::TextDecorationLine(DeclaredValue::Value(decoration));
+    declarations.write().declarations.push((decl, Default::default()));
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_CSSSupports2(property: *const nsACString, value: *const nsACString) -> bool {
     let property = unsafe { property.as_ref().unwrap().as_str_unchecked() };
     let id =  if let Ok(id) = PropertyId::parse(property.into()) {
         id
     } else {