stylo: Align eRestyle_Subtree value with RESTYLE_DESCENDANTS.

Handle the translation of eRestyle_Subtree into
(RESTYLE_SELF | RESTYLE_DESCENDANTS) in the From impl, too.
This commit is contained in:
Cameron McCormack 2017-03-10 17:55:36 +08:00
parent c90d3d2f06
commit c0996c6536

View file

@ -41,7 +41,7 @@ bitflags! {
/// ///
/// NB: In Gecko, we have RESTYLE_SUBTREE which is inclusive of self, /// NB: In Gecko, we have RESTYLE_SUBTREE which is inclusive of self,
/// but heycam isn't aware of a good reason for that. /// but heycam isn't aware of a good reason for that.
const RESTYLE_DESCENDANTS = 0x02, const RESTYLE_DESCENDANTS = 0x04,
/// Rerun selector matching on all later siblings of the element and all /// Rerun selector matching on all later siblings of the element and all
/// of their descendants. /// of their descendants.
@ -75,13 +75,11 @@ pub fn assert_restyle_hints_match() {
check_restyle_hints! { check_restyle_hints! {
nsRestyleHint_eRestyle_Self => RESTYLE_SELF, nsRestyleHint_eRestyle_Self => RESTYLE_SELF,
// XXX This for Servo actually means something like an hypothetical // Note that eRestyle_Subtree means "self and descendants", while
// Restyle_AllDescendants (but without running selector matching on the // RESTYLE_DESCENDANTS means descendants only. The From impl
// element). ServoRestyleManager interprets it like that, but in practice we // below handles converting eRestyle_Subtree into
// should align the behavior with Gecko adding a new restyle hint, maybe? // (RESTYLE_SELF | RESTYLE_DESCENDANTS).
// nsRestyleHint_eRestyle_Subtree => RESTYLE_DESCENDANTS,
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1291786
nsRestyleHint_eRestyle_SomeDescendants => RESTYLE_DESCENDANTS,
nsRestyleHint_eRestyle_LaterSiblings => RESTYLE_LATER_SIBLINGS, nsRestyleHint_eRestyle_LaterSiblings => RESTYLE_LATER_SIBLINGS,
nsRestyleHint_eRestyle_StyleAttribute => RESTYLE_STYLE_ATTRIBUTE, nsRestyleHint_eRestyle_StyleAttribute => RESTYLE_STYLE_ATTRIBUTE,
} }
@ -106,7 +104,14 @@ impl From<nsRestyleHint> for RestyleHint {
warn!("stylo: dropping unsupported restyle hint bits"); warn!("stylo: dropping unsupported restyle hint bits");
} }
Self::from_bits_truncate(raw_bits) let mut bits = Self::from_bits_truncate(raw_bits);
// eRestyle_Subtree converts to (RESTYLE_SELF | RESTYLE_DESCENDANTS).
if bits.contains(RESTYLE_DESCENDANTS) {
bits |= RESTYLE_SELF;
}
bits
} }
} }