accessible/src/windows/ia2/ia2AccessibleComponent.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: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim:expandtab:shiftwidth=2:tabstop=2:
     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 "ia2AccessibleComponent.h"
    10 #include "AccessibleComponent_i.c"
    12 #include "AccessibleWrap.h"
    13 #include "States.h"
    14 #include "IUnknownImpl.h"
    16 #include "nsIFrame.h"
    18 using namespace mozilla::a11y;
    20 // IUnknown
    22 STDMETHODIMP
    23 ia2AccessibleComponent::QueryInterface(REFIID iid, void** ppv)
    24 {
    25   if (!ppv)
    26     return E_INVALIDARG;
    28   *ppv = nullptr;
    30   if (IID_IAccessibleComponent == iid) {
    31     *ppv = static_cast<IAccessibleComponent*>(this);
    32     (reinterpret_cast<IUnknown*>(*ppv))->AddRef();
    33     return S_OK;
    34   }
    36   return E_NOINTERFACE;
    37 }
    39 // IAccessibleComponent
    41 STDMETHODIMP
    42 ia2AccessibleComponent::get_locationInParent(long* aX, long* aY)
    43 {
    44   A11Y_TRYBLOCK_BEGIN
    46   if (!aX || !aY)
    47     return E_INVALIDARG;
    49   *aX = 0;
    50   *aY = 0;
    52   AccessibleWrap* acc = static_cast<AccessibleWrap*>(this);
    53   if (acc->IsDefunct())
    54     return CO_E_OBJNOTCONNECTED;
    56   // If the object is not on any screen the returned position is (0,0).
    57   uint64_t state = acc->State();
    58   if (state & states::INVISIBLE)
    59     return S_OK;
    61   int32_t x = 0, y = 0, width = 0, height = 0;
    62   nsresult rv = acc->GetBounds(&x, &y, &width, &height);
    63   if (NS_FAILED(rv))
    64     return GetHRESULT(rv);
    66   Accessible* parentAcc = acc->Parent();
    68   // The coordinates of the returned position are relative to this object's
    69   // parent or relative to the screen on which this object is rendered if it
    70   // has no parent.
    71   if (!parentAcc) {
    72     *aX = x;
    73     *aY = y;
    74     return S_OK;
    75   }
    77   // The coordinates of the bounding box are given relative to the parent's
    78   // coordinate system.
    79   int32_t parentx = 0, parenty = 0;
    80   rv = acc->GetBounds(&parentx, &parenty, &width, &height);
    81   if (NS_FAILED(rv))
    82     return GetHRESULT(rv);
    84   *aX = x - parentx;
    85   *aY = y - parenty;
    86   return S_OK;
    88   A11Y_TRYBLOCK_END
    89 }
    91 STDMETHODIMP
    92 ia2AccessibleComponent::get_foreground(IA2Color* aForeground)
    93 {
    94   A11Y_TRYBLOCK_BEGIN
    96   if (!aForeground)
    97     return E_INVALIDARG;
    99   *aForeground = 0;
   101   AccessibleWrap* acc = static_cast<AccessibleWrap*>(this);
   102   if (acc->IsDefunct())
   103     return CO_E_OBJNOTCONNECTED;
   105   nsIFrame* frame = acc->GetFrame();
   106   if (frame)
   107     *aForeground = frame->StyleColor()->mColor;
   109   return S_OK;
   111   A11Y_TRYBLOCK_END
   112 }
   114 STDMETHODIMP
   115 ia2AccessibleComponent::get_background(IA2Color* aBackground)
   116 {
   117   A11Y_TRYBLOCK_BEGIN
   119   if (!aBackground)
   120     return E_INVALIDARG;
   122   *aBackground = 0;
   124   AccessibleWrap* acc = static_cast<AccessibleWrap*>(this);
   125   if (acc->IsDefunct())
   126     return CO_E_OBJNOTCONNECTED;
   128   nsIFrame* frame = acc->GetFrame();
   129   if (frame)
   130     *aBackground = frame->StyleBackground()->mBackgroundColor;
   132   return S_OK;
   134   A11Y_TRYBLOCK_END
   135 }

mercurial