OLD | NEW |
---|---|
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 "base/macros.h" | 8 #include "base/macros.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "ui/accessibility/ax_action_data.h" | 10 #include "ui/accessibility/ax_action_data.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 | 33 |
34 namespace views { | 34 namespace views { |
35 | 35 |
36 class View; | 36 class View; |
37 class Widget; | 37 class Widget; |
38 | 38 |
39 class VIEWS_EXPORT NativeViewAccessibility | 39 class VIEWS_EXPORT NativeViewAccessibility |
40 : public ui::AXPlatformNodeDelegate, | 40 : public ui::AXPlatformNodeDelegate, |
41 public WidgetObserver { | 41 public WidgetObserver { |
42 public: | 42 public: |
43 static NativeViewAccessibility* Create(View* view); | 43 // A method for View to create a new NativeViewAccessibility instance for the |
44 // given View. To retrieve an instance for |view|, use GetForView() instead. | |
45 static std::unique_ptr<NativeViewAccessibility> CreateForView(View* view); | |
tapted
2017/02/21 06:01:11
Let's move the unique_ptr/Destroy/CreateForView ch
Patti Lor
2017/02/27 05:31:04
Done.
| |
46 | |
47 // Retrieves the NativeViewAccessibility instance for the given View. This | |
48 // calls CreateForView() if it doesn't yet exist. | |
tapted
2017/02/21 06:01:11
Can we instead say "Invokes View::GetNativeViewAcc
Patti Lor
2017/02/27 05:31:04
Done.
| |
49 static NativeViewAccessibility* GetForView(View* view); | |
50 | |
51 ~NativeViewAccessibility() override; | |
44 | 52 |
45 gfx::NativeViewAccessible GetNativeObject(); | 53 gfx::NativeViewAccessible GetNativeObject(); |
46 | 54 |
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); | 55 void NotifyAccessibilityEvent(ui::AXEvent event_type); |
52 | 56 |
53 // Focuses or unfocuses a View. | 57 // Focuses or unfocuses a View. |
54 bool SetFocused(bool focused); | 58 bool SetFocused(bool focused); |
55 | 59 |
56 // ui::AXPlatformNodeDelegate | 60 // ui::AXPlatformNodeDelegate |
57 const ui::AXNodeData& GetData() override; | 61 const ui::AXNodeData& GetData() override; |
58 int GetChildCount() override; | 62 int GetChildCount() override; |
59 gfx::NativeViewAccessible ChildAtIndex(int index) override; | 63 gfx::NativeViewAccessible ChildAtIndex(int index) override; |
60 gfx::NativeWindow GetTopLevelWidget() override; | 64 gfx::NativeWindow GetTopLevelWidget() override; |
61 gfx::NativeViewAccessible GetParent() override; | 65 gfx::NativeViewAccessible GetParent() override; |
62 gfx::Vector2d GetGlobalCoordinateOffset() override; | 66 gfx::Vector2d GetGlobalCoordinateOffset() override; |
63 gfx::NativeViewAccessible HitTestSync(int x, int y) override; | 67 gfx::NativeViewAccessible HitTestSync(int x, int y) override; |
64 gfx::NativeViewAccessible GetFocus() override; | 68 gfx::NativeViewAccessible GetFocus() override; |
65 gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override; | 69 gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override; |
66 bool AccessibilityPerformAction(const ui::AXActionData& data) override; | 70 bool AccessibilityPerformAction(const ui::AXActionData& data) override; |
67 void DoDefaultAction() override; | 71 void DoDefaultAction() override; |
68 | 72 |
69 // WidgetObserver | 73 // WidgetObserver |
70 void OnWidgetDestroying(Widget* widget) override; | 74 void OnWidgetDestroying(Widget* widget) override; |
71 | 75 |
72 Widget* parent_widget() const { return parent_widget_; } | 76 Widget* parent_widget() const { return parent_widget_; } |
73 void SetParentWidget(Widget* parent_widget); | 77 void SetParentWidget(Widget* parent_widget); |
74 | 78 |
75 protected: | 79 protected: |
76 NativeViewAccessibility(View* view); | 80 NativeViewAccessibility(View* view); |
77 ~NativeViewAccessibility() override; | |
78 | 81 |
79 // Weak. Owns this. | 82 // Weak. Owns this. |
80 View* view_; | 83 View* view_; |
81 | 84 |
82 // Weak. Uses WidgetObserver to clear. This is set on the root view for | 85 // 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 | 86 // a widget that's owned by another widget, so we can walk back up the |
84 // tree. | 87 // tree. |
85 Widget* parent_widget_; | 88 Widget* parent_widget_; |
86 | 89 |
87 private: | 90 private: |
91 // Creates new platform-specific NativeViewAccessibility subclass instances. | |
92 static NativeViewAccessibility* Create(View* view); | |
93 | |
88 void PopulateChildWidgetVector(std::vector<Widget*>* result_child_widgets); | 94 void PopulateChildWidgetVector(std::vector<Widget*>* result_child_widgets); |
89 | 95 |
90 // We own this, but it is reference-counted on some platforms so we can't use | 96 // 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. | 97 // a scoped_ptr. It is dereferenced in the destructor. |
92 ui::AXPlatformNode* ax_node_; | 98 ui::AXPlatformNode* ax_node_; |
93 | 99 |
94 ui::AXNodeData data_; | 100 ui::AXNodeData data_; |
95 | 101 |
96 DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibility); | 102 DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibility); |
97 }; | 103 }; |
98 | 104 |
99 } // namespace views | 105 } // namespace views |
100 | 106 |
101 #endif // UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_H_ | 107 #endif // UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_H_ |
OLD | NEW |