| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
| 6 | 6 |
| 7 #include "content/browser/accessibility/browser_accessibility_win.h" | 7 #include "content/browser/accessibility/browser_accessibility_win.h" |
| 8 #include "content/common/accessibility_messages.h" | 8 #include "content/common/accessibility_messages.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 if (tracked_scroll_object_) { | 39 if (tracked_scroll_object_) { |
| 40 tracked_scroll_object_->Release(); | 40 tracked_scroll_object_->Release(); |
| 41 tracked_scroll_object_ = NULL; | 41 tracked_scroll_object_ = NULL; |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 // static | 45 // static |
| 46 AccessibilityNodeData BrowserAccessibilityManagerWin::GetEmptyDocument() { | 46 AccessibilityNodeData BrowserAccessibilityManagerWin::GetEmptyDocument() { |
| 47 AccessibilityNodeData empty_document; | 47 AccessibilityNodeData empty_document; |
| 48 empty_document.id = 0; | 48 empty_document.id = 0; |
| 49 empty_document.role = AccessibilityNodeData::ROLE_ROOT_WEB_AREA; | 49 empty_document.role = WebKit::WebAXRoleRootWebArea; |
| 50 empty_document.state = | 50 empty_document.state = |
| 51 (1 << AccessibilityNodeData::STATE_READONLY) | | 51 (1 << WebKit::WebAXStateEnabled) | |
| 52 (1 << AccessibilityNodeData::STATE_BUSY); | 52 (1 << WebKit::WebAXStateReadonly) | |
| 53 (1 << WebKit::WebAXStateBusy); |
| 53 return empty_document; | 54 return empty_document; |
| 54 } | 55 } |
| 55 | 56 |
| 56 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event, | 57 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event, |
| 57 LONG child_id) { | 58 LONG child_id) { |
| 58 if (parent_iaccessible()) | 59 if (parent_iaccessible()) |
| 59 ::NotifyWinEvent(event, parent_hwnd(), OBJID_CLIENT, child_id); | 60 ::NotifyWinEvent(event, parent_hwnd(), OBJID_CLIENT, child_id); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void BrowserAccessibilityManagerWin::AddNodeToMap(BrowserAccessibility* node) { | 63 void BrowserAccessibilityManagerWin::AddNodeToMap(BrowserAccessibility* node) { |
| 63 BrowserAccessibilityManager::AddNodeToMap(node); | 64 BrowserAccessibilityManager::AddNodeToMap(node); |
| 64 LONG unique_id_win = node->ToBrowserAccessibilityWin()->unique_id_win(); | 65 LONG unique_id_win = node->ToBrowserAccessibilityWin()->unique_id_win(); |
| 65 unique_id_to_renderer_id_map_[unique_id_win] = node->renderer_id(); | 66 unique_id_to_renderer_id_map_[unique_id_win] = node->renderer_id(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void BrowserAccessibilityManagerWin::RemoveNode(BrowserAccessibility* node) { | 69 void BrowserAccessibilityManagerWin::RemoveNode(BrowserAccessibility* node) { |
| 69 unique_id_to_renderer_id_map_.erase( | 70 unique_id_to_renderer_id_map_.erase( |
| 70 node->ToBrowserAccessibilityWin()->unique_id_win()); | 71 node->ToBrowserAccessibilityWin()->unique_id_win()); |
| 71 BrowserAccessibilityManager::RemoveNode(node); | 72 BrowserAccessibilityManager::RemoveNode(node); |
| 72 if (node == tracked_scroll_object_) { | 73 if (node == tracked_scroll_object_) { |
| 73 tracked_scroll_object_->Release(); | 74 tracked_scroll_object_->Release(); |
| 74 tracked_scroll_object_ = NULL; | 75 tracked_scroll_object_ = NULL; |
| 75 } | 76 } |
| 76 } | 77 } |
| 77 | 78 |
| 78 void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( | 79 void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( |
| 79 int type, | 80 WebKit::WebAXEvent event_type, |
| 80 BrowserAccessibility* node) { | 81 BrowserAccessibility* node) { |
| 81 LONG event_id = EVENT_MIN; | 82 LONG event_id = EVENT_MIN; |
| 82 switch (type) { | 83 switch (event_type) { |
| 83 case AccessibilityNotificationActiveDescendantChanged: | 84 case WebKit::WebAXEventActiveDescendantChanged: |
| 84 event_id = IA2_EVENT_ACTIVE_DESCENDANT_CHANGED; | 85 event_id = IA2_EVENT_ACTIVE_DESCENDANT_CHANGED; |
| 85 break; | 86 break; |
| 86 case AccessibilityNotificationAlert: | 87 case WebKit::WebAXEventAlert: |
| 87 event_id = EVENT_SYSTEM_ALERT; | 88 event_id = EVENT_SYSTEM_ALERT; |
| 88 break; | 89 break; |
| 89 case AccessibilityNotificationAriaAttributeChanged: | 90 case WebKit::WebAXEventAriaAttributeChanged: |
| 90 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; | 91 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; |
| 91 break; | 92 break; |
| 92 case AccessibilityNotificationAutocorrectionOccurred: | 93 case WebKit::WebAXEventAutocorrectionOccured: |
| 93 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; | 94 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; |
| 94 break; | 95 break; |
| 95 case AccessibilityNotificationBlur: | 96 case WebKit::WebAXEventBlur: |
| 96 // Equivalent to focus on the root. | 97 // Equivalent to focus on the root. |
| 97 event_id = EVENT_OBJECT_FOCUS; | 98 event_id = EVENT_OBJECT_FOCUS; |
| 98 node = GetRoot(); | 99 node = GetRoot(); |
| 99 break; | 100 break; |
| 100 case AccessibilityNotificationCheckStateChanged: | 101 case WebKit::WebAXEventCheckedStateChanged: |
| 101 event_id = EVENT_OBJECT_STATECHANGE; | 102 event_id = EVENT_OBJECT_STATECHANGE; |
| 102 break; | 103 break; |
| 103 case AccessibilityNotificationChildrenChanged: | 104 case WebKit::WebAXEventChildrenChanged: |
| 104 event_id = EVENT_OBJECT_REORDER; | 105 event_id = EVENT_OBJECT_REORDER; |
| 105 break; | 106 break; |
| 106 case AccessibilityNotificationFocusChanged: | 107 case WebKit::WebAXEventFocus: |
| 107 event_id = EVENT_OBJECT_FOCUS; | 108 event_id = EVENT_OBJECT_FOCUS; |
| 108 break; | 109 break; |
| 109 case AccessibilityNotificationInvalidStatusChanged: | 110 case WebKit::WebAXEventInvalidStatusChanged: |
| 110 event_id = EVENT_OBJECT_STATECHANGE; | 111 event_id = EVENT_OBJECT_STATECHANGE; |
| 111 break; | 112 break; |
| 112 case AccessibilityNotificationLiveRegionChanged: | 113 case WebKit::WebAXEventLiveRegionChanged: |
| 113 // TODO: try not firing a native notification at all, since | 114 // TODO: try not firing a native notification at all, since |
| 114 // on Windows, each individual item in a live region that changes | 115 // on Windows, each individual item in a live region that changes |
| 115 // already gets its own notification. | 116 // already gets its own notification. |
| 116 event_id = EVENT_OBJECT_REORDER; | 117 event_id = EVENT_OBJECT_REORDER; |
| 117 break; | 118 break; |
| 118 case AccessibilityNotificationLoadComplete: | 119 case WebKit::WebAXEventLoadComplete: |
| 119 event_id = IA2_EVENT_DOCUMENT_LOAD_COMPLETE; | 120 event_id = IA2_EVENT_DOCUMENT_LOAD_COMPLETE; |
| 120 break; | 121 break; |
| 121 case AccessibilityNotificationMenuListItemSelected: | 122 case WebKit::WebAXEventMenuListItemSelected: |
| 122 event_id = EVENT_OBJECT_FOCUS; | 123 event_id = EVENT_OBJECT_FOCUS; |
| 123 break; | 124 break; |
| 124 case AccessibilityNotificationMenuListValueChanged: | 125 case WebKit::WebAXEventMenuListValueChanged: |
| 125 event_id = EVENT_OBJECT_VALUECHANGE; | 126 event_id = EVENT_OBJECT_VALUECHANGE; |
| 126 break; | 127 break; |
| 127 case AccessibilityNotificationObjectHide: | 128 case WebKit::WebAXEventHide: |
| 128 event_id = EVENT_OBJECT_HIDE; | 129 event_id = EVENT_OBJECT_HIDE; |
| 129 break; | 130 break; |
| 130 case AccessibilityNotificationObjectShow: | 131 case WebKit::WebAXEventShow: |
| 131 event_id = EVENT_OBJECT_SHOW; | 132 event_id = EVENT_OBJECT_SHOW; |
| 132 break; | 133 break; |
| 133 case AccessibilityNotificationScrolledToAnchor: | 134 case WebKit::WebAXEventScrolledToAnchor: |
| 134 event_id = EVENT_SYSTEM_SCROLLINGSTART; | 135 event_id = EVENT_SYSTEM_SCROLLINGSTART; |
| 135 break; | 136 break; |
| 136 case AccessibilityNotificationSelectedChildrenChanged: | 137 case WebKit::WebAXEventSelectedChildrenChanged: |
| 137 event_id = EVENT_OBJECT_SELECTIONWITHIN; | 138 event_id = EVENT_OBJECT_SELECTIONWITHIN; |
| 138 break; | 139 break; |
| 139 case AccessibilityNotificationSelectedTextChanged: | 140 case WebKit::WebAXEventSelectedTextChanged: |
| 140 event_id = IA2_EVENT_TEXT_CARET_MOVED; | 141 event_id = IA2_EVENT_TEXT_CARET_MOVED; |
| 141 break; | 142 break; |
| 142 case AccessibilityNotificationTextChanged: | 143 case WebKit::WebAXEventTextChanged: |
| 143 event_id = EVENT_OBJECT_NAMECHANGE; | 144 event_id = EVENT_OBJECT_NAMECHANGE; |
| 144 break; | 145 break; |
| 145 case AccessibilityNotificationTextInserted: | 146 case WebKit::WebAXEventTextInserted: |
| 146 event_id = IA2_EVENT_TEXT_INSERTED; | 147 event_id = IA2_EVENT_TEXT_INSERTED; |
| 147 break; | 148 break; |
| 148 case AccessibilityNotificationTextRemoved: | 149 case WebKit::WebAXEventTextRemoved: |
| 149 event_id = IA2_EVENT_TEXT_REMOVED; | 150 event_id = IA2_EVENT_TEXT_REMOVED; |
| 150 break; | 151 break; |
| 151 case AccessibilityNotificationValueChanged: | 152 case WebKit::WebAXEventValueChanged: |
| 152 event_id = EVENT_OBJECT_VALUECHANGE; | 153 event_id = EVENT_OBJECT_VALUECHANGE; |
| 153 break; | 154 break; |
| 154 default: | 155 default: |
| 155 // Not all WebKit accessibility events result in a Windows | 156 // Not all WebKit accessibility events result in a Windows |
| 156 // accessibility notification. | 157 // accessibility notification. |
| 157 break; | 158 break; |
| 158 } | 159 } |
| 159 | 160 |
| 160 if (event_id != EVENT_MIN) { | 161 if (event_id != EVENT_MIN) { |
| 161 // Pass the node's unique id in the |child_id| argument to NotifyWinEvent; | 162 // Pass the node's unique id in the |child_id| argument to NotifyWinEvent; |
| 162 // the AT client will then call get_accChild on the HWND's accessibility | 163 // the AT client will then call get_accChild on the HWND's accessibility |
| 163 // object and pass it that same id, which we can use to retrieve the | 164 // object and pass it that same id, which we can use to retrieve the |
| 164 // IAccessible for this node. | 165 // IAccessible for this node. |
| 165 LONG child_id = node->ToBrowserAccessibilityWin()->unique_id_win(); | 166 LONG child_id = node->ToBrowserAccessibilityWin()->unique_id_win(); |
| 166 MaybeCallNotifyWinEvent(event_id, child_id); | 167 MaybeCallNotifyWinEvent(event_id, child_id); |
| 167 } | 168 } |
| 168 | 169 |
| 169 // If this is a layout complete notification (sent when a container scrolls) | 170 // If this is a layout complete notification (sent when a container scrolls) |
| 170 // and there is a descendant tracked object, send a notification on it. | 171 // and there is a descendant tracked object, send a notification on it. |
| 171 // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed. | 172 // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed. |
| 172 if (type == AccessibilityNotificationLayoutComplete && | 173 if (event_type == WebKit::WebAXEventLayoutComplete && |
| 173 tracked_scroll_object_ && | 174 tracked_scroll_object_ && |
| 174 tracked_scroll_object_->IsDescendantOf(node)) { | 175 tracked_scroll_object_->IsDescendantOf(node)) { |
| 175 MaybeCallNotifyWinEvent( | 176 MaybeCallNotifyWinEvent( |
| 176 IA2_EVENT_VISIBLE_DATA_CHANGED, | 177 IA2_EVENT_VISIBLE_DATA_CHANGED, |
| 177 tracked_scroll_object_->ToBrowserAccessibilityWin()->unique_id_win()); | 178 tracked_scroll_object_->ToBrowserAccessibilityWin()->unique_id_win()); |
| 178 tracked_scroll_object_->Release(); | 179 tracked_scroll_object_->Release(); |
| 179 tracked_scroll_object_ = NULL; | 180 tracked_scroll_object_ = NULL; |
| 180 } | 181 } |
| 181 } | 182 } |
| 182 | 183 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 194 unique_id_to_renderer_id_map_.find(unique_id_win); | 195 unique_id_to_renderer_id_map_.find(unique_id_win); |
| 195 if (iter != unique_id_to_renderer_id_map_.end()) { | 196 if (iter != unique_id_to_renderer_id_map_.end()) { |
| 196 BrowserAccessibility* result = GetFromRendererID(iter->second); | 197 BrowserAccessibility* result = GetFromRendererID(iter->second); |
| 197 if (result) | 198 if (result) |
| 198 return result->ToBrowserAccessibilityWin(); | 199 return result->ToBrowserAccessibilityWin(); |
| 199 } | 200 } |
| 200 return NULL; | 201 return NULL; |
| 201 } | 202 } |
| 202 | 203 |
| 203 } // namespace content | 204 } // namespace content |
| OLD | NEW |