summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authordmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-30 16:40:37 +0000
committerdmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-30 16:40:37 +0000
commita2b744888f9361c415c183da361863096dbb233b (patch)
tree7bb08929903d5de8601fb24af32580f631ab0ae7 /webkit/glue
parentc48d8fada025ccfabd3e95e22b150d66fc98cb39 (diff)
downloadchromium_src-a2b744888f9361c415c183da361863096dbb233b.zip
chromium_src-a2b744888f9361c415c183da361863096dbb233b.tar.gz
chromium_src-a2b744888f9361c415c183da361863096dbb233b.tar.bz2
Add html node info (tag name, attributes, and computed display) and document
info (url, title, mimetype, doctype) to WebAccessibility. BUG=none TEST=Modified unit test: RenderMessagesUnittest.WebAccessibility TEST=Added new browser test: RendererAccessibilityBrowserTest.TestCrossPlatformAccessibilityTree Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=57188 Review URL: http://codereview.chromium.org/3013035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57866 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/webaccessibility.cc37
-rw-r--r--webkit/glue/webaccessibility.h12
2 files changed, 49 insertions, 0 deletions
diff --git a/webkit/glue/webaccessibility.cc b/webkit/glue/webaccessibility.cc
index 7e5c0ef..d600d67 100644
--- a/webkit/glue/webaccessibility.cc
+++ b/webkit/glue/webaccessibility.cc
@@ -7,6 +7,13 @@
#include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h"
#include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h"
#include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityRole.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebAttribute.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebDocumentType.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebNamedNodeMap.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebNode.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
using WebKit::WebAccessibilityCache;
@@ -288,6 +295,36 @@ void WebAccessibility::Init(const WebKit::WebAccessibilityObject& src,
attributes[ATTR_HELP] = src.helpText();
if (src.keyboardShortcut().length())
attributes[ATTR_SHORTCUT] = src.keyboardShortcut();
+ if (src.hasComputedStyle())
+ attributes[ATTR_DISPLAY] = src.computedStyleDisplay();
+
+ WebKit::WebNode node = src.node();
+
+ if (!node.isNull() && node.isElementNode()) {
+ WebKit::WebElement element = node.to<WebKit::WebElement>();
+ attributes[ATTR_HTML_TAG] = 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()));
+ }
+ }
+
+ if (role == WebAccessibility::ROLE_DOCUMENT ||
+ role == WebAccessibility::ROLE_WEB_AREA) {
+ WebKit::WebDocument document = src.document();
+ attributes[ATTR_DOC_TITLE] = document.title();
+ attributes[ATTR_DOC_URL] = document.frame()->url().spec().utf16();
+ if (document.isXHTMLDocument())
+ attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/xhtml");
+ else
+ attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/html");
+
+ WebKit::WebDocumentType doctype = document.doctype();
+ if (!doctype.isNull())
+ attributes[ATTR_DOC_DOCTYPE] = doctype.name();
+ }
// Add the source object to the cache and store its id.
id = cache->addOrGetId(src);
diff --git a/webkit/glue/webaccessibility.h b/webkit/glue/webaccessibility.h
index e6202ee..bfab191 100644
--- a/webkit/glue/webaccessibility.h
+++ b/webkit/glue/webaccessibility.h
@@ -147,9 +147,20 @@ struct WebAccessibility {
STATE_UNAVAILABLE
};
+ // Additional optional attributes that can be optionally attached to
+ // a node.
enum Attribute {
+ // Doc attributes: only make sense when applied to the top-level
+ // Document node.
+ ATTR_DOC_URL,
+ ATTR_DOC_TITLE,
+ ATTR_DOC_MIMETYPE,
+ ATTR_DOC_DOCTYPE,
+
+ // Attributes that could apply to any node.
ATTR_ACTION,
ATTR_DESCRIPTION,
+ ATTR_DISPLAY,
ATTR_HELP,
ATTR_HTML_TAG,
ATTR_LINK_TARGET,
@@ -182,6 +193,7 @@ struct WebAccessibility {
WebKit::WebRect location;
std::map<int32, string16> attributes;
std::vector<WebAccessibility> children;
+ std::vector<std::pair<string16, string16> > html_attributes;
};
} // namespace webkit_glue