Skip to content

Commit

Permalink
geckolib: Don't panic when attempting to restyle an element with newl…
Browse files Browse the repository at this point in the history
…y applied XBL bindings.
  • Loading branch information
heycam committed Jun 12, 2017
1 parent c1ea54d commit 06860d8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ports/geckolib/glue.rs
Expand Up @@ -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,
Expand All @@ -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()
}

Expand Down

0 comments on commit 06860d8

Please sign in to comment.