Bug 1341714 - Part 3: stylo: Add support for <math> default language; r?heycam draft
authorManish Goregaokar <manishearth@gmail.com>
Sun, 26 Mar 2017 13:53:34 -0700
changeset 553931 29ff1c9e4c4c9b349672b4588e4c173b22828e66
parent 553930 86540afe00da4c7a274660faaffd734feef0761a
child 622239 cf944cd118bcf83b2455acbb2db98dfa61471bb1
push id51825
push userbmo:manishearth@gmail.com
push dateFri, 31 Mar 2017 00:26:38 +0000
reviewersheycam
bugs1341714
milestone55.0a1
Bug 1341714 - Part 3: stylo: Add support for <math> default language; r?heycam MozReview-Commit-ID: LhhSBzYjow5
servo/components/style/gecko/wrapper.rs
--- a/servo/components/style/gecko/wrapper.rs
+++ b/servo/components/style/gecko/wrapper.rs
@@ -610,16 +610,17 @@ impl<'le> PartialEq for GeckoElement<'le
 }
 
 impl<'le> PresentationalHintsSynthetizer for GeckoElement<'le> {
     fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
         where V: Push<ApplicableDeclarationBlock>,
     {
         use properties::longhands::text_align::SpecifiedValue as SpecifiedTextAlign;
         use properties::longhands::color::SpecifiedValue as SpecifiedColor;
+        use properties::longhands::_x_lang::SpecifiedValue as SpecifiedLang;
         use values::specified::color::Color;
         lazy_static! {
             static ref TH_RULE: ApplicableDeclarationBlock = {
                 let global_style_data = &*GLOBAL_STYLE_DATA;
                 let pdb = PropertyDeclarationBlock::with_one(
                     PropertyDeclaration::TextAlign(SpecifiedTextAlign::MozCenterOrInherit),
                     Importance::Normal
                 );
@@ -630,26 +631,40 @@ impl<'le> PresentationalHintsSynthetizer
                 let global_style_data = &*GLOBAL_STYLE_DATA;
                 let pdb = PropertyDeclarationBlock::with_one(
                     PropertyDeclaration::Color(SpecifiedColor(Color::InheritFromBodyQuirk.into())),
                     Importance::Normal
                 );
                 let arc = Arc::new(global_style_data.shared_lock.wrap(pdb));
                 ApplicableDeclarationBlock::from_declarations(arc, ServoCascadeLevel::PresHints)
             };
+            static ref MATHML_LANG_RULE: ApplicableDeclarationBlock = {
+                let global_style_data = &*GLOBAL_STYLE_DATA;
+                let pdb = PropertyDeclarationBlock::with_one(
+                    PropertyDeclaration::XLang(SpecifiedLang(atom!("x-math"))),
+                    Importance::Normal
+                );
+                let arc = Arc::new(global_style_data.shared_lock.wrap(pdb));
+                ApplicableDeclarationBlock::from_declarations(arc, ServoCascadeLevel::PresHints)
+            };
         };
 
+        let ns = self.get_namespace();
         // <th> elements get a default MozCenterOrInherit which may get overridden
-        if self.get_namespace() == &*Namespace(atom!("http://www.w3.org/1999/xhtml")) {
+        if ns == &*Namespace(atom!("http://www.w3.org/1999/xhtml")) {
             if self.get_local_name().as_ptr() == atom!("th").as_ptr() {
                 hints.push(TH_RULE.clone());
             } else if self.get_local_name().as_ptr() == atom!("table").as_ptr() &&
                       self.as_node().owner_doc().mCompatMode == structs::nsCompatibility::eCompatibility_NavQuirks {
                 hints.push(TABLE_COLOR_RULE.clone());
             }
+        } else if ns == &*Namespace(atom!("http://www.w3.org/1998/Math/MathML")) {
+            if self.get_local_name().as_ptr() == atom!("math").as_ptr() {
+                hints.push(MATHML_LANG_RULE.clone());
+            }
         }
         let declarations = unsafe { Gecko_GetHTMLPresentationAttrDeclarationBlock(self.0) };
         let declarations = declarations.and_then(|s| s.as_arc_opt());
         if let Some(decl) = declarations {
             hints.push(
                 ApplicableDeclarationBlock::from_declarations(Clone::clone(decl), ServoCascadeLevel::PresHints)
             );
         }