Bug 799078. Part 2: Get Mac plugin content scale factor from the device context instead of guessing. r=smichaud
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 09 Oct 2012 00:24:18 +1300
changeset 110254 256882fd63c7
parent 110253 0c8ac346e41b
child 110255 784bb7c5ea9c
push id23680
push useremorley@mozilla.com
push date2012-10-16 08:09 +0000
treeherdermozilla-central@8f145599e4bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmichaud
bugs799078
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 799078. Part 2: Get Mac plugin content scale factor from the device context instead of guessing. r=smichaud
dom/plugins/base/nsPluginInstanceOwner.cpp
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -3725,34 +3725,20 @@ NS_IMETHODIMP
 nsPluginInstanceOwner::GetContentsScaleFactor(double *result)
 {
   NS_ENSURE_ARG_POINTER(result);
   double scaleFactor = 1.0;
   // On Mac, device pixels need to be translated to (and from) "display pixels"
   // for plugins. On other platforms, plugin coordinates are always in device
   // pixels.
 #if defined(XP_MACOSX)
-  if (mWidget) {
-    scaleFactor = mWidget->GetDefaultScale();
-  } else {
-    nsCOMPtr<nsIScreenManager> screenMgr =
-      do_GetService("@mozilla.org/gfx/screenmanager;1");
-    if (screenMgr) {
-      nsCOMPtr<nsIScreen> screen;
-      nsIntRect screenRect = mObjectFrame->GetScreenRect();
-      screenMgr->ScreenForRect(screenRect.x, screenRect.y,
-                               screenRect.width, screenRect.height,
-                               getter_AddRefs(screen));
-      if (screen) {
-        nsresult rv = screen->GetContentsScaleFactor(&scaleFactor);
-        if (NS_FAILED(rv)) {
-          scaleFactor = 1.0;
-        }
-      }
-    }
+  nsIPresShell* presShell = nsContentUtils::FindPresShellForDocument(mContent->OwnerDoc());
+  if (presShell) {
+    scaleFactor = double(nsPresContext::AppUnitsPerCSSPixel())/
+      presShell->GetPresContext()->DeviceContext()->UnscaledAppUnitsPerDevPixel();
   }
 #endif
   *result = scaleFactor;
   return NS_OK;
 }
 
 void nsPluginInstanceOwner::SetFrame(nsObjectFrame *aFrame)
 {