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

Unified Diff: webkit/glue/webaccessibility.cc

Issue 7745035: Add a big grab bag of missing web accessibility functionality... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
« webkit/glue/webaccessibility.h ('K') | « webkit/glue/webaccessibility.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webaccessibility.cc
===================================================================
--- webkit/glue/webaccessibility.cc (revision 98225)
+++ webkit/glue/webaccessibility.cc (working copy)
@@ -26,12 +26,18 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
+using base::DoubleToString;
+using base::IntToString;
using WebKit::WebAccessibilityCache;
using WebKit::WebAccessibilityRole;
using WebKit::WebAccessibilityObject;
namespace webkit_glue {
+static std::string BoolToString(bool b) {
+ return b? "true": "false";
tony 2011/08/27 00:05:47 Nit: Space between b and ?
dmazzoni 2011/08/29 18:08:51 Done.
+}
+
// Provides a conversion between the WebKit::WebAccessibilityRole and a role
// supported on the Browser side. Listed alphabetically by the
// WebAccessibilityRole (except for default role).
@@ -245,9 +251,9 @@
if (o.isFocused())
state |= (1 << WebAccessibility::STATE_FOCUSED);
- if (o.roleValue() == WebKit::WebAccessibilityRolePopUpButton) {
+ if (o.roleValue() == WebKit::WebAccessibilityRolePopUpButton ||
+ o.ariaHasPopup()) {
state |= (1 << WebAccessibility::STATE_HASPOPUP);
-
if (!o.isCollapsed())
state |= (1 << WebAccessibility::STATE_EXPANDED);
}
@@ -276,9 +282,12 @@
if (o.isPasswordField())
state |= (1 << WebAccessibility::STATE_PROTECTED);
- if (o.isReadOnly())
+ if (o.isAriaReadOnly())
state |= (1 << WebAccessibility::STATE_READONLY);
+ if (o.isRequired())
+ state |= (1 << WebAccessibility::STATE_REQUIRED);
+
if (o.canSetSelectedAttribute())
state |= (1 << WebAccessibility::STATE_SELECTABLE);
@@ -291,6 +300,12 @@
if (!o.isEnabled())
state |= (1 << WebAccessibility::STATE_UNAVAILABLE);
+ if (o.isVertical())
+ state |= (1 << WebAccessibility::STATE_VERTICAL);
+
+ if (o.isVisited())
+ state |= (1 << WebAccessibility::STATE_VISITED);
+
return state;
}
@@ -309,28 +324,350 @@
WebAccessibility::~WebAccessibility() {
}
+std::string WebAccessibility::DebugString(bool recursive) {
+ std::string result;
+ static int indent = 0;
+
+ for (int i = 0; i < indent; i++)
+ result += " ";
+
+ result += "id=" + IntToString(id);
+
+ switch(role) {
+ case ROLE_ALERT: result += " ALERT"; break;
+ case ROLE_ALERT_DIALOG: result += " ALERT_DIALOG"; break;
+ case ROLE_ANNOTATION: result += " ANNOTATION"; break;
+ case ROLE_APPLICATION: result += " APPLICATION"; break;
+ case ROLE_ARTICLE: result += " ARTICLE"; break;
+ case ROLE_BROWSER: result += " BROWSER"; break;
+ case ROLE_BUSY_INDICATOR: result += " BUSY_INDICATOR"; break;
+ case ROLE_BUTTON: result += " BUTTON"; break;
+ case ROLE_CELL: result += " CELL"; break;
+ case ROLE_CHECKBOX: result += " CHECKBOX"; break;
+ case ROLE_COLOR_WELL: result += " COLOR_WELL"; break;
+ case ROLE_COLUMN: result += " COLUMN"; break;
+ case ROLE_COLUMN_HEADER: result += " COLUMN_HEADER"; break;
+ case ROLE_COMBO_BOX: result += " COMBO_BOX"; break;
+ case ROLE_DEFINITION_LIST_DEFINITION: result += " DL_DEFINITION"; break;
+ case ROLE_DEFINITION_LIST_TERM: result += " DL_TERM"; break;
+ case ROLE_DIALOG: result += " DIALOG"; break;
+ case ROLE_DIRECTORY: result += " DIRECTORY"; break;
+ case ROLE_DISCLOSURE_TRIANGLE: result += " DISCLOSURE_TRIANGLE"; break;
+ case ROLE_DOCUMENT: result += " DOCUMENT"; break;
+ case ROLE_DRAWER: result += " DRAWER"; break;
+ case ROLE_EDITABLE_TEXT: result += " EDITABLE_TEXT"; break;
+ case ROLE_GRID: result += " GRID"; break;
+ case ROLE_GROUP: result += " GROUP"; break;
+ case ROLE_GROW_AREA: result += " GROW_AREA"; break;
+ case ROLE_HEADING: result += " HEADING"; break;
+ case ROLE_HELP_TAG: result += " HELP_TAG"; break;
+ case ROLE_IGNORED: result += " IGNORED"; break;
+ case ROLE_IMAGE: result += " IMAGE"; break;
+ case ROLE_IMAGE_MAP: result += " IMAGE_MAP"; break;
+ case ROLE_IMAGE_MAP_LINK: result += " IMAGE_MAP_LINK"; break;
+ case ROLE_INCREMENTOR: result += " INCREMENTOR"; break;
+ case ROLE_LANDMARK_APPLICATION: result += " L_APPLICATION"; break;
+ case ROLE_LANDMARK_BANNER: result += " L_BANNER"; break;
+ case ROLE_LANDMARK_COMPLEMENTARY: result += " L_COMPLEMENTARY"; break;
+ case ROLE_LANDMARK_CONTENTINFO: result += " L_CONTENTINFO"; break;
+ case ROLE_LANDMARK_MAIN: result += " L_MAIN"; break;
+ case ROLE_LANDMARK_NAVIGATION: result += " L_NAVIGATION"; break;
+ case ROLE_LANDMARK_SEARCH: result += " L_SEARCH"; break;
+ case ROLE_LINK: result += " LINK"; break;
+ case ROLE_LIST: result += " LIST"; break;
+ case ROLE_LISTBOX: result += " LISTBOX"; break;
+ case ROLE_LISTBOX_OPTION: result += " LISTBOX_OPTION"; break;
+ case ROLE_LIST_ITEM: result += " LIST_ITEM"; break;
+ case ROLE_LIST_MARKER: result += " LIST_MARKER"; break;
+ case ROLE_LOG: result += " LOG"; break;
+ case ROLE_MARQUEE: result += " MARQUEE"; break;
+ case ROLE_MATH: result += " MATH"; break;
+ case ROLE_MATTE: result += " MATTE"; break;
+ case ROLE_MENU: result += " MENU"; break;
+ case ROLE_MENU_BAR: result += " MENU_BAR"; break;
+ case ROLE_MENU_BUTTON: result += " MENU_BUTTON"; break;
+ case ROLE_MENU_ITEM: result += " MENU_ITEM"; break;
+ case ROLE_MENU_LIST_OPTION: result += " MENU_LIST_OPTION"; break;
+ case ROLE_MENU_LIST_POPUP: result += " MENU_LIST_POPUP"; break;
+ case ROLE_NOTE: result += " NOTE"; break;
+ case ROLE_OUTLINE: result += " OUTLINE"; break;
+ case ROLE_POPUP_BUTTON: result += " POPUP_BUTTON"; break;
+ case ROLE_PROGRESS_INDICATOR: result += " PROGRESS_INDICATOR"; break;
+ case ROLE_RADIO_BUTTON: result += " RADIO_BUTTON"; break;
+ case ROLE_RADIO_GROUP: result += " RADIO_GROUP"; break;
+ case ROLE_REGION: result += " REGION"; break;
+ case ROLE_ROW: result += " ROW"; break;
+ case ROLE_ROW_HEADER: result += " ROW_HEADER"; break;
+ case ROLE_RULER: result += " RULER"; break;
+ case ROLE_RULER_MARKER: result += " RULER_MARKER"; break;
+ case ROLE_SCROLLAREA: result += " SCROLLAREA"; break;
+ case ROLE_SCROLLBAR: result += " SCROLLBAR"; break;
+ case ROLE_SHEET: result += " SHEET"; break;
+ case ROLE_SLIDER: result += " SLIDER"; break;
+ case ROLE_SLIDER_THUMB: result += " SLIDER_THUMB"; break;
+ case ROLE_SPLITTER: result += " SPLITTER"; break;
+ case ROLE_SPLIT_GROUP: result += " SPLIT_GROUP"; break;
+ case ROLE_STATIC_TEXT: result += " STATIC_TEXT"; break;
+ case ROLE_STATUS: result += " STATUS"; break;
+ case ROLE_SYSTEM_WIDE: result += " SYSTEM_WIDE"; break;
+ case ROLE_TAB: result += " TAB"; break;
+ case ROLE_TABLE: result += " TABLE"; break;
+ case ROLE_TABLE_HEADER_CONTAINER: result += " TABLE_HDR_CONTAINER"; break;
+ case ROLE_TAB_GROUP: result += " TAB_GROUP"; break;
+ case ROLE_TAB_LIST: result += " TAB_LIST"; break;
+ case ROLE_TAB_PANEL: result += " TAB_PANEL"; break;
+ case ROLE_TEXTAREA: result += " TEXTAREA"; break;
+ case ROLE_TEXT_FIELD: result += " TEXT_FIELD"; break;
+ case ROLE_TIMER: result += " TIMER"; break;
+ case ROLE_TOOLBAR: result += " TOOLBAR"; break;
+ case ROLE_TOOLTIP: result += " TOOLTIP"; break;
+ case ROLE_TREE: result += " TREE"; break;
+ case ROLE_TREE_GRID: result += " TREE_GRID"; break;
+ case ROLE_TREE_ITEM: result += " TREE_ITEM"; break;
+ case ROLE_UNKNOWN: result += " UNKNOWN"; break;
+ case ROLE_VALUE_INDICATOR: result += " VALUE_INDICATOR"; break;
+ case ROLE_WEBCORE_LINK: result += " WEBCORE_LINK"; break;
+ case ROLE_WEB_AREA: result += " WEB_AREA"; break;
+ case ROLE_WINDOW: result += " WINDOW"; break;
+ }
+
+ if (state & (1 << STATE_BUSY))
+ result += " BUSY";
+ if (state & (1 << STATE_CHECKED))
+ result += " CHECKED";
+ if (state & (1 << STATE_COLLAPSED))
+ result += " COLLAPSED";
+ if (state & (1 << STATE_EXPANDED))
+ result += " EXPANDED";
+ if (state & (1 << STATE_FOCUSABLE))
+ result += " FOCUSABLE";
+ if (state & (1 << STATE_FOCUSED))
+ result += " FOCUSED";
+ if (state & (1 << STATE_HASPOPUP))
+ result += " HASPOPUP";
+ if (state & (1 << STATE_HOTTRACKED))
+ result += " HOTTRACKED";
+ if (state & (1 << STATE_INDETERMINATE))
+ result += " INDETERMINATE";
+ if (state & (1 << STATE_INVISIBLE))
+ result += " INVISIBLE";
+ if (state & (1 << STATE_LINKED))
+ result += " LINKED";
+ if (state & (1 << STATE_MULTISELECTABLE))
+ result += " MULTISELECTABLE";
+ if (state & (1 << STATE_OFFSCREEN))
+ result += " OFFSCREEN";
+ if (state & (1 << STATE_PRESSED))
+ result += " PRESSED";
+ if (state & (1 << STATE_PROTECTED))
+ result += " PROTECTED";
+ if (state & (1 << STATE_READONLY))
+ result += " READONLY";
+ if (state & (1 << STATE_REQUIRED))
+ result += " REQUIRED";
+ if (state & (1 << STATE_SELECTABLE))
+ result += " SELECTABLE";
+ if (state & (1 << STATE_SELECTED))
+ result += " SELECTED";
+ if (state & (1 << STATE_TRAVERSED))
+ result += " TRAVERSED";
+ if (state & (1 << STATE_UNAVAILABLE))
+ result += " UNAVAILABLE";
+ if (state & (1 << STATE_VERTICAL))
+ result += " VERTICAL";
+ if (state & (1 << STATE_VISITED))
+ result += " VISITED";
+
+ std::string tmp = UTF16ToUTF8(name);
+ RemoveChars(tmp, "\n", &tmp);
+ if (!tmp.empty())
+ result += " name=" + tmp;
+
+ tmp = UTF16ToUTF8(value);
+ RemoveChars(tmp, "\n", &tmp);
+ if (!tmp.empty())
+ result += " value=" + tmp;
+
+ result += " (" + IntToString(location.x()) + ", " +
+ IntToString(location.y()) + ")-(" +
+ IntToString(location.width()) + ", " +
+ IntToString(location.height()) + ")";
+
+ std::map<IntAttribute, int32>& iattrs = int_attributes;
+ if (iattrs.find(ATTR_DOC_SCROLLX) != iattrs.end())
tony 2011/08/27 00:05:47 It would be faster to iterate over the map and swi
dmazzoni 2011/08/29 18:08:51 Done.
+ result += " scrollx=" + IntToString(iattrs[ATTR_DOC_SCROLLX]);
+ if (iattrs.find(ATTR_DOC_SCROLLY) != iattrs.end())
+ result += " scrolly=" + IntToString(iattrs[ATTR_DOC_SCROLLY]);
+ if (iattrs.find(ATTR_TEXT_SEL_START) != iattrs.end())
+ result += " sel_start=" + IntToString(iattrs[ATTR_TEXT_SEL_START]);
+ if (iattrs.find(ATTR_TEXT_SEL_END) != iattrs.end())
+ result += " sel_end=" + IntToString(iattrs[ATTR_TEXT_SEL_END]);
+ if (iattrs.find(ATTR_TABLE_ROW_COUNT) != iattrs.end())
+ result += " rows=" + IntToString(iattrs[ATTR_TABLE_ROW_COUNT]);
+ if (iattrs.find(ATTR_TABLE_COLUMN_COUNT) != iattrs.end())
+ result += " cols=" + IntToString(iattrs[ATTR_TABLE_COLUMN_COUNT]);
+ if (iattrs.find(ATTR_TABLE_CELL_COLUMN_INDEX) != iattrs.end())
+ result += " col=" + IntToString(iattrs[ATTR_TABLE_CELL_COLUMN_INDEX]);
+ if (iattrs.find(ATTR_TABLE_CELL_ROW_INDEX) != iattrs.end())
+ result += " row=" + IntToString(iattrs[ATTR_TABLE_CELL_ROW_INDEX]);
+ if (iattrs.find(ATTR_TABLE_CELL_COLUMN_SPAN) != iattrs.end())
+ result += " colspan=" + IntToString(iattrs[ATTR_TABLE_CELL_COLUMN_SPAN]);
+ if (iattrs.find(ATTR_TABLE_CELL_ROW_SPAN) != iattrs.end())
+ result += " rowspan=" + IntToString(iattrs[ATTR_TABLE_CELL_ROW_SPAN]);
+
+ std::map<StringAttribute, string16>& sattrs = string_attributes;
+ if (sattrs.find(ATTR_DOC_URL) != sattrs.end())
tony 2011/08/27 00:05:47 Same as above.
dmazzoni 2011/08/29 18:08:51 Done.
+ result += " doc_url=" + UTF16ToUTF8(sattrs[ATTR_DOC_URL]);
+ if (sattrs.find(ATTR_DOC_TITLE) != sattrs.end())
+ result += " doc_title=" + UTF16ToUTF8(sattrs[ATTR_DOC_TITLE]);
+ if (sattrs.find(ATTR_DOC_MIMETYPE) != sattrs.end())
+ result += " doc_mimetype=" + UTF16ToUTF8(sattrs[ATTR_DOC_MIMETYPE]);
+ if (sattrs.find(ATTR_DOC_DOCTYPE) != sattrs.end())
+ result += " doc_doctype=" + UTF16ToUTF8(sattrs[ATTR_DOC_DOCTYPE]);
+ if (sattrs.find(ATTR_ACCESS_KEY) != sattrs.end())
+ result += " access_key=" + UTF16ToUTF8(sattrs[ATTR_ACCESS_KEY]);
+ if (sattrs.find(ATTR_ACTION) != sattrs.end())
+ result += " action=" + UTF16ToUTF8(sattrs[ATTR_ACTION]);
+ if (sattrs.find(ATTR_DESCRIPTION) != sattrs.end())
+ result += " description=" + UTF16ToUTF8(sattrs[ATTR_DESCRIPTION]);
+ if (sattrs.find(ATTR_DISPLAY) != sattrs.end())
+ result += " display=" + UTF16ToUTF8(sattrs[ATTR_DISPLAY]);
+ if (sattrs.find(ATTR_HELP) != sattrs.end())
+ result += " help=" + UTF16ToUTF8(sattrs[ATTR_HELP]);
+ if (sattrs.find(ATTR_HTML_TAG) != sattrs.end())
+ result += " html_tag=" + UTF16ToUTF8(sattrs[ATTR_HTML_TAG]);
+ if (sattrs.find(ATTR_LIVE_RELEVANT) != sattrs.end())
+ result += " relevant=" + UTF16ToUTF8(sattrs[ATTR_LIVE_RELEVANT]);
+ if (sattrs.find(ATTR_LIVE_STATUS) != sattrs.end())
+ result += " live=" + UTF16ToUTF8(sattrs[ATTR_LIVE_STATUS]);
+ if (sattrs.find(ATTR_CONTAINER_LIVE_RELEVANT) != sattrs.end()) {
+ result += " container_relevant=" +
+ UTF16ToUTF8(sattrs[ATTR_CONTAINER_LIVE_RELEVANT]);
+ }
+ if (sattrs.find(ATTR_CONTAINER_LIVE_STATUS) != sattrs.end()) {
+ result += " container_live=" +
+ UTF16ToUTF8(sattrs[ATTR_CONTAINER_LIVE_STATUS]);
+ }
+ if (sattrs.find(ATTR_ROLE) != sattrs.end())
+ result += " role=" + UTF16ToUTF8(sattrs[ATTR_ROLE]);
+ if (sattrs.find(ATTR_SHORTCUT) != sattrs.end())
+ result += " shortcut=" + UTF16ToUTF8(sattrs[ATTR_SHORTCUT]);
+ if (sattrs.find(ATTR_URL) != sattrs.end())
+ result += " url=" + UTF16ToUTF8(sattrs[ATTR_URL]);
+
+ std::map<FloatAttribute, float>& fattrs = float_attributes;
+ if (fattrs.find(ATTR_DOC_LOADING_PROGRESS) != fattrs.end()) {
+ result += " doc_progress=" +
+ DoubleToString(fattrs[ATTR_DOC_LOADING_PROGRESS]);
+ }
+ if (fattrs.find(ATTR_VALUE_FOR_RANGE) != fattrs.end()) {
+ result += " value_for_range=" +
+ DoubleToString(fattrs[ATTR_VALUE_FOR_RANGE]);
+ }
+ if (fattrs.find(ATTR_MAX_VALUE_FOR_RANGE) != fattrs.end()) {
+ result += " max_value=" +
+ DoubleToString(fattrs[ATTR_MAX_VALUE_FOR_RANGE]);
+ }
+ if (fattrs.find(ATTR_MIN_VALUE_FOR_RANGE) != fattrs.end()) {
+ result += " min_value=" +
+ DoubleToString(fattrs[ATTR_MIN_VALUE_FOR_RANGE]);
+ }
+
+ std::map<BoolAttribute, bool>& battrs = bool_attributes;
+ if (battrs.find(ATTR_DOC_LOADED) != battrs.end())
+ result += " doc_loaded=" + BoolToString(battrs[ATTR_DOC_LOADED]);
+ if (battrs.find(ATTR_BUTTON_MIXED) != battrs.end())
+ result += " mixed=" + BoolToString(battrs[ATTR_BUTTON_MIXED]);
+ if (battrs.find(ATTR_LIVE_ATOMIC) != battrs.end())
+ result += " atomic=" + BoolToString(battrs[ATTR_LIVE_ATOMIC]);
+ if (battrs.find(ATTR_LIVE_BUSY) != battrs.end())
+ result += " busy=" + BoolToString(battrs[ATTR_LIVE_BUSY]);
+ if (battrs.find(ATTR_CONTAINER_LIVE_ATOMIC) != battrs.end()) {
+ result += " container_atomic=" +
+ BoolToString(battrs[ATTR_CONTAINER_LIVE_ATOMIC]);
+ }
+ if (battrs.find(ATTR_CONTAINER_LIVE_BUSY) != battrs.end()) {
+ result += " container_busy=" +
+ BoolToString(battrs[ATTR_CONTAINER_LIVE_BUSY]);
+ }
+
+ if (children.size() > 0)
tony 2011/08/27 00:05:47 Nit: !children.empty()
dmazzoni 2011/08/29 18:08:51 Done.
+ result += " children=" + IntToString(children.size());
+
+ if (indirect_child_ids.size() > 0) {
tony 2011/08/27 00:05:47 Nit: !empty()
dmazzoni 2011/08/29 18:08:51 Done.
+ result += " indirect_child_ids=";
+ for (size_t i = 0; i < indirect_child_ids.size(); i++) {
tony 2011/08/27 00:05:47 Nit: ++i
dmazzoni 2011/08/29 18:08:51 Fixed throughout.
+ if (i > 0)
+ result += ",";
+ result += IntToString(indirect_child_ids[i]);
+ }
+ }
+
+ if (line_breaks.size() > 0) {
tony 2011/08/27 00:05:47 Please make a helper function for printing a vecto
dmazzoni 2011/08/29 18:08:51 Done.
+ result += " line_breaks=";
+ for (size_t i = 0; i < line_breaks.size(); i++) {
+ if (i > 0)
+ result += ",";
+ result += IntToString(line_breaks[i]);
+ }
+ }
+
+ if (cell_ids.size() > 0) {
tony 2011/08/27 00:05:47 Nit: !empty()
dmazzoni 2011/08/29 18:08:51 Done.
+ result += " cell_ids=";
+ for (size_t i = 0; i < cell_ids.size(); i++) {
tony 2011/08/27 00:05:47 Nit: ++i
dmazzoni 2011/08/29 18:08:51 Done.
+ if (i > 0)
+ result += ",";
+ result += IntToString(cell_ids[i]);
+ }
+ }
+
+ if (recursive) {
+ result += "\n";
+ indent++;
tony 2011/08/27 00:05:47 Nit: ++indent
dmazzoni 2011/08/29 18:08:51 Done.
+ for (size_t i = 0; i < children.size(); i++)
+ result += children[i].DebugString(true);
+ indent--;
tony 2011/08/27 00:05:47 Nit: --indent
dmazzoni 2011/08/29 18:08:51 Done.
+ }
+
+ return result;
+}
+
void WebAccessibility::Init(const WebKit::WebAccessibilityObject& src,
WebKit::WebAccessibilityCache* cache,
bool include_children) {
name = src.title();
- value = src.stringValue();
role = ConvertRole(src.roleValue());
state = ConvertState(src);
location = src.boundingBoxRect();
+ if (src.valueDescription().length())
tony 2011/08/27 00:05:47 Nit: !.empty()
dmazzoni 2011/08/29 18:08:51 Actually this one is a WebString, which doesn't ha
+ value = src.valueDescription();
+ else
+ value = src.stringValue();
+
+ if (src.accessKey().length())
+ string_attributes[ATTR_ACCESS_KEY] = src.accessKey();
if (src.actionVerb().length())
string_attributes[ATTR_ACTION] = src.actionVerb();
+ if (src.isButtonStateMixed())
+ bool_attributes[ATTR_BUTTON_MIXED] = true;
if (src.accessibilityDescription().length())
string_attributes[ATTR_DESCRIPTION] = src.accessibilityDescription();
+ if (src.hasComputedStyle())
+ string_attributes[ATTR_DISPLAY] = src.computedStyleDisplay();
if (src.helpText().length())
string_attributes[ATTR_HELP] = src.helpText();
if (src.keyboardShortcut().length())
string_attributes[ATTR_SHORTCUT] = src.keyboardShortcut();
- if (src.hasComputedStyle())
- string_attributes[ATTR_DISPLAY] = src.computedStyleDisplay();
if (!src.url().isEmpty())
string_attributes[ATTR_URL] = src.url().spec().utf16();
+ if (role == ROLE_TREE_ITEM)
+ int_attributes[ATTR_HIERARCHICAL_LEVEL] = src.hierarchicalLevel();
+
+ if (role == ROLE_SLIDER)
+ include_children = false;
+
WebKit::WebNode node = src.node();
bool is_iframe = false;
@@ -344,10 +681,10 @@
string_attributes[ATTR_HTML_TAG] =
StringToLowerASCII(string16(element.tagName()));
for (unsigned i = 0; i < element.attributes().length(); i++) {
- html_attributes.push_back(
- std::pair<string16, string16>(
- element.attributes().attributeItem(i).localName(),
- element.attributes().attributeItem(i).value()));
+ string16 name = StringToLowerASCII(string16(
+ element.attributes().attributeItem(i).localName()));
+ string16 value = element.attributes().attributeItem(i).value();
+ html_attributes.push_back(std::pair<string16, string16>(name, value));
}
if (element.isFormControlElement()) {
@@ -367,8 +704,76 @@
line_breaks.push_back(src_line_breaks[i]);
}
}
+
+ // ARIA role.
+ if (element.hasAttribute("role")) {
+ string_attributes[ATTR_ROLE] = element.getAttribute("role");
+ }
+
+ // Live region attributes
+ if (element.hasAttribute("aria-atomic")) {
+ bool_attributes[ATTR_LIVE_ATOMIC] =
+ LowerCaseEqualsASCII(element.getAttribute("aria-atomic"), "true");
+ }
+ if (element.hasAttribute("aria-busy")) {
+ bool_attributes[ATTR_LIVE_BUSY] =
+ LowerCaseEqualsASCII(element.getAttribute("aria-busy"), "true");
+ }
+ if (element.hasAttribute("aria-live")) {
+ string_attributes[ATTR_LIVE_STATUS] = element.getAttribute("aria-live");
+ }
+ if (element.hasAttribute("aria-relevant")) {
+ string_attributes[ATTR_LIVE_RELEVANT] =
+ element.getAttribute("aria-relevant");
+ }
}
+ // Walk up the parent chain to set live region attributes of containers
+
+ WebKit::WebAccessibilityObject container_accessible = src;
+ while (!container_accessible.isNull()) {
+ WebKit::WebNode container_node = container_accessible.node();
+ if (!container_node.isNull() && container_node.isElementNode()) {
+ WebKit::WebElement container_elem =
+ container_node.to<WebKit::WebElement>();
+ if (container_elem.hasAttribute("aria-atomic") &&
+ bool_attributes.find(ATTR_CONTAINER_LIVE_ATOMIC) ==
+ bool_attributes.end()) {
+ bool_attributes[ATTR_CONTAINER_LIVE_ATOMIC] =
+ LowerCaseEqualsASCII(container_elem.getAttribute("aria-atomic"),
+ "true");
+ }
+ if (container_elem.hasAttribute("aria-busy") &&
+ bool_attributes.find(ATTR_CONTAINER_LIVE_BUSY) ==
+ bool_attributes.end()) {
+ bool_attributes[ATTR_CONTAINER_LIVE_BUSY] =
+ LowerCaseEqualsASCII(container_elem.getAttribute("aria-busy"),
+ "true");
+ }
+ if (container_elem.hasAttribute("aria-live") &&
+ string_attributes.find(ATTR_CONTAINER_LIVE_STATUS) ==
+ string_attributes.end()) {
+ string_attributes[ATTR_CONTAINER_LIVE_STATUS] =
+ container_elem.getAttribute("aria-live");
+ }
+ if (container_elem.hasAttribute("aria-relevant") &&
+ string_attributes.find(ATTR_CONTAINER_LIVE_RELEVANT) ==
+ string_attributes.end()) {
+ string_attributes[ATTR_CONTAINER_LIVE_RELEVANT] =
+ container_elem.getAttribute("aria-relevant");
+ }
+ }
+ container_accessible = container_accessible.parentObject();
+ }
+
+ if (role == WebAccessibility::ROLE_PROGRESS_INDICATOR ||
+ role == WebAccessibility::ROLE_SCROLLBAR ||
+ role == WebAccessibility::ROLE_SLIDER) {
+ float_attributes[ATTR_VALUE_FOR_RANGE] = src.valueForRange();
+ float_attributes[ATTR_MAX_VALUE_FOR_RANGE] = src.minValueForRange();
+ float_attributes[ATTR_MIN_VALUE_FOR_RANGE] = src.maxValueForRange();
+ }
+
if (role == WebAccessibility::ROLE_DOCUMENT ||
role == WebAccessibility::ROLE_WEB_AREA) {
const WebKit::WebDocument& document = src.document();
@@ -380,6 +785,9 @@
string_attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/xhtml");
else
string_attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/html");
+ bool_attributes[ATTR_DOC_LOADED] = src.isLoaded();
+ float_attributes[ATTR_DOC_LOADING_PROGRESS] =
+ src.estimatedLoadingProgress();
const WebKit::WebDocumentType& doctype = document.doctype();
if (!doctype.isNull())
@@ -394,14 +802,20 @@
int column_count = src.columnCount();
int row_count = src.rowCount();
if (column_count > 0 && row_count > 0) {
+ std::set<int> unique_cell_id_set;
int_attributes[ATTR_TABLE_COLUMN_COUNT] = column_count;
int_attributes[ATTR_TABLE_ROW_COUNT] = row_count;
for (int i = 0; i < column_count * row_count; i++) {
WebAccessibilityObject cell = src.cellForColumnAndRow(
i % column_count, i / column_count);
int cell_id = -1;
- if (!cell.isNull())
+ if (!cell.isNull()) {
cell_id = cache->addOrGetId(cell);
+ if (unique_cell_id_set.find(cell_id) == unique_cell_id_set.end()) {
David Tseng 2011/08/29 19:05:34 NIT: IS THIS NECESSSARY?
+ unique_cell_id_set.insert(cell_id);
+ unique_cell_ids.push_back(cell_id);
+ }
+ }
cell_ids.push_back(cell_id);
}
}
« webkit/glue/webaccessibility.h ('K') | « webkit/glue/webaccessibility.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698