accessible/src/generic/DocAccessible-inl.h

branch
TOR_BUG_9701
changeset 3
141e0f1194b1
equal deleted inserted replaced
-1:000000000000 0:7b7b0df7f692
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 #ifndef mozilla_a11y_DocAccessible_inl_h_
8 #define mozilla_a11y_DocAccessible_inl_h_
9
10 #include "DocAccessible.h"
11 #include "nsAccessibilityService.h"
12 #include "NotificationController.h"
13 #include "States.h"
14 #include "nsIScrollableFrame.h"
15
16 #ifdef A11Y_LOG
17 #include "Logging.h"
18 #endif
19
20 namespace mozilla {
21 namespace a11y {
22
23 inline void
24 DocAccessible::FireDelayedEvent(AccEvent* aEvent)
25 {
26 #ifdef A11Y_LOG
27 if (logging::IsEnabled(logging::eDocLoad))
28 logging::DocLoadEventFired(aEvent);
29 #endif
30
31 mNotificationController->QueueEvent(aEvent);
32 }
33
34 inline void
35 DocAccessible::FireDelayedEvent(uint32_t aEventType, Accessible* aTarget)
36 {
37 nsRefPtr<AccEvent> event = new AccEvent(aEventType, aTarget);
38 FireDelayedEvent(event);
39 }
40
41 inline void
42 DocAccessible::BindChildDocument(DocAccessible* aDocument)
43 {
44 mNotificationController->ScheduleChildDocBinding(aDocument);
45 }
46
47 template<class Class, class Arg>
48 inline void
49 DocAccessible::HandleNotification(Class* aInstance,
50 typename TNotification<Class, Arg>::Callback aMethod,
51 Arg* aArg)
52 {
53 if (mNotificationController) {
54 mNotificationController->HandleNotification<Class, Arg>(aInstance,
55 aMethod, aArg);
56 }
57 }
58
59 inline void
60 DocAccessible::UpdateText(nsIContent* aTextNode)
61 {
62 NS_ASSERTION(mNotificationController, "The document was shut down!");
63
64 // Ignore the notification if initial tree construction hasn't been done yet.
65 if (mNotificationController && HasLoadState(eTreeConstructed))
66 mNotificationController->ScheduleTextUpdate(aTextNode);
67 }
68
69 inline void
70 DocAccessible::AddScrollListener()
71 {
72 // Delay scroll initializing until the document has a root frame.
73 if (!mPresShell->GetRootFrame())
74 return;
75
76 mDocFlags |= eScrollInitialized;
77 nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable();
78 if (sf) {
79 sf->AddScrollPositionListener(this);
80
81 #ifdef A11Y_LOG
82 if (logging::IsEnabled(logging::eDocCreate))
83 logging::Text("add scroll listener");
84 #endif
85 }
86 }
87
88 inline void
89 DocAccessible::RemoveScrollListener()
90 {
91 nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable();
92 if (sf)
93 sf->RemoveScrollPositionListener(this);
94 }
95
96 inline void
97 DocAccessible::NotifyOfLoad(uint32_t aLoadEventType)
98 {
99 mLoadState |= eDOMLoaded;
100 mLoadEventType = aLoadEventType;
101
102 // If the document is loaded completely then network activity was presumingly
103 // caused by file loading. Fire busy state change event.
104 if (HasLoadState(eCompletelyLoaded) && IsLoadEventTarget()) {
105 nsRefPtr<AccEvent> stateEvent =
106 new AccStateChangeEvent(this, states::BUSY, false);
107 FireDelayedEvent(stateEvent);
108 }
109 }
110
111 inline void
112 DocAccessible::MaybeNotifyOfValueChange(Accessible* aAccessible)
113 {
114 a11y::role role = aAccessible->Role();
115 if (role == roles::ENTRY || role == roles::COMBOBOX)
116 FireDelayedEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, aAccessible);
117 }
118
119 inline Accessible*
120 DocAccessible::GetAccessibleEvenIfNotInMapOrContainer(nsINode* aNode) const
121 {
122 Accessible* acc = GetAccessibleEvenIfNotInMap(aNode);
123 return acc ? acc : GetContainerAccessible(aNode);
124 }
125
126 } // namespace a11y
127 } // namespace mozilla
128
129 #endif

mercurial