| 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 "content/shell/renderer/test_runner/web_ax_object_proxy.h" | 5 #include "content/shell/renderer/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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 261 } |
| 262 | 262 |
| 263 std::string DeprecatedGetHelpText(const blink::WebAXObject& object) { | 263 std::string DeprecatedGetHelpText(const blink::WebAXObject& object) { |
| 264 std::string help_text = object.deprecatedHelpText().utf8(); | 264 std::string help_text = object.deprecatedHelpText().utf8(); |
| 265 return help_text.insert(0, "AXHelp: "); | 265 return help_text.insert(0, "AXHelp: "); |
| 266 } | 266 } |
| 267 | 267 |
| 268 std::string GetStringValue(const blink::WebAXObject& object) { | 268 std::string GetStringValue(const blink::WebAXObject& object) { |
| 269 std::string value; | 269 std::string value; |
| 270 if (object.role() == blink::WebAXRoleColorWell) { | 270 if (object.role() == blink::WebAXRoleColorWell) { |
| 271 int r, g, b; | 271 unsigned int color = object.colorValue(); |
| 272 object.colorValue(r, g, b); | 272 unsigned int red = (color >> 16) & 0xFF; |
| 273 value = base::StringPrintf("rgb %7.5f %7.5f %7.5f 1", | 273 unsigned int green = (color >> 8) & 0xFF; |
| 274 r / 255., g / 255., b / 255.); | 274 unsigned int blue = color & 0xFF; |
| 275 value = base::StringPrintf("rgba(%d, %d, %d, 1)", |
| 276 red, green, blue); |
| 275 } else { | 277 } else { |
| 276 value = object.stringValue().utf8(); | 278 value = object.stringValue().utf8(); |
| 277 } | 279 } |
| 278 return value.insert(0, "AXValue: "); | 280 return value.insert(0, "AXValue: "); |
| 279 } | 281 } |
| 280 | 282 |
| 281 std::string GetRole(const blink::WebAXObject& object) { | 283 std::string GetRole(const blink::WebAXObject& object) { |
| 282 std::string role_string = RoleToString(object.role()); | 284 std::string role_string = RoleToString(object.role()); |
| 283 | 285 |
| 284 // Special-case canvas with fallback content because Chromium wants to treat | 286 // Special-case canvas with fallback content because Chromium wants to treat |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 end += inline_text_box.stringValue().length(); | 330 end += inline_text_box.stringValue().length(); |
| 329 if (characterIndex < start || characterIndex >= end) | 331 if (characterIndex < start || characterIndex >= end) |
| 330 continue; | 332 continue; |
| 331 blink::WebRect inline_text_box_rect = inline_text_box.boundingBoxRect(); | 333 blink::WebRect inline_text_box_rect = inline_text_box.boundingBoxRect(); |
| 332 int localIndex = characterIndex - start; | 334 int localIndex = characterIndex - start; |
| 333 blink::WebVector<int> character_offsets; | 335 blink::WebVector<int> character_offsets; |
| 334 inline_text_box.characterOffsets(character_offsets); | 336 inline_text_box.characterOffsets(character_offsets); |
| 335 DCHECK(character_offsets.size() > 0 && | 337 DCHECK(character_offsets.size() > 0 && |
| 336 character_offsets.size() == inline_text_box.stringValue().length()); | 338 character_offsets.size() == inline_text_box.stringValue().length()); |
| 337 switch (inline_text_box.textDirection()) { | 339 switch (inline_text_box.textDirection()) { |
| 340 case blink::WebAXTextDirectionUnknown: |
| 338 case blink::WebAXTextDirectionLR: { | 341 case blink::WebAXTextDirectionLR: { |
| 339 if (localIndex) { | 342 if (localIndex) { |
| 340 int left = inline_text_box_rect.x + character_offsets[localIndex - 1]; | 343 int left = inline_text_box_rect.x + character_offsets[localIndex - 1]; |
| 341 int width = character_offsets[localIndex] - | 344 int width = character_offsets[localIndex] - |
| 342 character_offsets[localIndex - 1]; | 345 character_offsets[localIndex - 1]; |
| 343 return blink::WebRect(left, inline_text_box_rect.y, | 346 return blink::WebRect(left, inline_text_box_rect.y, |
| 344 width, inline_text_box_rect.height); | 347 width, inline_text_box_rect.height); |
| 345 } | 348 } |
| 346 return blink::WebRect( | 349 return blink::WebRect( |
| 347 inline_text_box_rect.x, inline_text_box_rect.y, | 350 inline_text_box_rect.x, inline_text_box_rect.y, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 .SetProperty("isSelectedOptionActive", | 505 .SetProperty("isSelectedOptionActive", |
| 503 &WebAXObjectProxy::IsSelectedOptionActive) | 506 &WebAXObjectProxy::IsSelectedOptionActive) |
| 504 .SetProperty("isExpanded", &WebAXObjectProxy::IsExpanded) | 507 .SetProperty("isExpanded", &WebAXObjectProxy::IsExpanded) |
| 505 .SetProperty("isChecked", &WebAXObjectProxy::IsChecked) | 508 .SetProperty("isChecked", &WebAXObjectProxy::IsChecked) |
| 506 .SetProperty("isVisible", &WebAXObjectProxy::IsVisible) | 509 .SetProperty("isVisible", &WebAXObjectProxy::IsVisible) |
| 507 .SetProperty("isOffScreen", &WebAXObjectProxy::IsOffScreen) | 510 .SetProperty("isOffScreen", &WebAXObjectProxy::IsOffScreen) |
| 508 .SetProperty("isCollapsed", &WebAXObjectProxy::IsCollapsed) | 511 .SetProperty("isCollapsed", &WebAXObjectProxy::IsCollapsed) |
| 509 .SetProperty("hasPopup", &WebAXObjectProxy::HasPopup) | 512 .SetProperty("hasPopup", &WebAXObjectProxy::HasPopup) |
| 510 .SetProperty("isValid", &WebAXObjectProxy::IsValid) | 513 .SetProperty("isValid", &WebAXObjectProxy::IsValid) |
| 511 .SetProperty("isReadOnly", &WebAXObjectProxy::IsReadOnly) | 514 .SetProperty("isReadOnly", &WebAXObjectProxy::IsReadOnly) |
| 515 .SetProperty("backgroundColor", &WebAXObjectProxy::BackgroundColor) |
| 516 .SetProperty("color", &WebAXObjectProxy::Color) |
| 517 .SetProperty("colorValue", &WebAXObjectProxy::ColorValue) |
| 518 .SetProperty("fontSize", &WebAXObjectProxy::FontSize) |
| 512 .SetProperty("orientation", &WebAXObjectProxy::Orientation) | 519 .SetProperty("orientation", &WebAXObjectProxy::Orientation) |
| 513 .SetProperty("posInSet", &WebAXObjectProxy::PosInSet) | 520 .SetProperty("posInSet", &WebAXObjectProxy::PosInSet) |
| 514 .SetProperty("setSize", &WebAXObjectProxy::SetSize) | 521 .SetProperty("setSize", &WebAXObjectProxy::SetSize) |
| 515 .SetProperty("clickPointX", &WebAXObjectProxy::ClickPointX) | 522 .SetProperty("clickPointX", &WebAXObjectProxy::ClickPointX) |
| 516 .SetProperty("clickPointY", &WebAXObjectProxy::ClickPointY) | 523 .SetProperty("clickPointY", &WebAXObjectProxy::ClickPointY) |
| 517 .SetProperty("rowCount", &WebAXObjectProxy::RowCount) | 524 .SetProperty("rowCount", &WebAXObjectProxy::RowCount) |
| 518 .SetProperty("rowHeadersCount", &WebAXObjectProxy::RowHeadersCount) | 525 .SetProperty("rowHeadersCount", &WebAXObjectProxy::RowHeadersCount) |
| 519 .SetProperty("columnCount", &WebAXObjectProxy::ColumnCount) | 526 .SetProperty("columnCount", &WebAXObjectProxy::ColumnCount) |
| 520 .SetProperty("columnHeadersCount", &WebAXObjectProxy::ColumnHeadersCount) | 527 .SetProperty("columnHeadersCount", &WebAXObjectProxy::ColumnHeadersCount) |
| 521 .SetProperty("isClickable", &WebAXObjectProxy::IsClickable) | 528 .SetProperty("isClickable", &WebAXObjectProxy::IsClickable) |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 bool WebAXObjectProxy::IsValid() { | 822 bool WebAXObjectProxy::IsValid() { |
| 816 accessibility_object_.updateLayoutAndCheckValidity(); | 823 accessibility_object_.updateLayoutAndCheckValidity(); |
| 817 return !accessibility_object_.isDetached(); | 824 return !accessibility_object_.isDetached(); |
| 818 } | 825 } |
| 819 | 826 |
| 820 bool WebAXObjectProxy::IsReadOnly() { | 827 bool WebAXObjectProxy::IsReadOnly() { |
| 821 accessibility_object_.updateLayoutAndCheckValidity(); | 828 accessibility_object_.updateLayoutAndCheckValidity(); |
| 822 return accessibility_object_.isReadOnly(); | 829 return accessibility_object_.isReadOnly(); |
| 823 } | 830 } |
| 824 | 831 |
| 832 unsigned int WebAXObjectProxy::BackgroundColor() { |
| 833 accessibility_object_.updateLayoutAndCheckValidity(); |
| 834 return accessibility_object_.backgroundColor(); |
| 835 } |
| 836 |
| 837 unsigned int WebAXObjectProxy::Color() { |
| 838 accessibility_object_.updateLayoutAndCheckValidity(); |
| 839 unsigned int color = accessibility_object_.color(); |
| 840 // Remove the alpha because it's always 1 and thus not informative. |
| 841 return color & 0xFFFFFF; |
| 842 } |
| 843 |
| 844 // For input elements of type color. |
| 845 unsigned int WebAXObjectProxy::ColorValue() { |
| 846 accessibility_object_.updateLayoutAndCheckValidity(); |
| 847 return accessibility_object_.colorValue(); |
| 848 } |
| 849 |
| 850 float WebAXObjectProxy::FontSize() { |
| 851 accessibility_object_.updateLayoutAndCheckValidity(); |
| 852 return accessibility_object_.fontSize(); |
| 853 } |
| 854 |
| 825 std::string WebAXObjectProxy::Orientation() { | 855 std::string WebAXObjectProxy::Orientation() { |
| 826 accessibility_object_.updateLayoutAndCheckValidity(); | 856 accessibility_object_.updateLayoutAndCheckValidity(); |
| 827 if (accessibility_object_.orientation() == blink::WebAXOrientationVertical) | 857 if (accessibility_object_.orientation() == blink::WebAXOrientationVertical) |
| 828 return "AXOrientation: AXVerticalOrientation"; | 858 return "AXOrientation: AXVerticalOrientation"; |
| 829 else if (accessibility_object_.orientation() | 859 else if (accessibility_object_.orientation() |
| 830 == blink::WebAXOrientationHorizontal) | 860 == blink::WebAXOrientationHorizontal) |
| 831 return "AXOrientation: AXHorizontalOrientation"; | 861 return "AXOrientation: AXHorizontalOrientation"; |
| 832 | 862 |
| 833 return std::string(); | 863 return std::string(); |
| 834 } | 864 } |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 v8::Local<v8::Value> value_handle = gin::CreateHandle( | 1327 v8::Local<v8::Value> value_handle = gin::CreateHandle( |
| 1298 isolate, new WebAXObjectProxy(object, this)).ToV8(); | 1328 isolate, new WebAXObjectProxy(object, this)).ToV8(); |
| 1299 if (value_handle.IsEmpty()) | 1329 if (value_handle.IsEmpty()) |
| 1300 return v8::Local<v8::Object>(); | 1330 return v8::Local<v8::Object>(); |
| 1301 v8::Local<v8::Object> handle = value_handle->ToObject(isolate); | 1331 v8::Local<v8::Object> handle = value_handle->ToObject(isolate); |
| 1302 elements_.Append(handle); | 1332 elements_.Append(handle); |
| 1303 return handle; | 1333 return handle; |
| 1304 } | 1334 } |
| 1305 | 1335 |
| 1306 } // namespace content | 1336 } // namespace content |
| OLD | NEW |