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

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

Issue 4292001: Add basic support for accessibility hit testing within web contents.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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
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 "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h" 10 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h"
11 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h" 11 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityRole.h" 12 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityRole.h"
13 #include "third_party/WebKit/WebKit/chromium/public/WebAttribute.h" 13 #include "third_party/WebKit/WebKit/chromium/public/WebAttribute.h"
14 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" 14 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
15 #include "third_party/WebKit/WebKit/chromium/public/WebDocumentType.h" 15 #include "third_party/WebKit/WebKit/chromium/public/WebDocumentType.h"
16 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" 16 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
17 #include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h" 17 #include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h"
18 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" 18 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
19 #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" 19 #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h"
20 #include "third_party/WebKit/WebKit/chromium/public/WebNamedNodeMap.h" 20 #include "third_party/WebKit/WebKit/chromium/public/WebNamedNodeMap.h"
21 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" 21 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h"
22 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h"
22 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 23 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
23 24
24 using WebKit::WebAccessibilityCache; 25 using WebKit::WebAccessibilityCache;
25 using WebKit::WebAccessibilityRole; 26 using WebKit::WebAccessibilityRole;
26 using WebKit::WebAccessibilityObject; 27 using WebKit::WebAccessibilityObject;
27 28
28 namespace webkit_glue { 29 namespace webkit_glue {
29 30
30 // Provides a conversion between the WebKit::WebAccessibilityRole and a role 31 // Provides a conversion between the WebKit::WebAccessibilityRole and a role
31 // supported on the Browser side. Listed alphabetically by the 32 // supported on the Browser side. Listed alphabetically by the
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 attributes[ATTR_DOC_TITLE] = document.title(); 360 attributes[ATTR_DOC_TITLE] = document.title();
360 attributes[ATTR_DOC_URL] = document.frame()->url().spec().utf16(); 361 attributes[ATTR_DOC_URL] = document.frame()->url().spec().utf16();
361 if (document.isXHTMLDocument()) 362 if (document.isXHTMLDocument())
362 attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/xhtml"); 363 attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/xhtml");
363 else 364 else
364 attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/html"); 365 attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/html");
365 366
366 const WebKit::WebDocumentType& doctype = document.doctype(); 367 const WebKit::WebDocumentType& doctype = document.doctype();
367 if (!doctype.isNull()) 368 if (!doctype.isNull())
368 attributes[ATTR_DOC_DOCTYPE] = doctype.name(); 369 attributes[ATTR_DOC_DOCTYPE] = doctype.name();
370
371 const gfx::Size& scroll_offset = document.frame()->scrollOffset();
372 attributes[ATTR_DOC_SCROLLX] = base::IntToString16(scroll_offset.width());
373 attributes[ATTR_DOC_SCROLLY] = base::IntToString16(scroll_offset.height());
369 } 374 }
370 375
371 // Add the source object to the cache and store its id. 376 // Add the source object to the cache and store its id.
372 id = cache->addOrGetId(src); 377 id = cache->addOrGetId(src);
373 378
374 // Recursively create children. 379 // Recursively create children.
375 int child_count = src.childCount(); 380 int child_count = src.childCount();
376 for (int i = 0; i < child_count; i++) { 381 for (int i = 0; i < child_count; i++) {
377 WebAccessibilityObject child = src.childAt(i); 382 WebAccessibilityObject child = src.childAt(i);
378 383
379 // The child may be invalid due to issues in webkit accessibility code. 384 // The child may be invalid due to issues in webkit accessibility code.
380 // Don't add children are invalid thus preventing a crash. 385 // Don't add children are invalid thus preventing a crash.
381 // https://bugs.webkit.org/show_bug.cgi?id=44149 386 // https://bugs.webkit.org/show_bug.cgi?id=44149
382 // TODO(ctguil): We may want to remove this check as webkit stabilizes. 387 // TODO(ctguil): We may want to remove this check as webkit stabilizes.
383 if (child.isValid()) 388 if (child.isValid())
384 children.push_back(WebAccessibility(child, cache)); 389 children.push_back(WebAccessibility(child, cache));
385 } 390 }
386 } 391 }
387 392
388 } // namespace webkit_glue 393 } // namespace webkit_glue
OLDNEW
« chrome/browser/accessibility/browser_accessibility.h ('K') | « webkit/glue/webaccessibility.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698