Bug 1192910 - Stop triggering repaints when the displayport margins change without the displayport changing. r=kats
☠☠ backed out by c68584f32e4e ☠ ☠
authorMarkus Stange <mstange@themasta.com>
Mon, 07 Mar 2016 16:27:41 -0500
changeset 338003 4a56c6dc4c7eb19e9b169c77b9001c63bfcfe09e
parent 338002 eca3a6b94f7934377b099ddb22ae9c91f340cbfc
child 338004 9066ef31441959ae15b83d59395ed34d3ed03c0a
push id12405
push usercku@mozilla.com
push dateTue, 08 Mar 2016 03:35:29 +0000
reviewerskats
bugs1192910
milestone47.0a1
Bug 1192910 - Stop triggering repaints when the displayport margins change without the displayport changing. r=kats MozReview-Commit-ID: K1g6sNlZdRk
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1144,62 +1144,64 @@ nsLayoutUtils::SetDisplayPortMargins(nsI
   MOZ_ASSERT(aContent->GetComposedDoc() == aPresShell->GetDocument());
 
   DisplayPortMarginsPropertyData* currentData =
     static_cast<DisplayPortMarginsPropertyData*>(aContent->GetProperty(nsGkAtoms::DisplayPortMargins));
   if (currentData && currentData->mPriority > aPriority) {
     return false;
   }
 
-  if (currentData && currentData->mMargins == aMargins) {
-    return true;
-  }
+  nsRect oldDisplayPort;
+  bool hadDisplayPort = GetDisplayPort(aContent, &oldDisplayPort);
 
   aContent->SetProperty(nsGkAtoms::DisplayPortMargins,
                         new DisplayPortMarginsPropertyData(
                             aMargins, aPriority),
                         nsINode::DeleteProperty<DisplayPortMarginsPropertyData>);
 
+  nsRect newDisplayPort;
+  DebugOnly<bool> hasDisplayPort = GetDisplayPort(aContent, &newDisplayPort);
+  MOZ_ASSERT(hasDisplayPort);
+
+  bool changed = !hadDisplayPort ||
+        !oldDisplayPort.IsEqualEdges(newDisplayPort);
+
   if (gfxPrefs::LayoutUseContainersForRootFrames()) {
     nsIFrame* rootScrollFrame = aPresShell->GetRootScrollFrame();
     if (rootScrollFrame &&
         aContent == rootScrollFrame->GetContent() &&
         nsLayoutUtils::UsesAsyncScrolling(rootScrollFrame))
     {
       // 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) {
+  if (changed && aRepaintMode == RepaintMode::Repaint) {
     nsIFrame* frame = aContent->GetPrimaryFrame();
     if (frame) {
       frame->SchedulePaint();
     }
   }
 
   nsIFrame* frame = GetScrollFrameFromContent(aContent);
   nsIScrollableFrame* scrollableFrame = frame ? frame->GetScrollTargetFrame() : nullptr;
   if (!scrollableFrame) {
     return true;
   }
 
   scrollableFrame->TriggerDisplayPortExpiration();
 
   // Display port margins changing means that the set of visible images may
   // have drastically changed. Check if we should schedule an update.
-  nsRect oldDisplayPort;
-  bool hadDisplayPort =
+  hadDisplayPort =
     scrollableFrame->GetDisplayPortAtLastImageVisibilityUpdate(&oldDisplayPort);
 
-  nsRect newDisplayPort;
-  Unused << GetDisplayPort(aContent, &newDisplayPort);
-
   bool needImageVisibilityUpdate = !hadDisplayPort;
   // Check if the total size has changed by a large factor.
   if (!needImageVisibilityUpdate) {
     if ((newDisplayPort.width > 2 * oldDisplayPort.width) ||
         (oldDisplayPort.width > 2 * newDisplayPort.width) ||
         (newDisplayPort.height > 2 * oldDisplayPort.height) ||
         (oldDisplayPort.height > 2 * newDisplayPort.height)) {
       needImageVisibilityUpdate = true;