Bug 1112830 - Changed mCumulativeResolution of FrameMetrics.h to private and all correspondings files using this variable using getters and setters;r=kats

This commit is contained in:
Prabhjyot Singh Sodhi 2014-12-18 19:33:18 -05:00
parent 86811c850f
commit ae1f78b662
9 changed files with 37 additions and 28 deletions

View File

@ -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();

View File

@ -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.

View File

@ -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(),

View File

@ -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

View File

@ -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) {

View File

@ -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,

View File

@ -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));

View File

@ -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;

View File

@ -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