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

Side by Side Diff: ui/views/accessibility/native_view_accessibility.h

Issue 2718073003: Views a11y: Convert View's NativeViewAccessibility to a unique_ptr. (Closed)
Patch Set: Fix compile error. Created 3 years, 9 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 #ifndef UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_H_ 5 #ifndef UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_H_
6 #define UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_H_ 6 #define UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_H_
7 7
8 #include <memory>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "build/build_config.h" 11 #include "build/build_config.h"
10 #include "ui/accessibility/ax_action_data.h" 12 #include "ui/accessibility/ax_action_data.h"
11 #include "ui/accessibility/ax_node_data.h" 13 #include "ui/accessibility/ax_node_data.h"
12 #include "ui/accessibility/platform/ax_platform_node.h" 14 #include "ui/accessibility/platform/ax_platform_node.h"
13 #include "ui/accessibility/platform/ax_platform_node_delegate.h" 15 #include "ui/accessibility/platform/ax_platform_node_delegate.h"
14 #include "ui/gfx/native_widget_types.h" 16 #include "ui/gfx/native_widget_types.h"
15 #include "ui/views/views_export.h" 17 #include "ui/views/views_export.h"
16 #include "ui/views/widget/widget_observer.h" 18 #include "ui/views/widget/widget_observer.h"
17 19
(...skipping 15 matching lines...) Expand all
33 35
34 namespace views { 36 namespace views {
35 37
36 class View; 38 class View;
37 class Widget; 39 class Widget;
38 40
39 class VIEWS_EXPORT NativeViewAccessibility 41 class VIEWS_EXPORT NativeViewAccessibility
40 : public ui::AXPlatformNodeDelegate, 42 : public ui::AXPlatformNodeDelegate,
41 public WidgetObserver { 43 public WidgetObserver {
42 public: 44 public:
43 static NativeViewAccessibility* Create(View* view); 45 static std::unique_ptr<NativeViewAccessibility> Create(View* view);
46
47 ~NativeViewAccessibility() override;
44 48
45 gfx::NativeViewAccessible GetNativeObject(); 49 gfx::NativeViewAccessible GetNativeObject();
46 50
47 // Call Destroy rather than deleting this, because the subclass may
48 // use reference counting.
49 virtual void Destroy();
50
51 void NotifyAccessibilityEvent(ui::AXEvent event_type); 51 void NotifyAccessibilityEvent(ui::AXEvent event_type);
52 52
53 // Focuses or unfocuses a View. 53 // Focuses or unfocuses a View.
54 bool SetFocused(bool focused); 54 bool SetFocused(bool focused);
55 55
56 // ui::AXPlatformNodeDelegate 56 // ui::AXPlatformNodeDelegate
57 const ui::AXNodeData& GetData() override; 57 const ui::AXNodeData& GetData() override;
58 int GetChildCount() override; 58 int GetChildCount() override;
59 gfx::NativeViewAccessible ChildAtIndex(int index) override; 59 gfx::NativeViewAccessible ChildAtIndex(int index) override;
60 gfx::NativeWindow GetTopLevelWidget() override; 60 gfx::NativeWindow GetTopLevelWidget() override;
61 gfx::NativeViewAccessible GetParent() override; 61 gfx::NativeViewAccessible GetParent() override;
62 gfx::Vector2d GetGlobalCoordinateOffset() override; 62 gfx::Vector2d GetGlobalCoordinateOffset() override;
63 gfx::NativeViewAccessible HitTestSync(int x, int y) override; 63 gfx::NativeViewAccessible HitTestSync(int x, int y) override;
64 gfx::NativeViewAccessible GetFocus() override; 64 gfx::NativeViewAccessible GetFocus() override;
65 gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override; 65 gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override;
66 bool AccessibilityPerformAction(const ui::AXActionData& data) override; 66 bool AccessibilityPerformAction(const ui::AXActionData& data) override;
67 void DoDefaultAction() override; 67 void DoDefaultAction() override;
68 68
69 // WidgetObserver 69 // WidgetObserver
70 void OnWidgetDestroying(Widget* widget) override; 70 void OnWidgetDestroying(Widget* widget) override;
71 71
72 Widget* parent_widget() const { return parent_widget_; } 72 Widget* parent_widget() const { return parent_widget_; }
73 void SetParentWidget(Widget* parent_widget); 73 void SetParentWidget(Widget* parent_widget);
74 74
75 protected: 75 protected:
76 NativeViewAccessibility(View* view); 76 NativeViewAccessibility(View* view);
tapted 2017/02/28 06:29:12 nit: this should be declared explicit..
Patti Lor 2017/02/28 22:24:24 Thanks for always picking these up, I always miss
77 ~NativeViewAccessibility() override;
78 77
79 // Weak. Owns this. 78 // Weak. Owns this.
80 View* view_; 79 View* view_;
81 80
82 // Weak. Uses WidgetObserver to clear. This is set on the root view for 81 // Weak. Uses WidgetObserver to clear. This is set on the root view for
83 // a widget that's owned by another widget, so we can walk back up the 82 // a widget that's owned by another widget, so we can walk back up the
84 // tree. 83 // tree.
85 Widget* parent_widget_; 84 Widget* parent_widget_;
86 85
87 private: 86 private:
88 void PopulateChildWidgetVector(std::vector<Widget*>* result_child_widgets); 87 void PopulateChildWidgetVector(std::vector<Widget*>* result_child_widgets);
89 88
90 // We own this, but it is reference-counted on some platforms so we can't use 89 // We own this, but it is reference-counted on some platforms so we can't use
91 // a scoped_ptr. It is dereferenced in the destructor. 90 // a scoped_ptr. It is dereferenced in the destructor.
92 ui::AXPlatformNode* ax_node_; 91 ui::AXPlatformNode* ax_node_;
93 92
94 ui::AXNodeData data_; 93 ui::AXNodeData data_;
95 94
96 DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibility); 95 DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibility);
97 }; 96 };
98 97
99 } // namespace views 98 } // namespace views
100 99
101 #endif // UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_H_ 100 #endif // UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698