Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager_android.cc

Issue 2237943002: Remove now-unnecessary .obj() in Java method calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@switch-context
Patch Set: Rebase *again* :( Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 SetContentViewCore(content_view_core); 147 SetContentViewCore(content_view_core);
148 } 148 }
149 149
150 BrowserAccessibilityManagerAndroid::~BrowserAccessibilityManagerAndroid() { 150 BrowserAccessibilityManagerAndroid::~BrowserAccessibilityManagerAndroid() {
151 JNIEnv* env = AttachCurrentThread(); 151 JNIEnv* env = AttachCurrentThread();
152 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager(); 152 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager();
153 if (obj.is_null()) 153 if (obj.is_null())
154 return; 154 return;
155 155
156 Java_BrowserAccessibilityManager_onNativeObjectDestroyed( 156 Java_BrowserAccessibilityManager_onNativeObjectDestroyed(
157 env, obj.obj(),reinterpret_cast<intptr_t>(this)); 157 env, obj, reinterpret_cast<intptr_t>(this));
158 } 158 }
159 159
160 // static 160 // static
161 ui::AXTreeUpdate 161 ui::AXTreeUpdate
162 BrowserAccessibilityManagerAndroid::GetEmptyDocument() { 162 BrowserAccessibilityManagerAndroid::GetEmptyDocument() {
163 ui::AXNodeData empty_document; 163 ui::AXNodeData empty_document;
164 empty_document.id = 0; 164 empty_document.id = 0;
165 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; 165 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA;
166 empty_document.state = 1 << ui::AX_STATE_READ_ONLY; 166 empty_document.state = 1 << ui::AX_STATE_READ_ONLY;
167 167
168 ui::AXTreeUpdate update; 168 ui::AXTreeUpdate update;
169 update.root_id = empty_document.id; 169 update.root_id = empty_document.id;
170 update.nodes.push_back(empty_document); 170 update.nodes.push_back(empty_document);
171 return update; 171 return update;
172 } 172 }
173 173
174 void BrowserAccessibilityManagerAndroid::SetContentViewCore( 174 void BrowserAccessibilityManagerAndroid::SetContentViewCore(
175 ScopedJavaLocalRef<jobject> content_view_core) { 175 ScopedJavaLocalRef<jobject> content_view_core) {
176 if (content_view_core.is_null()) 176 if (content_view_core.is_null())
177 return; 177 return;
178 178
179 JNIEnv* env = AttachCurrentThread(); 179 JNIEnv* env = AttachCurrentThread();
180 java_ref_ = JavaObjectWeakGlobalRef( 180 java_ref_ = JavaObjectWeakGlobalRef(
181 env, Java_BrowserAccessibilityManager_create( 181 env, Java_BrowserAccessibilityManager_create(
182 env, reinterpret_cast<intptr_t>(this), 182 env, reinterpret_cast<intptr_t>(this), content_view_core)
183 content_view_core.obj()).obj()); 183 .obj());
184 } 184 }
185 185
186 bool BrowserAccessibilityManagerAndroid::ShouldExposePasswordText() { 186 bool BrowserAccessibilityManagerAndroid::ShouldExposePasswordText() {
187 JNIEnv* env = AttachCurrentThread(); 187 JNIEnv* env = AttachCurrentThread();
188 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager(); 188 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager();
189 if (obj.is_null()) 189 if (obj.is_null())
190 return false; 190 return false;
191 191
192 return Java_BrowserAccessibilityManager_shouldExposePasswordText( 192 return Java_BrowserAccessibilityManager_shouldExposePasswordText(env, obj);
193 env, obj.obj());
194 } 193 }
195 194
196 BrowserAccessibility* BrowserAccessibilityManagerAndroid::GetFocus() { 195 BrowserAccessibility* BrowserAccessibilityManagerAndroid::GetFocus() {
197 BrowserAccessibility* focus = BrowserAccessibilityManager::GetFocus(); 196 BrowserAccessibility* focus = BrowserAccessibilityManager::GetFocus();
198 return GetActiveDescendant(focus); 197 return GetActiveDescendant(focus);
199 } 198 }
200 199
201 void BrowserAccessibilityManagerAndroid::NotifyAccessibilityEvent( 200 void BrowserAccessibilityManagerAndroid::NotifyAccessibilityEvent(
202 BrowserAccessibilityEvent::Source source, 201 BrowserAccessibilityEvent::Source source,
203 ui::AXEvent event_type, 202 ui::AXEvent event_type,
(...skipping 18 matching lines...) Expand all
222 return; 221 return;
223 222
224 if (event_type == ui::AX_EVENT_HOVER) { 223 if (event_type == ui::AX_EVENT_HOVER) {
225 HandleHoverEvent(node); 224 HandleHoverEvent(node);
226 return; 225 return;
227 } 226 }
228 227
229 // Always send AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED to notify 228 // Always send AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED to notify
230 // the Android system that the accessibility hierarchy rooted at this 229 // the Android system that the accessibility hierarchy rooted at this
231 // node has changed. 230 // node has changed.
232 Java_BrowserAccessibilityManager_handleContentChanged( 231 Java_BrowserAccessibilityManager_handleContentChanged(env, obj,
233 env, obj.obj(), node->unique_id()); 232 node->unique_id());
234 233
235 // Ignore load complete events on iframes. 234 // Ignore load complete events on iframes.
236 if (event_type == ui::AX_EVENT_LOAD_COMPLETE && 235 if (event_type == ui::AX_EVENT_LOAD_COMPLETE &&
237 node->manager() != GetRootManager()) { 236 node->manager() != GetRootManager()) {
238 return; 237 return;
239 } 238 }
240 239
241 switch (event_type) { 240 switch (event_type) {
242 case ui::AX_EVENT_LOAD_COMPLETE: 241 case ui::AX_EVENT_LOAD_COMPLETE:
243 Java_BrowserAccessibilityManager_handlePageLoaded( 242 Java_BrowserAccessibilityManager_handlePageLoaded(
244 env, obj.obj(), GetFocus()->unique_id()); 243 env, obj, GetFocus()->unique_id());
245 break; 244 break;
246 case ui::AX_EVENT_FOCUS: 245 case ui::AX_EVENT_FOCUS:
247 Java_BrowserAccessibilityManager_handleFocusChanged( 246 Java_BrowserAccessibilityManager_handleFocusChanged(env, obj,
248 env, obj.obj(), node->unique_id()); 247 node->unique_id());
249 break; 248 break;
250 case ui::AX_EVENT_CHECKED_STATE_CHANGED: 249 case ui::AX_EVENT_CHECKED_STATE_CHANGED:
251 Java_BrowserAccessibilityManager_handleCheckStateChanged( 250 Java_BrowserAccessibilityManager_handleCheckStateChanged(
252 env, obj.obj(), node->unique_id()); 251 env, obj, node->unique_id());
253 break; 252 break;
254 case ui::AX_EVENT_CLICKED: 253 case ui::AX_EVENT_CLICKED:
255 Java_BrowserAccessibilityManager_handleClicked(env, obj.obj(), 254 Java_BrowserAccessibilityManager_handleClicked(env, obj,
256 node->unique_id()); 255 node->unique_id());
257 break; 256 break;
258 case ui::AX_EVENT_SCROLL_POSITION_CHANGED: 257 case ui::AX_EVENT_SCROLL_POSITION_CHANGED:
259 Java_BrowserAccessibilityManager_handleScrollPositionChanged( 258 Java_BrowserAccessibilityManager_handleScrollPositionChanged(
260 env, obj.obj(), node->unique_id()); 259 env, obj, node->unique_id());
261 break; 260 break;
262 case ui::AX_EVENT_SCROLLED_TO_ANCHOR: 261 case ui::AX_EVENT_SCROLLED_TO_ANCHOR:
263 Java_BrowserAccessibilityManager_handleScrolledToAnchor( 262 Java_BrowserAccessibilityManager_handleScrolledToAnchor(
264 env, obj.obj(), node->unique_id()); 263 env, obj, node->unique_id());
265 break; 264 break;
266 case ui::AX_EVENT_ALERT: 265 case ui::AX_EVENT_ALERT:
267 // An alert is a special case of live region. Fall through to the 266 // An alert is a special case of live region. Fall through to the
268 // next case to handle it. 267 // next case to handle it.
269 case ui::AX_EVENT_SHOW: { 268 case ui::AX_EVENT_SHOW: {
270 // This event is fired when an object appears in a live region. 269 // This event is fired when an object appears in a live region.
271 // Speak its text. 270 // Speak its text.
272 Java_BrowserAccessibilityManager_announceLiveRegionText( 271 Java_BrowserAccessibilityManager_announceLiveRegionText(
273 env, obj.obj(), 272 env, obj, base::android::ConvertUTF16ToJavaString(
274 base::android::ConvertUTF16ToJavaString( 273 env, android_node->GetText()));
275 env, android_node->GetText()).obj());
276 break; 274 break;
277 } 275 }
278 case ui::AX_EVENT_TEXT_SELECTION_CHANGED: 276 case ui::AX_EVENT_TEXT_SELECTION_CHANGED:
279 Java_BrowserAccessibilityManager_handleTextSelectionChanged( 277 Java_BrowserAccessibilityManager_handleTextSelectionChanged(
280 env, obj.obj(), node->unique_id()); 278 env, obj, node->unique_id());
281 break; 279 break;
282 case ui::AX_EVENT_TEXT_CHANGED: 280 case ui::AX_EVENT_TEXT_CHANGED:
283 case ui::AX_EVENT_VALUE_CHANGED: 281 case ui::AX_EVENT_VALUE_CHANGED:
284 if (android_node->IsEditableText() && GetFocus() == node) { 282 if (android_node->IsEditableText() && GetFocus() == node) {
285 Java_BrowserAccessibilityManager_handleEditableTextChanged( 283 Java_BrowserAccessibilityManager_handleEditableTextChanged(
286 env, obj.obj(), node->unique_id()); 284 env, obj, node->unique_id());
287 } else if (android_node->IsSlider()) { 285 } else if (android_node->IsSlider()) {
288 Java_BrowserAccessibilityManager_handleSliderChanged( 286 Java_BrowserAccessibilityManager_handleSliderChanged(env, obj,
289 env, obj.obj(), node->unique_id()); 287 node->unique_id());
290 } 288 }
291 break; 289 break;
292 default: 290 default:
293 // There are some notifications that aren't meaningful on Android. 291 // There are some notifications that aren't meaningful on Android.
294 // It's okay to skip them. 292 // It's okay to skip them.
295 break; 293 break;
296 } 294 }
297 } 295 }
298 296
299 void BrowserAccessibilityManagerAndroid::SendLocationChangeEvents( 297 void BrowserAccessibilityManagerAndroid::SendLocationChangeEvents(
300 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { 298 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) {
301 // Android is not very efficient at handling notifications, and location 299 // Android is not very efficient at handling notifications, and location
302 // changes in particular are frequent and not time-critical. If a lot of 300 // changes in particular are frequent and not time-critical. If a lot of
303 // nodes changed location, just send a single notification after a short 301 // nodes changed location, just send a single notification after a short
304 // delay (to batch them), rather than lots of individual notifications. 302 // delay (to batch them), rather than lots of individual notifications.
305 if (params.size() > 3) { 303 if (params.size() > 3) {
306 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager(); 304 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager();
307 JNIEnv* env = AttachCurrentThread(); 305 JNIEnv* env = AttachCurrentThread();
308 if (obj.is_null()) 306 if (obj.is_null())
309 return; 307 return;
310 Java_BrowserAccessibilityManager_sendDelayedWindowContentChangedEvent( 308 Java_BrowserAccessibilityManager_sendDelayedWindowContentChangedEvent(env,
311 env, obj.obj()); 309 obj);
312 return; 310 return;
313 } 311 }
314 312
315 BrowserAccessibilityManager::SendLocationChangeEvents(params); 313 BrowserAccessibilityManager::SendLocationChangeEvents(params);
316 } 314 }
317 315
318 base::android::ScopedJavaLocalRef<jstring> 316 base::android::ScopedJavaLocalRef<jstring>
319 BrowserAccessibilityManagerAndroid::GetSupportedHtmlElementTypes( 317 BrowserAccessibilityManagerAndroid::GetSupportedHtmlElementTypes(
320 JNIEnv* env, 318 JNIEnv* env,
321 const JavaParamRef<jobject>& obj) { 319 const JavaParamRef<jobject>& obj) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 node->CanScrollDown(), 418 node->CanScrollDown(),
421 node->CanScrollLeft(), 419 node->CanScrollLeft(),
422 node->CanScrollRight(), 420 node->CanScrollRight(),
423 node->IsClickable(), 421 node->IsClickable(),
424 node->IsEditableText(), 422 node->IsEditableText(),
425 node->IsEnabled(), 423 node->IsEnabled(),
426 node->IsFocusable(), 424 node->IsFocusable(),
427 node->IsFocused()); 425 node->IsFocused());
428 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoClassName( 426 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoClassName(
429 env, obj, info, 427 env, obj, info,
430 base::android::ConvertUTF8ToJavaString(env, node->GetClassName()).obj()); 428 base::android::ConvertUTF8ToJavaString(env, node->GetClassName()));
431 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoText( 429 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoText(
432 env, obj, info, 430 env, obj, info,
433 base::android::ConvertUTF16ToJavaString(env, node->GetText()).obj(), 431 base::android::ConvertUTF16ToJavaString(env, node->GetText()),
434 node->IsLink(), 432 node->IsLink(), node->IsEditableText());
435 node->IsEditableText());
436 base::string16 element_id; 433 base::string16 element_id;
437 if (node->GetHtmlAttribute("id", &element_id)) { 434 if (node->GetHtmlAttribute("id", &element_id)) {
438 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoViewIdResourceName( 435 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoViewIdResourceName(
439 env, obj, info, 436 env, obj, info,
440 base::android::ConvertUTF16ToJavaString(env, element_id).obj()); 437 base::android::ConvertUTF16ToJavaString(env, element_id));
441 } 438 }
442 439
443 gfx::Rect absolute_rect = node->GetPageBoundsRect(); 440 gfx::Rect absolute_rect = node->GetPageBoundsRect();
444 gfx::Rect parent_relative_rect = absolute_rect; 441 gfx::Rect parent_relative_rect = absolute_rect;
445 if (node->GetParent()) { 442 if (node->GetParent()) {
446 gfx::Rect parent_rect = node->GetParent()->GetPageBoundsRect(); 443 gfx::Rect parent_rect = node->GetParent()->GetPageBoundsRect();
447 parent_relative_rect.Offset(-parent_rect.OffsetFromOrigin()); 444 parent_relative_rect.Offset(-parent_rect.OffsetFromOrigin());
448 } 445 }
449 bool is_root = node->GetParent() == NULL; 446 bool is_root = node->GetParent() == NULL;
450 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLocation( 447 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLocation(
451 env, obj, info, 448 env, obj, info,
452 id, 449 id,
453 absolute_rect.x(), absolute_rect.y(), 450 absolute_rect.x(), absolute_rect.y(),
454 parent_relative_rect.x(), parent_relative_rect.y(), 451 parent_relative_rect.x(), parent_relative_rect.y(),
455 absolute_rect.width(), absolute_rect.height(), 452 absolute_rect.width(), absolute_rect.height(),
456 is_root); 453 is_root);
457 454
458 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoKitKatAttributes( 455 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoKitKatAttributes(
459 env, obj, info, 456 env, obj, info, is_root, node->IsEditableText(),
460 is_root, 457 base::android::ConvertUTF16ToJavaString(env, node->GetRoleDescription()));
461 node->IsEditableText(),
462 base::android::ConvertUTF16ToJavaString(
463 env, node->GetRoleDescription()).obj());
464 458
465 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLollipopAttributes( 459 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLollipopAttributes(
466 env, obj, info, 460 env, obj, info,
467 node->CanOpenPopup(), 461 node->CanOpenPopup(),
468 node->IsContentInvalid(), 462 node->IsContentInvalid(),
469 node->IsDismissable(), 463 node->IsDismissable(),
470 node->IsMultiLine(), 464 node->IsMultiLine(),
471 node->AndroidInputType(), 465 node->AndroidInputType(),
472 node->AndroidLiveRegionType()); 466 node->AndroidLiveRegionType());
473 if (node->IsCollection()) { 467 if (node->IsCollection()) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 return false; 503 return false;
510 504
511 Java_BrowserAccessibilityManager_setAccessibilityEventBooleanAttributes( 505 Java_BrowserAccessibilityManager_setAccessibilityEventBooleanAttributes(
512 env, obj, event, 506 env, obj, event,
513 node->IsChecked(), 507 node->IsChecked(),
514 node->IsEnabled(), 508 node->IsEnabled(),
515 node->IsPassword(), 509 node->IsPassword(),
516 node->IsScrollable()); 510 node->IsScrollable());
517 Java_BrowserAccessibilityManager_setAccessibilityEventClassName( 511 Java_BrowserAccessibilityManager_setAccessibilityEventClassName(
518 env, obj, event, 512 env, obj, event,
519 base::android::ConvertUTF8ToJavaString(env, node->GetClassName()).obj()); 513 base::android::ConvertUTF8ToJavaString(env, node->GetClassName()));
520 Java_BrowserAccessibilityManager_setAccessibilityEventListAttributes( 514 Java_BrowserAccessibilityManager_setAccessibilityEventListAttributes(
521 env, obj, event, 515 env, obj, event,
522 node->GetItemIndex(), 516 node->GetItemIndex(),
523 node->GetItemCount()); 517 node->GetItemCount());
524 Java_BrowserAccessibilityManager_setAccessibilityEventScrollAttributes( 518 Java_BrowserAccessibilityManager_setAccessibilityEventScrollAttributes(
525 env, obj, event, 519 env, obj, event,
526 node->GetScrollX(), 520 node->GetScrollX(),
527 node->GetScrollY(), 521 node->GetScrollY(),
528 node->GetMaxScrollX(), 522 node->GetMaxScrollX(),
529 node->GetMaxScrollY()); 523 node->GetMaxScrollY());
530 524
531 switch (event_type) { 525 switch (event_type) {
532 case ANDROID_ACCESSIBILITY_EVENT_TEXT_CHANGED: { 526 case ANDROID_ACCESSIBILITY_EVENT_TEXT_CHANGED: {
533 base::string16 before_text = node->GetTextChangeBeforeText(); 527 base::string16 before_text = node->GetTextChangeBeforeText();
534 base::string16 text = node->GetText(); 528 base::string16 text = node->GetText();
535 Java_BrowserAccessibilityManager_setAccessibilityEventTextChangedAttrs( 529 Java_BrowserAccessibilityManager_setAccessibilityEventTextChangedAttrs(
536 env, obj, event, 530 env, obj, event, node->GetTextChangeFromIndex(),
537 node->GetTextChangeFromIndex(), 531 node->GetTextChangeAddedCount(), node->GetTextChangeRemovedCount(),
538 node->GetTextChangeAddedCount(), 532 base::android::ConvertUTF16ToJavaString(env, before_text),
539 node->GetTextChangeRemovedCount(), 533 base::android::ConvertUTF16ToJavaString(env, text));
540 base::android::ConvertUTF16ToJavaString(
541 env, before_text).obj(),
542 base::android::ConvertUTF16ToJavaString(env, text).obj());
543 break; 534 break;
544 } 535 }
545 case ANDROID_ACCESSIBILITY_EVENT_TEXT_SELECTION_CHANGED: { 536 case ANDROID_ACCESSIBILITY_EVENT_TEXT_SELECTION_CHANGED: {
546 base::string16 text = node->GetText(); 537 base::string16 text = node->GetText();
547 Java_BrowserAccessibilityManager_setAccessibilityEventSelectionAttrs( 538 Java_BrowserAccessibilityManager_setAccessibilityEventSelectionAttrs(
548 env, obj, event, 539 env, obj, event, node->GetSelectionStart(), node->GetSelectionEnd(),
549 node->GetSelectionStart(),
550 node->GetSelectionEnd(),
551 node->GetEditableTextLength(), 540 node->GetEditableTextLength(),
552 base::android::ConvertUTF16ToJavaString(env, text).obj()); 541 base::android::ConvertUTF16ToJavaString(env, text));
553 break; 542 break;
554 } 543 }
555 default: 544 default:
556 break; 545 break;
557 } 546 }
558 547
559 Java_BrowserAccessibilityManager_setAccessibilityEventLollipopAttributes( 548 Java_BrowserAccessibilityManager_setAccessibilityEventLollipopAttributes(
560 env, obj, event, 549 env, obj, event,
561 node->CanOpenPopup(), 550 node->CanOpenPopup(),
562 node->IsContentInvalid(), 551 node->IsContentInvalid(),
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 while (ancestor && ancestor != GetRoot()) { 685 while (ancestor && ancestor != GetRoot()) {
697 if (ancestor->PlatformIsLeaf() || 686 if (ancestor->PlatformIsLeaf() ||
698 (ancestor->IsFocusable() && !ancestor->HasFocusableChild())) { 687 (ancestor->IsFocusable() && !ancestor->HasFocusableChild())) {
699 node = ancestor; 688 node = ancestor;
700 // Don't break - we want the highest ancestor that's focusable or a 689 // Don't break - we want the highest ancestor that's focusable or a
701 // leaf node. 690 // leaf node.
702 } 691 }
703 ancestor = static_cast<BrowserAccessibilityAndroid*>(ancestor->GetParent()); 692 ancestor = static_cast<BrowserAccessibilityAndroid*>(ancestor->GetParent());
704 } 693 }
705 694
706 Java_BrowserAccessibilityManager_handleHover( 695 Java_BrowserAccessibilityManager_handleHover(env, obj, node->unique_id());
707 env, obj.obj(), node->unique_id());
708 } 696 }
709 697
710 jint BrowserAccessibilityManagerAndroid::FindElementType( 698 jint BrowserAccessibilityManagerAndroid::FindElementType(
711 JNIEnv* env, 699 JNIEnv* env,
712 const JavaParamRef<jobject>& obj, 700 const JavaParamRef<jobject>& obj,
713 jint start_id, 701 jint start_id,
714 const JavaParamRef<jstring>& element_type_str, 702 const JavaParamRef<jstring>& element_type_str,
715 jboolean forwards) { 703 jboolean forwards) {
716 BrowserAccessibilityAndroid* start_node = GetFromUniqueID(start_id); 704 BrowserAccessibilityAndroid* start_node = GetFromUniqueID(start_id);
717 if (!start_node) 705 if (!start_node)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 BrowserAccessibilityAndroid* node = GetFromUniqueID(id); 743 BrowserAccessibilityAndroid* node = GetFromUniqueID(id);
756 if (!node) 744 if (!node)
757 return false; 745 return false;
758 746
759 jint start_index = -1; 747 jint start_index = -1;
760 int end_index = -1; 748 int end_index = -1;
761 if (NextAtGranularity(granularity, cursor_index, node, 749 if (NextAtGranularity(granularity, cursor_index, node,
762 &start_index, &end_index)) { 750 &start_index, &end_index)) {
763 base::string16 text = node->GetText(); 751 base::string16 text = node->GetText();
764 Java_BrowserAccessibilityManager_finishGranularityMove( 752 Java_BrowserAccessibilityManager_finishGranularityMove(
765 env, obj, base::android::ConvertUTF16ToJavaString( 753 env, obj, base::android::ConvertUTF16ToJavaString(env, text),
766 env, text).obj(),
767 extend_selection, start_index, end_index, true); 754 extend_selection, start_index, end_index, true);
768 return true; 755 return true;
769 } 756 }
770 return false; 757 return false;
771 } 758 }
772 759
773 jboolean BrowserAccessibilityManagerAndroid::PreviousAtGranularity( 760 jboolean BrowserAccessibilityManagerAndroid::PreviousAtGranularity(
774 JNIEnv* env, 761 JNIEnv* env,
775 const JavaParamRef<jobject>& obj, 762 const JavaParamRef<jobject>& obj,
776 jint granularity, 763 jint granularity,
777 jboolean extend_selection, 764 jboolean extend_selection,
778 jint id, 765 jint id,
779 jint cursor_index) { 766 jint cursor_index) {
780 BrowserAccessibilityAndroid* node = GetFromUniqueID(id); 767 BrowserAccessibilityAndroid* node = GetFromUniqueID(id);
781 if (!node) 768 if (!node)
782 return false; 769 return false;
783 770
784 jint start_index = -1; 771 jint start_index = -1;
785 int end_index = -1; 772 int end_index = -1;
786 if (PreviousAtGranularity(granularity, cursor_index, node, 773 if (PreviousAtGranularity(granularity, cursor_index, node,
787 &start_index, &end_index)) { 774 &start_index, &end_index)) {
788 Java_BrowserAccessibilityManager_finishGranularityMove( 775 Java_BrowserAccessibilityManager_finishGranularityMove(
789 env, obj, base::android::ConvertUTF16ToJavaString( 776 env, obj, base::android::ConvertUTF16ToJavaString(env, node->GetText()),
790 env, node->GetText()).obj(),
791 extend_selection, start_index, end_index, false); 777 extend_selection, start_index, end_index, false);
792 return true; 778 return true;
793 } 779 }
794 return false; 780 return false;
795 } 781 }
796 782
797 bool BrowserAccessibilityManagerAndroid::NextAtGranularity( 783 bool BrowserAccessibilityManagerAndroid::NextAtGranularity(
798 int32_t granularity, 784 int32_t granularity,
799 int32_t cursor_index, 785 int32_t cursor_index,
800 BrowserAccessibilityAndroid* node, 786 BrowserAccessibilityAndroid* node,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 const std::vector<ui::AXTreeDelegate::Change>& changes) { 908 const std::vector<ui::AXTreeDelegate::Change>& changes) {
923 BrowserAccessibilityManager::OnAtomicUpdateFinished( 909 BrowserAccessibilityManager::OnAtomicUpdateFinished(
924 tree, root_changed, changes); 910 tree, root_changed, changes);
925 911
926 if (root_changed) { 912 if (root_changed) {
927 JNIEnv* env = AttachCurrentThread(); 913 JNIEnv* env = AttachCurrentThread();
928 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager(); 914 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager();
929 if (obj.is_null()) 915 if (obj.is_null())
930 return; 916 return;
931 917
932 Java_BrowserAccessibilityManager_handleNavigate(env, obj.obj()); 918 Java_BrowserAccessibilityManager_handleNavigate(env, obj);
933 } 919 }
934 } 920 }
935 921
936 bool 922 bool
937 BrowserAccessibilityManagerAndroid::UseRootScrollOffsetsWhenComputingBounds() { 923 BrowserAccessibilityManagerAndroid::UseRootScrollOffsetsWhenComputingBounds() {
938 // The Java layer handles the root scroll offset. 924 // The Java layer handles the root scroll offset.
939 return false; 925 return false;
940 } 926 }
941 927
942 BrowserAccessibilityAndroid* 928 BrowserAccessibilityAndroid*
(...skipping 12 matching lines...) Expand all
955 941
956 JNIEnv* env = AttachCurrentThread(); 942 JNIEnv* env = AttachCurrentThread();
957 return root_manager->java_ref().get(env); 943 return root_manager->java_ref().get(env);
958 } 944 }
959 945
960 bool RegisterBrowserAccessibilityManager(JNIEnv* env) { 946 bool RegisterBrowserAccessibilityManager(JNIEnv* env) {
961 return RegisterNativesImpl(env); 947 return RegisterNativesImpl(env);
962 } 948 }
963 949
964 } // namespace content 950 } // namespace content
OLDNEW
« no previous file with comments | « content/app/android/child_process_service_impl.cc ('k') | content/browser/android/background_sync_network_observer_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698