DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (31ec81b5d7bb)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#pragma once

#include <windows.system.h>
#include <windows.ui.core.h>
#include <UIAutomation.h>
#include <UIAutomationCore.h>
#include <UIAutomationCoreApi.h>

#include "mozwrlbase.h"

#include "nsCOMPtr.h"
#include "mozilla/a11y/Accessible.h"
#include "UIAAccessibilityBridge.h"

// generated
#include "UIABridge.h"

namespace mozilla {
namespace widget {
namespace winrt {

using namespace Microsoft::WRL;

// represents the root window to UIA
[uuid("D3EDD951-0715-4501-A8E5-25D97EF35D5A")]
class UIABridge : public RuntimeClass<RuntimeClassFlags<RuntimeClassType::WinRtClassicComMix>,
  IUIABridge,
  IUIAElement,
  IRawElementProviderSimple,
  IRawElementProviderFragment,
  IRawElementProviderFragmentRoot>
{
  typedef ABI::Windows::UI::Core::ICoreWindow ICoreWindow;

  InspectableClass(L"IUIABridge", BaseTrust);

public:
  UIABridge() {}

  // IUIABridge
  IFACEMETHODIMP Init(IInspectable* view, IInspectable* window, LONG_PTR inner);
  IFACEMETHODIMP Disconnect();
  IFACEMETHODIMP FocusChangeEvent();

  // IUIAElement
  IFACEMETHODIMP SetFocusInternal(LONG_PTR aAccessible);
  IFACEMETHODIMP ClearFocus();

  // IRawElementProviderFragmentRoot
  IFACEMETHODIMP ElementProviderFromPoint(double x, double y, IRawElementProviderFragment ** retVal);
  IFACEMETHODIMP GetFocus(IRawElementProviderFragment ** retVal);

  // IRawElementProviderFragment
  IFACEMETHODIMP Navigate(NavigateDirection direction, IRawElementProviderFragment ** retVal);
  IFACEMETHODIMP GetRuntimeId(SAFEARRAY ** retVal);
  IFACEMETHODIMP get_BoundingRectangle(UiaRect * retVal);
  IFACEMETHODIMP GetEmbeddedFragmentRoots(SAFEARRAY ** retVal);
  IFACEMETHODIMP SetFocus();
  IFACEMETHODIMP get_FragmentRoot(IRawElementProviderFragmentRoot * * retVal);

  // IRawElementProviderSimple
  IFACEMETHODIMP get_ProviderOptions(ProviderOptions * retVal);
  IFACEMETHODIMP GetPatternProvider(PATTERNID iid, IUnknown * * retVal);
  IFACEMETHODIMP GetPropertyValue(PROPERTYID idProp, VARIANT * retVal );
  IFACEMETHODIMP get_HostRawElementProvider(IRawElementProviderSimple ** retVal);

protected:
  bool Connected();

private:
  Microsoft::WRL::ComPtr<ICoreWindow> mWindow;
#if defined(ACCESSIBILITY)
  nsRefPtr<AccessibilityBridge> mAccBridge;
  nsRefPtr<mozilla::a11y::Accessible> mAccessible;
#endif
};

[uuid("4438135F-F624-43DE-A417-275CE7A1A0CD")]
class UIATextElement : public RuntimeClass<RuntimeClassFlags<RuntimeClassType::WinRtClassicComMix>,
  IUIAElement,
  IRawElementProviderSimple,
  IRawElementProviderFragment,
  ITextProvider,
  IValueProvider >
{
  typedef ABI::Windows::Foundation::Rect Rect;

  InspectableClass(L"UIATextElement", BaseTrust);

public:
  UIATextElement() {}

  // IUIAElement
  IFACEMETHODIMP SetFocusInternal(LONG_PTR aAccessible);
  IFACEMETHODIMP ClearFocus();
  IFACEMETHODIMP FocusChangeEvent();

  // IRawElementProviderFragment
  IFACEMETHODIMP Navigate(NavigateDirection direction, IRawElementProviderFragment ** retVal);
  IFACEMETHODIMP GetRuntimeId(SAFEARRAY ** retVal);
  IFACEMETHODIMP get_BoundingRectangle(UiaRect * retVal);
  IFACEMETHODIMP GetEmbeddedFragmentRoots(SAFEARRAY ** retVal);
  IFACEMETHODIMP SetFocus();
  IFACEMETHODIMP get_FragmentRoot(IRawElementProviderFragmentRoot * * retVal);

  // IRawElementProviderSimple
  IFACEMETHODIMP get_ProviderOptions(ProviderOptions * retVal);
  IFACEMETHODIMP GetPatternProvider(PATTERNID iid, IUnknown * * retVal);
  IFACEMETHODIMP GetPropertyValue(PROPERTYID idProp, VARIANT * retVal );
  IFACEMETHODIMP get_HostRawElementProvider(IRawElementProviderSimple ** retVal);

  // ITextProvider
  IFACEMETHODIMP GetSelection(SAFEARRAY * *pRetVal);
  IFACEMETHODIMP GetVisibleRanges(SAFEARRAY * *pRetVal);
  IFACEMETHODIMP RangeFromChild(IRawElementProviderSimple *childElement, ITextRangeProvider **pRetVal);
  IFACEMETHODIMP RangeFromPoint(UiaPoint point, ITextRangeProvider **pRetVal);
  IFACEMETHODIMP get_DocumentRange(ITextRangeProvider **pRetVal);
  IFACEMETHODIMP get_SupportedTextSelection(SupportedTextSelection *pRetVal);

  // IValueProvider
  IFACEMETHODIMP SetValue(LPCWSTR val);
  IFACEMETHODIMP get_Value(BSTR *pRetVal);
  IFACEMETHODIMP get_IsReadOnly(BOOL *pRetVal);

  void SetIndexID(int id) {
    mIndexID = id;
  }

private:
  int mIndexID;
  nsCOMPtr<nsIAccessible> mAccessItem;
};

} } }