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

Side by Side Diff: content/shell/renderer/test_runner/web_ax_object_proxy.cc

Issue 1130733006: Adds color, font size, text direction and text styles to the accessibility tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt at exposing style info to the native APIs. Created 5 years, 7 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 | « content/shell/renderer/test_runner/web_ax_object_proxy.h ('k') | ui/accessibility/ax_enums.idl » ('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 "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
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 .SetProperty("isSelectedOptionActive", 504 .SetProperty("isSelectedOptionActive",
503 &WebAXObjectProxy::IsSelectedOptionActive) 505 &WebAXObjectProxy::IsSelectedOptionActive)
504 .SetProperty("isExpanded", &WebAXObjectProxy::IsExpanded) 506 .SetProperty("isExpanded", &WebAXObjectProxy::IsExpanded)
505 .SetProperty("isChecked", &WebAXObjectProxy::IsChecked) 507 .SetProperty("isChecked", &WebAXObjectProxy::IsChecked)
506 .SetProperty("isVisible", &WebAXObjectProxy::IsVisible) 508 .SetProperty("isVisible", &WebAXObjectProxy::IsVisible)
507 .SetProperty("isOffScreen", &WebAXObjectProxy::IsOffScreen) 509 .SetProperty("isOffScreen", &WebAXObjectProxy::IsOffScreen)
508 .SetProperty("isCollapsed", &WebAXObjectProxy::IsCollapsed) 510 .SetProperty("isCollapsed", &WebAXObjectProxy::IsCollapsed)
509 .SetProperty("hasPopup", &WebAXObjectProxy::HasPopup) 511 .SetProperty("hasPopup", &WebAXObjectProxy::HasPopup)
510 .SetProperty("isValid", &WebAXObjectProxy::IsValid) 512 .SetProperty("isValid", &WebAXObjectProxy::IsValid)
511 .SetProperty("isReadOnly", &WebAXObjectProxy::IsReadOnly) 513 .SetProperty("isReadOnly", &WebAXObjectProxy::IsReadOnly)
514 .SetProperty("backgroundColor", &WebAXObjectProxy::BackgroundColor)
515 .SetProperty("color", &WebAXObjectProxy::Color)
516 .SetProperty("colorValue", &WebAXObjectProxy::ColorValue)
517 .SetProperty("fontSize", &WebAXObjectProxy::FontSize)
512 .SetProperty("orientation", &WebAXObjectProxy::Orientation) 518 .SetProperty("orientation", &WebAXObjectProxy::Orientation)
513 .SetProperty("posInSet", &WebAXObjectProxy::PosInSet) 519 .SetProperty("posInSet", &WebAXObjectProxy::PosInSet)
514 .SetProperty("setSize", &WebAXObjectProxy::SetSize) 520 .SetProperty("setSize", &WebAXObjectProxy::SetSize)
515 .SetProperty("clickPointX", &WebAXObjectProxy::ClickPointX) 521 .SetProperty("clickPointX", &WebAXObjectProxy::ClickPointX)
516 .SetProperty("clickPointY", &WebAXObjectProxy::ClickPointY) 522 .SetProperty("clickPointY", &WebAXObjectProxy::ClickPointY)
517 .SetProperty("rowCount", &WebAXObjectProxy::RowCount) 523 .SetProperty("rowCount", &WebAXObjectProxy::RowCount)
518 .SetProperty("rowHeadersCount", &WebAXObjectProxy::RowHeadersCount) 524 .SetProperty("rowHeadersCount", &WebAXObjectProxy::RowHeadersCount)
519 .SetProperty("columnCount", &WebAXObjectProxy::ColumnCount) 525 .SetProperty("columnCount", &WebAXObjectProxy::ColumnCount)
520 .SetProperty("columnHeadersCount", &WebAXObjectProxy::ColumnHeadersCount) 526 .SetProperty("columnHeadersCount", &WebAXObjectProxy::ColumnHeadersCount)
521 .SetProperty("isClickable", &WebAXObjectProxy::IsClickable) 527 .SetProperty("isClickable", &WebAXObjectProxy::IsClickable)
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 bool WebAXObjectProxy::IsValid() { 821 bool WebAXObjectProxy::IsValid() {
816 accessibility_object_.updateLayoutAndCheckValidity(); 822 accessibility_object_.updateLayoutAndCheckValidity();
817 return !accessibility_object_.isDetached(); 823 return !accessibility_object_.isDetached();
818 } 824 }
819 825
820 bool WebAXObjectProxy::IsReadOnly() { 826 bool WebAXObjectProxy::IsReadOnly() {
821 accessibility_object_.updateLayoutAndCheckValidity(); 827 accessibility_object_.updateLayoutAndCheckValidity();
822 return accessibility_object_.isReadOnly(); 828 return accessibility_object_.isReadOnly();
823 } 829 }
824 830
831 unsigned int WebAXObjectProxy::BackgroundColor() {
832 accessibility_object_.updateLayoutAndCheckValidity();
833 return accessibility_object_.backgroundColor();
834 }
835
836 unsigned int WebAXObjectProxy::Color() {
837 accessibility_object_.updateLayoutAndCheckValidity();
838 unsigned int color = accessibility_object_.color();
839 // Remove the alpha because it's always 1 and thus not informative.
840 return color & 0xFFFFFF;
841 }
842
843 // For input elements of type color.
844 unsigned int WebAXObjectProxy::ColorValue() {
845 accessibility_object_.updateLayoutAndCheckValidity();
846 return accessibility_object_.colorValue();
847 }
848
849 float WebAXObjectProxy::FontSize() {
850 accessibility_object_.updateLayoutAndCheckValidity();
851 return accessibility_object_.fontSize();
852 }
853
825 std::string WebAXObjectProxy::Orientation() { 854 std::string WebAXObjectProxy::Orientation() {
826 accessibility_object_.updateLayoutAndCheckValidity(); 855 accessibility_object_.updateLayoutAndCheckValidity();
827 if (accessibility_object_.orientation() == blink::WebAXOrientationVertical) 856 if (accessibility_object_.orientation() == blink::WebAXOrientationVertical)
828 return "AXOrientation: AXVerticalOrientation"; 857 return "AXOrientation: AXVerticalOrientation";
829 else if (accessibility_object_.orientation() 858 else if (accessibility_object_.orientation()
830 == blink::WebAXOrientationHorizontal) 859 == blink::WebAXOrientationHorizontal)
831 return "AXOrientation: AXHorizontalOrientation"; 860 return "AXOrientation: AXHorizontalOrientation";
832 861
833 return std::string(); 862 return std::string();
834 } 863 }
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 v8::Local<v8::Value> value_handle = gin::CreateHandle( 1326 v8::Local<v8::Value> value_handle = gin::CreateHandle(
1298 isolate, new WebAXObjectProxy(object, this)).ToV8(); 1327 isolate, new WebAXObjectProxy(object, this)).ToV8();
1299 if (value_handle.IsEmpty()) 1328 if (value_handle.IsEmpty())
1300 return v8::Local<v8::Object>(); 1329 return v8::Local<v8::Object>();
1301 v8::Local<v8::Object> handle = value_handle->ToObject(isolate); 1330 v8::Local<v8::Object> handle = value_handle->ToObject(isolate);
1302 elements_.Append(handle); 1331 elements_.Append(handle);
1303 return handle; 1332 return handle;
1304 } 1333 }
1305 1334
1306 } // namespace content 1335 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/web_ax_object_proxy.h ('k') | ui/accessibility/ax_enums.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698