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

Side by Side Diff: ui/accessibility/platform/ax_platform_node_base.cc

Issue 2933353002: Forward four more BrowserAccessibility APIs to AXPlatformNode. (Closed)
Patch Set: Use SkColor.h instead Created 3 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/platform/ax_platform_node_base.h" 5 #include "ui/accessibility/platform/ax_platform_node_base.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/accessibility/ax_action_data.h" 8 #include "ui/accessibility/ax_action_data.h"
9 #include "ui/accessibility/ax_node_data.h" 9 #include "ui/accessibility/ax_node_data.h"
10 #include "ui/accessibility/platform/ax_platform_node_delegate.h" 10 #include "ui/accessibility/platform/ax_platform_node_delegate.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 bool AXPlatformNodeBase::SetTextSelection(int start_offset, int end_offset) { 206 bool AXPlatformNodeBase::SetTextSelection(int start_offset, int end_offset) {
207 ui::AXActionData action_data; 207 ui::AXActionData action_data;
208 action_data.action = ui::AX_ACTION_SET_SELECTION; 208 action_data.action = ui::AX_ACTION_SET_SELECTION;
209 action_data.anchor_node_id = action_data.focus_node_id = GetData().id; 209 action_data.anchor_node_id = action_data.focus_node_id = GetData().id;
210 action_data.anchor_offset = start_offset; 210 action_data.anchor_offset = start_offset;
211 action_data.focus_offset = end_offset; 211 action_data.focus_offset = end_offset;
212 DCHECK(delegate_); 212 DCHECK(delegate_);
213 return delegate_->AccessibilityPerformAction(action_data); 213 return delegate_->AccessibilityPerformAction(action_data);
214 } 214 }
215 215
216 bool AXPlatformNodeBase::IsTextOnlyObject() const {
217 return GetData().role == ui::AX_ROLE_STATIC_TEXT ||
218 GetData().role == ui::AX_ROLE_LINE_BREAK ||
219 GetData().role == ui::AX_ROLE_INLINE_TEXT_BOX;
220 }
221
222 bool AXPlatformNodeBase::IsNativeTextControl() const {
223 const std::string& html_tag = GetStringAttribute(ui::AX_ATTR_HTML_TAG);
224 if (html_tag == "input") {
225 std::string input_type;
226 if (!GetData().GetHtmlAttribute("type", &input_type))
227 return true;
228 return input_type.empty() || input_type == "email" ||
229 input_type == "password" || input_type == "search" ||
230 input_type == "tel" || input_type == "text" || input_type == "url" ||
231 input_type == "number";
232 }
233 return html_tag == "textarea";
234 }
235
236 bool AXPlatformNodeBase::IsSimpleTextControl() const {
237 // Time fields, color wells and spinner buttons might also use text fields as
238 // constituent parts, but they are not considered text fields as a whole.
239 switch (GetData().role) {
240 case ui::AX_ROLE_COMBO_BOX:
241 case ui::AX_ROLE_SEARCH_BOX:
242 return true;
243 case ui::AX_ROLE_TEXT_FIELD:
244 return !GetData().HasState(ui::AX_STATE_RICHLY_EDITABLE);
245 default:
246 return false;
247 }
248 }
249
250 // Indicates if this object is at the root of a rich edit text control.
251 bool AXPlatformNodeBase::IsRichTextControl() {
252 gfx::NativeViewAccessible parent_accessible = GetParent();
253 AXPlatformNodeBase* parent = FromNativeViewAccessible(parent_accessible);
254 if (!parent)
255 return false;
256
257 return GetData().HasState(ui::AX_STATE_RICHLY_EDITABLE) &&
258 (!parent || !parent->GetData().HasState(ui::AX_STATE_RICHLY_EDITABLE));
259 }
260
261 base::string16 AXPlatformNodeBase::GetInnerText() {
262 if (IsTextOnlyObject())
263 return GetString16Attribute(ui::AX_ATTR_NAME);
264
265 base::string16 text;
266 for (int i = 0; i < GetChildCount(); ++i) {
267 gfx::NativeViewAccessible child_accessible = ChildAtIndex(i);
268 AXPlatformNodeBase* child = FromNativeViewAccessible(child_accessible);
269 if (!child)
270 continue;
271
272 text += child->GetInnerText();
273 }
274 return text;
275 }
276
277 bool AXPlatformNodeBase::IsRangeValueSupported() const {
278 switch (GetData().role) {
279 case ui::AX_ROLE_PROGRESS_INDICATOR:
280 case ui::AX_ROLE_SLIDER:
281 case ui::AX_ROLE_SPIN_BUTTON:
282 case ui::AX_ROLE_SCROLL_BAR:
283 return true;
284 case ui::AX_ROLE_SPLITTER:
285 return GetData().HasState(ui::AX_STATE_FOCUSABLE);
286 default:
287 return false;
288 }
289 }
290
216 } // namespace ui 291 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_base.h ('k') | ui/accessibility/platform/ax_platform_node_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698