Bug 1582288. Don't get the display port in nsLayoutUtils::SetDisplayPortMargins when we don't need it because we don't have a frame. r=botond
authorTimothy Nikkel <tnikkel@gmail.com>
Fri, 20 Sep 2019 18:36:30 +0000
changeset 494338 9bb8cf06af1404e514589606da0914f79e64b160
parent 494337 f54880c23f57536a2ef4469cb3c11e88d498ac6a
child 494339 899aa346b320a180dca88be1485f19cee20d50c4
push id95969
push usertnikkel@mozilla.com
push dateFri, 20 Sep 2019 21:55:35 +0000
treeherderautoland@9bb8cf06af14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1582288
milestone71.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 1582288. Don't get the display port in nsLayoutUtils::SetDisplayPortMargins when we don't need it because we don't have a frame. r=botond It will generate a warning and is useless as explained in the code comment. Differential Revision: https://phabricator.services.mozilla.com/D46626
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1191,37 +1191,48 @@ bool nsLayoutUtils::SetDisplayPortMargin
 
   DisplayPortMarginsPropertyData* currentData =
       static_cast<DisplayPortMarginsPropertyData*>(
           aContent->GetProperty(nsGkAtoms::DisplayPortMargins));
   if (currentData && currentData->mPriority > aPriority) {
     return false;
   }
 
+  nsIFrame* scrollFrame = GetScrollFrameFromContent(aContent);
+
   nsRect oldDisplayPort;
-  bool hadDisplayPort = GetHighResolutionDisplayPort(aContent, &oldDisplayPort);
+  bool hadDisplayPort = false;
+  if (scrollFrame) {
+    // We only use the two return values from this function to call
+    // InvalidateForDisplayPortChange. InvalidateForDisplayPortChange does
+    // nothing if aContent does not have a frame. So getting the displayport is
+    // useless if the content has no frame, so we avoid calling this to avoid
+    // triggering a warning about not having a frame.
+    hadDisplayPort = GetHighResolutionDisplayPort(aContent, &oldDisplayPort);
+  }
 
   aContent->SetProperty(
       nsGkAtoms::DisplayPortMargins,
       new DisplayPortMarginsPropertyData(aMargins, aPriority),
       nsINode::DeleteProperty<DisplayPortMarginsPropertyData>);
 
   nsRect newDisplayPort;
   DebugOnly<bool> hasDisplayPort =
       GetHighResolutionDisplayPort(aContent, &newDisplayPort);
   MOZ_ASSERT(hasDisplayPort);
 
+  nsIScrollableFrame* scrollableFrame =
+      scrollFrame ? scrollFrame->GetScrollTargetFrame() : nullptr;
+  if (!scrollableFrame) {
+    return true;
+  }
+
   InvalidateForDisplayPortChange(aContent, hadDisplayPort, oldDisplayPort,
                                  newDisplayPort, aRepaintMode);
 
-  nsIScrollableFrame* scrollableFrame = FindScrollableFrameFor(aContent);
-  if (!scrollableFrame) {
-    return true;
-  }
-
   scrollableFrame->TriggerDisplayPortExpiration();
 
   // Display port margins changing means that the set of visible frames may
   // have drastically changed. Check if we should schedule an update.
   hadDisplayPort =
       scrollableFrame->GetDisplayPortAtLastApproximateFrameVisibilityUpdate(
           &oldDisplayPort);