Bug 1207420 - Improve GetBounds() to avoid recomputing every time. r=roc
☠☠ backed out by ffe864d77b17 ☠ ☠
authorThinker K.F. Li <thinker@codemud.net>
Mon, 28 Sep 2015 00:15:00 +0200
changeset 264632 160c4484f0a2
parent 264631 8fcdb4d03b9e
child 264633 5fe65fd49d02
push id65701
push usercbook@mozilla.com
push date2015-09-28 09:05 +0000
treeherdermozilla-inbound@5fe65fd49d02 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1207420
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1207420 - Improve GetBounds() to avoid recomputing every time. r=roc
layout/base/nsDisplayList.h
--- a/layout/base/nsDisplayList.h
+++ b/layout/base/nsDisplayList.h
@@ -3584,30 +3584,38 @@ class nsDisplayTransform: public nsDispl
 
   /*
    * Avoid doing UpdateBounds() during construction.
    */
   class StoreList : public nsDisplayWrapList {
   public:
     StoreList(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
               nsDisplayList* aList) :
-      nsDisplayWrapList(aBuilder, aFrame, aList) {}
+      nsDisplayWrapList(aBuilder, aFrame, aList),
+      mHasBounds(false) {}
     StoreList(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
               nsDisplayItem* aItem) :
-      nsDisplayWrapList(aBuilder, aFrame, aItem) {}
+      nsDisplayWrapList(aBuilder, aFrame, aItem),
+      mHasBounds(false) {}
     virtual ~StoreList() {}
 
     virtual void UpdateBounds(nsDisplayListBuilder* aBuilder) override {}
     virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
                              bool* aSnap) override {
-      // The bounds should not be computed until now, because we don't
-      // get accmulated transform before.
-      nsDisplayWrapList::UpdateBounds(aBuilder);
+      if (!mHasBounds) {
+        // The bounds should not be computed until now, because we don't
+        // get accmulated transform before.
+        nsDisplayWrapList::UpdateBounds(aBuilder);
+        mHasBounds = true;
+      }
       return nsDisplayWrapList::GetBounds(aBuilder, aSnap);
     }
+
+  private:
+    bool mHasBounds;
   };
 
 public:
   /**
    * Returns a matrix (in pixels) for the current frame. The matrix should be relative to
    * the current frame's coordinate space.
    *
    * @param aFrame The frame to compute the transform for.