| OLD | NEW |
| 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" | |
| 17 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 10 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
| 18 | 11 |
| 19 using WebKit::WebAccessibilityCache; | 12 using WebKit::WebAccessibilityCache; |
| 20 using WebKit::WebAccessibilityRole; | 13 using WebKit::WebAccessibilityRole; |
| 21 using WebKit::WebAccessibilityObject; | 14 using WebKit::WebAccessibilityObject; |
| 22 | 15 |
| 23 namespace webkit_glue { | 16 namespace webkit_glue { |
| 24 | 17 |
| 25 // Provides a conversion between the WebKit::WebAccessibilityRole and a role | 18 // Provides a conversion between the WebKit::WebAccessibilityRole and a role |
| 26 // supported on the Browser side. Listed alphabetically by the | 19 // supported on the Browser side. Listed alphabetically by the |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 location = src.boundingBoxRect(); | 278 location = src.boundingBoxRect(); |
| 286 | 279 |
| 287 if (src.actionVerb().length()) | 280 if (src.actionVerb().length()) |
| 288 attributes[ATTR_ACTION] = src.actionVerb(); | 281 attributes[ATTR_ACTION] = src.actionVerb(); |
| 289 if (src.accessibilityDescription().length()) | 282 if (src.accessibilityDescription().length()) |
| 290 attributes[ATTR_DESCRIPTION] = src.accessibilityDescription(); | 283 attributes[ATTR_DESCRIPTION] = src.accessibilityDescription(); |
| 291 if (src.helpText().length()) | 284 if (src.helpText().length()) |
| 292 attributes[ATTR_HELP] = src.helpText(); | 285 attributes[ATTR_HELP] = src.helpText(); |
| 293 if (src.keyboardShortcut().length()) | 286 if (src.keyboardShortcut().length()) |
| 294 attributes[ATTR_SHORTCUT] = src.keyboardShortcut(); | 287 attributes[ATTR_SHORTCUT] = src.keyboardShortcut(); |
| 295 if (src.hasComputedStyle()) | |
| 296 attributes[ATTR_DISPLAY] = src.computedStyleDisplay(); | |
| 297 | |
| 298 WebKit::WebNode node = src.node(); | |
| 299 | |
| 300 if (!node.isNull() && node.isElementNode()) { | |
| 301 WebKit::WebElement element = node.to<WebKit::WebElement>(); | |
| 302 attributes[ATTR_HTML_TAG] = element.tagName(); | |
| 303 for (unsigned i = 0; i < element.attributes().length(); i++) { | |
| 304 html_attributes.push_back( | |
| 305 std::pair<string16, string16>( | |
| 306 element.attributes().attributeItem(i).localName(), | |
| 307 element.attributes().attributeItem(i).value())); | |
| 308 } | |
| 309 } | |
| 310 | |
| 311 if (role == WebAccessibility::ROLE_DOCUMENT || | |
| 312 role == WebAccessibility::ROLE_WEB_AREA) { | |
| 313 WebKit::WebDocument document = src.document(); | |
| 314 attributes[ATTR_DOC_TITLE] = document.title(); | |
| 315 attributes[ATTR_DOC_URL] = document.frame()->url().spec().utf16(); | |
| 316 if (document.isXHTMLDocument()) | |
| 317 attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/xhtml"); | |
| 318 else | |
| 319 attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/html"); | |
| 320 attributes[ATTR_DOC_DOCTYPE] = document.doctype().name(); | |
| 321 } | |
| 322 | 288 |
| 323 // Add the source object to the cache and store its id. | 289 // Add the source object to the cache and store its id. |
| 324 id = cache->addOrGetId(src); | 290 id = cache->addOrGetId(src); |
| 325 | 291 |
| 326 // Recursively create children. | 292 // Recursively create children. |
| 327 int child_count = src.childCount(); | 293 int child_count = src.childCount(); |
| 328 children.resize(child_count); | 294 children.resize(child_count); |
| 329 for (int i = 0; i < child_count; i++) { | 295 for (int i = 0; i < child_count; i++) { |
| 330 children[i].Init(src.childAt(i), cache); | 296 children[i].Init(src.childAt(i), cache); |
| 331 } | 297 } |
| 332 } | 298 } |
| 333 | 299 |
| 334 } // namespace webkit_glue | 300 } // namespace webkit_glue |
| OLD | NEW |