| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/test_runner/web_ax_object_proxy.h" | 5 #include "content/shell/test_runner/web_ax_object_proxy.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "gin/handle.h" | 11 #include "gin/handle.h" |
| 12 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 12 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
| 13 #include "third_party/WebKit/public/platform/WebPoint.h" | 13 #include "third_party/WebKit/public/platform/WebPoint.h" |
| 14 #include "third_party/WebKit/public/platform/WebRect.h" | 14 #include "third_party/WebKit/public/platform/WebRect.h" |
| 15 #include "third_party/WebKit/public/platform/WebString.h" | 15 #include "third_party/WebKit/public/platform/WebString.h" |
| 16 #include "third_party/WebKit/public/web/WebFrame.h" | 16 #include "third_party/WebKit/public/web/WebFrame.h" |
| 17 #include "third_party/WebKit/public/web/WebKit.h" | 17 #include "third_party/WebKit/public/web/WebKit.h" |
| 18 #include "third_party/skia/include/core/SkMatrix44.h" | 18 #include "third_party/skia/include/core/SkMatrix44.h" |
| 19 #include "ui/gfx/geometry/rect_f.h" | 19 #include "ui/gfx/geometry/rect_f.h" |
| 20 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
| 21 | 21 |
| 22 namespace test_runner { | 22 namespace test_runner { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // Map role value to string, matching Safari/Mac platform implementation to | 26 // Map role value to string, matching Safari/Mac platform implementation to |
| 27 // avoid rebaselining layout tests. | 27 // avoid rebaselining layout tests. |
| 28 std::string RoleToString(blink::WebAXRole role) | 28 std::string RoleToString(blink::WebAXRole role) { |
| 29 { | |
| 30 std::string result = "AXRole: AX"; | 29 std::string result = "AXRole: AX"; |
| 31 switch (role) { | 30 switch (role) { |
| 32 case blink::WebAXRoleAbbr: | 31 case blink::WebAXRoleAbbr: |
| 33 return result.append("Abbr"); | 32 return result.append("Abbr"); |
| 34 case blink::WebAXRoleAlertDialog: | 33 case blink::WebAXRoleAlertDialog: |
| 35 return result.append("AlertDialog"); | 34 return result.append("AlertDialog"); |
| 36 case blink::WebAXRoleAlert: | 35 case blink::WebAXRoleAlert: |
| 37 return result.append("Alert"); | 36 return result.append("Alert"); |
| 38 case blink::WebAXRoleAnnotation: | 37 case blink::WebAXRoleAnnotation: |
| 39 return result.append("Annotation"); | 38 return result.append("Annotation"); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 } | 273 } |
| 275 } | 274 } |
| 276 | 275 |
| 277 std::string GetStringValue(const blink::WebAXObject& object) { | 276 std::string GetStringValue(const blink::WebAXObject& object) { |
| 278 std::string value; | 277 std::string value; |
| 279 if (object.role() == blink::WebAXRoleColorWell) { | 278 if (object.role() == blink::WebAXRoleColorWell) { |
| 280 unsigned int color = object.colorValue(); | 279 unsigned int color = object.colorValue(); |
| 281 unsigned int red = (color >> 16) & 0xFF; | 280 unsigned int red = (color >> 16) & 0xFF; |
| 282 unsigned int green = (color >> 8) & 0xFF; | 281 unsigned int green = (color >> 8) & 0xFF; |
| 283 unsigned int blue = color & 0xFF; | 282 unsigned int blue = color & 0xFF; |
| 284 value = base::StringPrintf("rgba(%d, %d, %d, 1)", | 283 value = base::StringPrintf("rgba(%d, %d, %d, 1)", red, green, blue); |
| 285 red, green, blue); | |
| 286 } else { | 284 } else { |
| 287 value = object.stringValue().utf8(); | 285 value = object.stringValue().utf8(); |
| 288 } | 286 } |
| 289 return value.insert(0, "AXValue: "); | 287 return value.insert(0, "AXValue: "); |
| 290 } | 288 } |
| 291 | 289 |
| 292 std::string GetRole(const blink::WebAXObject& object) { | 290 std::string GetRole(const blink::WebAXObject& object) { |
| 293 std::string role_string = RoleToString(object.role()); | 291 std::string role_string = RoleToString(object.role()); |
| 294 | 292 |
| 295 // Special-case canvas with fallback content because Chromium wants to treat | 293 // Special-case canvas with fallback content because Chromium wants to treat |
| (...skipping 28 matching lines...) Expand all Loading... |
| 324 // of an object by calling getRelativeBounds and then applying the offsets | 322 // of an object by calling getRelativeBounds and then applying the offsets |
| 325 // and transforms recursively on each container of this object. | 323 // and transforms recursively on each container of this object. |
| 326 blink::WebFloatRect BoundsForObject(const blink::WebAXObject& object) { | 324 blink::WebFloatRect BoundsForObject(const blink::WebAXObject& object) { |
| 327 blink::WebAXObject container; | 325 blink::WebAXObject container; |
| 328 blink::WebFloatRect bounds; | 326 blink::WebFloatRect bounds; |
| 329 SkMatrix44 matrix; | 327 SkMatrix44 matrix; |
| 330 object.getRelativeBounds(container, bounds, matrix); | 328 object.getRelativeBounds(container, bounds, matrix); |
| 331 gfx::RectF computedBounds(0, 0, bounds.width, bounds.height); | 329 gfx::RectF computedBounds(0, 0, bounds.width, bounds.height); |
| 332 while (!container.isDetached()) { | 330 while (!container.isDetached()) { |
| 333 computedBounds.Offset(bounds.x, bounds.y); | 331 computedBounds.Offset(bounds.x, bounds.y); |
| 334 computedBounds.Offset( | 332 computedBounds.Offset(-container.getScrollOffset().x, |
| 335 -container.getScrollOffset().x, -container.getScrollOffset().y); | 333 -container.getScrollOffset().y); |
| 336 if (!matrix.isIdentity()) { | 334 if (!matrix.isIdentity()) { |
| 337 gfx::Transform transform(matrix); | 335 gfx::Transform transform(matrix); |
| 338 transform.TransformRect(&computedBounds); | 336 transform.TransformRect(&computedBounds); |
| 339 } | 337 } |
| 340 container.getRelativeBounds(container, bounds, matrix); | 338 container.getRelativeBounds(container, bounds, matrix); |
| 341 } | 339 } |
| 342 return blink::WebFloatRect(computedBounds.x(), | 340 return blink::WebFloatRect(computedBounds.x(), computedBounds.y(), |
| 343 computedBounds.y(), | 341 computedBounds.width(), computedBounds.height()); |
| 344 computedBounds.width(), | |
| 345 computedBounds.height()); | |
| 346 } | 342 } |
| 347 | 343 |
| 348 blink::WebRect BoundsForCharacter(const blink::WebAXObject& object, | 344 blink::WebRect BoundsForCharacter(const blink::WebAXObject& object, |
| 349 int characterIndex) { | 345 int characterIndex) { |
| 350 DCHECK_EQ(object.role(), blink::WebAXRoleStaticText); | 346 DCHECK_EQ(object.role(), blink::WebAXRoleStaticText); |
| 351 int end = 0; | 347 int end = 0; |
| 352 for (unsigned i = 0; i < object.childCount(); i++) { | 348 for (unsigned i = 0; i < object.childCount(); i++) { |
| 353 blink::WebAXObject inline_text_box = object.childAt(i); | 349 blink::WebAXObject inline_text_box = object.childAt(i); |
| 354 DCHECK_EQ(inline_text_box.role(), blink::WebAXRoleInlineTextBox); | 350 DCHECK_EQ(inline_text_box.role(), blink::WebAXRoleInlineTextBox); |
| 355 int start = end; | 351 int start = end; |
| 356 blink::WebString name = inline_text_box.name(); | 352 blink::WebString name = inline_text_box.name(); |
| 357 end += name.length(); | 353 end += name.length(); |
| 358 if (characterIndex < start || characterIndex >= end) | 354 if (characterIndex < start || characterIndex >= end) |
| 359 continue; | 355 continue; |
| 360 | 356 |
| 361 blink::WebFloatRect inline_text_box_rect = BoundsForObject(inline_text_box); | 357 blink::WebFloatRect inline_text_box_rect = BoundsForObject(inline_text_box); |
| 362 | 358 |
| 363 int localIndex = characterIndex - start; | 359 int localIndex = characterIndex - start; |
| 364 blink::WebVector<int> character_offsets; | 360 blink::WebVector<int> character_offsets; |
| 365 inline_text_box.characterOffsets(character_offsets); | 361 inline_text_box.characterOffsets(character_offsets); |
| 366 if (character_offsets.size() != name.length()) | 362 if (character_offsets.size() != name.length()) |
| 367 return blink::WebRect(); | 363 return blink::WebRect(); |
| 368 | 364 |
| 369 switch (inline_text_box.textDirection()) { | 365 switch (inline_text_box.textDirection()) { |
| 370 case blink::WebAXTextDirectionLR: { | 366 case blink::WebAXTextDirectionLR: { |
| 371 if (localIndex) { | 367 if (localIndex) { |
| 372 int left = inline_text_box_rect.x + character_offsets[localIndex - 1]; | 368 int left = inline_text_box_rect.x + character_offsets[localIndex - 1]; |
| 373 int width = character_offsets[localIndex] - | 369 int width = |
| 374 character_offsets[localIndex - 1]; | 370 character_offsets[localIndex] - character_offsets[localIndex - 1]; |
| 375 return blink::WebRect(left, inline_text_box_rect.y, | 371 return blink::WebRect(left, inline_text_box_rect.y, width, |
| 376 width, inline_text_box_rect.height); | 372 inline_text_box_rect.height); |
| 377 } | 373 } |
| 378 return blink::WebRect( | 374 return blink::WebRect(inline_text_box_rect.x, inline_text_box_rect.y, |
| 379 inline_text_box_rect.x, inline_text_box_rect.y, | 375 character_offsets[0], |
| 380 character_offsets[0], inline_text_box_rect.height); | 376 inline_text_box_rect.height); |
| 381 } | 377 } |
| 382 case blink::WebAXTextDirectionRL: { | 378 case blink::WebAXTextDirectionRL: { |
| 383 int right = inline_text_box_rect.x + inline_text_box_rect.width; | 379 int right = inline_text_box_rect.x + inline_text_box_rect.width; |
| 384 | 380 |
| 385 if (localIndex) { | 381 if (localIndex) { |
| 386 int left = right - character_offsets[localIndex]; | 382 int left = right - character_offsets[localIndex]; |
| 387 int width = character_offsets[localIndex] - | 383 int width = |
| 388 character_offsets[localIndex - 1]; | 384 character_offsets[localIndex] - character_offsets[localIndex - 1]; |
| 389 return blink::WebRect(left, inline_text_box_rect.y, | 385 return blink::WebRect(left, inline_text_box_rect.y, width, |
| 390 width, inline_text_box_rect.height); | 386 inline_text_box_rect.height); |
| 391 } | 387 } |
| 392 int left = right - character_offsets[0]; | 388 int left = right - character_offsets[0]; |
| 393 return blink::WebRect( | 389 return blink::WebRect(left, inline_text_box_rect.y, |
| 394 left, inline_text_box_rect.y, | 390 character_offsets[0], |
| 395 character_offsets[0], inline_text_box_rect.height); | 391 inline_text_box_rect.height); |
| 396 } | 392 } |
| 397 case blink::WebAXTextDirectionTB: { | 393 case blink::WebAXTextDirectionTB: { |
| 398 if (localIndex) { | 394 if (localIndex) { |
| 399 int top = inline_text_box_rect.y + character_offsets[localIndex - 1]; | 395 int top = inline_text_box_rect.y + character_offsets[localIndex - 1]; |
| 400 int height = character_offsets[localIndex] - | 396 int height = |
| 401 character_offsets[localIndex - 1]; | 397 character_offsets[localIndex] - character_offsets[localIndex - 1]; |
| 402 return blink::WebRect(inline_text_box_rect.x, top, | 398 return blink::WebRect(inline_text_box_rect.x, top, |
| 403 inline_text_box_rect.width, height); | 399 inline_text_box_rect.width, height); |
| 404 } | 400 } |
| 405 return blink::WebRect(inline_text_box_rect.x, inline_text_box_rect.y, | 401 return blink::WebRect(inline_text_box_rect.x, inline_text_box_rect.y, |
| 406 inline_text_box_rect.width, character_offsets[0]); | 402 inline_text_box_rect.width, character_offsets[0]); |
| 407 } | 403 } |
| 408 case blink::WebAXTextDirectionBT: { | 404 case blink::WebAXTextDirectionBT: { |
| 409 int bottom = inline_text_box_rect.y + inline_text_box_rect.height; | 405 int bottom = inline_text_box_rect.y + inline_text_box_rect.height; |
| 410 | 406 |
| 411 if (localIndex) { | 407 if (localIndex) { |
| 412 int top = bottom - character_offsets[localIndex]; | 408 int top = bottom - character_offsets[localIndex]; |
| 413 int height = character_offsets[localIndex] - | 409 int height = |
| 414 character_offsets[localIndex - 1]; | 410 character_offsets[localIndex] - character_offsets[localIndex - 1]; |
| 415 return blink::WebRect(inline_text_box_rect.x, top, | 411 return blink::WebRect(inline_text_box_rect.x, top, |
| 416 inline_text_box_rect.width, height); | 412 inline_text_box_rect.width, height); |
| 417 } | 413 } |
| 418 int top = bottom - character_offsets[0]; | 414 int top = bottom - character_offsets[0]; |
| 419 return blink::WebRect(inline_text_box_rect.x, top, | 415 return blink::WebRect(inline_text_box_rect.x, top, |
| 420 inline_text_box_rect.width, character_offsets[0]); | 416 inline_text_box_rect.width, character_offsets[0]); |
| 421 } | 417 } |
| 422 } | 418 } |
| 423 } | 419 } |
| 424 | 420 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 | 538 |
| 543 void addObjectVectorAttribute( | 539 void addObjectVectorAttribute( |
| 544 blink::WebAXObjectVectorAttribute attribute, | 540 blink::WebAXObjectVectorAttribute attribute, |
| 545 const blink::WebVector<blink::WebAXObject>& value) override { | 541 const blink::WebVector<blink::WebAXObject>& value) override { |
| 546 object_vector_attributes[attribute] = value; | 542 object_vector_attributes[attribute] = value; |
| 547 } | 543 } |
| 548 }; | 544 }; |
| 549 | 545 |
| 550 } // namespace | 546 } // namespace |
| 551 | 547 |
| 552 gin::WrapperInfo WebAXObjectProxy::kWrapperInfo = { | 548 gin::WrapperInfo WebAXObjectProxy::kWrapperInfo = {gin::kEmbedderNativeGin}; |
| 553 gin::kEmbedderNativeGin}; | |
| 554 | 549 |
| 555 WebAXObjectProxy::WebAXObjectProxy(const blink::WebAXObject& object, | 550 WebAXObjectProxy::WebAXObjectProxy(const blink::WebAXObject& object, |
| 556 WebAXObjectProxy::Factory* factory) | 551 WebAXObjectProxy::Factory* factory) |
| 557 : accessibility_object_(object), | 552 : accessibility_object_(object), factory_(factory) {} |
| 558 factory_(factory) { | |
| 559 } | |
| 560 | 553 |
| 561 WebAXObjectProxy::~WebAXObjectProxy() {} | 554 WebAXObjectProxy::~WebAXObjectProxy() {} |
| 562 | 555 |
| 563 gin::ObjectTemplateBuilder | 556 gin::ObjectTemplateBuilder WebAXObjectProxy::GetObjectTemplateBuilder( |
| 564 WebAXObjectProxy::GetObjectTemplateBuilder(v8::Isolate* isolate) { | 557 v8::Isolate* isolate) { |
| 565 return gin::Wrappable<WebAXObjectProxy>::GetObjectTemplateBuilder(isolate) | 558 return gin::Wrappable<WebAXObjectProxy>::GetObjectTemplateBuilder(isolate) |
| 566 .SetProperty("role", &WebAXObjectProxy::Role) | 559 .SetProperty("role", &WebAXObjectProxy::Role) |
| 567 .SetProperty("stringValue", &WebAXObjectProxy::StringValue) | 560 .SetProperty("stringValue", &WebAXObjectProxy::StringValue) |
| 568 .SetProperty("language", &WebAXObjectProxy::Language) | 561 .SetProperty("language", &WebAXObjectProxy::Language) |
| 569 .SetProperty("x", &WebAXObjectProxy::X) | 562 .SetProperty("x", &WebAXObjectProxy::X) |
| 570 .SetProperty("y", &WebAXObjectProxy::Y) | 563 .SetProperty("y", &WebAXObjectProxy::Y) |
| 571 .SetProperty("width", &WebAXObjectProxy::Width) | 564 .SetProperty("width", &WebAXObjectProxy::Width) |
| 572 .SetProperty("height", &WebAXObjectProxy::Height) | 565 .SetProperty("height", &WebAXObjectProxy::Height) |
| 573 .SetProperty("intValue", &WebAXObjectProxy::IntValue) | 566 .SetProperty("intValue", &WebAXObjectProxy::IntValue) |
| 574 .SetProperty("minValue", &WebAXObjectProxy::MinValue) | 567 .SetProperty("minValue", &WebAXObjectProxy::MinValue) |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 if (notification_callback_.IsEmpty()) | 733 if (notification_callback_.IsEmpty()) |
| 741 return; | 734 return; |
| 742 | 735 |
| 743 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); | 736 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); |
| 744 if (context.IsEmpty()) | 737 if (context.IsEmpty()) |
| 745 return; | 738 return; |
| 746 | 739 |
| 747 v8::Isolate* isolate = blink::mainThreadIsolate(); | 740 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 748 | 741 |
| 749 v8::Local<v8::Value> argv[] = { | 742 v8::Local<v8::Value> argv[] = { |
| 750 v8::String::NewFromUtf8(isolate, notification_name.data(), | 743 v8::String::NewFromUtf8(isolate, notification_name.data(), |
| 751 v8::String::kNormalString, | 744 v8::String::kNormalString, |
| 752 notification_name.size()), | 745 notification_name.size()), |
| 753 }; | 746 }; |
| 754 frame->callFunctionEvenIfScriptDisabled( | 747 frame->callFunctionEvenIfScriptDisabled( |
| 755 v8::Local<v8::Function>::New(isolate, notification_callback_), | 748 v8::Local<v8::Function>::New(isolate, notification_callback_), |
| 756 context->Global(), | 749 context->Global(), arraysize(argv), argv); |
| 757 arraysize(argv), | |
| 758 argv); | |
| 759 } | 750 } |
| 760 | 751 |
| 761 void WebAXObjectProxy::Reset() { | 752 void WebAXObjectProxy::Reset() { |
| 762 notification_callback_.Reset(); | 753 notification_callback_.Reset(); |
| 763 } | 754 } |
| 764 | 755 |
| 765 std::string WebAXObjectProxy::Role() { | 756 std::string WebAXObjectProxy::Role() { |
| 766 accessibility_object_.updateLayoutAndCheckValidity(); | 757 accessibility_object_.updateLayoutAndCheckValidity(); |
| 767 return GetRole(accessibility_object_); | 758 return GetRole(accessibility_object_); |
| 768 } | 759 } |
| 769 | 760 |
| 770 std::string WebAXObjectProxy::StringValue() { | 761 std::string WebAXObjectProxy::StringValue() { |
| 771 accessibility_object_.updateLayoutAndCheckValidity(); | 762 accessibility_object_.updateLayoutAndCheckValidity(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 return accessibility_object_.maxValueForRange(); | 808 return accessibility_object_.maxValueForRange(); |
| 818 } | 809 } |
| 819 | 810 |
| 820 std::string WebAXObjectProxy::ValueDescription() { | 811 std::string WebAXObjectProxy::ValueDescription() { |
| 821 accessibility_object_.updateLayoutAndCheckValidity(); | 812 accessibility_object_.updateLayoutAndCheckValidity(); |
| 822 return GetValueDescription(accessibility_object_); | 813 return GetValueDescription(accessibility_object_); |
| 823 } | 814 } |
| 824 | 815 |
| 825 int WebAXObjectProxy::ChildrenCount() { | 816 int WebAXObjectProxy::ChildrenCount() { |
| 826 accessibility_object_.updateLayoutAndCheckValidity(); | 817 accessibility_object_.updateLayoutAndCheckValidity(); |
| 827 int count = 1; // Root object always has only one child, the WebView. | 818 int count = 1; // Root object always has only one child, the WebView. |
| 828 if (!IsRoot()) | 819 if (!IsRoot()) |
| 829 count = accessibility_object_.childCount(); | 820 count = accessibility_object_.childCount(); |
| 830 return count; | 821 return count; |
| 831 } | 822 } |
| 832 | 823 |
| 833 v8::Local<v8::Value> WebAXObjectProxy::SelectionAnchorObject() { | 824 v8::Local<v8::Value> WebAXObjectProxy::SelectionAnchorObject() { |
| 834 accessibility_object_.updateLayoutAndCheckValidity(); | 825 accessibility_object_.updateLayoutAndCheckValidity(); |
| 835 | 826 |
| 836 blink::WebAXObject anchorObject; | 827 blink::WebAXObject anchorObject; |
| 837 int anchorOffset = -1; | 828 int anchorOffset = -1; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 868 accessibility_object_.updateLayoutAndCheckValidity(); | 859 accessibility_object_.updateLayoutAndCheckValidity(); |
| 869 | 860 |
| 870 blink::WebAXObject anchorObject; | 861 blink::WebAXObject anchorObject; |
| 871 int anchorOffset = -1; | 862 int anchorOffset = -1; |
| 872 blink::WebAXTextAffinity anchorAffinity; | 863 blink::WebAXTextAffinity anchorAffinity; |
| 873 blink::WebAXObject focusObject; | 864 blink::WebAXObject focusObject; |
| 874 int focusOffset = -1; | 865 int focusOffset = -1; |
| 875 blink::WebAXTextAffinity focusAffinity; | 866 blink::WebAXTextAffinity focusAffinity; |
| 876 accessibility_object_.selection(anchorObject, anchorOffset, anchorAffinity, | 867 accessibility_object_.selection(anchorObject, anchorOffset, anchorAffinity, |
| 877 focusObject, focusOffset, focusAffinity); | 868 focusObject, focusOffset, focusAffinity); |
| 878 return anchorAffinity == blink::WebAXTextAffinityUpstream ? | 869 return anchorAffinity == blink::WebAXTextAffinityUpstream ? "upstream" |
| 879 "upstream" : "downstream"; | 870 : "downstream"; |
| 880 } | 871 } |
| 881 | 872 |
| 882 v8::Local<v8::Value> WebAXObjectProxy::SelectionFocusObject() { | 873 v8::Local<v8::Value> WebAXObjectProxy::SelectionFocusObject() { |
| 883 accessibility_object_.updateLayoutAndCheckValidity(); | 874 accessibility_object_.updateLayoutAndCheckValidity(); |
| 884 | 875 |
| 885 blink::WebAXObject anchorObject; | 876 blink::WebAXObject anchorObject; |
| 886 int anchorOffset = -1; | 877 int anchorOffset = -1; |
| 887 blink::WebAXTextAffinity anchorAffinity; | 878 blink::WebAXTextAffinity anchorAffinity; |
| 888 blink::WebAXObject focusObject; | 879 blink::WebAXObject focusObject; |
| 889 int focusOffset = -1; | 880 int focusOffset = -1; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 917 accessibility_object_.updateLayoutAndCheckValidity(); | 908 accessibility_object_.updateLayoutAndCheckValidity(); |
| 918 | 909 |
| 919 blink::WebAXObject anchorObject; | 910 blink::WebAXObject anchorObject; |
| 920 int anchorOffset = -1; | 911 int anchorOffset = -1; |
| 921 blink::WebAXTextAffinity anchorAffinity; | 912 blink::WebAXTextAffinity anchorAffinity; |
| 922 blink::WebAXObject focusObject; | 913 blink::WebAXObject focusObject; |
| 923 int focusOffset = -1; | 914 int focusOffset = -1; |
| 924 blink::WebAXTextAffinity focusAffinity; | 915 blink::WebAXTextAffinity focusAffinity; |
| 925 accessibility_object_.selection(anchorObject, anchorOffset, anchorAffinity, | 916 accessibility_object_.selection(anchorObject, anchorOffset, anchorAffinity, |
| 926 focusObject, focusOffset, focusAffinity); | 917 focusObject, focusOffset, focusAffinity); |
| 927 return focusAffinity == blink::WebAXTextAffinityUpstream ? | 918 return focusAffinity == blink::WebAXTextAffinityUpstream ? "upstream" |
| 928 "upstream" : "downstream"; | 919 : "downstream"; |
| 929 } | 920 } |
| 930 | 921 |
| 931 int WebAXObjectProxy::SelectionStart() { | 922 int WebAXObjectProxy::SelectionStart() { |
| 932 accessibility_object_.updateLayoutAndCheckValidity(); | 923 accessibility_object_.updateLayoutAndCheckValidity(); |
| 933 return accessibility_object_.selectionStart(); | 924 return accessibility_object_.selectionStart(); |
| 934 } | 925 } |
| 935 | 926 |
| 936 int WebAXObjectProxy::SelectionEnd() { | 927 int WebAXObjectProxy::SelectionEnd() { |
| 937 accessibility_object_.updateLayoutAndCheckValidity(); | 928 accessibility_object_.updateLayoutAndCheckValidity(); |
| 938 return accessibility_object_.selectionEnd(); | 929 return accessibility_object_.selectionEnd(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 | 1060 |
| 1070 float WebAXObjectProxy::FontSize() { | 1061 float WebAXObjectProxy::FontSize() { |
| 1071 accessibility_object_.updateLayoutAndCheckValidity(); | 1062 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1072 return accessibility_object_.fontSize(); | 1063 return accessibility_object_.fontSize(); |
| 1073 } | 1064 } |
| 1074 | 1065 |
| 1075 std::string WebAXObjectProxy::Orientation() { | 1066 std::string WebAXObjectProxy::Orientation() { |
| 1076 accessibility_object_.updateLayoutAndCheckValidity(); | 1067 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1077 if (accessibility_object_.orientation() == blink::WebAXOrientationVertical) | 1068 if (accessibility_object_.orientation() == blink::WebAXOrientationVertical) |
| 1078 return "AXOrientation: AXVerticalOrientation"; | 1069 return "AXOrientation: AXVerticalOrientation"; |
| 1079 else if (accessibility_object_.orientation() | 1070 else if (accessibility_object_.orientation() == |
| 1080 == blink::WebAXOrientationHorizontal) | 1071 blink::WebAXOrientationHorizontal) |
| 1081 return "AXOrientation: AXHorizontalOrientation"; | 1072 return "AXOrientation: AXHorizontalOrientation"; |
| 1082 | 1073 |
| 1083 return std::string(); | 1074 return std::string(); |
| 1084 } | 1075 } |
| 1085 | 1076 |
| 1086 int WebAXObjectProxy::PosInSet() { | 1077 int WebAXObjectProxy::PosInSet() { |
| 1087 accessibility_object_.updateLayoutAndCheckValidity(); | 1078 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1088 return accessibility_object_.posInSet(); | 1079 return accessibility_object_.posInSet(); |
| 1089 } | 1080 } |
| 1090 | 1081 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1115 blink::WebVector<blink::WebAXObject> headers; | 1106 blink::WebVector<blink::WebAXObject> headers; |
| 1116 accessibility_object_.rowHeaders(headers); | 1107 accessibility_object_.rowHeaders(headers); |
| 1117 return static_cast<int32_t>(headers.size()); | 1108 return static_cast<int32_t>(headers.size()); |
| 1118 } | 1109 } |
| 1119 | 1110 |
| 1120 int32_t WebAXObjectProxy::ColumnCount() { | 1111 int32_t WebAXObjectProxy::ColumnCount() { |
| 1121 accessibility_object_.updateLayoutAndCheckValidity(); | 1112 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1122 return static_cast<int32_t>(accessibility_object_.columnCount()); | 1113 return static_cast<int32_t>(accessibility_object_.columnCount()); |
| 1123 } | 1114 } |
| 1124 | 1115 |
| 1125 int32_t WebAXObjectProxy::ColumnHeadersCount() | 1116 int32_t WebAXObjectProxy::ColumnHeadersCount() { |
| 1126 { | |
| 1127 accessibility_object_.updateLayoutAndCheckValidity(); | 1117 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1128 blink::WebVector<blink::WebAXObject> headers; | 1118 blink::WebVector<blink::WebAXObject> headers; |
| 1129 accessibility_object_.columnHeaders(headers); | 1119 accessibility_object_.columnHeaders(headers); |
| 1130 return static_cast<int32_t>(headers.size()); | 1120 return static_cast<int32_t>(headers.size()); |
| 1131 } | 1121 } |
| 1132 | 1122 |
| 1133 bool WebAXObjectProxy::IsClickable() { | 1123 bool WebAXObjectProxy::IsClickable() { |
| 1134 accessibility_object_.updateLayoutAndCheckValidity(); | 1124 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1135 return accessibility_object_.isClickable(); | 1125 return accessibility_object_.isClickable(); |
| 1136 } | 1126 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1163 blink::WebVector<blink::WebAXObject> elements = | 1153 blink::WebVector<blink::WebAXObject> elements = |
| 1164 attribute_adapter.object_vector_attributes | 1154 attribute_adapter.object_vector_attributes |
| 1165 [blink::WebAXObjectVectorAttribute::AriaFlowTo]; | 1155 [blink::WebAXObjectVectorAttribute::AriaFlowTo]; |
| 1166 size_t elementCount = elements.size(); | 1156 size_t elementCount = elements.size(); |
| 1167 if (index >= elementCount) | 1157 if (index >= elementCount) |
| 1168 return v8::Local<v8::Object>(); | 1158 return v8::Local<v8::Object>(); |
| 1169 | 1159 |
| 1170 return factory_->GetOrCreate(elements[index]); | 1160 return factory_->GetOrCreate(elements[index]); |
| 1171 } | 1161 } |
| 1172 | 1162 |
| 1173 v8::Local<v8::Object> WebAXObjectProxy::AriaOwnsElementAtIndex(unsigned index) | 1163 v8::Local<v8::Object> WebAXObjectProxy::AriaOwnsElementAtIndex(unsigned index) { |
| 1174 { | |
| 1175 accessibility_object_.updateLayoutAndCheckValidity(); | 1164 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1176 blink::WebVector<blink::WebAXObject> elements; | 1165 blink::WebVector<blink::WebAXObject> elements; |
| 1177 accessibility_object_.ariaOwns(elements); | 1166 accessibility_object_.ariaOwns(elements); |
| 1178 size_t elementCount = elements.size(); | 1167 size_t elementCount = elements.size(); |
| 1179 if (index >= elementCount) | 1168 if (index >= elementCount) |
| 1180 return v8::Local<v8::Object>(); | 1169 return v8::Local<v8::Object>(); |
| 1181 | 1170 |
| 1182 return factory_->GetOrCreate(elements[index]); | 1171 return factory_->GetOrCreate(elements[index]); |
| 1183 } | 1172 } |
| 1184 | 1173 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 for (int i = 1; i < len; i++) { | 1212 for (int i = 1; i < len; i++) { |
| 1224 blink::WebRect next = BoundsForCharacter(accessibility_object_, start + i); | 1213 blink::WebRect next = BoundsForCharacter(accessibility_object_, start + i); |
| 1225 int right = std::max(bounds.x + bounds.width, next.x + next.width); | 1214 int right = std::max(bounds.x + bounds.width, next.x + next.width); |
| 1226 int bottom = std::max(bounds.y + bounds.height, next.y + next.height); | 1215 int bottom = std::max(bounds.y + bounds.height, next.y + next.height); |
| 1227 bounds.x = std::min(bounds.x, next.x); | 1216 bounds.x = std::min(bounds.x, next.x); |
| 1228 bounds.y = std::min(bounds.y, next.y); | 1217 bounds.y = std::min(bounds.y, next.y); |
| 1229 bounds.width = right - bounds.x; | 1218 bounds.width = right - bounds.x; |
| 1230 bounds.height = bottom - bounds.y; | 1219 bounds.height = bottom - bounds.y; |
| 1231 } | 1220 } |
| 1232 | 1221 |
| 1233 return base::StringPrintf("{x: %d, y: %d, width: %d, height: %d}", | 1222 return base::StringPrintf("{x: %d, y: %d, width: %d, height: %d}", bounds.x, |
| 1234 bounds.x, bounds.y, bounds.width, bounds.height); | 1223 bounds.y, bounds.width, bounds.height); |
| 1235 } | 1224 } |
| 1236 | 1225 |
| 1237 v8::Local<v8::Object> WebAXObjectProxy::ChildAtIndex(int index) { | 1226 v8::Local<v8::Object> WebAXObjectProxy::ChildAtIndex(int index) { |
| 1238 accessibility_object_.updateLayoutAndCheckValidity(); | 1227 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1239 return GetChildAtIndex(index); | 1228 return GetChildAtIndex(index); |
| 1240 } | 1229 } |
| 1241 | 1230 |
| 1242 v8::Local<v8::Object> WebAXObjectProxy::ElementAtPoint(int x, int y) { | 1231 v8::Local<v8::Object> WebAXObjectProxy::ElementAtPoint(int x, int y) { |
| 1243 accessibility_object_.updateLayoutAndCheckValidity(); | 1232 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1244 blink::WebPoint point(x, y); | 1233 blink::WebPoint point(x, y); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 return base::StringPrintf("{%d, %d}", row_index, row_span); | 1276 return base::StringPrintf("{%d, %d}", row_index, row_span); |
| 1288 } | 1277 } |
| 1289 | 1278 |
| 1290 std::string WebAXObjectProxy::ColumnIndexRange() { | 1279 std::string WebAXObjectProxy::ColumnIndexRange() { |
| 1291 accessibility_object_.updateLayoutAndCheckValidity(); | 1280 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1292 unsigned column_index = accessibility_object_.cellColumnIndex(); | 1281 unsigned column_index = accessibility_object_.cellColumnIndex(); |
| 1293 unsigned column_span = accessibility_object_.cellColumnSpan(); | 1282 unsigned column_span = accessibility_object_.cellColumnSpan(); |
| 1294 return base::StringPrintf("{%d, %d}", column_index, column_span); | 1283 return base::StringPrintf("{%d, %d}", column_index, column_span); |
| 1295 } | 1284 } |
| 1296 | 1285 |
| 1297 v8::Local<v8::Object> WebAXObjectProxy::CellForColumnAndRow( | 1286 v8::Local<v8::Object> WebAXObjectProxy::CellForColumnAndRow(int column, |
| 1298 int column, int row) { | 1287 int row) { |
| 1299 accessibility_object_.updateLayoutAndCheckValidity(); | 1288 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1300 blink::WebAXObject obj = | 1289 blink::WebAXObject obj = |
| 1301 accessibility_object_.cellForColumnAndRow(column, row); | 1290 accessibility_object_.cellForColumnAndRow(column, row); |
| 1302 if (obj.isNull()) | 1291 if (obj.isNull()) |
| 1303 return v8::Local<v8::Object>(); | 1292 return v8::Local<v8::Object>(); |
| 1304 | 1293 |
| 1305 return factory_->GetOrCreate(obj); | 1294 return factory_->GetOrCreate(obj); |
| 1306 } | 1295 } |
| 1307 | 1296 |
| 1308 void WebAXObjectProxy::SetSelectedTextRange(int selection_start, | 1297 void WebAXObjectProxy::SetSelectedTextRange(int selection_start, int length) { |
| 1309 int length) { | |
| 1310 accessibility_object_.updateLayoutAndCheckValidity(); | 1298 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1311 accessibility_object_.setSelectedTextRange(selection_start, | 1299 accessibility_object_.setSelectedTextRange(selection_start, |
| 1312 selection_start + length); | 1300 selection_start + length); |
| 1313 } | 1301 } |
| 1314 | 1302 |
| 1315 void WebAXObjectProxy::SetSelection( | 1303 void WebAXObjectProxy::SetSelection(v8::Local<v8::Value> anchor_object, |
| 1316 v8::Local<v8::Value> anchor_object, int anchor_offset, | 1304 int anchor_offset, |
| 1317 v8::Local<v8::Value> focus_object, int focus_offset) { | 1305 v8::Local<v8::Value> focus_object, |
| 1306 int focus_offset) { |
| 1318 if (anchor_object.IsEmpty() || focus_object.IsEmpty() || | 1307 if (anchor_object.IsEmpty() || focus_object.IsEmpty() || |
| 1319 !anchor_object->IsObject() || !focus_object->IsObject() || | 1308 !anchor_object->IsObject() || !focus_object->IsObject() || |
| 1320 anchor_offset < 0 || focus_offset < 0) { | 1309 anchor_offset < 0 || focus_offset < 0) { |
| 1321 return; | 1310 return; |
| 1322 } | 1311 } |
| 1323 | 1312 |
| 1324 WebAXObjectProxy* web_ax_anchor = nullptr; | 1313 WebAXObjectProxy* web_ax_anchor = nullptr; |
| 1325 if (!gin::ConvertFromV8( | 1314 if (!gin::ConvertFromV8(blink::mainThreadIsolate(), anchor_object, |
| 1326 blink::mainThreadIsolate(), anchor_object, &web_ax_anchor)) { | 1315 &web_ax_anchor)) { |
| 1327 return; | 1316 return; |
| 1328 } | 1317 } |
| 1329 DCHECK(web_ax_anchor); | 1318 DCHECK(web_ax_anchor); |
| 1330 | 1319 |
| 1331 WebAXObjectProxy* web_ax_focus = nullptr; | 1320 WebAXObjectProxy* web_ax_focus = nullptr; |
| 1332 if (!gin::ConvertFromV8( | 1321 if (!gin::ConvertFromV8(blink::mainThreadIsolate(), focus_object, |
| 1333 blink::mainThreadIsolate(), focus_object, &web_ax_focus)) { | 1322 &web_ax_focus)) { |
| 1334 return; | 1323 return; |
| 1335 } | 1324 } |
| 1336 DCHECK(web_ax_focus); | 1325 DCHECK(web_ax_focus); |
| 1337 | 1326 |
| 1338 accessibility_object_.updateLayoutAndCheckValidity(); | 1327 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1339 accessibility_object_.setSelection( | 1328 accessibility_object_.setSelection( |
| 1340 web_ax_anchor->accessibility_object_, anchor_offset, | 1329 web_ax_anchor->accessibility_object_, anchor_offset, |
| 1341 web_ax_focus->accessibility_object_, focus_offset); | 1330 web_ax_focus->accessibility_object_, focus_offset); |
| 1342 } | 1331 } |
| 1343 | 1332 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 void WebAXObjectProxy::TakeFocus() { | 1409 void WebAXObjectProxy::TakeFocus() { |
| 1421 accessibility_object_.updateLayoutAndCheckValidity(); | 1410 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1422 accessibility_object_.setFocused(true); | 1411 accessibility_object_.setFocused(true); |
| 1423 } | 1412 } |
| 1424 | 1413 |
| 1425 void WebAXObjectProxy::ScrollToMakeVisible() { | 1414 void WebAXObjectProxy::ScrollToMakeVisible() { |
| 1426 accessibility_object_.updateLayoutAndCheckValidity(); | 1415 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1427 accessibility_object_.scrollToMakeVisible(); | 1416 accessibility_object_.scrollToMakeVisible(); |
| 1428 } | 1417 } |
| 1429 | 1418 |
| 1430 void WebAXObjectProxy::ScrollToMakeVisibleWithSubFocus(int x, int y, | 1419 void WebAXObjectProxy::ScrollToMakeVisibleWithSubFocus(int x, |
| 1431 int width, int height) { | 1420 int y, |
| 1421 int width, |
| 1422 int height) { |
| 1432 accessibility_object_.updateLayoutAndCheckValidity(); | 1423 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1433 accessibility_object_.scrollToMakeVisibleWithSubFocus( | 1424 accessibility_object_.scrollToMakeVisibleWithSubFocus( |
| 1434 blink::WebRect(x, y, width, height)); | 1425 blink::WebRect(x, y, width, height)); |
| 1435 } | 1426 } |
| 1436 | 1427 |
| 1437 void WebAXObjectProxy::ScrollToGlobalPoint(int x, int y) { | 1428 void WebAXObjectProxy::ScrollToGlobalPoint(int x, int y) { |
| 1438 accessibility_object_.updateLayoutAndCheckValidity(); | 1429 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1439 accessibility_object_.scrollToGlobalPoint(blink::WebPoint(x, y)); | 1430 accessibility_object_.scrollToGlobalPoint(blink::WebPoint(x, y)); |
| 1440 } | 1431 } |
| 1441 | 1432 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1468 accessibility_object_.updateLayoutAndCheckValidity(); | 1459 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1469 return BoundsForObject(accessibility_object_).height; | 1460 return BoundsForObject(accessibility_object_).height; |
| 1470 } | 1461 } |
| 1471 | 1462 |
| 1472 int WebAXObjectProxy::WordStart(int character_index) { | 1463 int WebAXObjectProxy::WordStart(int character_index) { |
| 1473 accessibility_object_.updateLayoutAndCheckValidity(); | 1464 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1474 if (accessibility_object_.role() != blink::WebAXRoleStaticText) | 1465 if (accessibility_object_.role() != blink::WebAXRoleStaticText) |
| 1475 return -1; | 1466 return -1; |
| 1476 | 1467 |
| 1477 int word_start = 0, word_end = 0; | 1468 int word_start = 0, word_end = 0; |
| 1478 GetBoundariesForOneWord(accessibility_object_, character_index, | 1469 GetBoundariesForOneWord(accessibility_object_, character_index, word_start, |
| 1479 word_start, word_end); | 1470 word_end); |
| 1480 return word_start; | 1471 return word_start; |
| 1481 } | 1472 } |
| 1482 | 1473 |
| 1483 int WebAXObjectProxy::WordEnd(int character_index) { | 1474 int WebAXObjectProxy::WordEnd(int character_index) { |
| 1484 accessibility_object_.updateLayoutAndCheckValidity(); | 1475 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1485 if (accessibility_object_.role() != blink::WebAXRoleStaticText) | 1476 if (accessibility_object_.role() != blink::WebAXRoleStaticText) |
| 1486 return -1; | 1477 return -1; |
| 1487 | 1478 |
| 1488 int word_start = 0, word_end = 0; | 1479 int word_start = 0, word_end = 0; |
| 1489 GetBoundariesForOneWord(accessibility_object_, character_index, | 1480 GetBoundariesForOneWord(accessibility_object_, character_index, word_start, |
| 1490 word_start, word_end); | 1481 word_end); |
| 1491 return word_end; | 1482 return word_end; |
| 1492 } | 1483 } |
| 1493 | 1484 |
| 1494 v8::Local<v8::Object> WebAXObjectProxy::NextOnLine() { | 1485 v8::Local<v8::Object> WebAXObjectProxy::NextOnLine() { |
| 1495 accessibility_object_.updateLayoutAndCheckValidity(); | 1486 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1496 blink::WebAXObject obj = accessibility_object_.nextOnLine(); | 1487 blink::WebAXObject obj = accessibility_object_.nextOnLine(); |
| 1497 if (obj.isNull()) | 1488 if (obj.isNull()) |
| 1498 return v8::Local<v8::Object>(); | 1489 return v8::Local<v8::Object>(); |
| 1499 | 1490 |
| 1500 return factory_->GetOrCreate(obj); | 1491 return factory_->GetOrCreate(obj); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1519 std::string WebAXObjectProxy::Name() { | 1510 std::string WebAXObjectProxy::Name() { |
| 1520 accessibility_object_.updateLayoutAndCheckValidity(); | 1511 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1521 return accessibility_object_.name().utf8(); | 1512 return accessibility_object_.name().utf8(); |
| 1522 } | 1513 } |
| 1523 | 1514 |
| 1524 std::string WebAXObjectProxy::NameFrom() { | 1515 std::string WebAXObjectProxy::NameFrom() { |
| 1525 accessibility_object_.updateLayoutAndCheckValidity(); | 1516 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1526 blink::WebAXNameFrom nameFrom = blink::WebAXNameFromUninitialized; | 1517 blink::WebAXNameFrom nameFrom = blink::WebAXNameFromUninitialized; |
| 1527 blink::WebVector<blink::WebAXObject> nameObjects; | 1518 blink::WebVector<blink::WebAXObject> nameObjects; |
| 1528 accessibility_object_.name(nameFrom, nameObjects); | 1519 accessibility_object_.name(nameFrom, nameObjects); |
| 1529 switch(nameFrom) { | 1520 switch (nameFrom) { |
| 1530 case blink::WebAXNameFromUninitialized: | 1521 case blink::WebAXNameFromUninitialized: |
| 1531 return ""; | 1522 return ""; |
| 1532 case blink::WebAXNameFromAttribute: | 1523 case blink::WebAXNameFromAttribute: |
| 1533 return "attribute"; | 1524 return "attribute"; |
| 1534 case blink::WebAXNameFromCaption: | 1525 case blink::WebAXNameFromCaption: |
| 1535 return "caption"; | 1526 return "caption"; |
| 1536 case blink::WebAXNameFromContents: | 1527 case blink::WebAXNameFromContents: |
| 1537 return "contents"; | 1528 return "contents"; |
| 1538 case blink::WebAXNameFromPlaceholder: | 1529 case blink::WebAXNameFromPlaceholder: |
| 1539 return "placeholder"; | 1530 return "placeholder"; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1567 return factory_->GetOrCreate(nameObjects[index]); | 1558 return factory_->GetOrCreate(nameObjects[index]); |
| 1568 } | 1559 } |
| 1569 | 1560 |
| 1570 std::string WebAXObjectProxy::Description() { | 1561 std::string WebAXObjectProxy::Description() { |
| 1571 accessibility_object_.updateLayoutAndCheckValidity(); | 1562 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1572 blink::WebAXNameFrom nameFrom; | 1563 blink::WebAXNameFrom nameFrom; |
| 1573 blink::WebVector<blink::WebAXObject> nameObjects; | 1564 blink::WebVector<blink::WebAXObject> nameObjects; |
| 1574 accessibility_object_.name(nameFrom, nameObjects); | 1565 accessibility_object_.name(nameFrom, nameObjects); |
| 1575 blink::WebAXDescriptionFrom descriptionFrom; | 1566 blink::WebAXDescriptionFrom descriptionFrom; |
| 1576 blink::WebVector<blink::WebAXObject> descriptionObjects; | 1567 blink::WebVector<blink::WebAXObject> descriptionObjects; |
| 1577 return accessibility_object_.description( | 1568 return accessibility_object_ |
| 1578 nameFrom, descriptionFrom, descriptionObjects).utf8(); | 1569 .description(nameFrom, descriptionFrom, descriptionObjects) |
| 1570 .utf8(); |
| 1579 } | 1571 } |
| 1580 | 1572 |
| 1581 std::string WebAXObjectProxy::DescriptionFrom() { | 1573 std::string WebAXObjectProxy::DescriptionFrom() { |
| 1582 accessibility_object_.updateLayoutAndCheckValidity(); | 1574 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1583 blink::WebAXNameFrom nameFrom; | 1575 blink::WebAXNameFrom nameFrom; |
| 1584 blink::WebVector<blink::WebAXObject> nameObjects; | 1576 blink::WebVector<blink::WebAXObject> nameObjects; |
| 1585 accessibility_object_.name(nameFrom, nameObjects); | 1577 accessibility_object_.name(nameFrom, nameObjects); |
| 1586 blink::WebAXDescriptionFrom descriptionFrom = | 1578 blink::WebAXDescriptionFrom descriptionFrom = |
| 1587 blink::WebAXDescriptionFromUninitialized; | 1579 blink::WebAXDescriptionFromUninitialized; |
| 1588 blink::WebVector<blink::WebAXObject> descriptionObjects; | 1580 blink::WebVector<blink::WebAXObject> descriptionObjects; |
| 1589 accessibility_object_.description( | 1581 accessibility_object_.description(nameFrom, descriptionFrom, |
| 1590 nameFrom, descriptionFrom, descriptionObjects); | 1582 descriptionObjects); |
| 1591 switch(descriptionFrom) { | 1583 switch (descriptionFrom) { |
| 1592 case blink::WebAXDescriptionFromUninitialized: | 1584 case blink::WebAXDescriptionFromUninitialized: |
| 1593 return ""; | 1585 return ""; |
| 1594 case blink::WebAXDescriptionFromAttribute: | 1586 case blink::WebAXDescriptionFromAttribute: |
| 1595 return "attribute"; | 1587 return "attribute"; |
| 1596 case blink::WebAXDescriptionFromContents: | 1588 case blink::WebAXDescriptionFromContents: |
| 1597 return "contents"; | 1589 return "contents"; |
| 1598 case blink::WebAXDescriptionFromRelatedElement: | 1590 case blink::WebAXDescriptionFromRelatedElement: |
| 1599 return "relatedElement"; | 1591 return "relatedElement"; |
| 1600 } | 1592 } |
| 1601 | 1593 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1616 return GetMisspellings(accessibility_object_).size(); | 1608 return GetMisspellings(accessibility_object_).size(); |
| 1617 } | 1609 } |
| 1618 | 1610 |
| 1619 int WebAXObjectProxy::DescriptionElementCount() { | 1611 int WebAXObjectProxy::DescriptionElementCount() { |
| 1620 accessibility_object_.updateLayoutAndCheckValidity(); | 1612 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1621 blink::WebAXNameFrom nameFrom; | 1613 blink::WebAXNameFrom nameFrom; |
| 1622 blink::WebVector<blink::WebAXObject> nameObjects; | 1614 blink::WebVector<blink::WebAXObject> nameObjects; |
| 1623 accessibility_object_.name(nameFrom, nameObjects); | 1615 accessibility_object_.name(nameFrom, nameObjects); |
| 1624 blink::WebAXDescriptionFrom descriptionFrom; | 1616 blink::WebAXDescriptionFrom descriptionFrom; |
| 1625 blink::WebVector<blink::WebAXObject> descriptionObjects; | 1617 blink::WebVector<blink::WebAXObject> descriptionObjects; |
| 1626 accessibility_object_.description( | 1618 accessibility_object_.description(nameFrom, descriptionFrom, |
| 1627 nameFrom, descriptionFrom, descriptionObjects); | 1619 descriptionObjects); |
| 1628 return static_cast<int>(descriptionObjects.size()); | 1620 return static_cast<int>(descriptionObjects.size()); |
| 1629 } | 1621 } |
| 1630 | 1622 |
| 1631 v8::Local<v8::Object> WebAXObjectProxy::DescriptionElementAtIndex( | 1623 v8::Local<v8::Object> WebAXObjectProxy::DescriptionElementAtIndex( |
| 1632 unsigned index) { | 1624 unsigned index) { |
| 1633 accessibility_object_.updateLayoutAndCheckValidity(); | 1625 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1634 blink::WebAXNameFrom nameFrom; | 1626 blink::WebAXNameFrom nameFrom; |
| 1635 blink::WebVector<blink::WebAXObject> nameObjects; | 1627 blink::WebVector<blink::WebAXObject> nameObjects; |
| 1636 accessibility_object_.name(nameFrom, nameObjects); | 1628 accessibility_object_.name(nameFrom, nameObjects); |
| 1637 blink::WebAXDescriptionFrom descriptionFrom; | 1629 blink::WebAXDescriptionFrom descriptionFrom; |
| 1638 blink::WebVector<blink::WebAXObject> descriptionObjects; | 1630 blink::WebVector<blink::WebAXObject> descriptionObjects; |
| 1639 accessibility_object_.description( | 1631 accessibility_object_.description(nameFrom, descriptionFrom, |
| 1640 nameFrom, descriptionFrom, descriptionObjects); | 1632 descriptionObjects); |
| 1641 if (index >= descriptionObjects.size()) | 1633 if (index >= descriptionObjects.size()) |
| 1642 return v8::Local<v8::Object>(); | 1634 return v8::Local<v8::Object>(); |
| 1643 return factory_->GetOrCreate(descriptionObjects[index]); | 1635 return factory_->GetOrCreate(descriptionObjects[index]); |
| 1644 } | 1636 } |
| 1645 | 1637 |
| 1646 v8::Local<v8::Object> WebAXObjectProxy::OffsetContainer() { | 1638 v8::Local<v8::Object> WebAXObjectProxy::OffsetContainer() { |
| 1647 accessibility_object_.updateLayoutAndCheckValidity(); | 1639 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1648 blink::WebAXObject container; | 1640 blink::WebAXObject container; |
| 1649 blink::WebFloatRect bounds; | 1641 blink::WebFloatRect bounds; |
| 1650 SkMatrix44 matrix; | 1642 SkMatrix44 matrix; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1691 bool WebAXObjectProxy::HasNonIdentityTransform() { | 1683 bool WebAXObjectProxy::HasNonIdentityTransform() { |
| 1692 accessibility_object_.updateLayoutAndCheckValidity(); | 1684 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1693 accessibility_object_.updateLayoutAndCheckValidity(); | 1685 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1694 blink::WebAXObject container; | 1686 blink::WebAXObject container; |
| 1695 blink::WebFloatRect bounds; | 1687 blink::WebFloatRect bounds; |
| 1696 SkMatrix44 matrix; | 1688 SkMatrix44 matrix; |
| 1697 accessibility_object_.getRelativeBounds(container, bounds, matrix); | 1689 accessibility_object_.getRelativeBounds(container, bounds, matrix); |
| 1698 return !matrix.isIdentity(); | 1690 return !matrix.isIdentity(); |
| 1699 } | 1691 } |
| 1700 | 1692 |
| 1701 RootWebAXObjectProxy::RootWebAXObjectProxy( | 1693 RootWebAXObjectProxy::RootWebAXObjectProxy(const blink::WebAXObject& object, |
| 1702 const blink::WebAXObject &object, Factory *factory) | 1694 Factory* factory) |
| 1703 : WebAXObjectProxy(object, factory) { | 1695 : WebAXObjectProxy(object, factory) {} |
| 1704 } | |
| 1705 | 1696 |
| 1706 v8::Local<v8::Object> RootWebAXObjectProxy::GetChildAtIndex(unsigned index) { | 1697 v8::Local<v8::Object> RootWebAXObjectProxy::GetChildAtIndex(unsigned index) { |
| 1707 if (index) | 1698 if (index) |
| 1708 return v8::Local<v8::Object>(); | 1699 return v8::Local<v8::Object>(); |
| 1709 | 1700 |
| 1710 return factory()->GetOrCreate(accessibility_object()); | 1701 return factory()->GetOrCreate(accessibility_object()); |
| 1711 } | 1702 } |
| 1712 | 1703 |
| 1713 bool RootWebAXObjectProxy::IsRoot() const { | 1704 bool RootWebAXObjectProxy::IsRoot() const { |
| 1714 return true; | 1705 return true; |
| 1715 } | 1706 } |
| 1716 | 1707 |
| 1717 WebAXObjectProxyList::WebAXObjectProxyList() | 1708 WebAXObjectProxyList::WebAXObjectProxyList() |
| 1718 : elements_(blink::mainThreadIsolate()) { | 1709 : elements_(blink::mainThreadIsolate()) {} |
| 1719 } | |
| 1720 | 1710 |
| 1721 WebAXObjectProxyList::~WebAXObjectProxyList() { | 1711 WebAXObjectProxyList::~WebAXObjectProxyList() { |
| 1722 Clear(); | 1712 Clear(); |
| 1723 } | 1713 } |
| 1724 | 1714 |
| 1725 void WebAXObjectProxyList::Clear() { | 1715 void WebAXObjectProxyList::Clear() { |
| 1726 v8::Isolate* isolate = blink::mainThreadIsolate(); | 1716 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 1727 v8::HandleScope handle_scope(isolate); | 1717 v8::HandleScope handle_scope(isolate); |
| 1728 size_t elementCount = elements_.Size(); | 1718 size_t elementCount = elements_.Size(); |
| 1729 for (size_t i = 0; i < elementCount; i++) { | 1719 for (size_t i = 0; i < elementCount; i++) { |
| 1730 WebAXObjectProxy* unwrapped_object = NULL; | 1720 WebAXObjectProxy* unwrapped_object = NULL; |
| 1731 bool result = gin::ConvertFromV8(isolate, elements_.Get(i), | 1721 bool result = |
| 1732 &unwrapped_object); | 1722 gin::ConvertFromV8(isolate, elements_.Get(i), &unwrapped_object); |
| 1733 DCHECK(result); | 1723 DCHECK(result); |
| 1734 DCHECK(unwrapped_object); | 1724 DCHECK(unwrapped_object); |
| 1735 unwrapped_object->Reset(); | 1725 unwrapped_object->Reset(); |
| 1736 } | 1726 } |
| 1737 elements_.Clear(); | 1727 elements_.Clear(); |
| 1738 } | 1728 } |
| 1739 | 1729 |
| 1740 v8::Local<v8::Object> WebAXObjectProxyList::GetOrCreate( | 1730 v8::Local<v8::Object> WebAXObjectProxyList::GetOrCreate( |
| 1741 const blink::WebAXObject& object) { | 1731 const blink::WebAXObject& object) { |
| 1742 if (object.isNull()) | 1732 if (object.isNull()) |
| 1743 return v8::Local<v8::Object>(); | 1733 return v8::Local<v8::Object>(); |
| 1744 | 1734 |
| 1745 v8::Isolate* isolate = blink::mainThreadIsolate(); | 1735 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 1746 | 1736 |
| 1747 size_t elementCount = elements_.Size(); | 1737 size_t elementCount = elements_.Size(); |
| 1748 for (size_t i = 0; i < elementCount; i++) { | 1738 for (size_t i = 0; i < elementCount; i++) { |
| 1749 WebAXObjectProxy* unwrapped_object = NULL; | 1739 WebAXObjectProxy* unwrapped_object = NULL; |
| 1750 bool result = gin::ConvertFromV8(isolate, elements_.Get(i), | 1740 bool result = |
| 1751 &unwrapped_object); | 1741 gin::ConvertFromV8(isolate, elements_.Get(i), &unwrapped_object); |
| 1752 DCHECK(result); | 1742 DCHECK(result); |
| 1753 DCHECK(unwrapped_object); | 1743 DCHECK(unwrapped_object); |
| 1754 if (unwrapped_object->IsEqualToObject(object)) | 1744 if (unwrapped_object->IsEqualToObject(object)) |
| 1755 return elements_.Get(i); | 1745 return elements_.Get(i); |
| 1756 } | 1746 } |
| 1757 | 1747 |
| 1758 v8::Local<v8::Value> value_handle = gin::CreateHandle( | 1748 v8::Local<v8::Value> value_handle = |
| 1759 isolate, new WebAXObjectProxy(object, this)).ToV8(); | 1749 gin::CreateHandle(isolate, new WebAXObjectProxy(object, this)).ToV8(); |
| 1760 if (value_handle.IsEmpty()) | 1750 if (value_handle.IsEmpty()) |
| 1761 return v8::Local<v8::Object>(); | 1751 return v8::Local<v8::Object>(); |
| 1762 v8::Local<v8::Object> handle = value_handle->ToObject(isolate); | 1752 v8::Local<v8::Object> handle = value_handle->ToObject(isolate); |
| 1763 elements_.Append(handle); | 1753 elements_.Append(handle); |
| 1764 return handle; | 1754 return handle; |
| 1765 } | 1755 } |
| 1766 | 1756 |
| 1767 } // namespace test_runner | 1757 } // namespace test_runner |
| OLD | NEW |