accessible/src/windows/msaa/ApplicationAccessibleWrap.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* vim:expandtab:shiftwidth=4:tabstop=4:
     3  */
     4 /* This Source Code Form is subject to the terms of the Mozilla Public
     5  * License, v. 2.0. If a copy of the MPL was not distributed with this
     6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     8 #include "ApplicationAccessibleWrap.h"
    10 #include "AccessibleApplication_i.c"
    11 #include "IUnknownImpl.h"
    13 #include "nsIGfxInfo.h"
    14 #include "nsIPersistentProperties2.h"
    15 #include "nsServiceManagerUtils.h"
    17 using namespace mozilla;
    18 using namespace mozilla::a11y;
    20 ////////////////////////////////////////////////////////////////////////////////
    21 // nsISupports
    22 NS_IMPL_ISUPPORTS_INHERITED0(ApplicationAccessibleWrap,
    23                              ApplicationAccessible)
    25 already_AddRefed<nsIPersistentProperties>
    26 ApplicationAccessibleWrap::NativeAttributes()
    27 {
    28   nsCOMPtr<nsIPersistentProperties> attributes =
    29     do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
    31   nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
    32   if (gfxInfo) {
    33     bool isD2DEnabled = false;
    34     gfxInfo->GetD2DEnabled(&isD2DEnabled);
    35     nsAutoString unused;
    36     attributes->SetStringProperty(
    37       NS_LITERAL_CSTRING("D2D"),
    38       isD2DEnabled ? NS_LITERAL_STRING("true") : NS_LITERAL_STRING("false"),
    39         unused);
    40   }
    42   return attributes.forget();
    43 }
    45 ////////////////////////////////////////////////////////////////////////////////
    46 // IUnknown
    48 STDMETHODIMP
    49 ApplicationAccessibleWrap::QueryInterface(REFIID iid, void** ppv)
    50 {
    51   if (!ppv)
    52     return E_INVALIDARG;
    54   *ppv = nullptr;
    56   if (IID_IAccessibleApplication == iid) {
    57     *ppv = static_cast<IAccessibleApplication*>(this);
    58     (reinterpret_cast<IUnknown*>(*ppv))->AddRef();
    59     return S_OK;
    60   }
    62   return AccessibleWrap::QueryInterface(iid, ppv);
    63 }
    65 ////////////////////////////////////////////////////////////////////////////////
    66 // IAccessibleApplication
    68 STDMETHODIMP
    69 ApplicationAccessibleWrap::get_appName(BSTR* aName)
    70 {
    71   A11Y_TRYBLOCK_BEGIN
    73   if (!aName)
    74     return E_INVALIDARG;
    76   *aName = nullptr;
    78   if (IsDefunct())
    79     return CO_E_OBJNOTCONNECTED;
    81   nsAutoString name;
    82   nsresult rv = GetAppName(name);
    83   if (NS_FAILED(rv))
    84     return GetHRESULT(rv);
    86   if (name.IsEmpty())
    87     return S_FALSE;
    89   *aName = ::SysAllocStringLen(name.get(), name.Length());
    90   return *aName ? S_OK : E_OUTOFMEMORY;
    92   A11Y_TRYBLOCK_END
    93 }
    95 STDMETHODIMP
    96 ApplicationAccessibleWrap::get_appVersion(BSTR* aVersion)
    97 {
    98   A11Y_TRYBLOCK_BEGIN
   100   if (!aVersion)
   101     return E_INVALIDARG;
   103   *aVersion = nullptr;
   105   if (IsDefunct())
   106     return CO_E_OBJNOTCONNECTED;
   108   nsAutoString version;
   109   nsresult rv = GetAppVersion(version);
   110   if (NS_FAILED(rv))
   111     return GetHRESULT(rv);
   113   if (version.IsEmpty())
   114     return S_FALSE;
   116   *aVersion = ::SysAllocStringLen(version.get(), version.Length());
   117   return *aVersion ? S_OK : E_OUTOFMEMORY;
   119   A11Y_TRYBLOCK_END
   120 }
   122 STDMETHODIMP
   123 ApplicationAccessibleWrap::get_toolkitName(BSTR* aName)
   124 {
   125   A11Y_TRYBLOCK_BEGIN
   127   if (!aName)
   128     return E_INVALIDARG;
   130   if (IsDefunct())
   131     return CO_E_OBJNOTCONNECTED;
   133   nsAutoString name;
   134   nsresult rv = GetPlatformName(name);
   135   if (NS_FAILED(rv))
   136     return GetHRESULT(rv);
   138   if (name.IsEmpty())
   139     return S_FALSE;
   141   *aName = ::SysAllocStringLen(name.get(), name.Length());
   142   return *aName ? S_OK : E_OUTOFMEMORY;
   144   A11Y_TRYBLOCK_END
   145 }
   147 STDMETHODIMP
   148 ApplicationAccessibleWrap::get_toolkitVersion(BSTR* aVersion)
   149 {
   150   A11Y_TRYBLOCK_BEGIN
   152   if (!aVersion)
   153     return E_INVALIDARG;
   155   *aVersion = nullptr;
   157   if (IsDefunct())
   158     return CO_E_OBJNOTCONNECTED;
   160   nsAutoString version;
   161   nsresult rv = GetPlatformVersion(version);
   162   if (NS_FAILED(rv))
   163     return GetHRESULT(rv);
   165   if (version.IsEmpty())
   166     return S_FALSE;
   168   *aVersion = ::SysAllocStringLen(version.get(), version.Length());
   169   return *aVersion ? S_OK : E_OUTOFMEMORY;
   171   A11Y_TRYBLOCK_END
   172 }

mercurial