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

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

Issue 67473013: Support KitKat accessibility APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebaseline expectations Created 7 years, 1 month 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 <cmath> 7 #include <cmath>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 parent_relative_rect.Offset(-parent_rect.OffsetFromOrigin()); 221 parent_relative_rect.Offset(-parent_rect.OffsetFromOrigin());
222 } 222 }
223 bool is_root = node->parent() == NULL; 223 bool is_root = node->parent() == NULL;
224 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLocation( 224 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLocation(
225 env, obj, info, 225 env, obj, info,
226 absolute_rect.x(), absolute_rect.y(), 226 absolute_rect.x(), absolute_rect.y(),
227 parent_relative_rect.x(), parent_relative_rect.y(), 227 parent_relative_rect.x(), parent_relative_rect.y(),
228 absolute_rect.width(), absolute_rect.height(), 228 absolute_rect.width(), absolute_rect.height(),
229 is_root); 229 is_root);
230 230
231 // New KitKat APIs
232 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoKitKatAttributes(
233 env, obj, info,
234 node->CanOpenPopup(),
235 node->IsContentInvalid(),
236 node->IsDismissable(),
237 node->IsMultiLine(),
238 node->AndroidInputType(),
239 node->AndroidLiveRegionType());
240 if (node->IsCollection()) {
241 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoCollectionInfo(
242 env, obj, info,
243 node->RowCount(),
244 node->ColumnCount(),
245 node->IsHierarchical());
246 }
247 if (node->IsCollectionItem() || node->IsHeading()) {
248 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoCollectionItemInfo(
249 env, obj, info,
250 node->RowIndex(),
251 node->RowSpan(),
252 node->ColumnIndex(),
253 node->ColumnSpan(),
254 node->IsHeading());
255 }
256 if (node->IsRangeType()) {
257 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoRangeInfo(
258 env, obj, info,
259 node->AndroidRangeType(),
260 node->RangeMin(),
261 node->RangeMax(),
262 node->RangeCurrentValue());
263 }
264
231 return true; 265 return true;
232 } 266 }
233 267
234 jboolean BrowserAccessibilityManagerAndroid::PopulateAccessibilityEvent( 268 jboolean BrowserAccessibilityManagerAndroid::PopulateAccessibilityEvent(
235 JNIEnv* env, jobject obj, jobject event, jint id, jint event_type) { 269 JNIEnv* env, jobject obj, jobject event, jint id, jint event_type) {
236 BrowserAccessibilityAndroid* node = static_cast<BrowserAccessibilityAndroid*>( 270 BrowserAccessibilityAndroid* node = static_cast<BrowserAccessibilityAndroid*>(
237 GetFromRendererID(id)); 271 GetFromRendererID(id));
238 if (!node) 272 if (!node)
239 return false; 273 return false;
240 274
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 env, obj, event, 308 env, obj, event,
275 node->GetSelectionStart(), 309 node->GetSelectionStart(),
276 node->GetSelectionEnd(), 310 node->GetSelectionEnd(),
277 node->GetEditableTextLength(), 311 node->GetEditableTextLength(),
278 base::android::ConvertUTF16ToJavaString(env, node->GetText()).obj()); 312 base::android::ConvertUTF16ToJavaString(env, node->GetText()).obj());
279 break; 313 break;
280 default: 314 default:
281 break; 315 break;
282 } 316 }
283 317
318 // Backwards-compatible fallback for new KitKat APIs.
319 Java_BrowserAccessibilityManager_setAccessibilityEventKitKatAttributes(
320 env, obj, event,
321 node->CanOpenPopup(),
322 node->IsContentInvalid(),
323 node->IsDismissable(),
324 node->IsMultiLine(),
325 node->AndroidInputType(),
326 node->AndroidLiveRegionType());
327 if (node->IsCollection()) {
328 Java_BrowserAccessibilityManager_setAccessibilityEventCollectionInfo(
329 env, obj, event,
330 node->RowCount(),
331 node->ColumnCount(),
332 node->IsHierarchical());
333 }
334 if (node->IsCollectionItem() || node->IsHeading()) {
335 Java_BrowserAccessibilityManager_setAccessibilityEventCollectionItemInfo(
336 env, obj, event,
337 node->RowIndex(),
338 node->RowSpan(),
339 node->ColumnIndex(),
340 node->ColumnSpan(),
341 node->IsHeading());
342 }
343 if (node->IsRangeType()) {
344 Java_BrowserAccessibilityManager_setAccessibilityEventRangeInfo(
345 env, obj, event,
346 node->AndroidRangeType(),
347 node->RangeMin(),
348 node->RangeMax(),
349 node->RangeCurrentValue());
350 }
351
284 return true; 352 return true;
285 } 353 }
286 354
287 void BrowserAccessibilityManagerAndroid::Click( 355 void BrowserAccessibilityManagerAndroid::Click(
288 JNIEnv* env, jobject obj, jint id) { 356 JNIEnv* env, jobject obj, jint id) {
289 BrowserAccessibility* node = GetFromRendererID(id); 357 BrowserAccessibility* node = GetFromRendererID(id);
290 if (node) 358 if (node)
291 DoDefaultAction(*node); 359 DoDefaultAction(*node);
292 } 360 }
293 361
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 BrowserAccessibilityManagerAndroid::UseRootScrollOffsetsWhenComputingBounds() { 434 BrowserAccessibilityManagerAndroid::UseRootScrollOffsetsWhenComputingBounds() {
367 // The Java layer handles the root scroll offset. 435 // The Java layer handles the root scroll offset.
368 return false; 436 return false;
369 } 437 }
370 438
371 bool RegisterBrowserAccessibilityManager(JNIEnv* env) { 439 bool RegisterBrowserAccessibilityManager(JNIEnv* env) {
372 return RegisterNativesImpl(env); 440 return RegisterNativesImpl(env);
373 } 441 }
374 442
375 } // namespace content 443 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698