stylo: Add support for <table> color quirk

MozReview-Commit-ID: 56IKARwfbhw
This commit is contained in:
Manish Goregaokar 2017-03-26 13:53:34 -07:00 committed by Manish Goregaokar
parent 0392e58a2f
commit 1c23296d8a
No known key found for this signature in database
GPG key ID: 3BBF4D3E2EF79F98
6 changed files with 62 additions and 25 deletions

View file

@ -624,12 +624,23 @@ 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;
use properties::longhands::text_align::SpecifiedValue as SpecifiedTextAlign;
use properties::longhands::color::SpecifiedValue as SpecifiedColor;
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(SpecifiedValue::MozCenterOrInherit),
PropertyDeclaration::TextAlign(SpecifiedTextAlign::MozCenterOrInherit),
Importance::Normal
);
let arc = Arc::new(global_style_data.shared_lock.wrap(pdb));
ApplicableDeclarationBlock::from_declarations(arc, ServoCascadeLevel::PresHints)
};
static ref TABLE_COLOR_RULE: ApplicableDeclarationBlock = {
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));
@ -638,9 +649,13 @@ impl<'le> PresentationalHintsSynthetizer for GeckoElement<'le> {
};
// <th> elements get a default MozCenterOrInherit which may get overridden
if self.get_namespace() == &*Namespace(atom!("http://www.w3.org/1999/xhtml")) &&
self.get_local_name().as_ptr() == atom!("th").as_ptr() {
hints.push(TH_RULE.clone());
if self.get_namespace() == &*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());
}
}
let declarations = unsafe { Gecko_GetHTMLPresentationAttrDeclarationBlock(self.0) };
let declarations = declarations.and_then(|s| s.as_arc_opt());