Bug 1000350. Don't overwrite a layout set display port base with an APZC-guessed one. r=kats
authorTimothy Nikkel <tnikkel@gmail.com>
Sat, 26 Apr 2014 00:13:36 -0500
changeset 198907 ce0bd55265b30145842dbbd98b33b1d95d9e7405
parent 198906 6ee5752cdf5be5f7b10ef60f976dc326a667e24c
child 198908 30b52597454bb20a22967ad448141caaeccb3038
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1000350
milestone31.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 1000350. Don't overwrite a layout set display port base with an APZC-guessed one. r=kats APZC set ones are only meant to fill in the gaps, use them only if we have nothing else.
gfx/layers/apz/util/APZCCallbackHelper.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -239,17 +239,17 @@ APZCCallbackHelper::UpdateRootFrame(nsID
                                                 alignment.width,
                                                 alignment.height,
                                                 element, 0);
         CSSRect baseCSS = aMetrics.mCompositionBounds / aMetrics.GetZoomToParent();
         nsRect base(baseCSS.x * nsPresContext::AppUnitsPerCSSPixel(),
                     baseCSS.y * nsPresContext::AppUnitsPerCSSPixel(),
                     baseCSS.width * nsPresContext::AppUnitsPerCSSPixel(),
                     baseCSS.height * nsPresContext::AppUnitsPerCSSPixel());
-        nsLayoutUtils::SetDisplayPortBase(content, base);
+        nsLayoutUtils::SetDisplayPortBaseIfNotSet(content, base);
     }
 }
 
 void
 APZCCallbackHelper::UpdateSubFrame(nsIContent* aContent,
                                    FrameMetrics& aMetrics)
 {
     // Precondition checks
@@ -294,17 +294,17 @@ APZCCallbackHelper::UpdateSubFrame(nsICo
                                                    alignment.width,
                                                    alignment.height,
                                                    element, 0);
             CSSRect baseCSS = aMetrics.mCompositionBounds / aMetrics.GetZoomToParent();
             nsRect base(baseCSS.x * nsPresContext::AppUnitsPerCSSPixel(),
                         baseCSS.y * nsPresContext::AppUnitsPerCSSPixel(),
                         baseCSS.width * nsPresContext::AppUnitsPerCSSPixel(),
                         baseCSS.height * nsPresContext::AppUnitsPerCSSPixel());
-            nsLayoutUtils::SetDisplayPortBase(aContent, base);
+            nsLayoutUtils::SetDisplayPortBaseIfNotSet(aContent, base);
         }
     }
 
     aMetrics.SetScrollOffset(actualScrollOffset);
 }
 
 already_AddRefed<nsIDOMWindowUtils>
 APZCCallbackHelper::GetDOMWindowUtils(const nsIDocument* aDoc)
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -824,16 +824,24 @@ nsLayoutUtils::SetDisplayPortMargins(nsI
 
 void
 nsLayoutUtils::SetDisplayPortBase(nsIContent* aContent, const nsRect& aBase)
 {
   aContent->SetProperty(nsGkAtoms::DisplayPortBase, new nsRect(aBase),
                         nsINode::DeleteProperty<nsRect>);
 }
 
+void
+nsLayoutUtils::SetDisplayPortBaseIfNotSet(nsIContent* aContent, const nsRect& aBase)
+{
+  if (!aContent->GetProperty(nsGkAtoms::DisplayPortBase)) {
+    SetDisplayPortBase(aContent, aBase);
+  }
+}
+
 bool
 nsLayoutUtils::GetCriticalDisplayPort(nsIContent* aContent, nsRect* aResult)
 {
   void* property = aContent->GetProperty(nsGkAtoms::CriticalDisplayPort);
   if (!property) {
     return false;
   }
 
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -182,18 +182,21 @@ public:
                                     uint32_t aAlignmentX,
                                     uint32_t aAlignmentY,
                                     uint32_t aPriority = 0,
                                     RepaintMode aRepaintMode = RepaintMode::Repaint);
 
   /**
    * Set the display port base rect for given element to be used with display
    * port margins.
+   * SetDisplayPortBaseIfNotSet is like SetDisplayPortBase except it only sets
+   * the display port base to aBase if no display port base is currently set.
    */
   static void SetDisplayPortBase(nsIContent* aContent, const nsRect& aBase);
+  static void SetDisplayPortBaseIfNotSet(nsIContent* aContent, const nsRect& aBase);
 
   /**
    * Get the critical display port for the given element.
    */
   static bool GetCriticalDisplayPort(nsIContent* aContent, nsRect* aResult = nullptr);
 
   /**
    * Use heuristics to figure out the child list that