Auto merge of #17285 - heycam:newly-bound, r=bholley

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

From https://bugzilla.mozilla.org/show_bug.cgi?id=1370793.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17285)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-12 18:46:41 -07:00 committed by GitHub
commit 8449eb4a62
4 changed files with 37 additions and 13 deletions

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()
}