Bug 1535862. Don't use a property after changing it in nsDOMWindowUtils::SetDisplayPortForElement. r=botond
authorTimothy Nikkel <tnikkel@gmail.com>
Sat, 16 Mar 2019 22:14:35 +0000
changeset 522388 9d4aec1e584c81b11616c79dd30988ae6de25817
parent 522387 ec61f19960f3ad4067c6be72a429447c705800c9
child 522389 37761497b6c1c9f52f9bb526892274fe6ac0fb7b
push id10871
push usercbrindusan@mozilla.com
push dateMon, 18 Mar 2019 15:49:32 +0000
treeherdermozilla-beta@018abdd16060 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1535862
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 1535862. Don't use a property after changing it in nsDOMWindowUtils::SetDisplayPortForElement. r=botond Differential Revision: https://phabricator.services.mozilla.com/D23801
dom/base/nsDOMWindowUtils.cpp
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -430,20 +430,28 @@ nsDOMWindowUtils::SetDisplayPortForEleme
   if (!aElement) {
     return NS_ERROR_INVALID_ARG;
   }
 
   if (aElement->GetUncomposedDoc() != presShell->GetDocument()) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  DisplayPortPropertyData* currentData = static_cast<DisplayPortPropertyData*>(
-      aElement->GetProperty(nsGkAtoms::DisplayPort));
-  if (currentData && currentData->mPriority > aPriority) {
-    return NS_OK;
+  bool hadDisplayPort = false;
+  nsRect oldDisplayPort;
+  {
+    DisplayPortPropertyData* currentData = static_cast<DisplayPortPropertyData*>(
+        aElement->GetProperty(nsGkAtoms::DisplayPort));
+    if (currentData) {
+      if (currentData->mPriority > aPriority) {
+        return NS_OK;
+      }
+      hadDisplayPort = true;
+      oldDisplayPort = currentData->mRect;
+    }
   }
 
   nsRect displayport(nsPresContext::CSSPixelsToAppUnits(aXPx),
                      nsPresContext::CSSPixelsToAppUnits(aYPx),
                      nsPresContext::CSSPixelsToAppUnits(aWidthPx),
                      nsPresContext::CSSPixelsToAppUnits(aHeightPx));
 
   aElement->SetProperty(nsGkAtoms::DisplayPort,
@@ -456,18 +464,17 @@ nsDOMWindowUtils::SetDisplayPortForEleme
         nsLayoutUtils::UsesAsyncScrolling(rootScrollFrame)) {
       // We are setting a root displayport for a document.
       // The pres shell needs a special flag set.
       presShell->SetIgnoreViewportScrolling(true);
     }
   }
 
   nsLayoutUtils::InvalidateForDisplayPortChange(
-      aElement, !!currentData, currentData ? currentData->mRect : nsRect(),
-      displayport);
+      aElement, hadDisplayPort, oldDisplayPort, displayport);
 
   nsIFrame* rootFrame = presShell->GetRootFrame();
   if (rootFrame) {
     rootFrame->SchedulePaint();
 
     // If we are hiding something that is a display root then send empty paint
     // transaction in order to release retained layers because it won't get
     // any more paint requests when it is hidden.