From 072bee695613fe1b0753aea3c7072ea7adbe092f Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Thu, 30 May 2013 16:34:32 +1200 Subject: [PATCH] Bug 874295. On non-Android platforms (and eventually for Android), use call GetDefaultScale instead of GetDevicePixelsPerMetaViewportPixel. r=mbrubeck --HG-- extra : rebase_source : 9c0544baccfe277e9340d185f189eda174923eb4 --- content/base/public/nsContentUtils.h | 4 ++++ content/base/src/nsContentUtils.cpp | 2 ++ content/base/src/nsDocument.cpp | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index 8f7797e49405..4977d4178269 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -1560,10 +1560,14 @@ public: uint32_t aDisplayWidth, uint32_t aDisplayHeight); +#ifdef MOZ_WIDGET_ANDROID /** * The device-pixel-to-CSS-px ratio used to adjust meta viewport values. + * XXX Not to be used --- use nsIWidget::GetDefaultScale instead. Will be + * removed when bug 803207 is fixed. */ static double GetDevicePixelsPerMetaViewportPixel(nsIWidget* aWidget); +#endif // Call EnterMicroTask when you're entering JS execution. // Usually the best way to do this is to use nsAutoMicroTask. diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 858fb3e020f7..f42dcf4922ef 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -4905,6 +4905,7 @@ nsContentUtils::GetViewportInfo(nsIDocument *aDocument, return aDocument->GetViewportInfo(aDisplayWidth, aDisplayHeight); } +#ifdef MOZ_WIDGET_ANDROID /* static */ double nsContentUtils::GetDevicePixelsPerMetaViewportPixel(nsIWidget* aWidget) @@ -4926,6 +4927,7 @@ nsContentUtils::GetDevicePixelsPerMetaViewportPixel(nsIWidget* aWidget) // For very high-density displays like the iPhone 4, use an integer ratio. return floor(dpi / 150.0); } +#endif /* static */ nsresult diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 0eccf5208b19..e16cfae2f34c 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -6892,7 +6892,12 @@ nsDocument::GetViewportInfo(uint32_t aDisplayWidth, } // Now convert the scale into device pixels per CSS pixel. nsIWidget *widget = nsContentUtils::WidgetForDocument(this); +#ifdef MOZ_WIDGET_ANDROID + // Temporarily use special Android code until bug 803207 is fixed double pixelRatio = widget ? nsContentUtils::GetDevicePixelsPerMetaViewportPixel(widget) : 1.0; +#else + double pixelRatio = widget ? widget->GetDefaultScale() : 1.0; +#endif float scaleFloat = mScaleFloat * pixelRatio; float scaleMinFloat= mScaleMinFloat * pixelRatio; float scaleMaxFloat = mScaleMaxFloat * pixelRatio;