tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

UiaRoot.cpp (1619B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "UiaRoot.h"
      8 
      9 #include "MsaaRootAccessible.h"
     10 #include "RootAccessible.h"
     11 
     12 using namespace mozilla;
     13 using namespace mozilla::a11y;
     14 
     15 // UiaRoot
     16 
     17 Accessible* UiaRoot::Acc() {
     18  auto* mr = static_cast<MsaaRootAccessible*>(this);
     19  return static_cast<MsaaAccessible*>(mr)->Acc();
     20 }
     21 
     22 // IRawElementProviderFragmentRoot
     23 
     24 STDMETHODIMP
     25 UiaRoot::ElementProviderFromPoint(
     26    double aX, double aY,
     27    __RPC__deref_out_opt IRawElementProviderFragment** aRetVal) {
     28  if (!aRetVal) {
     29    return E_INVALIDARG;
     30  }
     31  *aRetVal = nullptr;
     32  Accessible* acc = Acc();
     33  if (!acc) {
     34    return CO_E_OBJNOTCONNECTED;
     35  }
     36  if (Accessible* target = acc->ChildAtPoint(
     37          aX, aY, Accessible::EWhichChildAtPoint::DeepestChild)) {
     38    RefPtr<IRawElementProviderFragment> fragment =
     39        MsaaAccessible::GetFrom(target);
     40    fragment.forget(aRetVal);
     41  }
     42  return S_OK;
     43 }
     44 
     45 STDMETHODIMP
     46 UiaRoot::GetFocus(__RPC__deref_out_opt IRawElementProviderFragment** aRetVal) {
     47  if (!aRetVal) {
     48    return E_INVALIDARG;
     49  }
     50  *aRetVal = nullptr;
     51  Accessible* acc = Acc();
     52  if (!acc) {
     53    return CO_E_OBJNOTCONNECTED;
     54  }
     55  if (Accessible* focus = acc->FocusedChild()) {
     56    RefPtr<IRawElementProviderFragment> fragment =
     57        MsaaAccessible::GetFrom(focus);
     58    fragment.forget(aRetVal);
     59  }
     60  return S_OK;
     61 }