Add an nsIGfxInfo function to query monitors. (bug 1175005 part 1, r=mattwoodrow)
☠☠ backed out by 1329c533bb46 ☠ ☠
authorDavid Anderson <danderson@mozilla.com>
Wed, 17 Jun 2015 23:11:55 -0700
changeset 283941 a02884944d456b1c3e0bf2e65c1a8bfda199d337
parent 283940 961059b7073e87a6cff75f73a91d67df09a44af7
child 283942 9fac75be77b7b002a6a8b39fa2bc445ffa7acc3c
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1175005
milestone42.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
Add an nsIGfxInfo function to query monitors. (bug 1175005 part 1, r=mattwoodrow)
widget/GfxInfoBase.cpp
widget/GfxInfoBase.h
widget/nsIGfxInfo.idl
--- a/widget/GfxInfoBase.cpp
+++ b/widget/GfxInfoBase.cpp
@@ -1158,16 +1158,30 @@ GfxInfoBase::RemoveCollector(GfxInfoColl
     }
   }
   if (sCollectors->IsEmpty()) {
     delete sCollectors;
     sCollectors = nullptr;
   }
 }
 
+NS_IMETHODIMP
+GfxInfoBase::GetMonitors(JSContext* aCx, JS::MutableHandleValue aResult)
+{
+  JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0));
+
+  nsresult rv = FindMonitors(aCx, array);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+
+  aResult.setObject(*array);
+  return NS_OK;
+}
+
 GfxInfoCollectorBase::GfxInfoCollectorBase()
 {
   GfxInfoBase::AddCollector(this);
 }
 
 GfxInfoCollectorBase::~GfxInfoCollectorBase()
 {
   GfxInfoBase::RemoveCollector(this);
--- a/widget/GfxInfoBase.h
+++ b/widget/GfxInfoBase.h
@@ -49,17 +49,18 @@ public:
   // using GfxInfoBase::GetFeatureStatus;
   // using GfxInfoBase::GetFeatureSuggestedDriverVersion;
   // using GfxInfoBase::GetWebGLParameter;
   // to import the relevant methods into their namespace.
   NS_IMETHOD GetFeatureStatus(int32_t aFeature, int32_t *_retval) override;
   NS_IMETHOD GetFeatureSuggestedDriverVersion(int32_t aFeature, nsAString & _retval) override;
   NS_IMETHOD GetWebGLParameter(const nsAString & aParam, nsAString & _retval) override;
 
-    NS_IMETHOD GetFailures(uint32_t *failureCount, int32_t** indices, char ***failures) override;
+  NS_IMETHOD GetMonitors(JSContext* cx, JS::MutableHandleValue _retval);
+  NS_IMETHOD GetFailures(uint32_t *failureCount, int32_t** indices, char ***failures) override;
   NS_IMETHOD_(void) LogFailure(const nsACString &failure) override;
   NS_IMETHOD GetInfo(JSContext*, JS::MutableHandle<JS::Value>) override;
 
   // Initialization function. If you override this, you must call this class's
   // version of Init first.
   // We need Init to be called separately from the constructor so we can
   // register as an observer after all derived classes have been constructed
   // and we know we have a non-zero refcount.
@@ -84,16 +85,20 @@ public:
 
   // Convenience to get the application version
   static const nsCString& GetApplicationVersion();
 
   virtual nsresult FindMonitors(JSContext* cx, JS::HandleObject array) {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
+  virtual nsresult FindMonitors(JSContext* cx, JS::HandleObject array) {
+    return NS_ERROR_NOT_IMPLEMENTED;
+  }
+
 protected:
 
   virtual ~GfxInfoBase();
 
   virtual nsresult GetFeatureStatusImpl(int32_t aFeature, int32_t* aStatus,
                                         nsAString& aSuggestedDriverVersion,
                                         const nsTArray<GfxDriverInfo>& aDriverInfo,
                                         OperatingSystem* aOS = nullptr);
--- a/widget/nsIGfxInfo.idl
+++ b/widget/nsIGfxInfo.idl
@@ -3,17 +3,17 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 /* NOTE: this interface is completely undesigned, not stable and likely to change */
 
-[scriptable, uuid(b0cd9d34-8dba-4b1d-8126-ca21826dbf35)]
+[scriptable, uuid(47eedfa0-f7cb-445b-b5cf-a2ca83600560)]
 interface nsIGfxInfo : nsISupports
 {
   /*
    * These are win32-specific
    */
   readonly attribute boolean D2DEnabled;
   readonly attribute boolean DWriteEnabled;
   readonly attribute DOMString DWriteVersion;
@@ -49,16 +49,27 @@ interface nsIGfxInfo : nsISupports
   readonly attribute DOMString adapterDriverVersion;
   readonly attribute DOMString adapterDriverVersion2;
   
   readonly attribute DOMString adapterDriverDate;
   readonly attribute DOMString adapterDriverDate2;
 
   readonly attribute boolean isGPU2Active;
 
+  /**
+   * Returns an array of objects describing each monitor. Guaranteed properties
+   * are "screenWidth" and "screenHeight". This is only implemented on Desktop.
+   *
+   * Windows additionally supplies "refreshRate" and "pseudoDisplay".
+   *
+   * OS X additionally supplies "scale".
+   */
+  [implicit_jscontext]
+  jsval getMonitors();
+
   void getFailures(
                out unsigned long failureCount,
                [optional, array, size_is(failureCount)] out long indices,
                [retval, array, size_is(failureCount)] out string failures);
 
   [noscript, notxpcom] void logFailure(in ACString failure);
   /*
    * A set of constants for features that we can ask this GfxInfo object