| 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_BASE_H_ | 5 #ifndef UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_BASE_H_ |
| 6 #define UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_BASE_H_ | 6 #define UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_BASE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "ui/accessibility/ax_action_data.h" | 12 #include "ui/accessibility/ax_action_data.h" |
| 13 #include "ui/accessibility/ax_node_data.h" | 13 #include "ui/accessibility/ax_node_data.h" |
| 14 #include "ui/accessibility/platform/ax_platform_node.h" | 14 #include "ui/accessibility/platform/ax_platform_node.h" |
| 15 #include "ui/accessibility/platform/ax_platform_node_delegate.h" | 15 #include "ui/accessibility/platform/ax_platform_node_delegate.h" |
| 16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 17 #include "ui/views/accessibility/native_view_accessibility.h" | 17 #include "ui/views/accessibility/native_view_accessibility.h" |
| 18 #include "ui/views/views_export.h" | 18 #include "ui/views/views_export.h" |
| 19 #include "ui/views/widget/widget_observer.h" | 19 #include "ui/views/widget/widget_observer.h" |
| 20 | 20 |
| 21 namespace views { | 21 namespace views { |
| 22 | 22 |
| 23 namespace test { |
| 24 class NativeViewAccessibilityBaseIgnoredElementsTest; |
| 25 } |
| 26 |
| 23 class View; | 27 class View; |
| 24 class Widget; | 28 class Widget; |
| 25 | 29 |
| 26 // Shared base class for platforms that require an implementation of | 30 // Shared base class for platforms that require an implementation of |
| 27 // NativeViewAccessibility to interface with the native accessibility toolkit. | 31 // NativeViewAccessibility to interface with the native accessibility toolkit. |
| 28 class VIEWS_EXPORT NativeViewAccessibilityBase | 32 class VIEWS_EXPORT NativeViewAccessibilityBase |
| 29 : public NativeViewAccessibility, | 33 : public NativeViewAccessibility, |
| 30 public ui::AXPlatformNodeDelegate, | 34 public ui::AXPlatformNodeDelegate, |
| 31 public WidgetObserver { | 35 public WidgetObserver { |
| 32 public: | 36 public: |
| 37 // Convenience method for checking if a View should be ignored by a11y. |
| 38 static bool IsIgnoredView(View* view); |
| 39 |
| 33 ~NativeViewAccessibilityBase() override; | 40 ~NativeViewAccessibilityBase() override; |
| 34 | 41 |
| 35 // NativeViewAccessibility: | 42 // NativeViewAccessibility: |
| 36 gfx::NativeViewAccessible GetNativeObject() override; | 43 gfx::NativeViewAccessible GetNativeObject() override; |
| 37 void NotifyAccessibilityEvent(ui::AXEvent event_type) override; | 44 void NotifyAccessibilityEvent(ui::AXEvent event_type) override; |
| 38 | 45 |
| 39 // ui::AXPlatformNodeDelegate | 46 // ui::AXPlatformNodeDelegate |
| 40 const ui::AXNodeData& GetData() const override; | 47 const ui::AXNodeData& GetData() const override; |
| 41 int GetChildCount() override; | 48 int GetChildCount() override; |
| 42 gfx::NativeViewAccessible ChildAtIndex(int index) override; | 49 gfx::NativeViewAccessible ChildAtIndex(int index) override; |
| 43 gfx::NativeWindow GetTopLevelWidget() override; | 50 gfx::NativeWindow GetTopLevelWidget() override; |
| 44 gfx::NativeViewAccessible GetParent() override; | 51 gfx::NativeViewAccessible GetParent() override; |
| 45 gfx::Rect GetScreenBoundsRect() const override; | 52 gfx::Rect GetScreenBoundsRect() const override; |
| 46 gfx::NativeViewAccessible HitTestSync(int x, int y) override; | 53 gfx::NativeViewAccessible HitTestSync(int x, int y) override; |
| 47 gfx::NativeViewAccessible GetFocus() override; | 54 gfx::NativeViewAccessible GetFocus() override; |
| 48 gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override; | 55 gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override; |
| 49 bool AccessibilityPerformAction(const ui::AXActionData& data) override; | 56 bool AccessibilityPerformAction(const ui::AXActionData& data) override; |
| 50 | 57 |
| 51 // WidgetObserver | 58 // WidgetObserver |
| 52 void OnWidgetDestroying(Widget* widget) override; | 59 void OnWidgetDestroying(Widget* widget) override; |
| 53 | 60 |
| 54 Widget* parent_widget() const { return parent_widget_; } | 61 Widget* parent_widget() const { return parent_widget_; } |
| 55 void SetParentWidget(Widget* parent_widget); | 62 void SetParentWidget(Widget* parent_widget); |
| 56 | 63 |
| 57 protected: | 64 protected: |
| 65 friend class test::NativeViewAccessibilityBaseIgnoredElementsTest; |
| 66 |
| 67 // Retrieves the NativeViewAccessibility instance for the given View. This |
| 68 // invokes View::GetNativeViewAccessible() to ensure it exists. |
| 69 static NativeViewAccessibilityBase* GetForView(View* view); |
| 70 |
| 58 explicit NativeViewAccessibilityBase(View* view); | 71 explicit NativeViewAccessibilityBase(View* view); |
| 59 | 72 |
| 73 // Retrieves the gfx::NativeViewAccessibility for |view_|'s Widget/Rootview. |
| 74 virtual gfx::NativeViewAccessible GetNativeViewAccessibleForWidget(); |
| 75 |
| 60 // Weak. Owns this. | 76 // Weak. Owns this. |
| 61 View* view_; | 77 View* view_; |
| 62 | 78 |
| 63 // Weak. Uses WidgetObserver to clear. This is set on the root view for | 79 // Weak. Uses WidgetObserver to clear. This is set on the root view for |
| 64 // a widget that's owned by another widget, so we can walk back up the | 80 // a widget that's owned by another widget, so we can walk back up the |
| 65 // tree. | 81 // tree. |
| 66 Widget* parent_widget_; | 82 Widget* parent_widget_; |
| 67 | 83 |
| 68 protected: | 84 protected: |
| 69 virtual gfx::RectF GetBoundsInScreen() const; | 85 virtual gfx::RectF GetBoundsInScreen() const; |
| 70 | 86 |
| 71 private: | 87 private: |
| 72 void PopulateChildWidgetVector(std::vector<Widget*>* result_child_widgets); | 88 void PopulateChildWidgetVector(std::vector<Widget*>* result_child_widgets); |
| 73 | 89 |
| 74 // We own this, but it is reference-counted on some platforms so we can't use | 90 // We own this, but it is reference-counted on some platforms so we can't use |
| 75 // a scoped_ptr. It is dereferenced in the destructor. | 91 // a scoped_ptr. It is dereferenced in the destructor. |
| 76 ui::AXPlatformNode* ax_node_; | 92 ui::AXPlatformNode* ax_node_; |
| 77 | 93 |
| 94 // Accessibility information associated to |view_|. |
| 78 mutable ui::AXNodeData data_; | 95 mutable ui::AXNodeData data_; |
| 79 | 96 |
| 80 DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibilityBase); | 97 DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibilityBase); |
| 81 }; | 98 }; |
| 82 | 99 |
| 83 } // namespace views | 100 } // namespace views |
| 84 | 101 |
| 85 #endif // UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_BASE_H_ | 102 #endif // UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_BASE_H_ |
| OLD | NEW |