| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 5 #ifndef CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
| 6 #define CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 6 #define CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | |
| 10 #include <utility> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 14 #include "build/build_config.h" | |
| 15 #include "webkit/glue/webaccessibility.h" | |
| 16 | |
| 17 class BrowserAccessibilityManager; | |
| 18 #if defined(OS_WIN) | |
| 19 class BrowserAccessibilityWin; | |
| 20 #endif | |
| 21 | |
| 22 using webkit_glue::WebAccessibility; | |
| 23 | 10 |
| 24 //////////////////////////////////////////////////////////////////////////////// | 11 //////////////////////////////////////////////////////////////////////////////// |
| 25 // | 12 // |
| 26 // BrowserAccessibility | 13 // BrowserAccessibility |
| 27 // | 14 // |
| 28 // Class implementing the cross platform interface for the Browser-Renderer | 15 // Class implementing the cross platform interface for the Browser-Renderer |
| 29 // communication of accessibility information, providing accessibility | 16 // communication of accessibility information, providing accessibility |
| 30 // to be used by screen readers and other assistive technology (AT). | 17 // to be used by screen readers and other assistive technology (AT). |
| 31 // | 18 // |
| 32 // An implementation for each platform handles platform specific accessibility | 19 // An implementation for each platform handles platform specific accessibility |
| 33 // APIs. | 20 // APIs. |
| 34 // | 21 // |
| 35 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
| 36 class BrowserAccessibility { | 23 class BrowserAccessibility { |
| 37 public: | 24 public: |
| 38 // Creates a platform specific BrowserAccessibility. Ownership passes to the | 25 // Creates the platform specific BrowserAccessibility. Ownership passes to the |
| 39 // caller. | 26 // caller. |
| 40 static BrowserAccessibility* Create(); | |
| 41 | |
| 42 virtual ~BrowserAccessibility(); | 27 virtual ~BrowserAccessibility(); |
| 43 | 28 |
| 44 // Initialize this object | |
| 45 void Initialize(BrowserAccessibilityManager* manager, | |
| 46 BrowserAccessibility* parent, | |
| 47 int32 child_id, | |
| 48 int32 index_in_parent, | |
| 49 const WebAccessibility& src); | |
| 50 | |
| 51 // Add a child of this object. | |
| 52 void AddChild(BrowserAccessibility* child); | |
| 53 | |
| 54 // Return true if this object is equal to or a descendant of |ancestor|. | |
| 55 bool IsDescendantOf(BrowserAccessibility* ancestor); | |
| 56 | |
| 57 // Returns the parent of this object, or NULL if it's the root. | |
| 58 BrowserAccessibility* GetParent(); | |
| 59 | |
| 60 // Returns the number of children of this object. | |
| 61 uint32 GetChildCount(); | |
| 62 | |
| 63 // Return a pointer to the child with the given index. | |
| 64 BrowserAccessibility* GetChild(uint32 child_index); | |
| 65 | |
| 66 // Return the previous sibling of this object, or NULL if it's the first | |
| 67 // child of its parent. | |
| 68 BrowserAccessibility* GetPreviousSibling(); | |
| 69 | |
| 70 // Return the next sibling of this object, or NULL if it's the last child | |
| 71 // of its parent. | |
| 72 BrowserAccessibility* GetNextSibling(); | |
| 73 | |
| 74 // Replace a child object. Used when updating the accessibility tree. | |
| 75 void ReplaceChild( | |
| 76 const BrowserAccessibility* old_acc, | |
| 77 BrowserAccessibility* new_acc); | |
| 78 | |
| 79 // Accessors | |
| 80 int32 child_id() const { return child_id_; } | |
| 81 const std::vector<BrowserAccessibility*>& children() const { | |
| 82 return children_; | |
| 83 } | |
| 84 int32 renderer_id() const { return renderer_id_; } | |
| 85 int32 index_in_parent() const { return index_in_parent_; } | |
| 86 WebKit::WebRect location() const { return location_; } | |
| 87 | |
| 88 #if defined(OS_WIN) | |
| 89 BrowserAccessibilityWin* toBrowserAccessibilityWin(); | |
| 90 #endif | |
| 91 | |
| 92 protected: | 29 protected: |
| 93 BrowserAccessibility(); | 30 BrowserAccessibility(); |
| 94 | 31 |
| 95 // Perform platform specific initialization. This can be called multiple times | |
| 96 // during the lifetime of this instance after the members of this base object | |
| 97 // have been reset with new values from the renderer process. | |
| 98 virtual void Initialize() = 0; | |
| 99 | |
| 100 // Remove references to all children and delete them if possible. | |
| 101 virtual void ReleaseTree() = 0; | |
| 102 | |
| 103 // Release a reference to this node. This may be a no-op on platforms other | |
| 104 // than windows. | |
| 105 virtual void ReleaseReference() = 0; | |
| 106 | |
| 107 // The manager of this tree of accessibility objects; needed for | |
| 108 // global operations like focus tracking. | |
| 109 BrowserAccessibilityManager* manager_; | |
| 110 | |
| 111 // The parent of this object, may be NULL if we're the root object. | |
| 112 BrowserAccessibility* parent_; | |
| 113 | |
| 114 // The ID of this object; globally unique within the browser process. | |
| 115 int32 child_id_; | |
| 116 | |
| 117 // The index of this within its parent object. | |
| 118 int32 index_in_parent_; | |
| 119 | |
| 120 // The ID of this object in the renderer process. | |
| 121 int32 renderer_id_; | |
| 122 | |
| 123 // The children of this object. | |
| 124 std::vector<BrowserAccessibility*> children_; | |
| 125 | |
| 126 // Accessibility metadata from the renderer | |
| 127 string16 name_; | |
| 128 string16 value_; | |
| 129 std::map<int32, string16> attributes_; | |
| 130 std::vector<std::pair<string16, string16> > html_attributes_; | |
| 131 int32 role_; | |
| 132 int32 state_; | |
| 133 string16 role_name_; | |
| 134 WebKit::WebRect location_; | |
| 135 | |
| 136 private: | 32 private: |
| 137 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); | 33 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); |
| 138 }; | 34 }; |
| 139 | 35 |
| 140 #endif // CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 36 #endif // CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
| OLD | NEW |