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

Side by Side Diff: ui/accessibility/ax_text_utils.cc

Issue 2518183002: Moved action verbs out of Blink. (Closed)
Patch Set: Added missing braces. Created 4 years 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
« no previous file with comments | « ui/accessibility/ax_text_utils.h ('k') | ui/accessibility/ax_tree_combiner.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/accessibility/ax_text_utils.h" 5 #include "ui/accessibility/ax_text_utils.h"
6 6
7 #include "base/i18n/break_iterator.h" 7 #include "base/i18n/break_iterator.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "ui/base/l10n/l10n_util.h"
12 #include "ui/strings/grit/ui_strings.h"
10 13
11 namespace ui { 14 namespace ui {
12 15
13 // line_breaks is a Misnomer. Blink provides the start offsets of each line 16 // line_breaks is a Misnomer. Blink provides the start offsets of each line
14 // not the line breaks. 17 // not the line breaks.
15 // TODO(nektar): Rename line_breaks a11y attribute and variable references. 18 // TODO(nektar): Rename line_breaks a11y attribute and variable references.
16 size_t FindAccessibleTextBoundary(const base::string16& text, 19 size_t FindAccessibleTextBoundary(const base::string16& text,
17 const std::vector<int>& line_breaks, 20 const std::vector<int>& line_breaks,
18 TextBoundaryType boundary, 21 TextBoundaryType boundary,
19 size_t start_offset, 22 size_t start_offset,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 108 }
106 109
107 if (direction == FORWARDS_DIRECTION) { 110 if (direction == FORWARDS_DIRECTION) {
108 result++; 111 result++;
109 } else { 112 } else {
110 result--; 113 result--;
111 } 114 }
112 } 115 }
113 } 116 }
114 117
118 base::string16 ActionToString(const AXSupportedAction supported_action) {
119 switch (supported_action) {
120 case AX_SUPPORTED_ACTION_NONE:
121 return base::string16();
122 case AX_SUPPORTED_ACTION_ACTIVATE:
123 return l10n_util::GetStringUTF16(IDS_AX_ACTIVATE_ACTION_VERB);
124 case AX_SUPPORTED_ACTION_CHECK:
125 return l10n_util::GetStringUTF16(IDS_AX_CHECK_ACTION_VERB);
126 case AX_SUPPORTED_ACTION_CLICK:
127 return l10n_util::GetStringUTF16(IDS_AX_CLICK_ACTION_VERB);
128 case AX_SUPPORTED_ACTION_JUMP:
129 return l10n_util::GetStringUTF16(IDS_AX_JUMP_ACTION_VERB);
130 case AX_SUPPORTED_ACTION_OPEN:
131 return l10n_util::GetStringUTF16(IDS_AX_OPEN_ACTION_VERB);
132 case AX_SUPPORTED_ACTION_PRESS:
133 return l10n_util::GetStringUTF16(IDS_AX_PRESS_ACTION_VERB);
134 case AX_SUPPORTED_ACTION_SELECT:
135 return l10n_util::GetStringUTF16(IDS_AX_SELECT_ACTION_VERB);
136 case AX_SUPPORTED_ACTION_UNCHECK:
137 return l10n_util::GetStringUTF16(IDS_AX_UNCHECK_ACTION_VERB);
138 }
139 NOTREACHED();
140 return base::string16();
141 }
142
143 // Some APIs on Linux and Windows need to return non-localized action names.
144 base::string16 ActionToUnlocalizedString(
145 const AXSupportedAction supported_action) {
146 switch (supported_action) {
147 case ui::AX_SUPPORTED_ACTION_NONE:
148 return base::UTF8ToUTF16("none");
149 case ui::AX_SUPPORTED_ACTION_ACTIVATE:
150 return base::UTF8ToUTF16("activate");
151 case ui::AX_SUPPORTED_ACTION_CHECK:
152 return base::UTF8ToUTF16("check");
153 case ui::AX_SUPPORTED_ACTION_CLICK:
154 return base::UTF8ToUTF16("click");
155 case ui::AX_SUPPORTED_ACTION_JUMP:
156 return base::UTF8ToUTF16("jump");
157 case ui::AX_SUPPORTED_ACTION_OPEN:
158 return base::UTF8ToUTF16("open");
159 case ui::AX_SUPPORTED_ACTION_PRESS:
160 return base::UTF8ToUTF16("press");
161 case ui::AX_SUPPORTED_ACTION_SELECT:
162 return base::UTF8ToUTF16("select");
163 case ui::AX_SUPPORTED_ACTION_UNCHECK:
164 return base::UTF8ToUTF16("uncheck");
165 }
166 NOTREACHED();
167 return base::string16();
168 }
169
115 } // namespace ui 170 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/ax_text_utils.h ('k') | ui/accessibility/ax_tree_combiner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698