diff options
author | dmazzoni <dmazzoni@chromium.org> | 2015-04-10 18:53:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-11 01:53:42 +0000 |
commit | ffb594391b2c6b179a94d99df278fe4fe5dea9d2 (patch) | |
tree | 0bfe8cfda21ee310cc03d6213a2df976dc5c7878 /content | |
parent | 2ddeda2fc018a923330266e26ba35fea3e925d84 (diff) | |
download | chromium_src-ffb594391b2c6b179a94d99df278fe4fe5dea9d2.zip chromium_src-ffb594391b2c6b179a94d99df278fe4fe5dea9d2.tar.gz chromium_src-ffb594391b2c6b179a94d99df278fe4fe5dea9d2.tar.bz2 |
Explicitly call deprecated AX name calculation API.
This change explicitly calls deprecated AX name calculation functions
so that we can delete the ones without the deprecated prefix. It also
starts to add WebAXObjectProxy support for the new name calculation API
so that we can start to implement it and write layout tests for it.
BUG=473220
Review URL: https://codereview.chromium.org/1074953003
Cr-Commit-Position: refs/heads/master@{#324751}
Diffstat (limited to 'content')
3 files changed, 112 insertions, 37 deletions
diff --git a/content/renderer/accessibility/blink_ax_tree_source.cc b/content/renderer/accessibility/blink_ax_tree_source.cc index 9ea0112..0707716 100644 --- a/content/renderer/accessibility/blink_ax_tree_source.cc +++ b/content/renderer/accessibility/blink_ax_tree_source.cc @@ -218,7 +218,7 @@ void BlinkAXTreeSource::SerializeNode(blink::WebAXObject src, dst->state = AXStateFromBlink(src); dst->location = src.boundingBoxRect(); dst->id = src.axID(); - std::string name = UTF16ToUTF8(src.title()); + std::string name = UTF16ToUTF8(src.deprecatedTitle()); std::string value; if (src.valueDescription().length()) { @@ -288,27 +288,29 @@ void BlinkAXTreeSource::SerializeNode(blink::WebAXObject src, dst->AddBoolAttribute(ui::AX_ATTR_BUTTON_MIXED, true); if (src.canSetValueAttribute()) dst->AddBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE, true); - if (src.accessibilityDescription().length()) { - dst->AddStringAttribute(ui::AX_ATTR_DESCRIPTION, - UTF16ToUTF8(src.accessibilityDescription())); + if (src.deprecatedAccessibilityDescription().length()) { + dst->AddStringAttribute( + ui::AX_ATTR_DESCRIPTION, + UTF16ToUTF8(src.deprecatedAccessibilityDescription())); } if (src.hasComputedStyle()) { dst->AddStringAttribute(ui::AX_ATTR_DISPLAY, UTF16ToUTF8(src.computedStyleDisplay())); } - if (src.helpText().length()) - dst->AddStringAttribute(ui::AX_ATTR_HELP, UTF16ToUTF8(src.helpText())); - if (src.placeholder().length()) { + if (src.deprecatedHelpText().length()) + dst->AddStringAttribute(ui::AX_ATTR_HELP, + UTF16ToUTF8(src.deprecatedHelpText())); + if (src.deprecatedPlaceholder().length()) { dst->AddStringAttribute(ui::AX_ATTR_PLACEHOLDER, - UTF16ToUTF8(src.placeholder())); + UTF16ToUTF8(src.deprecatedPlaceholder())); } if (src.keyboardShortcut().length()) { dst->AddStringAttribute(ui::AX_ATTR_SHORTCUT, UTF16ToUTF8(src.keyboardShortcut())); } - if (!src.titleUIElement().isDetached()) { + if (!src.deprecatedTitleUIElement().isDetached()) { dst->AddIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT, - src.titleUIElement().axID()); + src.deprecatedTitleUIElement().axID()); } if (!src.ariaActiveDescendant().isDetached()) { dst->AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, @@ -574,7 +576,7 @@ void BlinkAXTreeSource::SerializeNode(blink::WebAXObject src, AddIntListAttributeFromWebObjects(ui::AX_ATTR_CONTROLS_IDS, controls, dst); WebVector<WebAXObject> describedby; - if (src.ariaDescribedby(describedby)) { + if (src.deprecatedAriaDescribedby(describedby)) { AddIntListAttributeFromWebObjects( ui::AX_ATTR_DESCRIBEDBY_IDS, describedby, dst); } @@ -589,7 +591,7 @@ void BlinkAXTreeSource::SerializeNode(blink::WebAXObject src, AddIntListAttributeFromWebObjects(ui::AX_ATTR_FLOWTO_IDS, flowTo, dst); WebVector<WebAXObject> labelledby; - if (src.ariaLabelledby(labelledby)) { + if (src.deprecatedAriaLabelledby(labelledby)) { AddIntListAttributeFromWebObjects( ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst); } diff --git a/content/shell/renderer/test_runner/web_ax_object_proxy.cc b/content/shell/renderer/test_runner/web_ax_object_proxy.cc index c776704..d139fda0 100644 --- a/content/shell/renderer/test_runner/web_ax_object_proxy.cc +++ b/content/shell/renderer/test_runner/web_ax_object_proxy.cc @@ -255,13 +255,13 @@ std::string RoleToString(blink::WebAXRole role) } } -std::string GetDescription(const blink::WebAXObject& object) { - std::string description = object.accessibilityDescription().utf8(); +std::string DeprecatedGetDescription(const blink::WebAXObject& object) { + std::string description = object.deprecatedAccessibilityDescription().utf8(); return description.insert(0, "AXDescription: "); } -std::string GetHelpText(const blink::WebAXObject& object) { - std::string help_text = object.helpText().utf8(); +std::string DeprecatedGetHelpText(const blink::WebAXObject& object) { + std::string help_text = object.deprecatedHelpText().utf8(); return help_text.insert(0, "AXHelp: "); } @@ -292,8 +292,8 @@ std::string GetRole(const blink::WebAXObject& object) { return role_string; } -std::string GetTitle(const blink::WebAXObject& object) { - std::string title = object.title().utf8(); +std::string DeprecatedGetTitle(const blink::WebAXObject& object) { + std::string title = object.deprecatedTitle().utf8(); return title.insert(0, "AXTitle: "); } @@ -309,11 +309,11 @@ std::string GetLanguage(const blink::WebAXObject& object) { std::string GetAttributes(const blink::WebAXObject& object) { // FIXME: Concatenate all attributes of the AXObject. - std::string attributes(GetTitle(object)); + std::string attributes(DeprecatedGetTitle(object)); attributes.append("\n"); attributes.append(GetRole(object)); attributes.append("\n"); - attributes.append(GetDescription(object)); + attributes.append(DeprecatedGetDescription(object)); return attributes; } @@ -475,9 +475,6 @@ gin::ObjectTemplateBuilder WebAXObjectProxy::GetObjectTemplateBuilder(v8::Isolate* isolate) { return gin::Wrappable<WebAXObjectProxy>::GetObjectTemplateBuilder(isolate) .SetProperty("role", &WebAXObjectProxy::Role) - .SetProperty("title", &WebAXObjectProxy::Title) - .SetProperty("description", &WebAXObjectProxy::Description) - .SetProperty("helpText", &WebAXObjectProxy::HelpText) .SetProperty("stringValue", &WebAXObjectProxy::StringValue) .SetProperty("language", &WebAXObjectProxy::Language) .SetProperty("x", &WebAXObjectProxy::X) @@ -539,7 +536,6 @@ WebAXObjectProxy::GetObjectTemplateBuilder(v8::Isolate* isolate) { .SetMethod("rowIndexRange", &WebAXObjectProxy::RowIndexRange) .SetMethod("columnIndexRange", &WebAXObjectProxy::ColumnIndexRange) .SetMethod("cellForColumnAndRow", &WebAXObjectProxy::CellForColumnAndRow) - .SetMethod("titleUIElement", &WebAXObjectProxy::TitleUIElement) .SetMethod("setSelectedTextRange", &WebAXObjectProxy::SetSelectedTextRange) .SetMethod("isAttributeSettable", &WebAXObjectProxy::IsAttributeSettable) @@ -570,7 +566,32 @@ WebAXObjectProxy::GetObjectTemplateBuilder(v8::Isolate* isolate) { .SetMethod("addNotificationListener", &WebAXObjectProxy::SetNotificationListener) .SetMethod("removeNotificationListener", - &WebAXObjectProxy::UnsetNotificationListener); + &WebAXObjectProxy::UnsetNotificationListener) + // + // DEPRECATED accessible name and description accessors + // + .SetProperty("title", &WebAXObjectProxy::DeprecatedTitle) + .SetProperty("description", &WebAXObjectProxy::DeprecatedDescription) + .SetProperty("helpText", &WebAXObjectProxy::DeprecatedHelpText) + .SetMethod("titleUIElement", &WebAXObjectProxy::DeprecatedTitleUIElement) + .SetProperty("deprecatedTitle", + &WebAXObjectProxy::DeprecatedTitle) + .SetProperty("deprecatedDescription", + &WebAXObjectProxy::DeprecatedDescription) + .SetProperty("deprecatedHelpText", + &WebAXObjectProxy::DeprecatedHelpText) + .SetMethod("deprecatedTitleUIElement", + &WebAXObjectProxy::DeprecatedTitleUIElement) + // + // NEW accessible name and description accessors + // + .SetProperty("name", &WebAXObjectProxy::Name) + .SetProperty("nameFrom", &WebAXObjectProxy::NameFrom) + .SetMethod("nameElementCount", &WebAXObjectProxy::NameElementCount) + .SetMethod("nameElementAtIndex", &WebAXObjectProxy::NameElementAtIndex); + // TODO(dmazzoni): add "description", etc. once LayoutTests have + // been updated to call deprecatedDescription instead. + } v8::Handle<v8::Object> WebAXObjectProxy::GetChildAtIndex(unsigned index) { @@ -618,19 +639,19 @@ std::string WebAXObjectProxy::Role() { return GetRole(accessibility_object_); } -std::string WebAXObjectProxy::Title() { +std::string WebAXObjectProxy::DeprecatedTitle() { accessibility_object_.updateLayoutAndCheckValidity(); - return GetTitle(accessibility_object_); + return DeprecatedGetTitle(accessibility_object_); } -std::string WebAXObjectProxy::Description() { +std::string WebAXObjectProxy::DeprecatedDescription() { accessibility_object_.updateLayoutAndCheckValidity(); - return GetDescription(accessibility_object_); + return DeprecatedGetDescription(accessibility_object_); } -std::string WebAXObjectProxy::HelpText() { +std::string WebAXObjectProxy::DeprecatedHelpText() { accessibility_object_.updateLayoutAndCheckValidity(); - return GetHelpText(accessibility_object_); + return DeprecatedGetHelpText(accessibility_object_); } std::string WebAXObjectProxy::StringValue() { @@ -1018,9 +1039,9 @@ v8::Handle<v8::Object> WebAXObjectProxy::CellForColumnAndRow( return factory_->GetOrCreate(obj); } -v8::Handle<v8::Object> WebAXObjectProxy::TitleUIElement() { +v8::Handle<v8::Object> WebAXObjectProxy::DeprecatedTitleUIElement() { accessibility_object_.updateLayoutAndCheckValidity(); - blink::WebAXObject obj = accessibility_object_.titleUIElement(); + blink::WebAXObject obj = accessibility_object_.deprecatedTitleUIElement(); if (obj.isNull()) return v8::Handle<v8::Object>(); @@ -1144,6 +1165,50 @@ int WebAXObjectProxy::WordEnd(int character_index) { return word_end; } +std::string WebAXObjectProxy::Name() { + accessibility_object_.updateLayoutAndCheckValidity(); + blink::WebAXNameFrom nameFrom; + blink::WebVector<blink::WebAXObject> nameObjects; + return accessibility_object_.name(nameFrom, nameObjects).utf8(); +} + +std::string WebAXObjectProxy::NameFrom() { + accessibility_object_.updateLayoutAndCheckValidity(); + blink::WebAXNameFrom nameFrom; + blink::WebVector<blink::WebAXObject> nameObjects; + accessibility_object_.name(nameFrom, nameObjects); + switch(nameFrom) { + case blink::WebAXNameFromAttribute: + return "attribute"; + case blink::WebAXNameFromContents: + return "contents"; + case blink::WebAXNameFromPlaceholder: + return "placeholder"; + case blink::WebAXNameFromRelatedElement: + return "relatedElement"; + default: + return "unknown"; + } +} + +int WebAXObjectProxy::NameElementCount() { + accessibility_object_.updateLayoutAndCheckValidity(); + blink::WebAXNameFrom nameFrom; + blink::WebVector<blink::WebAXObject> nameObjects; + accessibility_object_.name(nameFrom, nameObjects); + return static_cast<int>(nameObjects.size()); +} + +v8::Handle<v8::Object> WebAXObjectProxy::NameElementAtIndex(unsigned index) { + accessibility_object_.updateLayoutAndCheckValidity(); + blink::WebAXNameFrom nameFrom; + blink::WebVector<blink::WebAXObject> nameObjects; + accessibility_object_.name(nameFrom, nameObjects); + if (index >= nameObjects.size()) + return v8::Handle<v8::Object>(); + return factory_->GetOrCreate(nameObjects[index]); +} + RootWebAXObjectProxy::RootWebAXObjectProxy( const blink::WebAXObject &object, Factory *factory) : WebAXObjectProxy(object, factory) { diff --git a/content/shell/renderer/test_runner/web_ax_object_proxy.h b/content/shell/renderer/test_runner/web_ax_object_proxy.h index b97ef49..9a48d49 100644 --- a/content/shell/renderer/test_runner/web_ax_object_proxy.h +++ b/content/shell/renderer/test_runner/web_ax_object_proxy.h @@ -58,9 +58,6 @@ class WebAXObjectProxy : public gin::Wrappable<WebAXObjectProxy> { // Bound properties. std::string Role(); - std::string Title(); - std::string Description(); - std::string HelpText(); std::string StringValue(); std::string Language(); int X(); @@ -118,7 +115,6 @@ class WebAXObjectProxy : public gin::Wrappable<WebAXObjectProxy> { std::string RowIndexRange(); std::string ColumnIndexRange(); v8::Handle<v8::Object> CellForColumnAndRow(int column, int row); - v8::Handle<v8::Object> TitleUIElement(); void SetSelectedTextRange(int selection_start, int length); bool IsAttributeSettable(const std::string& attribute); bool IsPressActionSupported(); @@ -139,6 +135,18 @@ class WebAXObjectProxy : public gin::Wrappable<WebAXObjectProxy> { int WordStart(int character_index); int WordEnd(int character_index); + // DEPRECATED accessible name and description accessors + std::string DeprecatedTitle(); + std::string DeprecatedDescription(); + std::string DeprecatedHelpText(); + v8::Handle<v8::Object> DeprecatedTitleUIElement(); + + // NEW accessible name and description accessors + std::string Name(); + std::string NameFrom(); + int NameElementCount(); + v8::Handle<v8::Object> NameElementAtIndex(unsigned index); + blink::WebAXObject accessibility_object_; Factory* factory_; |