From ae1f78b6621dced8357e6a75c00d9fbbdff184ff Mon Sep 17 00:00:00 2001 From: Prabhjyot Singh Sodhi Date: Thu, 18 Dec 2014 19:33:18 -0500 Subject: [PATCH] Bug 1112830 - Changed mCumulativeResolution of FrameMetrics.h to private and all correspondings files using this variable using getters and setters;r=kats --- dom/ipc/TabChild.cpp | 11 +++++----- gfx/layers/FrameMetrics.h | 22 ++++++++++++++----- gfx/layers/LayersLogging.cpp | 2 +- gfx/layers/apz/src/APZCTreeManager.cpp | 4 ++-- gfx/layers/apz/src/AsyncPanZoomController.cpp | 8 +++---- .../composite/AsyncCompositionManager.cpp | 4 ++-- .../gtest/TestAsyncPanZoomController.cpp | 2 +- layout/base/nsDisplayList.cpp | 10 ++++----- layout/base/nsLayoutUtils.cpp | 2 +- 9 files changed, 37 insertions(+), 28 deletions(-) diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 0803ddc0e53..768da386a52 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -248,11 +248,10 @@ TabChildBase::InitializeRootMetrics() mLastRootMetrics.SetDevPixelsPerCSSPixel(WebWidget()->GetDefaultScale()); // We use ParentLayerToLayerScale(1) below in order to turn the // async zoom amount into the gecko zoom amount. - mLastRootMetrics.mCumulativeResolution = - mLastRootMetrics.GetZoom() / mLastRootMetrics.GetDevPixelsPerCSSPixel() * ParentLayerToLayerScale(1); + mLastRootMetrics.SetCumulativeResolution(mLastRootMetrics.GetZoom() / mLastRootMetrics.GetDevPixelsPerCSSPixel() * ParentLayerToLayerScale(1)); // This is the root layer, so the cumulative resolution is the same // as the resolution. - mLastRootMetrics.mPresShellResolution = mLastRootMetrics.mCumulativeResolution.scale; + mLastRootMetrics.mPresShellResolution = mLastRootMetrics.GetCumulativeResolution().scale; mLastRootMetrics.SetScrollOffset(CSSPoint(0, 0)); TABC_LOG("After InitializeRootMetrics, mLastRootMetrics is %s\n", @@ -430,12 +429,12 @@ TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize) } } - metrics.mCumulativeResolution = metrics.GetZoom() + metrics.SetCumulativeResolution(metrics.GetZoom() / metrics.GetDevPixelsPerCSSPixel() - * ParentLayerToLayerScale(1); + * ParentLayerToLayerScale(1)); // This is the root layer, so the cumulative resolution is the same // as the resolution. - metrics.mPresShellResolution = metrics.mCumulativeResolution.scale; + metrics.mPresShellResolution = metrics.GetCumulativeResolution().scale; utils->SetResolution(metrics.mPresShellResolution, metrics.mPresShellResolution); CSSSize scrollPort = metrics.CalculateCompositedSizeInCssPixels(); diff --git a/gfx/layers/FrameMetrics.h b/gfx/layers/FrameMetrics.h index 5ee30c1ee5a..ac5c0d6c5c5 100644 --- a/gfx/layers/FrameMetrics.h +++ b/gfx/layers/FrameMetrics.h @@ -303,13 +303,17 @@ public: // it does not convert between any coordinate spaces for which we have names. float mPresShellResolution; - // The cumulative resolution that the current frame has been painted at. - // This is the product of the pres-shell resolutions of the document - // containing this scroll frame and its ancestors, and any css-driven - // resolution. This information is provided by Gecko at layout/paint time. - LayoutDeviceToLayerScale mCumulativeResolution; - public: + void SetCumulativeResolution(const LayoutDeviceToLayerScale& aCumulativeResolution) + { + mCumulativeResolution = aCumulativeResolution; + } + + LayoutDeviceToLayerScale GetCumulativeResolution() const + { + return mCumulativeResolution; + } + void SetDevPixelsPerCSSPixel(const CSSToLayoutDeviceScale& aDevPixelsPerCSSPixel) { mDevPixelsPerCSSPixel = aDevPixelsPerCSSPixel; @@ -528,6 +532,12 @@ public: } private: + // The cumulative resolution that the current frame has been painted at. + // This is the product of the pres-shell resolutions of the document + // containing this scroll frame and its ancestors, and any css-driven + // resolution. This information is provided by Gecko at layout/paint time. + LayoutDeviceToLayerScale mCumulativeResolution; + // New fields from now on should be made private and old fields should // be refactored to be private. diff --git a/gfx/layers/LayersLogging.cpp b/gfx/layers/LayersLogging.cpp index 65c1bcc2066..b98b1ec8ed2 100644 --- a/gfx/layers/LayersLogging.cpp +++ b/gfx/layers/LayersLogging.cpp @@ -191,7 +191,7 @@ AppendToString(std::stringstream& aStream, const FrameMetrics& m, AppendToString(aStream, m.GetViewport(), "] [v="); aStream << nsPrintfCString("] [z=(ld=%.3f r=%.3f cr=%.3f z=%.3f er=%.3f)", m.GetDevPixelsPerCSSPixel().scale, m.mPresShellResolution, - m.mCumulativeResolution.scale, m.GetZoom().scale, + m.GetCumulativeResolution().scale, m.GetZoom().scale, m.GetExtraResolution().scale).get(); aStream << nsPrintfCString("] [u=(%d %d %lu)", m.GetScrollOffsetUpdated(), m.GetDoSmoothScroll(), diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index e1e3c60472d..6d6392bb875 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -214,7 +214,7 @@ ComputeTouchSensitiveRegion(GeckoContentController* aController, // this approximation may not be accurate in the presence of a css-driven // resolution. LayoutDeviceToParentLayerScale parentCumulativeResolution = - aMetrics.mCumulativeResolution + aMetrics.GetCumulativeResolution() / ParentLayerToLayerScale(aMetrics.mPresShellResolution); visible = visible.Intersect(touchSensitiveRegion * aMetrics.GetDevPixelsPerCSSPixel() @@ -561,7 +561,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(TreeBuildingState& aState, // resolution; this approximation may not be accurate in the presence of // a css-driven resolution. LayoutDeviceToParentLayerScale parentCumulativeResolution = - aLayer.Metrics().mCumulativeResolution + aLayer.Metrics().GetCumulativeResolution() / ParentLayerToLayerScale(aLayer.Metrics().mPresShellResolution); subtreeEventRegions.AndWith(ParentLayerIntRect::ToUntyped( RoundedIn(touchSensitiveRegion diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index f7f0fe4b55a..42a0f3ad7f5 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -2656,7 +2656,7 @@ Matrix4x4 AsyncPanZoomController::GetTransformToLastDispatchedPaint() const { LayerPoint scrollChange = (mLastContentPaintMetrics.GetScrollOffset() - mLastDispatchedPaintMetrics.GetScrollOffset()) * mLastContentPaintMetrics.GetDevPixelsPerCSSPixel() - * mLastContentPaintMetrics.mCumulativeResolution + * mLastContentPaintMetrics.GetCumulativeResolution() // This transform ("LD" in the terminology of the comment above // GetScreenToApzcTransform() in APZCTreeManager.h) is applied in a // coordinate space that includes the APZC's CSS transform ("LC"). @@ -2765,8 +2765,8 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri // our zoom to reflect that. Note that we can't just take // aLayerMetrics.mZoom because the APZ may have additional async zoom // since the repaint request. - float totalResolutionChange = aLayerMetrics.mCumulativeResolution.scale - / mFrameMetrics.mCumulativeResolution.scale; + float totalResolutionChange = aLayerMetrics.GetCumulativeResolution().scale + / mFrameMetrics.GetCumulativeResolution().scale; float presShellResolutionChange = aLayerMetrics.mPresShellResolution / mFrameMetrics.mPresShellResolution; mFrameMetrics.ZoomBy(totalResolutionChange / presShellResolutionChange); @@ -2783,7 +2783,7 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri mFrameMetrics.mCompositionBounds = aLayerMetrics.mCompositionBounds; mFrameMetrics.SetRootCompositionSize(aLayerMetrics.GetRootCompositionSize()); mFrameMetrics.mPresShellResolution = aLayerMetrics.mPresShellResolution; - mFrameMetrics.mCumulativeResolution = aLayerMetrics.mCumulativeResolution; + mFrameMetrics.SetCumulativeResolution(aLayerMetrics.GetCumulativeResolution()); mFrameMetrics.SetHasScrollgrab(aLayerMetrics.GetHasScrollgrab()); if (scrollOffsetUpdated) { diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index c5d0d9395d6..0a22a8eea50 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -636,7 +636,7 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer) // doesn't have the necessary transform to display correctly. We use the // bottom-most scrollable metrics because that should have the most accurate // cumulative resolution for aLayer. - LayoutDeviceToLayerScale resolution = bottom.mCumulativeResolution; + LayoutDeviceToLayerScale resolution = bottom.GetCumulativeResolution(); oldTransform.PreScale(resolution.scale, resolution.scale, 1); // For the purpose of aligning fixed and sticky layers, we disregard @@ -871,7 +871,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer) // appears to be that metrics.mZoom is poorly initialized in some scenarios. In these scenarios, // however, we can assume there is no async zooming in progress and so the following statement // works fine. - CSSToParentLayerScale userZoom(metrics.GetDevPixelsPerCSSPixel() * metrics.mCumulativeResolution * LayerToParentLayerScale(1)); + CSSToParentLayerScale userZoom(metrics.GetDevPixelsPerCSSPixel() * metrics.GetCumulativeResolution() * LayerToParentLayerScale(1)); ParentLayerPoint userScroll = metrics.GetScrollOffset() * userZoom; SyncViewportInfo(displayPort, geckoZoom, mLayersUpdated, userScroll, userZoom, fixedLayerMargins, diff --git a/gfx/tests/gtest/TestAsyncPanZoomController.cpp b/gfx/tests/gtest/TestAsyncPanZoomController.cpp index 57cab48de00..ebb193e8130 100644 --- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp +++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp @@ -819,7 +819,7 @@ TEST_F(APZCBasicTester, ComplexTransform) { metrics.mDisplayPort = CSSRect(-1, -1, 6, 6); metrics.SetScrollOffset(CSSPoint(10, 10)); metrics.mScrollableRect = CSSRect(0, 0, 50, 50); - metrics.mCumulativeResolution = LayoutDeviceToLayerScale(2); + metrics.SetCumulativeResolution(LayoutDeviceToLayerScale(2)); metrics.mPresShellResolution = 2.0f; metrics.SetZoom(CSSToParentLayerScale(6)); metrics.SetDevPixelsPerCSSPixel(CSSToLayoutDeviceScale(3)); diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 0e811952a53..6ccee26693a 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -750,13 +750,13 @@ nsDisplayScrollLayer::ComputeFrameMetrics(nsIFrame* aForFrame, // all the pres shells from here up to the root, as well as any css-driven // resolution. We don't need to compute it as it's already stored in the // container parameters. - metrics.mCumulativeResolution = LayoutDeviceToLayerScale(aContainerParameters.mXScale, - aContainerParameters.mYScale); + metrics.SetCumulativeResolution(LayoutDeviceToLayerScale(aContainerParameters.mXScale, + aContainerParameters.mYScale)); LayoutDeviceToScreenScale resolutionToScreen( presShell->GetCumulativeResolution().width * nsLayoutUtils::GetTransformToAncestorScale(aScrollFrame ? aScrollFrame : aForFrame).width); - metrics.SetExtraResolution(metrics.mCumulativeResolution / resolutionToScreen); + metrics.SetExtraResolution(metrics.GetCumulativeResolution() / resolutionToScreen); metrics.SetDevPixelsPerCSSPixel(CSSToLayoutDeviceScale( (float)nsPresContext::AppUnitsPerCSSPixel() / auPerDevPixel)); @@ -764,7 +764,7 @@ nsDisplayScrollLayer::ComputeFrameMetrics(nsIFrame* aForFrame, // Initially, AsyncPanZoomController should render the content to the screen // at the painted resolution. const LayerToParentLayerScale layerToParentLayerScale(1.0f); - metrics.SetZoom(metrics.mCumulativeResolution * metrics.GetDevPixelsPerCSSPixel() + metrics.SetZoom(metrics.GetCumulativeResolution() * metrics.GetDevPixelsPerCSSPixel() * layerToParentLayerScale); if (presShell) { @@ -787,7 +787,7 @@ nsDisplayScrollLayer::ComputeFrameMetrics(nsIFrame* aForFrame, nsRect compositionBounds(frameForCompositionBoundsCalculation->GetOffsetToCrossDoc(aReferenceFrame), frameForCompositionBoundsCalculation->GetSize()); ParentLayerRect frameBounds = LayoutDeviceRect::FromAppUnits(compositionBounds, auPerDevPixel) - * metrics.mCumulativeResolution + * metrics.GetCumulativeResolution() * layerToParentLayerScale; metrics.mCompositionBounds = frameBounds; diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 1b5c24acad5..8b4191545bc 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -2808,7 +2808,7 @@ CalculateFrameMetricsForDisplayPort(nsIScrollableFrame* aScrollFrame) { LayerToParentLayerScale layerToParentLayerScale(1.0f); metrics.SetDevPixelsPerCSSPixel(deviceScale); metrics.mPresShellResolution = resolution; - metrics.mCumulativeResolution = cumulativeResolution; + metrics.SetCumulativeResolution(cumulativeResolution); metrics.SetZoom(deviceScale * cumulativeResolution * layerToParentLayerScale); // Only the size of the composition bounds is relevant to the