mirror of
https://github.com/servo/servo.git
synced 2025-06-28 02:53:48 +01:00
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:
parent
920585bd74
commit
bd314747da
8 changed files with 76 additions and 22 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue