diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index cbfc8924e25..9ec7ee3cf76 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -624,9 +624,9 @@ impl<'le> PresentationalHintsSynthetizer for GeckoElement<'le> { fn synthesize_presentational_hints_for_legacy_attributes(&self, hints: &mut V) where V: Push, { - use properties::longhands::text_align::SpecifiedValue as SpecifiedTextAlign; - use properties::longhands::color::SpecifiedValue as SpecifiedColor; use properties::longhands::_x_lang::SpecifiedValue as SpecifiedLang; + use properties::longhands::color::SpecifiedValue as SpecifiedColor; + use properties::longhands::text_align::SpecifiedValue as SpecifiedTextAlign; use values::specified::color::Color; lazy_static! { static ref TH_RULE: ApplicableDeclarationBlock = { @@ -667,10 +667,6 @@ impl<'le> PresentationalHintsSynthetizer for GeckoElement<'le> { 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()); @@ -686,6 +682,30 @@ impl<'le> PresentationalHintsSynthetizer for GeckoElement<'le> { ApplicableDeclarationBlock::from_declarations(Clone::clone(decl), ServoCascadeLevel::PresHints) ); } + + // xml:lang has precedence over lang, which can be + // set by Gecko_GetHTMLPresentationAttrDeclarationBlock + // + // http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#language + let ptr = unsafe { + bindings::Gecko_GetXMLLangValue(self.0) + }; + if !ptr.is_null() { + let global_style_data = &*GLOBAL_STYLE_DATA; + + let pdb = PropertyDeclarationBlock::with_one( + PropertyDeclaration::XLang(SpecifiedLang(Atom::from(ptr))), + Importance::Normal + ); + let arc = Arc::new(global_style_data.shared_lock.wrap(pdb)); + hints.push(ApplicableDeclarationBlock::from_declarations(arc, ServoCascadeLevel::PresHints)) + } + // MathML's default lang has precedence over both `lang` and `xml:lang` + 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()); + } + } } } diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 999beb32e0e..f076001f46b 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -479,6 +479,10 @@ extern "C" { pub fn Gecko_GetElementId(element: RawGeckoElementBorrowed) -> *mut nsIAtom; } +extern "C" { + pub fn Gecko_GetXMLLangValue(element: RawGeckoElementBorrowed) + -> *mut nsIAtom; +} extern "C" { pub fn Gecko_AtomAttrValue(element: RawGeckoElementBorrowed, attribute: *mut nsIAtom) -> *mut nsIAtom; diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 2cf46210317..b2b64e1c212 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -211,8 +211,8 @@ impl ToComputedValue for specified::Color { specified::Color::MozVisitedHyperlinktext => to_rgba(pres_context.mVisitedLinkColor), specified::Color::InheritFromBodyQuirk => { use dom::TElement; - use gecko_bindings::bindings::Gecko_GetBody; use gecko::wrapper::GeckoElement; + use gecko_bindings::bindings::Gecko_GetBody; let body = unsafe { Gecko_GetBody(pres_context) };