geckolib: Don't panic when attempting to restyle an element with newly applied XBL bindings.

This commit is contained in:
Cameron McCormack 2017-06-11 19:11:50 +08:00
parent c1ea54d3c4
commit 06860d85c6

View file

@ -263,9 +263,11 @@ pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
let traversal_flags = match (root_behavior, restyle_behavior) {
(Root::Normal, Restyle::Normal) |
(Root::Normal, Restyle::ForNewlyBoundElement) |
(Root::Normal, Restyle::ForAnimationOnly)
=> TraversalFlags::empty(),
(Root::UnstyledChildrenOnly, Restyle::Normal) |
(Root::UnstyledChildrenOnly, Restyle::ForNewlyBoundElement) |
(Root::UnstyledChildrenOnly, Restyle::ForAnimationOnly)
=> UNSTYLED_CHILDREN_ONLY,
(Root::Normal, Restyle::ForCSSRuleChanges) => FOR_CSS_RULE_CHANGES,
@ -291,6 +293,14 @@ pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
traversal_flags,
unsafe { &*snapshots });
if restyle_behavior == Restyle::ForNewlyBoundElement {
// In this mode, we only ever restyle new elements, so there is no
// need for a post-traversal, and the borrow_data().unwrap() call below
// could panic, so we don't bother computing whether a post-traversal
// is required.
return false;
}
element.has_dirty_descendants() || element.borrow_data().unwrap().has_restyle()
}