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

Side by Side Diff: content/browser/accessibility/dump_accessibility_tree_helper.cc

Issue 10823073: Improve accessible name calculation on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/accessibility/dump_accessibility_tree_helper.h" 5 #include "content/browser/accessibility/dump_accessibility_tree_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 10
11 namespace { 11 namespace {
12 const int kIndentSpaces = 4; 12 const int kIndentSpaces = 4;
13 const char* kSkipString = "@NO_DUMP";
13 } 14 }
14 15
15 DumpAccessibilityTreeHelper::DumpAccessibilityTreeHelper() { 16 DumpAccessibilityTreeHelper::DumpAccessibilityTreeHelper() {
16 Initialize(); 17 Initialize();
17 } 18 }
18 19
19 DumpAccessibilityTreeHelper::~DumpAccessibilityTreeHelper() { 20 DumpAccessibilityTreeHelper::~DumpAccessibilityTreeHelper() {
20 } 21 }
21 22
22 void DumpAccessibilityTreeHelper::DumpAccessibilityTree( 23 void DumpAccessibilityTreeHelper::DumpAccessibilityTree(
23 BrowserAccessibility* node, string16* contents) { 24 BrowserAccessibility* node, string16* contents) {
24 RecursiveDumpAccessibilityTree(node, contents, 0); 25 RecursiveDumpAccessibilityTree(node, contents, 0);
25 } 26 }
26 27
27 void DumpAccessibilityTreeHelper::RecursiveDumpAccessibilityTree( 28 void DumpAccessibilityTreeHelper::RecursiveDumpAccessibilityTree(
28 BrowserAccessibility* node, string16* contents, int indent) { 29 BrowserAccessibility* node, string16* contents, int indent) {
29 scoped_array<char> prefix(new char[indent + 1]); 30 scoped_array<char> prefix(new char[indent + 1]);
30 for (int i = 0; i < indent; ++i) 31 for (int i = 0; i < indent; ++i)
31 prefix[i] = ' '; 32 prefix[i] = ' ';
32 prefix[indent] = '\0'; 33 prefix[indent] = '\0';
33 34
34 *contents += ToString(node, prefix.get()); 35 string16 line = ToString(node, prefix.get());
36 if (line.find(ASCIIToUTF16(kSkipString)) != string16::npos)
37 return;
38
39 *contents += line;
35 for (size_t i = 0; i < node->children().size(); ++i) { 40 for (size_t i = 0; i < node->children().size(); ++i) {
36 RecursiveDumpAccessibilityTree(node->children()[i], contents, 41 RecursiveDumpAccessibilityTree(node->children()[i], contents,
37 indent + kIndentSpaces); 42 indent + kIndentSpaces);
38 } 43 }
39 } 44 }
40 45
41 void DumpAccessibilityTreeHelper::SetFilters( 46 void DumpAccessibilityTreeHelper::SetFilters(
42 const std::set<string16>& allow_filters, 47 const std::set<string16>& allow_filters,
43 const std::set<string16>& deny_filters) { 48 const std::set<string16>& deny_filters) {
44 allow_filters_ = allow_filters; 49 allow_filters_ = allow_filters;
(...skipping 23 matching lines...) Expand all
68 if (!MatchesFilters(attr, include_by_default)) 73 if (!MatchesFilters(attr, include_by_default))
69 return; 74 return;
70 if (!line_.empty()) 75 if (!line_.empty())
71 line_ += ASCIIToUTF16(" "); 76 line_ += ASCIIToUTF16(" ");
72 line_ += attr; 77 line_ += attr;
73 } 78 }
74 79
75 string16 DumpAccessibilityTreeHelper::FinishLine() { 80 string16 DumpAccessibilityTreeHelper::FinishLine() {
76 return line_; 81 return line_;
77 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698