style: Implement the body text color quirk in a more straight-forward way.

This avoids grabbing the document when values that inherit from the body,
whatever that means, aren't under the body.

In that case we'll get a semi-random value, but that's also mishandled by Gecko
anyways (and probably Blink, though haven't tested), and doesn't really make
much sense.
This commit is contained in:
Emilio Cobos Álvarez 2017-09-15 10:09:19 +02:00
parent 920585bd74
commit bd314747da
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
8 changed files with 76 additions and 22 deletions

View file

@ -7,7 +7,8 @@
#![allow(unsafe_code)]
#![deny(missing_docs)]
use context::{ElementCascadeInputs, SelectorFlagsMap, SharedStyleContext, StyleContext};
use context::{ElementCascadeInputs, QuirksMode, SelectorFlagsMap};
use context::{SharedStyleContext, StyleContext};
use data::ElementData;
use dom::TElement;
use invalidation::element::restyle_hints::{RESTYLE_CSS_ANIMATIONS, RESTYLE_CSS_TRANSITIONS};
@ -586,6 +587,21 @@ pub trait MatchMethods : TElement {
}
}
if context.shared.stylist.quirks_mode() == QuirksMode::Quirks {
if self.is_html_document_body_element() {
// NOTE(emilio): We _could_ handle dynamic changes to it if it
// changes and before we reach our children the cascade stops,
// but we don't track right now whether we use the document body
// color, and nobody else handles that properly anyway.
let device = context.shared.stylist.device();
// Needed for the "inherit from body" quirk.
let text_color = new_primary_style.get_color().clone_color();
device.set_body_text_color(text_color);
}
}
// Don't accumulate damage if we're in a forgetful traversal.
if context.shared.traversal_flags.contains(traversal_flags::Forgetful) {
return ChildCascadeRequirement::MustCascadeChildren;