From cc96ea4f38c374fe5b13f9ff1d039f868bb3d0c8 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 30 Aug 2013 13:11:01 -0400 Subject: [PATCH] Bug 907754 - Ensure that the zoom on the FrameMetrics is initialized correctly for all frames. r=tn RecordFrameMetrics gets called on a variety of layers. Previously it would incorrectly set mZoom for a number of these layers. For scrollable container layers inside the main document, it would set the mResolution from the presShell's resolution, thus compounding the painted resolution. Furthermore, for iframes inside the document, it would assign mZoom the value from TabChild's mLastMetrics, which is only meant to apply to the top-level document. Prior to multi-apzc work these values were never used so it didn't matter but now they are so they should be assigned correctly. --- dom/ipc/TabChild.h | 2 -- layout/base/nsDisplayList.cpp | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 75793fc65058..862f0fb4cb9c 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -300,8 +300,6 @@ public: void GetDPI(float* aDPI); void GetDefaultScale(double *aScale); - CSSToScreenScale GetZoom() { return mLastMetrics.mZoom; } - ScreenOrientation GetOrientation() { return mOrientation; } void SetBackgroundColor(const nscolor& aColor); diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 2735193d202b..b12509ec0d4d 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -660,15 +660,22 @@ static void RecordFrameMetrics(nsIFrame* aForFrame, metrics.mScrollId = aScrollId; nsIPresShell* presShell = presContext->GetPresShell(); - if (TabChild *tc = GetTabChildFrom(presShell)) { - metrics.mZoom = tc->GetZoom(); + if (metrics.mScrollId == FrameMetrics::ROOT_SCROLL_ID) { + metrics.mResolution = LayoutDeviceToLayerScale(presShell->GetXResolution(), + presShell->GetYResolution()); + } else { + // Only the root scrollable frame for a given presShell should pick up + // the presShell's resolution. All the other subframes are 1.0. + metrics.mResolution = LayoutDeviceToLayerScale(1.0f); } - metrics.mResolution = LayoutDeviceToLayerScale(presShell->GetXResolution(), - presShell->GetYResolution()); - metrics.mDevPixelsPerCSSPixel = CSSToLayoutDeviceScale( (float)nsPresContext::AppUnitsPerCSSPixel() / auPerDevPixel); + // Provide an initial zoom to the AsyncPanZoomController so that it + // renders the content to the screen at the painted resolution. + metrics.mZoom = metrics.mResolution * metrics.mDevPixelsPerCSSPixel + * LayerToScreenScale(1.0f); + metrics.mMayHaveTouchListeners = aMayHaveTouchListeners; if (nsIWidget* widget = aForFrame->GetNearestWidget()) {