accessible/src/windows/msaa/HTMLWin32ObjectAccessible.cpp

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:4d05b2c7c0c9
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 "HTMLWin32ObjectAccessible.h"
7
8 #include "Role.h"
9 #include "States.h"
10
11 using namespace mozilla::a11y;
12
13 ////////////////////////////////////////////////////////////////////////////////
14 // HTMLWin32ObjectOwnerAccessible
15 ////////////////////////////////////////////////////////////////////////////////
16
17 HTMLWin32ObjectOwnerAccessible::
18 HTMLWin32ObjectOwnerAccessible(nsIContent* aContent,
19 DocAccessible* aDoc, void* aHwnd) :
20 AccessibleWrap(aContent, aDoc), mHwnd(aHwnd)
21 {
22 // Our only child is a HTMLWin32ObjectAccessible object.
23 if (mHwnd)
24 mNativeAccessible = new HTMLWin32ObjectAccessible(mHwnd);
25 }
26
27 ////////////////////////////////////////////////////////////////////////////////
28 // HTMLWin32ObjectOwnerAccessible: Accessible implementation
29
30 void
31 HTMLWin32ObjectOwnerAccessible::Shutdown()
32 {
33 AccessibleWrap::Shutdown();
34 mNativeAccessible = nullptr;
35 }
36
37 role
38 HTMLWin32ObjectOwnerAccessible::NativeRole()
39 {
40 return roles::EMBEDDED_OBJECT;
41 }
42
43 bool
44 HTMLWin32ObjectOwnerAccessible::NativelyUnavailable() const
45 {
46 // XXX: No HWND means this is windowless plugin which is not accessible in
47 // the meantime.
48 return !mHwnd;
49 }
50
51 ////////////////////////////////////////////////////////////////////////////////
52 // HTMLWin32ObjectOwnerAccessible: Accessible protected implementation
53
54 void
55 HTMLWin32ObjectOwnerAccessible::CacheChildren()
56 {
57 if (mNativeAccessible)
58 AppendChild(mNativeAccessible);
59 }
60
61
62 ////////////////////////////////////////////////////////////////////////////////
63 // HTMLWin32ObjectAccessible
64 ////////////////////////////////////////////////////////////////////////////////
65
66 HTMLWin32ObjectAccessible::HTMLWin32ObjectAccessible(void* aHwnd) :
67 DummyAccessible()
68 {
69 mHwnd = aHwnd;
70 if (mHwnd) {
71 // The plugin is not windowless. In this situation we use
72 // use its inner child owned by the plugin so that we don't get
73 // in an infinite loop, where the WM_GETOBJECT's get forwarded
74 // back to us and create another HTMLWin32ObjectAccessible
75 HWND childWnd = ::GetWindow((HWND)aHwnd, GW_CHILD);
76 if (childWnd) {
77 mHwnd = childWnd;
78 }
79 }
80 }
81
82 NS_IMETHODIMP
83 HTMLWin32ObjectAccessible::GetNativeInterface(void** aNativeAccessible)
84 {
85 if (mHwnd) {
86 ::AccessibleObjectFromWindow(static_cast<HWND>(mHwnd),
87 OBJID_WINDOW, IID_IAccessible,
88 aNativeAccessible);
89 }
90 return NS_OK;
91 }
92

mercurial