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

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: Delete AXNodeData::Init() and clear bitfields in AXNodeData() instead. 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;
44 43
45 // Views may misbehave if their widget is closed; return an unknown role 44 // Views may misbehave if their widget is closed; return an unknown role
46 // rather than possibly crashing. 45 // rather than possibly crashing.
47 if (!view_->GetWidget() || view_->GetWidget()->IsClosed()) { 46 if (!view_->GetWidget() || view_->GetWidget()->IsClosed()) {
48 data_.role = ui::AX_ROLE_UNKNOWN; 47 data_.role = ui::AX_ROLE_UNKNOWN;
49 data_.state = 1 << ui::AX_STATE_DISABLED; 48 data_.AddState(ui::AX_STATE_DISABLED);
50 return data_; 49 return data_;
51 } 50 }
52 51
53 view_->GetAccessibleNodeData(&data_); 52 view_->GetAccessibleNodeData(&data_);
54 data_.location = GetBoundsInScreen(); 53 data_.location = GetBoundsInScreen();
55 base::string16 description; 54 base::string16 description;
56 view_->GetTooltipText(gfx::Point(), &description); 55 view_->GetTooltipText(gfx::Point(), &description);
57 data_.AddStringAttribute(ui::AX_ATTR_DESCRIPTION, 56 data_.AddStringAttribute(ui::AX_ATTR_DESCRIPTION,
58 base::UTF16ToUTF8(description)); 57 base::UTF16ToUTF8(description));
59 58
60 if (view_->IsAccessibilityFocusable()) 59 if (view_->IsAccessibilityFocusable())
61 data_.state |= (1 << ui::AX_STATE_FOCUSABLE); 60 data_.AddState(ui::AX_STATE_FOCUSABLE);
62 61
63 if (!view_->enabled()) 62 if (!view_->enabled())
64 data_.state |= (1 << ui::AX_STATE_DISABLED); 63 data_.AddState(ui::AX_STATE_DISABLED);
65 64
66 if (!view_->IsDrawn()) 65 if (!view_->IsDrawn())
67 data_.state |= (1 << ui::AX_STATE_INVISIBLE); 66 data_.AddState(ui::AX_STATE_INVISIBLE);
68 67
69 return data_; 68 return data_;
70 } 69 }
71 70
72 int NativeViewAccessibilityBase::GetChildCount() { 71 int NativeViewAccessibilityBase::GetChildCount() {
73 int child_count = view_->child_count(); 72 int child_count = view_->child_count();
74 73
75 std::vector<Widget*> child_widgets; 74 std::vector<Widget*> child_widgets;
76 PopulateChildWidgetVector(&child_widgets); 75 PopulateChildWidgetVector(&child_widgets);
77 child_count += child_widgets.size(); 76 child_count += child_widgets.size();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 child_widget_platform_node->GetDelegate()); 219 child_widget_platform_node->GetDelegate());
221 if (child_widget_view_accessibility->parent_widget() != widget) 220 if (child_widget_view_accessibility->parent_widget() != widget)
222 child_widget_view_accessibility->SetParentWidget(widget); 221 child_widget_view_accessibility->SetParentWidget(widget);
223 } 222 }
224 223
225 result_child_widgets->push_back(child_widget); 224 result_child_widgets->push_back(child_widget);
226 } 225 }
227 } 226 }
228 227
229 } // namespace views 228 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698