Add an nsIGfxInfo function to query monitors. (bug 1175005 part 1, r=mattwoodrow)
authorDavid Anderson <danderson@mozilla.com>
Wed, 17 Jun 2015 23:11:55 -0700
changeset 281868 2dba54b89ec8cc7a6c73eb38e8d539a5fe80bde3
parent 281867 1db9723f1617d9c9fbeadc2cd186d8b59010f543
child 281869 59a89d5db8f0d80b0703a69345ebffe947326bac
push id897
push userjlund@mozilla.com
push dateMon, 14 Sep 2015 18:56:12 +0000
treeherdermozilla-release@9411e2d2b214 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1175005
milestone41.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.
@@ -80,16 +81,20 @@ public:
   virtual nsString Hardware() { return EmptyString(); }
   virtual nsString Product() { return EmptyString(); }
   virtual nsString Manufacturer() { return EmptyString(); }
   virtual uint32_t OperatingSystemVersion() { return 0; }
 
   // Convenience to get the application version
   static const nsCString& GetApplicationVersion();
 
+  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