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

Side by Side Diff: webkit/glue/webaccessibility.cc

Issue 3013035: Add html node info (tag name, attributes, and computed display) and document... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Add html node info (tag name, attributes, and computed display) and document... Created 10 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webaccessibility.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/glue/webaccessibility.h" 5 #include "webkit/glue/webaccessibility.h"
6 6
7 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h" 7 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h"
8 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h" 8 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h"
9 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityRole.h" 9 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityRole.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebAttribute.h"
11 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebDocumentType.h"
13 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
14 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
15 #include "third_party/WebKit/WebKit/chromium/public/WebNamedNodeMap.h"
16 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 17 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
11 18
12 using WebKit::WebAccessibilityCache; 19 using WebKit::WebAccessibilityCache;
13 using WebKit::WebAccessibilityRole; 20 using WebKit::WebAccessibilityRole;
14 using WebKit::WebAccessibilityObject; 21 using WebKit::WebAccessibilityObject;
15 22
16 namespace webkit_glue { 23 namespace webkit_glue {
17 24
18 // Provides a conversion between the WebKit::WebAccessibilityRole and a role 25 // Provides a conversion between the WebKit::WebAccessibilityRole and a role
19 // supported on the Browser side. Listed alphabetically by the 26 // supported on the Browser side. Listed alphabetically by the
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 location = src.boundingBoxRect(); 288 location = src.boundingBoxRect();
282 289
283 if (src.actionVerb().length()) 290 if (src.actionVerb().length())
284 attributes[ATTR_ACTION] = src.actionVerb(); 291 attributes[ATTR_ACTION] = src.actionVerb();
285 if (src.accessibilityDescription().length()) 292 if (src.accessibilityDescription().length())
286 attributes[ATTR_DESCRIPTION] = src.accessibilityDescription(); 293 attributes[ATTR_DESCRIPTION] = src.accessibilityDescription();
287 if (src.helpText().length()) 294 if (src.helpText().length())
288 attributes[ATTR_HELP] = src.helpText(); 295 attributes[ATTR_HELP] = src.helpText();
289 if (src.keyboardShortcut().length()) 296 if (src.keyboardShortcut().length())
290 attributes[ATTR_SHORTCUT] = src.keyboardShortcut(); 297 attributes[ATTR_SHORTCUT] = src.keyboardShortcut();
298 if (src.hasComputedStyle())
299 attributes[ATTR_DISPLAY] = src.computedStyleDisplay();
300
301 WebKit::WebNode node = src.node();
302
303 if (!node.isNull() && node.isElementNode()) {
304 WebKit::WebElement element = node.to<WebKit::WebElement>();
305 attributes[ATTR_HTML_TAG] = element.tagName();
306 for (unsigned i = 0; i < element.attributes().length(); i++) {
307 html_attributes.push_back(
308 std::pair<string16, string16>(
309 element.attributes().attributeItem(i).localName(),
310 element.attributes().attributeItem(i).value()));
311 }
312 }
313
314 if (role == WebAccessibility::ROLE_DOCUMENT ||
315 role == WebAccessibility::ROLE_WEB_AREA) {
316 WebKit::WebDocument document = src.document();
317 attributes[ATTR_DOC_TITLE] = document.title();
318 attributes[ATTR_DOC_URL] = document.frame()->url().spec().utf16();
319 if (document.isXHTMLDocument())
320 attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/xhtml");
321 else
322 attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/html");
323
324 WebKit::WebDocumentType doctype = document.doctype();
325 if (!doctype.isNull())
326 attributes[ATTR_DOC_DOCTYPE] = doctype.name();
327 }
291 328
292 // Add the source object to the cache and store its id. 329 // Add the source object to the cache and store its id.
293 id = cache->addOrGetId(src); 330 id = cache->addOrGetId(src);
294 331
295 // Recursively create children. 332 // Recursively create children.
296 int child_count = src.childCount(); 333 int child_count = src.childCount();
297 children.resize(child_count); 334 children.resize(child_count);
298 for (int i = 0; i < child_count; i++) { 335 for (int i = 0; i < child_count; i++) {
299 children[i].Init(src.childAt(i), cache); 336 children[i].Init(src.childAt(i), cache);
300 } 337 }
301 } 338 }
302 339
303 } // namespace webkit_glue 340 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webaccessibility.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698