tor-browser

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

MsaaRootAccessible.cpp (2503B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #include "mozilla/a11y/Compatibility.h"
      7 #include "mozilla/a11y/DocAccessibleParent.h"
      8 #include "mozilla/dom/BrowserParent.h"
      9 #include "MsaaRootAccessible.h"
     10 #include "Relation.h"
     11 #include "RootAccessible.h"
     12 #include "EnumVariant.h"
     13 
     14 #include <oleauto.h>
     15 
     16 using namespace mozilla;
     17 using namespace mozilla::a11y;
     18 
     19 RootAccessible* MsaaRootAccessible::RootAcc() {
     20  return static_cast<RootAccessible*>(LocalAcc());
     21 }
     22 
     23 ////////////////////////////////////////////////////////////////////////////////
     24 // Aggregated IUnknown
     25 HRESULT
     26 MsaaRootAccessible::InternalQueryInterface(REFIID aIid, void** aOutInterface) {
     27  if (!aOutInterface) {
     28    return E_INVALIDARG;
     29  }
     30 
     31  if (NS_WARN_IF(!NS_IsMainThread())) {
     32    // Bug 1949617: The COM marshaler sometimes calls QueryInterface on the
     33    // wrong thread.
     34    return RPC_E_WRONG_THREAD;
     35  }
     36 
     37  // InternalQueryInterface should always return its internal unknown
     38  // when queried for IID_IUnknown...
     39  if (aIid == IID_IUnknown) {
     40    RefPtr<IUnknown> punk(&mInternalUnknown);
     41    punk.forget(aOutInterface);
     42    return S_OK;
     43  }
     44 
     45  if (Compatibility::IsUiaEnabled() &&
     46      aIid == IID_IRawElementProviderFragmentRoot) {
     47    RefPtr<IRawElementProviderFragmentRoot> root = this;
     48    root.forget(aOutInterface);
     49    return S_OK;
     50  }
     51 
     52  // ...Otherwise we pass through to the base COM implementation of
     53  // QueryInterface which is provided by MsaaDocAccessible.
     54  return MsaaDocAccessible::QueryInterface(aIid, aOutInterface);
     55 }
     56 
     57 ULONG
     58 MsaaRootAccessible::InternalAddRef() { return MsaaDocAccessible::AddRef(); }
     59 
     60 ULONG
     61 MsaaRootAccessible::InternalRelease() { return MsaaDocAccessible::Release(); }
     62 
     63 already_AddRefed<IUnknown> MsaaRootAccessible::Aggregate(IUnknown* aOuter) {
     64  MOZ_ASSERT(mOuter &&
     65             (mOuter == &mInternalUnknown || mOuter == aOuter || !aOuter));
     66  if (!aOuter) {
     67    // If there is no aOuter then we should always set mOuter to
     68    // mInternalUnknown. This is standard COM aggregation stuff.
     69    mOuter = &mInternalUnknown;
     70    return nullptr;
     71  }
     72 
     73  mOuter = aOuter;
     74  return GetInternalUnknown();
     75 }
     76 
     77 already_AddRefed<IUnknown> MsaaRootAccessible::GetInternalUnknown() {
     78  RefPtr<IUnknown> result(&mInternalUnknown);
     79  return result.forget();
     80 }