Bug 1075670 - Use previous function for calculating process offset. r=smaug
authorDavid Parks <davidp99@gmail.com>
Tue, 24 Feb 2015 11:06:57 -0800
changeset 261510 659c402432821c923d8cf6ee9344a94dc7e00b59
parent 261509 45b61c78ee2d5288568a8a907e41348486e08c8b
child 261511 0e5726f6a3472c477e30fd68b345850863073020
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1075670
milestone39.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 1075670 - Use previous function for calculating process offset. r=smaug On B2G, the primary frame for tab content was not giving the correct process offset so we revert back to the mechanism we used to have in nsSubdocumentFrame.
dom/ipc/TabParent.cpp
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -899,16 +899,48 @@ TabParent::RecvSetDimensions(const uint3
     treeOwnerAsWin->SetSize(aCx, aCy, true);
     return true;
   }
 
   MOZ_ASSERT(false, "Unknown flags!");
   return false;
 }
 
+static nsIntPoint
+GetChromeDisplacement(nsFrameLoader *aFrameLoader)
+{
+  if (!aFrameLoader) {
+    return nsIntPoint();
+  }
+
+  // Calculate the displacement from the primary frame of the tab
+  // content to the top-level frame of the widget we are in.
+  nsIFrame* contentFrame = aFrameLoader->GetPrimaryFrameOfOwningContent();
+  if (!contentFrame) {
+    return nsIntPoint();
+  }
+
+  nsIFrame* nextFrame = nsLayoutUtils::GetCrossDocParentFrame(contentFrame);
+  if (!nextFrame) {
+    NS_WARNING("Couldn't find window chrome to calculate displacement to.");
+    return nsIntPoint();
+  }
+
+  nsIFrame* rootFrame = nextFrame;
+  while (nextFrame) {
+    rootFrame = nextFrame;
+    nextFrame = nsLayoutUtils::GetCrossDocParentFrame(rootFrame);
+  }
+
+  nsPoint offset = contentFrame->GetOffsetToCrossDoc(rootFrame);
+  int32_t appUnitsPerDevPixel = rootFrame->PresContext()->AppUnitsPerDevPixel();
+  return nsIntPoint((int)(offset.x/appUnitsPerDevPixel),
+                    (int)(offset.y/appUnitsPerDevPixel));
+}
+
 void
 TabParent::UpdateDimensions(const nsIntRect& rect, const nsIntSize& size)
 {
   if (mIsDestroyed) {
     return;
   }
   hal::ScreenConfiguration config;
   hal::GetCurrentScreenConfiguration(&config);
@@ -923,17 +955,19 @@ TabParent::UpdateDimensions(const nsIntR
       contentRect.y += widget->GetClientOffset().y;
     }
 
     mUpdatedDimensions = true;
     mRect = contentRect;
     mDimensions = size;
     mOrientation = orientation;
 
-    nsIntPoint chromeOffset = -GetChildProcessOffset();
+    nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
+    nsIntPoint chromeOffset = GetChromeDisplacement(frameLoader);
+
     unused << SendUpdateDimensions(mRect, mDimensions, mOrientation, chromeOffset);
   }
 }
 
 void
 TabParent::UpdateFrame(const FrameMetrics& aFrameMetrics)
 {
   if (!mIsDestroyed) {