Bug 874295. On non-Android platforms (and eventually for Android), use call GetDefaultScale instead of GetDevicePixelsPerMetaViewportPixel. r=mbrubeck

--HG--
extra : rebase_source : 92e6c476f847349969430d96fa363b6f46bb8d5b
This commit is contained in:
Robert O'Callahan 2013-05-30 16:34:32 +12:00
parent 4a5fb8a9b7
commit f476fe7554
3 changed files with 11 additions and 0 deletions

View File

@ -1560,10 +1560,14 @@ public:
uint32_t aDisplayWidth, uint32_t aDisplayWidth,
uint32_t aDisplayHeight); uint32_t aDisplayHeight);
#ifdef MOZ_WIDGET_ANDROID
/** /**
* The device-pixel-to-CSS-px ratio used to adjust meta viewport values. * 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); static double GetDevicePixelsPerMetaViewportPixel(nsIWidget* aWidget);
#endif
// Call EnterMicroTask when you're entering JS execution. // Call EnterMicroTask when you're entering JS execution.
// Usually the best way to do this is to use nsAutoMicroTask. // Usually the best way to do this is to use nsAutoMicroTask.

View File

@ -4902,6 +4902,7 @@ nsContentUtils::GetViewportInfo(nsIDocument *aDocument,
return aDocument->GetViewportInfo(aDisplayWidth, aDisplayHeight); return aDocument->GetViewportInfo(aDisplayWidth, aDisplayHeight);
} }
#ifdef MOZ_WIDGET_ANDROID
/* static */ /* static */
double double
nsContentUtils::GetDevicePixelsPerMetaViewportPixel(nsIWidget* aWidget) nsContentUtils::GetDevicePixelsPerMetaViewportPixel(nsIWidget* aWidget)
@ -4923,6 +4924,7 @@ nsContentUtils::GetDevicePixelsPerMetaViewportPixel(nsIWidget* aWidget)
// For very high-density displays like the iPhone 4, use an integer ratio. // For very high-density displays like the iPhone 4, use an integer ratio.
return floor(dpi / 150.0); return floor(dpi / 150.0);
} }
#endif
/* static */ /* static */
nsresult nsresult

View File

@ -6892,7 +6892,12 @@ nsDocument::GetViewportInfo(uint32_t aDisplayWidth,
} }
// Now convert the scale into device pixels per CSS pixel. // Now convert the scale into device pixels per CSS pixel.
nsIWidget *widget = nsContentUtils::WidgetForDocument(this); 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; double pixelRatio = widget ? nsContentUtils::GetDevicePixelsPerMetaViewportPixel(widget) : 1.0;
#else
double pixelRatio = widget ? widget->GetDefaultScale() : 1.0;
#endif
float scaleFloat = mScaleFloat * pixelRatio; float scaleFloat = mScaleFloat * pixelRatio;
float scaleMinFloat= mScaleMinFloat * pixelRatio; float scaleMinFloat= mScaleMinFloat * pixelRatio;
float scaleMaxFloat = mScaleMaxFloat * pixelRatio; float scaleMaxFloat = mScaleMaxFloat * pixelRatio;