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

@ -2113,9 +2113,9 @@ extern "C" {
} }
extern "C" { extern "C" {
pub fn Servo_StyleRule_GetSelectorTextAtIndex(rule: pub fn Servo_StyleRule_GetSelectorTextAtIndex(rule:
RawServoStyleRuleBorrowed, RawServoStyleRuleBorrowed,
index: u32, index: u32,
result: *mut nsAString); result: *mut nsAString);
} }
extern "C" { extern "C" {
pub fn Servo_StyleRule_GetSpecificityAtIndex(rule: pub fn Servo_StyleRule_GetSpecificityAtIndex(rule:

View file

@ -6644,9 +6644,10 @@ pub mod root {
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum TraversalRestyleBehavior { pub enum TraversalRestyleBehavior {
Normal = 0, Normal = 0,
ForReconstruct = 1, ForNewlyBoundElement = 1,
ForAnimationOnly = 2, ForReconstruct = 2,
ForCSSRuleChanges = 3, ForAnimationOnly = 3,
ForCSSRuleChanges = 4,
} }
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
@ -10436,6 +10437,12 @@ pub mod root {
eFloatID_SpellCheckerUnderlineRelativeSize = 1, eFloatID_SpellCheckerUnderlineRelativeSize = 1,
eFloatID_CaretAspectRatio = 2, eFloatID_CaretAspectRatio = 2,
} }
pub const LookAndFeel_FontID_FontID_MINIMUM:
root::mozilla::LookAndFeel_FontID =
LookAndFeel_FontID::eFont_Caption;
pub const LookAndFeel_FontID_FontID_MAXIMUM:
root::mozilla::LookAndFeel_FontID =
LookAndFeel_FontID::eFont_Widget;
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum LookAndFeel_FontID { pub enum LookAndFeel_FontID {
@ -34397,7 +34404,7 @@ pub mod root {
root::nsCharTraits ) )); root::nsCharTraits ) ));
} }
#[test] #[test]
fn __bindgen_test_layout__bindgen_ty_id_215166_instantiation_103() { fn __bindgen_test_layout__bindgen_ty_id_215184_instantiation_103() {
assert_eq!(::std::mem::size_of::<u8>() , 1usize , concat ! ( assert_eq!(::std::mem::size_of::<u8>() , 1usize , concat ! (
"Size of template specialization: " , stringify ! ( u8 ) "Size of template specialization: " , stringify ! ( u8 )
)); ));
@ -34406,7 +34413,7 @@ pub mod root {
) )); ) ));
} }
#[test] #[test]
fn __bindgen_test_layout__bindgen_ty_id_215202_instantiation_104() { fn __bindgen_test_layout__bindgen_ty_id_215220_instantiation_104() {
assert_eq!(::std::mem::size_of::<u8>() , 1usize , concat ! ( assert_eq!(::std::mem::size_of::<u8>() , 1usize , concat ! (
"Size of template specialization: " , stringify ! ( u8 ) "Size of template specialization: " , stringify ! ( u8 )
)); ));

View file

@ -6500,9 +6500,10 @@ pub mod root {
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum TraversalRestyleBehavior { pub enum TraversalRestyleBehavior {
Normal = 0, Normal = 0,
ForReconstruct = 1, ForNewlyBoundElement = 1,
ForAnimationOnly = 2, ForReconstruct = 2,
ForCSSRuleChanges = 3, ForAnimationOnly = 3,
ForCSSRuleChanges = 4,
} }
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
@ -10169,6 +10170,12 @@ pub mod root {
eFloatID_SpellCheckerUnderlineRelativeSize = 1, eFloatID_SpellCheckerUnderlineRelativeSize = 1,
eFloatID_CaretAspectRatio = 2, eFloatID_CaretAspectRatio = 2,
} }
pub const LookAndFeel_FontID_FontID_MINIMUM:
root::mozilla::LookAndFeel_FontID =
LookAndFeel_FontID::eFont_Caption;
pub const LookAndFeel_FontID_FontID_MAXIMUM:
root::mozilla::LookAndFeel_FontID =
LookAndFeel_FontID::eFont_Widget;
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum LookAndFeel_FontID { pub enum LookAndFeel_FontID {
@ -33852,7 +33859,7 @@ pub mod root {
root::nsCharTraits ) )); root::nsCharTraits ) ));
} }
#[test] #[test]
fn __bindgen_test_layout__bindgen_ty_id_211327_instantiation_98() { fn __bindgen_test_layout__bindgen_ty_id_211345_instantiation_98() {
assert_eq!(::std::mem::size_of::<u8>() , 1usize , concat ! ( assert_eq!(::std::mem::size_of::<u8>() , 1usize , concat ! (
"Size of template specialization: " , stringify ! ( u8 ) "Size of template specialization: " , stringify ! ( u8 )
)); ));
@ -33861,7 +33868,7 @@ pub mod root {
) )); ) ));
} }
#[test] #[test]
fn __bindgen_test_layout__bindgen_ty_id_211363_instantiation_99() { fn __bindgen_test_layout__bindgen_ty_id_211381_instantiation_99() {
assert_eq!(::std::mem::size_of::<u8>() , 1usize , concat ! ( assert_eq!(::std::mem::size_of::<u8>() , 1usize , concat ! (
"Size of template specialization: " , stringify ! ( u8 ) "Size of template specialization: " , stringify ! ( u8 )
)); ));

View file

@ -263,9 +263,11 @@ pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
let traversal_flags = match (root_behavior, restyle_behavior) { let traversal_flags = match (root_behavior, restyle_behavior) {
(Root::Normal, Restyle::Normal) | (Root::Normal, Restyle::Normal) |
(Root::Normal, Restyle::ForNewlyBoundElement) |
(Root::Normal, Restyle::ForAnimationOnly) (Root::Normal, Restyle::ForAnimationOnly)
=> TraversalFlags::empty(), => TraversalFlags::empty(),
(Root::UnstyledChildrenOnly, Restyle::Normal) | (Root::UnstyledChildrenOnly, Restyle::Normal) |
(Root::UnstyledChildrenOnly, Restyle::ForNewlyBoundElement) |
(Root::UnstyledChildrenOnly, Restyle::ForAnimationOnly) (Root::UnstyledChildrenOnly, Restyle::ForAnimationOnly)
=> UNSTYLED_CHILDREN_ONLY, => UNSTYLED_CHILDREN_ONLY,
(Root::Normal, Restyle::ForCSSRuleChanges) => FOR_CSS_RULE_CHANGES, (Root::Normal, Restyle::ForCSSRuleChanges) => FOR_CSS_RULE_CHANGES,
@ -291,6 +293,14 @@ pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
traversal_flags, traversal_flags,
unsafe { &*snapshots }); 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() element.has_dirty_descendants() || element.borrow_data().unwrap().has_restyle()
} }