Bug 1192910 - When modifying display port margins, don't schedule paints if the actual display port hasn't changed. r?mattwoodrow draft
authorMarkus Stange <mstange@themasta.com>
Thu, 31 Dec 2015 00:03:43 +0100
changeset 318192 208cae926bae1f22c5ab533db02b85cb93a27ff9
parent 318187 acc7e020c59be78b080b3d57ad7effbd72573c11
child 318193 42d920e9651d8942ed6e64f1f508a3cf61c1f843
push id8849
push usermstange@themasta.com
push dateThu, 31 Dec 2015 15:36:21 +0000
reviewersmattwoodrow
bugs1192910
milestone46.0a1
Bug 1192910 - When modifying display port margins, don't schedule paints if the actual display port hasn't changed. r?mattwoodrow
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1105,16 +1105,19 @@ nsLayoutUtils::SetDisplayPortMargins(nsI
   if (currentData && currentData->mPriority > aPriority) {
     return false;
   }
 
   if (currentData && currentData->mMargins == aMargins) {
     return true;
   }
 
+  nsRect oldDisplayPort;
+  GetDisplayPort(aContent, &oldDisplayPort);
+
   aContent->SetProperty(nsGkAtoms::DisplayPortMargins,
                         new DisplayPortMarginsPropertyData(
                             aMargins, aPriority),
                         nsINode::DeleteProperty<DisplayPortMarginsPropertyData>);
 
   if (gfxPrefs::LayoutUseContainersForRootFrames()) {
     nsIFrame* rootScrollFrame = aPresShell->GetRootScrollFrame();
     if (rootScrollFrame &&
@@ -1123,26 +1126,31 @@ nsLayoutUtils::SetDisplayPortMargins(nsI
     {
       // We are setting a root displayport for a document.
       // If we have APZ, then set a special flag on the pres shell so
       // that we don't get scrollbars drawn.
       aPresShell->SetIgnoreViewportScrolling(true);
     }
   }
 
-  if (aRepaintMode == RepaintMode::Repaint) {
-    nsIFrame* frame = aContent->GetPrimaryFrame();
-    if (frame) {
-      frame->SchedulePaint();
-    }
-  }
-
-  // Display port margins changing means that the set of visible images may
-  // have drastically changed. Schedule an update.
-  aPresShell->ScheduleImageVisibilityUpdate();
+  nsRect newDisplayPort;
+  GetDisplayPort(aContent, &newDisplayPort);
+
+  if (!newDisplayPort.IsEqualEdges(oldDisplayPort)) {
+    if (aRepaintMode == RepaintMode::Repaint) {
+      nsIFrame* frame = aContent->GetPrimaryFrame();
+      if (frame) {
+        frame->SchedulePaint();
+      }
+    }
+
+    // Display port margins changing means that the set of visible images may
+    // have drastically changed. Schedule an update.
+    aPresShell->ScheduleImageVisibilityUpdate();
+  }
 
   return true;
 }
 
 void
 nsLayoutUtils::SetDisplayPortBase(nsIContent* aContent, const nsRect& aBase)
 {
   aContent->SetProperty(nsGkAtoms::DisplayPortBase, new nsRect(aBase),