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

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

Issue 1435113003: Make use of new AX name calc in Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix issue with ariaTextAlternative Created 5 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 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 "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "gin/handle.h" 8 #include "gin/handle.h"
9 #include "third_party/WebKit/public/platform/WebPoint.h" 9 #include "third_party/WebKit/public/platform/WebPoint.h"
10 #include "third_party/WebKit/public/platform/WebRect.h" 10 #include "third_party/WebKit/public/platform/WebRect.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 std::string value_description = object.valueDescription().utf8(); 292 std::string value_description = object.valueDescription().utf8();
293 return value_description.insert(0, "AXValueDescription: "); 293 return value_description.insert(0, "AXValueDescription: ");
294 } 294 }
295 295
296 std::string GetLanguage(const blink::WebAXObject& object) { 296 std::string GetLanguage(const blink::WebAXObject& object) {
297 std::string language = object.language().utf8(); 297 std::string language = object.language().utf8();
298 return language.insert(0, "AXLanguage: "); 298 return language.insert(0, "AXLanguage: ");
299 } 299 }
300 300
301 std::string GetAttributes(const blink::WebAXObject& object) { 301 std::string GetAttributes(const blink::WebAXObject& object) {
302 blink::WebAXNameFrom nameFrom; 302 std::string attributes(object.name().utf8());
303 blink::WebVector<blink::WebAXObject> nameObjects;
304 std::string attributes(object.name(nameFrom, nameObjects).utf8());
305 attributes.append("\n"); 303 attributes.append("\n");
306 attributes.append(GetRole(object)); 304 attributes.append(GetRole(object));
307 return attributes; 305 return attributes;
308 } 306 }
309 307
310 blink::WebRect BoundsForCharacter(const blink::WebAXObject& object, 308 blink::WebRect BoundsForCharacter(const blink::WebAXObject& object,
311 int characterIndex) { 309 int characterIndex) {
312 DCHECK_EQ(object.role(), blink::WebAXRoleStaticText); 310 DCHECK_EQ(object.role(), blink::WebAXRoleStaticText);
313 int end = 0; 311 int end = 0;
314 for (unsigned i = 0; i < object.childCount(); i++) { 312 for (unsigned i = 0; i < object.childCount(); i++) {
315 blink::WebAXObject inline_text_box = object.childAt(i); 313 blink::WebAXObject inline_text_box = object.childAt(i);
316 DCHECK_EQ(inline_text_box.role(), blink::WebAXRoleInlineTextBox); 314 DCHECK_EQ(inline_text_box.role(), blink::WebAXRoleInlineTextBox);
317 int start = end; 315 int start = end;
318 end += inline_text_box.stringValue().length(); 316 blink::WebString name = inline_text_box.name();
317 end += name.length();
319 if (characterIndex < start || characterIndex >= end) 318 if (characterIndex < start || characterIndex >= end)
320 continue; 319 continue;
321 blink::WebRect inline_text_box_rect = inline_text_box.boundingBoxRect(); 320 blink::WebRect inline_text_box_rect = inline_text_box.boundingBoxRect();
322 int localIndex = characterIndex - start; 321 int localIndex = characterIndex - start;
323 blink::WebVector<int> character_offsets; 322 blink::WebVector<int> character_offsets;
324 inline_text_box.characterOffsets(character_offsets); 323 inline_text_box.characterOffsets(character_offsets);
325 DCHECK(character_offsets.size() > 0 && 324 DCHECK(character_offsets.size() > 0 &&
326 character_offsets.size() == inline_text_box.stringValue().length()); 325 character_offsets.size() == name.length());
327 switch (inline_text_box.textDirection()) { 326 switch (inline_text_box.textDirection()) {
328 case blink::WebAXTextDirectionLR: { 327 case blink::WebAXTextDirectionLR: {
329 if (localIndex) { 328 if (localIndex) {
330 int left = inline_text_box_rect.x + character_offsets[localIndex - 1]; 329 int left = inline_text_box_rect.x + character_offsets[localIndex - 1];
331 int width = character_offsets[localIndex] - 330 int width = character_offsets[localIndex] -
332 character_offsets[localIndex - 1]; 331 character_offsets[localIndex - 1];
333 return blink::WebRect(left, inline_text_box_rect.y, 332 return blink::WebRect(left, inline_text_box_rect.y,
334 width, inline_text_box_rect.height); 333 width, inline_text_box_rect.height);
335 } 334 }
336 return blink::WebRect( 335 return blink::WebRect(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 385
387 void GetBoundariesForOneWord(const blink::WebAXObject& object, 386 void GetBoundariesForOneWord(const blink::WebAXObject& object,
388 int character_index, 387 int character_index,
389 int& word_start, 388 int& word_start,
390 int& word_end) { 389 int& word_end) {
391 int end = 0; 390 int end = 0;
392 for (unsigned i = 0; i < object.childCount(); i++) { 391 for (unsigned i = 0; i < object.childCount(); i++) {
393 blink::WebAXObject inline_text_box = object.childAt(i); 392 blink::WebAXObject inline_text_box = object.childAt(i);
394 DCHECK_EQ(inline_text_box.role(), blink::WebAXRoleInlineTextBox); 393 DCHECK_EQ(inline_text_box.role(), blink::WebAXRoleInlineTextBox);
395 int start = end; 394 int start = end;
396 end += inline_text_box.stringValue().length(); 395 blink::WebString name = inline_text_box.name();
396 end += name.length();
397 if (end <= character_index) 397 if (end <= character_index)
398 continue; 398 continue;
399 int localIndex = character_index - start; 399 int localIndex = character_index - start;
400 400
401 blink::WebVector<int> starts; 401 blink::WebVector<int> starts;
402 blink::WebVector<int> ends; 402 blink::WebVector<int> ends;
403 inline_text_box.wordBoundaries(starts, ends); 403 inline_text_box.wordBoundaries(starts, ends);
404 size_t word_count = starts.size(); 404 size_t word_count = starts.size();
405 DCHECK_EQ(ends.size(), word_count); 405 DCHECK_EQ(ends.size(), word_count);
406 406
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 accessibility_object_.updateLayoutAndCheckValidity(); 1292 accessibility_object_.updateLayoutAndCheckValidity();
1293 blink::WebAXObject obj = accessibility_object_.previousOnLine(); 1293 blink::WebAXObject obj = accessibility_object_.previousOnLine();
1294 if (obj.isNull()) 1294 if (obj.isNull())
1295 return v8::Local<v8::Object>(); 1295 return v8::Local<v8::Object>();
1296 1296
1297 return factory_->GetOrCreate(obj); 1297 return factory_->GetOrCreate(obj);
1298 } 1298 }
1299 1299
1300 std::string WebAXObjectProxy::Name() { 1300 std::string WebAXObjectProxy::Name() {
1301 accessibility_object_.updateLayoutAndCheckValidity(); 1301 accessibility_object_.updateLayoutAndCheckValidity();
1302 blink::WebAXNameFrom nameFrom; 1302 return accessibility_object_.name().utf8();
1303 blink::WebVector<blink::WebAXObject> nameObjects;
1304 return accessibility_object_.name(nameFrom, nameObjects).utf8();
1305 } 1303 }
1306 1304
1307 std::string WebAXObjectProxy::NameFrom() { 1305 std::string WebAXObjectProxy::NameFrom() {
1308 accessibility_object_.updateLayoutAndCheckValidity(); 1306 accessibility_object_.updateLayoutAndCheckValidity();
1309 blink::WebAXNameFrom nameFrom = blink::WebAXNameFromUninitialized; 1307 blink::WebAXNameFrom nameFrom = blink::WebAXNameFromUninitialized;
1310 blink::WebVector<blink::WebAXObject> nameObjects; 1308 blink::WebVector<blink::WebAXObject> nameObjects;
1311 accessibility_object_.name(nameFrom, nameObjects); 1309 accessibility_object_.name(nameFrom, nameObjects);
1312 switch(nameFrom) { 1310 switch(nameFrom) {
1313 case blink::WebAXNameFromUninitialized: 1311 case blink::WebAXNameFromUninitialized:
1314 return ""; 1312 return "";
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 v8::Local<v8::Value> value_handle = gin::CreateHandle( 1473 v8::Local<v8::Value> value_handle = gin::CreateHandle(
1476 isolate, new WebAXObjectProxy(object, this)).ToV8(); 1474 isolate, new WebAXObjectProxy(object, this)).ToV8();
1477 if (value_handle.IsEmpty()) 1475 if (value_handle.IsEmpty())
1478 return v8::Local<v8::Object>(); 1476 return v8::Local<v8::Object>();
1479 v8::Local<v8::Object> handle = value_handle->ToObject(isolate); 1477 v8::Local<v8::Object> handle = value_handle->ToObject(isolate);
1480 elements_.Append(handle); 1478 elements_.Append(handle);
1481 return handle; 1479 return handle;
1482 } 1480 }
1483 1481
1484 } // namespace test_runner 1482 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/html_viewer/ax_provider_impl.cc ('k') | content/browser/accessibility/accessibility_tree_formatter_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698