style: Make checks for attribute/state dependencies take stylist dirty state into account.

This is a follow-up Servo-side change for https://bugzilla.mozilla.org/show_bug.cgi?id=1352306
which caused some test failures on landing.
This commit is contained in:
Cameron McCormack 2017-06-19 09:33:02 +08:00
parent 8c58736989
commit accd2752ce
2 changed files with 18 additions and 2 deletions

View file

@ -546,13 +546,29 @@ impl Stylist {
pub fn might_have_attribute_dependency(&self,
local_name: &LocalName)
-> bool {
if *local_name == local_name!("style") {
if self.is_cleared || self.is_device_dirty {
// We can't tell what attributes are in our style rules until
// we rebuild.
true
} else if *local_name == local_name!("style") {
self.style_attribute_dependency
} else {
self.attribute_dependencies.might_contain_hash(local_name.get_hash())
}
}
/// Returns whether the given ElementState bit might be relied upon by a
/// selector of some rule in the stylist.
pub fn might_have_state_dependency(&self, state: ElementState) -> bool {
if self.is_cleared || self.is_device_dirty {
// If self.is_cleared is true, we can't tell what states our style
// rules rely on until we rebuild.
true
} else {
self.state_dependencies.intersects(state)
}
}
/// Returns whether the given ElementState bit is relied upon by a selector
/// of some rule in the stylist.
pub fn has_state_dependency(&self, state: ElementState) -> bool {

View file

@ -3066,5 +3066,5 @@ pub extern "C" fn Servo_StyleSet_MightHaveAttributeDependency(raw_data: RawServo
pub extern "C" fn Servo_StyleSet_HasStateDependency(raw_data: RawServoStyleSetBorrowed,
state: u64) -> bool {
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
data.stylist.has_state_dependency(ElementState::from_bits_truncate(state))
data.stylist.might_have_state_dependency(ElementState::from_bits_truncate(state))
}