servo: Merge #14565 - style: Make some removed assertions Servo-only instead (from emilio:assert); r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 13 Dec 2016 00:32:28 -0800
changeset 340324 0ea1d828c66589d690e55ed98ab927a0a268a318
parent 340323 fe2de6d7fa7f946d66aaff3acaf16bba29f62ddc
child 340325 e112a04957731eb2d22369cc8ce662b60b55ff44
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
servo: Merge #14565 - style: Make some removed assertions Servo-only instead (from emilio:assert); r=heycam These were removed in #14560. r? @heycam or @bholley Source-Repo: https://github.com/servo/servo Source-Revision: fb6f88624af8795a417ccb8abe7abf9e9aa8ec9e
servo/components/style/dom.rs
servo/components/style/matching.rs
--- a/servo/components/style/dom.rs
+++ b/servo/components/style/dom.rs
@@ -243,16 +243,19 @@ pub trait TElement : PartialEq + Debug +
     /// Atomically notes that a child has been processed during bottom-up
     /// traversal. Returns the number of children left to process.
     fn did_process_child(&self) -> isize;
 
     /// Returns true if this element's style is display:none. Panics if
     /// the element has no style.
     fn is_display_none(&self) -> bool {
         let data = self.borrow_data().unwrap();
+        // See the comment on `cascade_node` about getting the up-to-date parent
+        // style for why we allow this on Gecko.
+        debug_assert!(cfg!(gecko) || data.has_current_styles());
         data.styles().is_display_none()
     }
 
     /// Gets a reference to the ElementData container.
     fn get_data(&self) -> Option<&AtomicRefCell<ElementData>>;
 
     /// Immutably borrows the ElementData.
     fn borrow_data(&self) -> Option<AtomicRef<ElementData>> {
--- a/servo/components/style/matching.rs
+++ b/servo/components/style/matching.rs
@@ -728,16 +728,23 @@ pub trait MatchMethods : TElement {
                                     primary_rule_node: StrongRuleNode,
                                     pseudo_rule_nodes: PseudoRuleNodes,
                                     primary_is_shareable: bool)
         where Ctx: StyleContext<'a>
     {
         // Get our parent's style.
         let parent_data = parent.as_ref().map(|x| x.borrow_data().unwrap());
         let parent_style = parent_data.as_ref().map(|d| {
+            // Sometimes Gecko eagerly styles things without processing pending
+            // restyles first. In general we'd like to avoid this, but there can
+            // be good reasons (for example, needing to construct a frame for
+            // some small piece of newly-added content in order to do something
+            // specific with that frame, but not wanting to flush all of
+            // layout).
+            debug_assert!(cfg!(gecko) || d.has_current_styles());
             &d.styles().primary.values
         });
 
         let mut new_styles;
         let mut possibly_expired_animations = vec![];
 
         let damage = {
             debug_assert!(!data.has_current_styles());