summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/common/render_messages.cc4
-rw-r--r--chrome/common/render_messages_unittest.cc13
-rw-r--r--webkit/glue/webaccessibility.cc34
-rw-r--r--webkit/glue/webaccessibility.h12
4 files changed, 63 insertions, 0 deletions
diff --git a/chrome/common/render_messages.cc b/chrome/common/render_messages.cc
index 3e17733..10b22e4 100644
--- a/chrome/common/render_messages.cc
+++ b/chrome/common/render_messages.cc
@@ -792,6 +792,7 @@ void ParamTraits<webkit_glue::WebAccessibility>::Write(Message* m,
WriteParam(m, p.location);
WriteParam(m, p.attributes);
WriteParam(m, p.children);
+ WriteParam(m, p.html_attributes);
}
bool ParamTraits<webkit_glue::WebAccessibility>::Read(
@@ -813,6 +814,7 @@ bool ParamTraits<webkit_glue::WebAccessibility>::Read(
ret = ret && ReadParam(m, iter, &p->location);
ret = ret && ReadParam(m, iter, &p->attributes);
ret = ret && ReadParam(m, iter, &p->children);
+ ret = ret && ReadParam(m, iter, &p->html_attributes);
return ret;
}
@@ -834,6 +836,8 @@ void ParamTraits<webkit_glue::WebAccessibility>::Log(const param_type& p,
LogParam(p.attributes, l);
l->append(", ");
LogParam(p.children, l);
+ l->append(", ");
+ LogParam(p.html_attributes, l);
l->append(")");
}
diff --git a/chrome/common/render_messages_unittest.cc b/chrome/common/render_messages_unittest.cc
index 4fc0aab..d45d5df 100644
--- a/chrome/common/render_messages_unittest.cc
+++ b/chrome/common/render_messages_unittest.cc
@@ -23,6 +23,10 @@ TEST(RenderMessagesUnittest, WebAccessibility) {
(1 << webkit_glue::WebAccessibility::STATE_CHECKED) |
(1 << webkit_glue::WebAccessibility::STATE_FOCUSED);
input.location = WebKit::WebRect(11, 22, 333, 444);
+ input.html_attributes.push_back(
+ std::pair<string16, string16>(ASCIIToUTF16("id"), ASCIIToUTF16("a")));
+ input.html_attributes.push_back(
+ std::pair<string16, string16>(ASCIIToUTF16("class"), ASCIIToUTF16("b")));
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
IPC::WriteParam(&msg, input);
@@ -39,6 +43,15 @@ TEST(RenderMessagesUnittest, WebAccessibility) {
EXPECT_EQ(input.state, output.state);
EXPECT_EQ(input.location, output.location);
EXPECT_EQ(input.children.size(), output.children.size());
+ EXPECT_EQ(input.html_attributes.size(), output.html_attributes.size());
+ EXPECT_EQ(input.html_attributes[0].first,
+ output.html_attributes[0].first);
+ EXPECT_EQ(input.html_attributes[0].second,
+ output.html_attributes[0].second);
+ EXPECT_EQ(input.html_attributes[1].first,
+ output.html_attributes[1].first);
+ EXPECT_EQ(input.html_attributes[1].second,
+ output.html_attributes[1].second);
// Test a corrupt case.
IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL);
diff --git a/webkit/glue/webaccessibility.cc b/webkit/glue/webaccessibility.cc
index b6e0d5e..8b007d3 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;
@@ -285,6 +292,33 @@ 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");
+ attributes[ATTR_DOC_DOCTYPE] = document.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 305bc0ca..1836948 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,
@@ -180,6 +191,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