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

Side by Side Diff: ui/views/accessibility/native_view_accessibility_base.cc

Issue 2860883003: A11y: Add/refactor methods for manipulating bitfields on AXNodeData. (Closed)
Patch Set: Revert comment. Created 3 years, 7 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/views/accessibility/native_view_accessibility_base.h" 5 #include "ui/views/accessibility/native_view_accessibility_base.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "ui/events/event_utils.h" 9 #include "ui/events/event_utils.h"
10 #include "ui/gfx/native_widget_types.h" 10 #include "ui/gfx/native_widget_types.h"
(...skipping 22 matching lines...) Expand all
33 33
34 void NativeViewAccessibilityBase::NotifyAccessibilityEvent( 34 void NativeViewAccessibilityBase::NotifyAccessibilityEvent(
35 ui::AXEvent event_type) { 35 ui::AXEvent event_type) {
36 ax_node_->NotifyAccessibilityEvent(event_type); 36 ax_node_->NotifyAccessibilityEvent(event_type);
37 } 37 }
38 38
39 // ui::AXPlatformNodeDelegate 39 // ui::AXPlatformNodeDelegate
40 40
41 const ui::AXNodeData& NativeViewAccessibilityBase::GetData() const { 41 const ui::AXNodeData& NativeViewAccessibilityBase::GetData() const {
42 data_ = ui::AXNodeData(); 42 data_ = ui::AXNodeData();
43 data_.state = 0; 43 data_.ClearBitfields();
44 44
45 // Views may misbehave if their widget is closed; return an unknown role 45 // Views may misbehave if their widget is closed; return an unknown role
46 // rather than possibly crashing. 46 // rather than possibly crashing.
47 if (!view_->GetWidget() || view_->GetWidget()->IsClosed()) { 47 if (!view_->GetWidget() || view_->GetWidget()->IsClosed()) {
48 data_.role = ui::AX_ROLE_UNKNOWN; 48 data_.role = ui::AX_ROLE_UNKNOWN;
49 data_.state = 1 << ui::AX_STATE_DISABLED; 49 data_.AddState(ui::AX_STATE_DISABLED);
50 return data_; 50 return data_;
51 } 51 }
52 52
53 view_->GetAccessibleNodeData(&data_); 53 view_->GetAccessibleNodeData(&data_);
54 data_.location = GetBoundsInScreen(); 54 data_.location = GetBoundsInScreen();
55 base::string16 description; 55 base::string16 description;
56 view_->GetTooltipText(gfx::Point(), &description); 56 view_->GetTooltipText(gfx::Point(), &description);
57 data_.AddStringAttribute(ui::AX_ATTR_DESCRIPTION, 57 data_.AddStringAttribute(ui::AX_ATTR_DESCRIPTION,
58 base::UTF16ToUTF8(description)); 58 base::UTF16ToUTF8(description));
59 59
60 if (view_->IsAccessibilityFocusable()) 60 if (view_->IsAccessibilityFocusable())
61 data_.state |= (1 << ui::AX_STATE_FOCUSABLE); 61 data_.AddState(ui::AX_STATE_FOCUSABLE);
62 62
63 if (!view_->enabled()) 63 if (!view_->enabled())
64 data_.state |= (1 << ui::AX_STATE_DISABLED); 64 data_.AddState(ui::AX_STATE_DISABLED);
65 65
66 if (!view_->IsDrawn()) 66 if (!view_->IsDrawn())
67 data_.state |= (1 << ui::AX_STATE_INVISIBLE); 67 data_.AddState(ui::AX_STATE_INVISIBLE);
68 68
69 return data_; 69 return data_;
70 } 70 }
71 71
72 int NativeViewAccessibilityBase::GetChildCount() { 72 int NativeViewAccessibilityBase::GetChildCount() {
73 int child_count = view_->child_count(); 73 int child_count = view_->child_count();
74 74
75 std::vector<Widget*> child_widgets; 75 std::vector<Widget*> child_widgets;
76 PopulateChildWidgetVector(&child_widgets); 76 PopulateChildWidgetVector(&child_widgets);
77 child_count += child_widgets.size(); 77 child_count += child_widgets.size();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 child_widget_platform_node->GetDelegate()); 220 child_widget_platform_node->GetDelegate());
221 if (child_widget_view_accessibility->parent_widget() != widget) 221 if (child_widget_view_accessibility->parent_widget() != widget)
222 child_widget_view_accessibility->SetParentWidget(widget); 222 child_widget_view_accessibility->SetParentWidget(widget);
223 } 223 }
224 224
225 result_child_widgets->push_back(child_widget); 225 result_child_widgets->push_back(child_widget);
226 } 226 }
227 } 227 }
228 228
229 } // namespace views 229 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698