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

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

Powered by Google App Engine
This is Rietveld 408576698