| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_android.h" | 5 #include "content/browser/accessibility/browser_accessibility_manager_android.h" |
| 6 | 6 |
| 7 #include "base/i18n/char_iterator.h" | 7 #include "base/i18n/char_iterator.h" |
| 8 #include "content/browser/accessibility/browser_accessibility_android.h" | 8 #include "content/browser/accessibility/browser_accessibility_android.h" |
| 9 #include "content/browser/accessibility/web_contents_accessibility_android.h" | 9 #include "content/browser/accessibility/web_contents_accessibility_android.h" |
| 10 #include "content/common/accessibility_messages.h" | 10 #include "content/common/accessibility_messages.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // fire an event for those changes, but we do want to make sure our internal | 106 // fire an event for those changes, but we do want to make sure our internal |
| 107 // state is correct, so we call OnDataChanged() and then return. | 107 // state is correct, so we call OnDataChanged() and then return. |
| 108 if (android_node->IsPassword() && original_node != node) { | 108 if (android_node->IsPassword() && original_node != node) { |
| 109 android_node->OnDataChanged(); | 109 android_node->OnDataChanged(); |
| 110 return; | 110 return; |
| 111 } | 111 } |
| 112 | 112 |
| 113 // Always send AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED to notify | 113 // Always send AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED to notify |
| 114 // the Android system that the accessibility hierarchy rooted at this | 114 // the Android system that the accessibility hierarchy rooted at this |
| 115 // node has changed. | 115 // node has changed. |
| 116 wcax->HandleContentChanged(android_node->unique_id()); | 116 wcax->HandleContentChanged(node->unique_id()); |
| 117 | 117 |
| 118 // Ignore load complete events on iframes. | 118 // Ignore load complete events on iframes. |
| 119 if (event_type == ui::AX_EVENT_LOAD_COMPLETE && | 119 if (event_type == ui::AX_EVENT_LOAD_COMPLETE && |
| 120 node->manager() != GetRootManager()) { | 120 node->manager() != GetRootManager()) { |
| 121 return; | 121 return; |
| 122 } | 122 } |
| 123 | 123 |
| 124 switch (event_type) { | 124 switch (event_type) { |
| 125 case ui::AX_EVENT_LOAD_COMPLETE: { | 125 case ui::AX_EVENT_LOAD_COMPLETE: |
| 126 auto* android_focused = | 126 wcax->HandlePageLoaded(GetFocus()->unique_id()); |
| 127 static_cast<BrowserAccessibilityAndroid*>(GetFocus()); | 127 break; |
| 128 wcax->HandlePageLoaded(android_focused->unique_id()); | |
| 129 } break; | |
| 130 case ui::AX_EVENT_FOCUS: | 128 case ui::AX_EVENT_FOCUS: |
| 131 wcax->HandleFocusChanged(android_node->unique_id()); | 129 wcax->HandleFocusChanged(node->unique_id()); |
| 132 break; | 130 break; |
| 133 case ui::AX_EVENT_CHECKED_STATE_CHANGED: | 131 case ui::AX_EVENT_CHECKED_STATE_CHANGED: |
| 134 wcax->HandleCheckStateChanged(android_node->unique_id()); | 132 wcax->HandleCheckStateChanged(node->unique_id()); |
| 135 break; | 133 break; |
| 136 case ui::AX_EVENT_CLICKED: | 134 case ui::AX_EVENT_CLICKED: |
| 137 wcax->HandleClicked(android_node->unique_id()); | 135 wcax->HandleClicked(node->unique_id()); |
| 138 break; | 136 break; |
| 139 case ui::AX_EVENT_SCROLL_POSITION_CHANGED: | 137 case ui::AX_EVENT_SCROLL_POSITION_CHANGED: |
| 140 wcax->HandleScrollPositionChanged(android_node->unique_id()); | 138 wcax->HandleScrollPositionChanged(node->unique_id()); |
| 141 break; | 139 break; |
| 142 case ui::AX_EVENT_SCROLLED_TO_ANCHOR: | 140 case ui::AX_EVENT_SCROLLED_TO_ANCHOR: |
| 143 wcax->HandleScrolledToAnchor(android_node->unique_id()); | 141 wcax->HandleScrolledToAnchor(node->unique_id()); |
| 144 break; | 142 break; |
| 145 case ui::AX_EVENT_ALERT: | 143 case ui::AX_EVENT_ALERT: |
| 146 // An alert is a special case of live region. Fall through to the | 144 // An alert is a special case of live region. Fall through to the |
| 147 // next case to handle it. | 145 // next case to handle it. |
| 148 case ui::AX_EVENT_SHOW: { | 146 case ui::AX_EVENT_SHOW: { |
| 149 // This event is fired when an object appears in a live region. | 147 // This event is fired when an object appears in a live region. |
| 150 // Speak its text. | 148 // Speak its text. |
| 151 base::string16 text = android_node->GetText(); | 149 base::string16 text = android_node->GetText(); |
| 152 wcax->AnnounceLiveRegionText(text); | 150 wcax->AnnounceLiveRegionText(text); |
| 153 break; | 151 break; |
| 154 } | 152 } |
| 155 case ui::AX_EVENT_TEXT_SELECTION_CHANGED: | 153 case ui::AX_EVENT_TEXT_SELECTION_CHANGED: |
| 156 wcax->HandleTextSelectionChanged(android_node->unique_id()); | 154 wcax->HandleTextSelectionChanged(node->unique_id()); |
| 157 break; | 155 break; |
| 158 case ui::AX_EVENT_TEXT_CHANGED: | 156 case ui::AX_EVENT_TEXT_CHANGED: |
| 159 case ui::AX_EVENT_VALUE_CHANGED: | 157 case ui::AX_EVENT_VALUE_CHANGED: |
| 160 if (android_node->IsEditableText() && GetFocus() == node) { | 158 if (android_node->IsEditableText() && GetFocus() == node) { |
| 161 wcax->HandleEditableTextChanged(android_node->unique_id()); | 159 wcax->HandleEditableTextChanged(node->unique_id()); |
| 162 } else if (android_node->IsSlider()) { | 160 } else if (android_node->IsSlider()) { |
| 163 wcax->HandleSliderChanged(android_node->unique_id()); | 161 wcax->HandleSliderChanged(node->unique_id()); |
| 164 } | 162 } |
| 165 break; | 163 break; |
| 166 default: | 164 default: |
| 167 // There are some notifications that aren't meaningful on Android. | 165 // There are some notifications that aren't meaningful on Android. |
| 168 // It's okay to skip them. | 166 // It's okay to skip them. |
| 169 break; | 167 break; |
| 170 } | 168 } |
| 171 } | 169 } |
| 172 | 170 |
| 173 void BrowserAccessibilityManagerAndroid::SendLocationChangeEvents( | 171 void BrowserAccessibilityManagerAndroid::SendLocationChangeEvents( |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 BrowserAccessibility* parent_node = GetParentNodeFromParentTree(); | 336 BrowserAccessibility* parent_node = GetParentNodeFromParentTree(); |
| 339 if (!parent_node) | 337 if (!parent_node) |
| 340 return web_contents_accessibility_; | 338 return web_contents_accessibility_; |
| 341 | 339 |
| 342 auto* parent_manager = | 340 auto* parent_manager = |
| 343 static_cast<BrowserAccessibilityManagerAndroid*>(parent_node->manager()); | 341 static_cast<BrowserAccessibilityManagerAndroid*>(parent_node->manager()); |
| 344 return parent_manager->GetWebContentsAXFromRootManager(); | 342 return parent_manager->GetWebContentsAXFromRootManager(); |
| 345 } | 343 } |
| 346 | 344 |
| 347 } // namespace content | 345 } // namespace content |
| OLD | NEW |