Make Servo_TraverseSubtree return whether it did any work. draft
authorCameron McCormack <cam@mcc.id.au>
Wed, 18 Jan 2017 15:55:20 +0800
changeset 466630 eb2c9e58966c92e4d0046e82a555af764a98e1be
parent 466629 3e623aa798ff1051cdabc2584e8dbbf83ebc86d6
child 466631 e11facc678e5cecdfa2608a292e40bb35508c62a
push id42945
push userbmo:cam@mcc.id.au
push dateThu, 26 Jan 2017 07:00:37 +0000
milestone53.0a1
Make Servo_TraverseSubtree return whether it did any work. MozReview-Commit-ID: 8EWxdt0pZ6W
servo/components/style/gecko_bindings/bindings.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/gecko_bindings/bindings.rs
+++ b/servo/components/style/gecko_bindings/bindings.rs
@@ -1372,17 +1372,17 @@ extern "C" {
     pub fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
                                     pseudo_tag: *mut nsIAtom,
                                     set: RawServoStyleSetBorrowed)
      -> ServoComputedValuesStrong;
 }
 extern "C" {
     pub fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
                                  set: RawServoStyleSetBorrowed,
-                                 root_behavior: TraversalRootBehavior);
+                                 root_behavior: TraversalRootBehavior) -> bool;
 }
 extern "C" {
     pub fn Servo_AssertTreeIsClean(root: RawGeckoElementBorrowed);
 }
 extern "C" {
     pub fn Servo_GetStyleFont(computed_values:
                                   ServoComputedValuesBorrowedOrNull)
      -> *const nsStyleFont;
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -144,24 +144,29 @@ fn traverse_subtree(element: GeckoElemen
     if per_doc_data.num_threads == 1 || per_doc_data.work_queue.is_none() {
         sequential::traverse_dom(&traversal, element, token);
     } else {
         parallel::traverse_dom(&traversal, element, known_depth, token,
                                per_doc_data.work_queue.as_mut().unwrap());
     }
 }
 
+/// Traverses the subtree rooted at `root` for restyling.  Returns whether a
+/// Gecko post-traversal (to perform lazy frame construction, or consume any
+/// RestyleData, or drop any ElementData) is required.
 #[no_mangle]
 pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
                                         raw_data: RawServoStyleSetBorrowed,
-                                        behavior: structs::TraversalRootBehavior) -> () {
+                                        behavior: structs::TraversalRootBehavior) -> bool {
     let element = GeckoElement(root);
     debug!("Servo_TraverseSubtree: {:?}", element);
     traverse_subtree(element, raw_data,
                      behavior == structs::TraversalRootBehavior::UnstyledChildrenOnly);
+
+    element.has_dirty_descendants() || element.mutate_data().unwrap().has_restyle()
 }
 
 /// Takes a ServoAnimationValues and populates it with the animation values corresponding
 /// to a given property declaration block
 #[no_mangle]
 pub extern "C" fn Servo_AnimationValues_Populate(anim: RawGeckoAnimationValueListBorrowedMut,
                                                  declarations: RawServoDeclarationBlockBorrowed,
                                                  style: ServoComputedValuesBorrowed,