OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 // Returns the bounds of the given range in coordinates relative to the | 106 // Returns the bounds of the given range in coordinates relative to the |
107 // top-left corner of the overall web area. Only valid when the | 107 // top-left corner of the overall web area. Only valid when the |
108 // role is WebAXRoleStaticText. | 108 // role is WebAXRoleStaticText. |
109 gfx::Rect GetLocalBoundsForRange(int start, int len) const; | 109 gfx::Rect GetLocalBoundsForRange(int start, int len) const; |
110 | 110 |
111 // Same as GetLocalBoundsForRange, in screen coordinates. Only valid when | 111 // Same as GetLocalBoundsForRange, in screen coordinates. Only valid when |
112 // the role is WebAXRoleStaticText. | 112 // the role is WebAXRoleStaticText. |
113 gfx::Rect GetGlobalBoundsForRange(int start, int len) const; | 113 gfx::Rect GetGlobalBoundsForRange(int start, int len) const; |
114 | 114 |
115 // Searches in the given text and from the given offset until the start of | 115 // Starting at the given offset, searches through this object's text until the |
116 // the next or previous word is found and returns its position. | 116 // beginning of the next or previous word is found and returns its position. |
117 // In case there is no word boundary before or after the given offset, it | 117 // In case there is no word boundary before or after the given offset, it |
118 // returns one past the last character, i.e. the text's length. | 118 // returns one past the last character, i.e. the text's length. |
119 // If the given offset is already at the start of a word, returns the start | 119 // If the given offset is already at the start of a word, returns the start |
120 // of the next word if the search is forwards and the given offset if it is | 120 // of the next word if the search is forwards. It returns the given offset |
121 // backwards. | 121 // if the search is backwards. |
122 // If the start offset is equal to -1 and the search is in the forwards | 122 // If the start offset is equal to -1 and the search is in the forwards |
123 // direction, returns the start boundary of the first word. | 123 // direction, it returns the start boundary of the first word. |
124 // Start offsets that are not in the range -1 to text length are invalid. | 124 // Start offsets that are not in the range -1 to text length are invalid. |
125 int GetWordStartBoundary( | 125 int GetWordStartBoundary( |
126 int start, ui::TextBoundaryDirection direction) const; | 126 int offset, ui::TextBoundaryDirection direction) const; |
| 127 |
| 128 // Starting at the given offset, searches either forwards or backwards through |
| 129 // this object's text until it finds a change in text style. If the search is |
| 130 // in the forwards direction, it returns the start of the next style span. If |
| 131 // the search is in the backwards direction, it returns the start of the |
| 132 // current style span. |
| 133 // In case there is no style change after the given offset, it returns one |
| 134 // past the last character, i.e. the text's length. |
| 135 int GetStyleChangeBoundary( |
| 136 int offset, ui::TextBoundaryDirection direction) const; |
127 | 137 |
128 // Returns the deepest descendant that contains the specified point | 138 // Returns the deepest descendant that contains the specified point |
129 // (in global screen coordinates). | 139 // (in global screen coordinates). |
130 BrowserAccessibility* BrowserAccessibilityForPoint(const gfx::Point& point); | 140 BrowserAccessibility* BrowserAccessibilityForPoint(const gfx::Point& point); |
131 | 141 |
132 // Marks this object for deletion, releases our reference to it, and | 142 // Marks this object for deletion, releases our reference to it, and |
133 // nulls out the pointer to the underlying AXNode. May not delete | 143 // nulls out the pointer to the underlying AXNode. May not delete |
134 // the object immediately due to reference counting. | 144 // the object immediately due to reference counting. |
135 // | 145 // |
136 // Reference counting is used on some platforms because the | 146 // Reference counting is used on some platforms because the |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 268 |
259 // Returns true if this node is an editable text field of any kind. | 269 // Returns true if this node is an editable text field of any kind. |
260 bool IsEditableText() const; | 270 bool IsEditableText() const; |
261 | 271 |
262 // True if this is a web area, and its grandparent is a presentational iframe. | 272 // True if this is a web area, and its grandparent is a presentational iframe. |
263 bool IsWebAreaForPresentationalIframe() const; | 273 bool IsWebAreaForPresentationalIframe() const; |
264 | 274 |
265 protected: | 275 protected: |
266 BrowserAccessibility(); | 276 BrowserAccessibility(); |
267 | 277 |
| 278 // Returns the first deepest descendant that is an object with complete text |
| 279 // information. |
| 280 BrowserAccessibility* GetFirstTextLeaf() const; |
| 281 |
268 // The manager of this tree of accessibility objects. | 282 // The manager of this tree of accessibility objects. |
269 BrowserAccessibilityManager* manager_; | 283 BrowserAccessibilityManager* manager_; |
270 | 284 |
271 // The underlying node. | 285 // The underlying node. |
272 ui::AXNode* node_; | 286 ui::AXNode* node_; |
273 | 287 |
274 private: | 288 private: |
275 // Return the sum of the lengths of all static text descendants, | 289 // Returns true if the object is a leaf for purposes of text retrieval. |
276 // including this object if it's static text. | 290 bool IsTextLeaf() const; |
| 291 |
| 292 // Return the sum of the lengths of all text leaf descendants, |
| 293 // including this object if it's a text leaf. |
277 int GetStaticTextLenRecursive() const; | 294 int GetStaticTextLenRecursive() const; |
278 | 295 |
| 296 // Returns the text leaf in which the given text offset lies and the offset |
| 297 // at which the leaf's text starts. |
| 298 BrowserAccessibility* GetTextLeafAtOffset(int offset, int* leaf_start_offset)
const; |
| 299 |
| 300 // Returns the last deepest descendant that is an object with complete text |
| 301 // information. |
| 302 BrowserAccessibility* GetLastTextLeaf() const; |
| 303 |
| 304 // Returns the next object that is a text leaf, if any. |
| 305 BrowserAccessibility* GetNextTextLeaf() const; |
| 306 |
| 307 // Returns the previous object that is a text leaf, if any. |
| 308 BrowserAccessibility* GetPreviousTextLeaf() const; |
| 309 |
279 // Similar to GetParent(), but includes nodes that are the host of a | 310 // Similar to GetParent(), but includes nodes that are the host of a |
280 // subtree rather than skipping over them - because they contain important | 311 // subtree rather than skipping over them - because they contain important |
281 // bounds offsets. | 312 // bounds offsets. |
282 BrowserAccessibility* GetParentForBoundsCalculation() const; | 313 BrowserAccessibility* GetParentForBoundsCalculation() const; |
283 | 314 |
284 // Convert the bounding rectangle of an element (which is relative to | 315 // Convert the bounding rectangle of an element (which is relative to |
285 // its nearest scrollable ancestor) to local bounds (which are relative | 316 // its nearest scrollable ancestor) to local bounds (which are relative |
286 // to the top of the web accessibility tree). | 317 // to the top of the web accessibility tree). |
287 gfx::Rect ElementBoundsToLocalBounds(gfx::Rect bounds) const; | 318 gfx::Rect ElementBoundsToLocalBounds(gfx::Rect bounds) const; |
288 | 319 |
| 320 // Returns true if the two objects have the same text style attributes. |
| 321 static bool HaveSameStyle(BrowserAccessibility& object1, |
| 322 BrowserAccessibility& object2); |
| 323 |
289 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); | 324 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); |
290 }; | 325 }; |
291 | 326 |
292 } // namespace content | 327 } // namespace content |
293 | 328 |
294 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 329 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
OLD | NEW |