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