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.
This commit is contained in:
Kartikaya Gupta 2013-08-30 13:11:01 -04:00
Родитель 8a1bb24abf
Коммит cc96ea4f38
2 изменённых файлов: 12 добавлений и 7 удалений

Просмотреть файл

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

Просмотреть файл

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