From 5ebb5ec1c3bd4879667d5e3775f8a2ac34577f5d Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 17 Jun 2015 23:11:55 -0700 Subject: [PATCH] Add an nsIGfxInfo function to query monitors. (bug 1175005 part 1, r=mattwoodrow) --- widget/GfxInfoBase.cpp | 14 ++++++++++++++ widget/GfxInfoBase.h | 7 ++++++- widget/nsIGfxInfo.idl | 13 ++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index 8625ba228a6..cf3e28b9570 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -1163,6 +1163,20 @@ GfxInfoBase::RemoveCollector(GfxInfoCollectorBase* collector) } } +NS_IMETHODIMP +GfxInfoBase::GetMonitors(JSContext* aCx, JS::MutableHandleValue aResult) +{ + JS::Rooted 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); diff --git a/widget/GfxInfoBase.h b/widget/GfxInfoBase.h index 6b539f234dc..be73e5a7f91 100644 --- a/widget/GfxInfoBase.h +++ b/widget/GfxInfoBase.h @@ -54,7 +54,8 @@ public: 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) override; @@ -89,6 +90,10 @@ public: return NS_ERROR_NOT_IMPLEMENTED; } + virtual nsresult FindMonitors(JSContext* cx, JS::HandleObject array) { + return NS_ERROR_NOT_IMPLEMENTED; + } + protected: virtual ~GfxInfoBase(); diff --git a/widget/nsIGfxInfo.idl b/widget/nsIGfxInfo.idl index fde9e6b27ff..8b10556b2fa 100644 --- a/widget/nsIGfxInfo.idl +++ b/widget/nsIGfxInfo.idl @@ -8,7 +8,7 @@ /* 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 { /* @@ -54,6 +54,17 @@ interface nsIGfxInfo : nsISupports 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,