Bug 1526957 - Part 3: Optimize AutoBuildingDisplayList IsTransformed() check r=mattwoodrow
authorMiko Mynttinen <mikokm@gmail.com>
Mon, 18 Feb 2019 15:33:52 +0000
changeset 520678 09e06443d63a424f09c707d1130405e32ced9997
parent 520677 362f0046f81e2f08fd58dc3fb26bedbeba48f413
child 520679 6e630f7bd8b47187cbfba4a4640fa408f02cb241
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1526957
milestone67.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 1526957 - Part 3: Optimize AutoBuildingDisplayList IsTransformed() check r=mattwoodrow Depends on D19858 Differential Revision: https://phabricator.services.mozilla.com/D19859
layout/generic/nsFrame.cpp
layout/painting/nsDisplayList.h
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2908,17 +2908,17 @@ void nsIFrame::BuildDisplayListForStacki
           nsLayoutUtils::GetNearestScrollableFrame(
               GetParent(), nsLayoutUtils::SCROLLABLE_SAME_DOC |
                                nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN));
   bool useFixedPosition = disp->mPosition == NS_STYLE_POSITION_FIXED &&
                           (nsLayoutUtils::IsFixedPosFrameInDisplayPort(this) ||
                            BuilderHasScrolledClip(aBuilder));
 
   nsDisplayListBuilder::AutoBuildingDisplayList buildingDisplayList(
-      aBuilder, this, visibleRect, dirtyRect);
+      aBuilder, this, visibleRect, dirtyRect, isTransformed);
 
   // Depending on the effects that are applied to this frame, we can create
   // multiple container display items and wrap them around our contents.
   // This enum lists all the potential container display items, in the order
   // outside to inside.
   enum class ContainerItemType : uint8_t {
     eNone = 0,
     eOwnLayerIfNeeded,
@@ -3447,18 +3447,19 @@ void nsIFrame::BuildDisplayListForSimple
   const nsPoint offset = aChild->GetOffsetTo(this);
   const nsRect visible = aBuilder->GetVisibleRect() - offset;
   const nsRect dirty = aBuilder->GetDirtyRect() - offset;
 
   if (!DescendIntoChild(aBuilder, aChild, visible, dirty)) {
     return;
   }
 
+  // Child cannot be transformed since it is not a stacking context.
   nsDisplayListBuilder::AutoBuildingDisplayList buildingForChild(
-      aBuilder, aChild, visible, dirty);
+      aBuilder, aChild, visible, dirty, false);
 
   CheckForApzAwareEventHandlers(aBuilder, aChild);
 
   aBuilder->BuildCompositorHitTestInfoIfNeeded(
       aChild, aLists.BorderBackground(),
       buildingForChild.IsAnimatedGeometryRoot());
 
   aChild->MarkAbsoluteFramesForDisplayList(aBuilder);
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -1078,49 +1078,58 @@ class nsDisplayListBuilder {
    * building display items.
    * aVisibleRect and aDirtyRect are relative to aForChild.
    */
   class AutoBuildingDisplayList {
    public:
     AutoBuildingDisplayList(nsDisplayListBuilder* aBuilder, nsIFrame* aForChild,
                             const nsRect& aVisibleRect,
                             const nsRect& aDirtyRect)
+        : AutoBuildingDisplayList(aBuilder, aForChild, aVisibleRect, aDirtyRect,
+                                  aForChild->IsTransformed()) {}
+
+    AutoBuildingDisplayList(nsDisplayListBuilder* aBuilder, nsIFrame* aForChild,
+                            const nsRect& aVisibleRect,
+                            const nsRect& aDirtyRect, const bool aIsTransformed)
         : mBuilder(aBuilder),
           mPrevFrame(aBuilder->mCurrentFrame),
           mPrevReferenceFrame(aBuilder->mCurrentReferenceFrame),
           mPrevHitTestArea(aBuilder->mHitTestArea),
           mPrevHitTestInfo(aBuilder->mHitTestInfo),
           mPrevOffset(aBuilder->mCurrentOffsetToReferenceFrame),
           mPrevVisibleRect(aBuilder->mVisibleRect),
           mPrevDirtyRect(aBuilder->mDirtyRect),
           mPrevAGR(aBuilder->mCurrentAGR),
           mPrevAncestorHasApzAwareEventHandler(
               aBuilder->mAncestorHasApzAwareEventHandler),
           mPrevBuildingInvisibleItems(aBuilder->mBuildingInvisibleItems),
           mPrevInInvalidSubtree(aBuilder->mInInvalidSubtree) {
-      if (aForChild->IsTransformed()) {
+      if (aIsTransformed) {
         aBuilder->mCurrentOffsetToReferenceFrame = nsPoint();
         aBuilder->mCurrentReferenceFrame = aForChild;
       } else if (aBuilder->mCurrentFrame == aForChild->GetParent()) {
         aBuilder->mCurrentOffsetToReferenceFrame += aForChild->GetPosition();
       } else {
         aBuilder->mCurrentReferenceFrame = aBuilder->FindReferenceFrameFor(
             aForChild, &aBuilder->mCurrentOffsetToReferenceFrame);
       }
+
       bool isAsync;
       mCurrentAGRState = aBuilder->IsAnimatedGeometryRoot(aForChild, isAsync);
+
       if (aBuilder->mCurrentFrame == aForChild->GetParent()) {
         if (mCurrentAGRState == AGR_YES) {
           aBuilder->mCurrentAGR = aBuilder->WrapAGRForFrame(
               aForChild, isAsync, aBuilder->mCurrentAGR);
         }
-      } else if (aForChild != aBuilder->mCurrentFrame) {
+      } else if (aBuilder->mCurrentFrame != aForChild) {
         aBuilder->mCurrentAGR =
             aBuilder->FindAnimatedGeometryRootFor(aForChild);
       }
+
       MOZ_ASSERT(nsLayoutUtils::IsAncestorFrameCrossDoc(
           aBuilder->RootReferenceFrame(), *aBuilder->mCurrentAGR));
       aBuilder->mInInvalidSubtree =
           aBuilder->mInInvalidSubtree || aForChild->IsFrameModified();
       aBuilder->mCurrentFrame = aForChild;
       aBuilder->mVisibleRect = aVisibleRect;
       aBuilder->mDirtyRect =
           aBuilder->mInInvalidSubtree ? aVisibleRect : aDirtyRect;