Bug 1338776 - Support GetContentsScaleFactor and GetDefaultCSSScaleFactor in ScreenProxy. r?jfkthame draft
authorJonathan Kew <jkew@mozilla.com>
Fri, 29 Jul 2016 17:10:17 +0100
changeset 485200 e1bb2a76b4fdec59e2526482557d3253fc5a2053
parent 484601 c0807d6938c13e43add377d5838df7168a59971e
child 545970 6ed8b38c85d8082c2df2b86b82b6a858ec9ffbd9
push id45682
push userVYV03354@nifty.ne.jp
push dateThu, 16 Feb 2017 12:15:40 +0000
reviewersjfkthame
bugs1338776
milestone54.0a1
Bug 1338776 - Support GetContentsScaleFactor and GetDefaultCSSScaleFactor in ScreenProxy. r?jfkthame MozReview-Commit-ID: 182XriWmTpn
dom/ipc/PScreenManager.ipdl
dom/ipc/ScreenManagerParent.cpp
widget/ScreenProxy.cpp
widget/ScreenProxy.h
--- a/dom/ipc/PScreenManager.ipdl
+++ b/dom/ipc/PScreenManager.ipdl
@@ -18,16 +18,17 @@ struct ScreenDetails {
   uint32_t id;
   nsIntRect rect;
   nsIntRect rectDisplayPix;
   nsIntRect availRect;
   nsIntRect availRectDisplayPix;
   int32_t pixelDepth;
   int32_t colorDepth;
   double contentsScaleFactor;
+  double defaultCSSScaleFactor;
 };
 
 nested(upto inside_cpow) sync protocol PScreenManager
 {
   manager PContent;
 
 parent:
     nested(inside_sync) sync Refresh()
--- a/dom/ipc/ScreenManagerParent.cpp
+++ b/dom/ipc/ScreenManagerParent.cpp
@@ -211,16 +211,21 @@ ScreenManagerParent::ExtractScreenDetail
   NS_ENSURE_SUCCESS(rv, false);
   aDetails.colorDepth() = colorDepth;
 
   double contentsScaleFactor = 1.0;
   rv = aScreen->GetContentsScaleFactor(&contentsScaleFactor);
   NS_ENSURE_SUCCESS(rv, false);
   aDetails.contentsScaleFactor() = contentsScaleFactor;
 
+  double defaultCSSScaleFactor = 1.0;
+  rv = aScreen->GetDefaultCSSScaleFactor(&defaultCSSScaleFactor);
+  NS_ENSURE_SUCCESS(rv, false);
+  aDetails.defaultCSSScaleFactor() = defaultCSSScaleFactor;
+
   return true;
 }
 
 void
 ScreenManagerParent::ActorDestroy(ActorDestroyReason why)
 {
 }
 
--- a/widget/ScreenProxy.cpp
+++ b/widget/ScreenProxy.cpp
@@ -16,16 +16,17 @@ namespace mozilla {
 namespace widget {
 
 using namespace mozilla::dom;
 
 static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
 
 ScreenProxy::ScreenProxy(nsScreenManagerProxy* aScreenManager, ScreenDetails aDetails)
   : mContentsScaleFactor(0)
+  , mDefaultCSSScaleFactor(0)
   , mScreenManager(aScreenManager)
   , mId(0)
   , mPixelDepth(0)
   , mColorDepth(0)
   , mCacheValid(false)
   , mCacheWillInvalidate(false)
 {
   PopulateByDetails(aDetails);
@@ -123,27 +124,50 @@ ScreenProxy::GetColorDepth(int32_t *aCol
   if (!EnsureCacheIsValid()) {
     return NS_ERROR_FAILURE;
   }
 
   *aColorDepth = mColorDepth;
   return NS_OK;
 }
 
+NS_IMETHODIMP
+ScreenProxy::GetContentsScaleFactor(double* aContentsScaleFactor)
+{
+  if (!EnsureCacheIsValid()) {
+    return NS_ERROR_FAILURE;
+  }
+
+  *aContentsScaleFactor = mContentsScaleFactor;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+ScreenProxy::GetDefaultCSSScaleFactor(double* aScaleFactor)
+{
+  if (!EnsureCacheIsValid()) {
+    return NS_ERROR_FAILURE;
+  }
+
+  *aScaleFactor = mDefaultCSSScaleFactor;
+  return NS_OK;
+}
+
 void
 ScreenProxy::PopulateByDetails(ScreenDetails aDetails)
 {
   mId = aDetails.id();
   mRect = nsIntRect(aDetails.rect());
   mRectDisplayPix = nsIntRect(aDetails.rectDisplayPix());
   mAvailRect = nsIntRect(aDetails.availRect());
   mAvailRectDisplayPix = nsIntRect(aDetails.availRectDisplayPix());
   mPixelDepth = aDetails.pixelDepth();
   mColorDepth = aDetails.colorDepth();
   mContentsScaleFactor = aDetails.contentsScaleFactor();
+  mDefaultCSSScaleFactor = aDetails.defaultCSSScaleFactor();
 }
 
 bool
 ScreenProxy::EnsureCacheIsValid()
 {
   if (mCacheValid) {
     return true;
   }
--- a/widget/ScreenProxy.h
+++ b/widget/ScreenProxy.h
@@ -39,24 +39,28 @@ public:
                             int32_t* aHeight) override;
     NS_IMETHOD GetAvailRectDisplayPix(int32_t* aLeft,
                                       int32_t* aTop,
                                       int32_t* aWidth,
                                       int32_t* aHeight) override;
     NS_IMETHOD GetPixelDepth(int32_t* aPixelDepth) override;
     NS_IMETHOD GetColorDepth(int32_t* aColorDepth) override;
 
+    NS_IMETHOD GetContentsScaleFactor(double* aContentsScaleFactor) override;
+    NS_IMETHOD GetDefaultCSSScaleFactor(double* aScaleFactor) override;
+
 private:
 
     void PopulateByDetails(mozilla::dom::ScreenDetails aDetails);
     bool EnsureCacheIsValid();
     void InvalidateCacheOnNextTick();
     void InvalidateCache();
 
     double mContentsScaleFactor;
+    double mDefaultCSSScaleFactor;
     RefPtr<nsScreenManagerProxy> mScreenManager;
     uint32_t mId;
     int32_t mPixelDepth;
     int32_t mColorDepth;
     nsIntRect mRect;
     nsIntRect mRectDisplayPix;
     nsIntRect mAvailRect;
     nsIntRect mAvailRectDisplayPix;