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

Side by Side Diff: components/test_runner/web_ax_object_proxy.cc

Issue 2169273004: Switch all LayoutTests to use new accessibility relative bounding box API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix absolute bounds in AXInlineTextBox::elementRect 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/accessibility/bounds-calc.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/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"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 DCHECK_EQ(object.role(), blink::WebAXRoleStaticText); 344 DCHECK_EQ(object.role(), blink::WebAXRoleStaticText);
345 int end = 0; 345 int end = 0;
346 for (unsigned i = 0; i < object.childCount(); i++) { 346 for (unsigned i = 0; i < object.childCount(); i++) {
347 blink::WebAXObject inline_text_box = object.childAt(i); 347 blink::WebAXObject inline_text_box = object.childAt(i);
348 DCHECK_EQ(inline_text_box.role(), blink::WebAXRoleInlineTextBox); 348 DCHECK_EQ(inline_text_box.role(), blink::WebAXRoleInlineTextBox);
349 int start = end; 349 int start = end;
350 blink::WebString name = inline_text_box.name(); 350 blink::WebString name = inline_text_box.name();
351 end += name.length(); 351 end += name.length();
352 if (characterIndex < start || characterIndex >= end) 352 if (characterIndex < start || characterIndex >= end)
353 continue; 353 continue;
354 blink::WebRect inline_text_box_rect = inline_text_box.boundingBoxRect(); 354
355 blink::WebFloatRect inline_text_box_rect = BoundsForObject(inline_text_box);
356
355 int localIndex = characterIndex - start; 357 int localIndex = characterIndex - start;
356 blink::WebVector<int> character_offsets; 358 blink::WebVector<int> character_offsets;
357 inline_text_box.characterOffsets(character_offsets); 359 inline_text_box.characterOffsets(character_offsets);
358 DCHECK(character_offsets.size() > 0 && 360 DCHECK(character_offsets.size() > 0 &&
359 character_offsets.size() == name.length()); 361 character_offsets.size() == name.length());
360 switch (inline_text_box.textDirection()) { 362 switch (inline_text_box.textDirection()) {
361 case blink::WebAXTextDirectionLR: { 363 case blink::WebAXTextDirectionLR: {
362 if (localIndex) { 364 if (localIndex) {
363 int left = inline_text_box_rect.x + character_offsets[localIndex - 1]; 365 int left = inline_text_box_rect.x + character_offsets[localIndex - 1];
364 int width = character_offsets[localIndex] - 366 int width = character_offsets[localIndex] -
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 return GetStringValue(accessibility_object_); 727 return GetStringValue(accessibility_object_);
726 } 728 }
727 729
728 std::string WebAXObjectProxy::Language() { 730 std::string WebAXObjectProxy::Language() {
729 accessibility_object_.updateLayoutAndCheckValidity(); 731 accessibility_object_.updateLayoutAndCheckValidity();
730 return GetLanguage(accessibility_object_); 732 return GetLanguage(accessibility_object_);
731 } 733 }
732 734
733 int WebAXObjectProxy::X() { 735 int WebAXObjectProxy::X() {
734 accessibility_object_.updateLayoutAndCheckValidity(); 736 accessibility_object_.updateLayoutAndCheckValidity();
735 return accessibility_object_.boundingBoxRect().x; 737 return BoundsForObject(accessibility_object_).x;
736 } 738 }
737 739
738 int WebAXObjectProxy::Y() { 740 int WebAXObjectProxy::Y() {
739 accessibility_object_.updateLayoutAndCheckValidity(); 741 accessibility_object_.updateLayoutAndCheckValidity();
740 return accessibility_object_.boundingBoxRect().y; 742 return BoundsForObject(accessibility_object_).y;
741 } 743 }
742 744
743 int WebAXObjectProxy::Width() { 745 int WebAXObjectProxy::Width() {
744 accessibility_object_.updateLayoutAndCheckValidity(); 746 accessibility_object_.updateLayoutAndCheckValidity();
745 return accessibility_object_.boundingBoxRect().width; 747 return BoundsForObject(accessibility_object_).width;
746 } 748 }
747 749
748 int WebAXObjectProxy::Height() { 750 int WebAXObjectProxy::Height() {
749 accessibility_object_.updateLayoutAndCheckValidity(); 751 accessibility_object_.updateLayoutAndCheckValidity();
750 return accessibility_object_.boundingBoxRect().height; 752 return BoundsForObject(accessibility_object_).height;
751 } 753 }
752 754
753 int WebAXObjectProxy::IntValue() { 755 int WebAXObjectProxy::IntValue() {
754 accessibility_object_.updateLayoutAndCheckValidity(); 756 accessibility_object_.updateLayoutAndCheckValidity();
755 if (accessibility_object_.supportsRangeValue()) 757 if (accessibility_object_.supportsRangeValue())
756 return accessibility_object_.valueForRange(); 758 return accessibility_object_.valueForRange();
757 else if (accessibility_object_.role() == blink::WebAXRoleHeading) 759 else if (accessibility_object_.role() == blink::WebAXRoleHeading)
758 return accessibility_object_.headingLevel(); 760 return accessibility_object_.headingLevel();
759 else 761 else
760 return atoi(accessibility_object_.stringValue().utf8().data()); 762 return atoi(accessibility_object_.stringValue().utf8().data());
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 accessibility_object_.updateLayoutAndCheckValidity(); 1349 accessibility_object_.updateLayoutAndCheckValidity();
1348 return accessibility_object_.scrollOffset().x; 1350 return accessibility_object_.scrollOffset().x;
1349 } 1351 }
1350 1352
1351 int WebAXObjectProxy::ScrollY() { 1353 int WebAXObjectProxy::ScrollY() {
1352 accessibility_object_.updateLayoutAndCheckValidity(); 1354 accessibility_object_.updateLayoutAndCheckValidity();
1353 return accessibility_object_.scrollOffset().y; 1355 return accessibility_object_.scrollOffset().y;
1354 } 1356 }
1355 1357
1356 float WebAXObjectProxy::BoundsX() { 1358 float WebAXObjectProxy::BoundsX() {
1359 accessibility_object_.updateLayoutAndCheckValidity();
1357 return BoundsForObject(accessibility_object_).x; 1360 return BoundsForObject(accessibility_object_).x;
1358 } 1361 }
1359 1362
1360 float WebAXObjectProxy::BoundsY() { 1363 float WebAXObjectProxy::BoundsY() {
1364 accessibility_object_.updateLayoutAndCheckValidity();
1361 return BoundsForObject(accessibility_object_).y; 1365 return BoundsForObject(accessibility_object_).y;
1362 } 1366 }
1363 1367
1364 float WebAXObjectProxy::BoundsWidth() { 1368 float WebAXObjectProxy::BoundsWidth() {
1369 accessibility_object_.updateLayoutAndCheckValidity();
1365 return BoundsForObject(accessibility_object_).width; 1370 return BoundsForObject(accessibility_object_).width;
1366 } 1371 }
1367 1372
1368 float WebAXObjectProxy::BoundsHeight() { 1373 float WebAXObjectProxy::BoundsHeight() {
1374 accessibility_object_.updateLayoutAndCheckValidity();
1369 return BoundsForObject(accessibility_object_).height; 1375 return BoundsForObject(accessibility_object_).height;
1370 } 1376 }
1371 1377
1372 int WebAXObjectProxy::WordStart(int character_index) { 1378 int WebAXObjectProxy::WordStart(int character_index) {
1373 accessibility_object_.updateLayoutAndCheckValidity(); 1379 accessibility_object_.updateLayoutAndCheckValidity();
1374 if (accessibility_object_.role() != blink::WebAXRoleStaticText) 1380 if (accessibility_object_.role() != blink::WebAXRoleStaticText)
1375 return -1; 1381 return -1;
1376 1382
1377 int word_start = 0, word_end = 0; 1383 int word_start = 0, word_end = 0;
1378 GetBoundariesForOneWord(accessibility_object_, character_index, 1384 GetBoundariesForOneWord(accessibility_object_, character_index,
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 v8::Local<v8::Value> value_handle = gin::CreateHandle( 1658 v8::Local<v8::Value> value_handle = gin::CreateHandle(
1653 isolate, new WebAXObjectProxy(object, this)).ToV8(); 1659 isolate, new WebAXObjectProxy(object, this)).ToV8();
1654 if (value_handle.IsEmpty()) 1660 if (value_handle.IsEmpty())
1655 return v8::Local<v8::Object>(); 1661 return v8::Local<v8::Object>();
1656 v8::Local<v8::Object> handle = value_handle->ToObject(isolate); 1662 v8::Local<v8::Object> handle = value_handle->ToObject(isolate);
1657 elements_.Append(handle); 1663 elements_.Append(handle);
1658 return handle; 1664 return handle;
1659 } 1665 }
1660 1666
1661 } // namespace test_runner 1667 } // namespace test_runner
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/accessibility/bounds-calc.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698