| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "content/browser/accessibility/ax_platform_position.h" |
| 18 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 19 #include "third_party/WebKit/public/web/WebAXEnums.h" | 20 #include "third_party/WebKit/public/web/WebAXEnums.h" |
| 20 #include "ui/accessibility/ax_node.h" | 21 #include "ui/accessibility/ax_node.h" |
| 21 #include "ui/accessibility/ax_node_data.h" | 22 #include "ui/accessibility/ax_node_data.h" |
| 23 #include "ui/accessibility/ax_range.h" |
| 22 #include "ui/accessibility/ax_text_utils.h" | 24 #include "ui/accessibility/ax_text_utils.h" |
| 23 | 25 |
| 24 // Set PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL if this platform has | 26 // Set PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL if this platform has |
| 25 // a platform-specific subclass of BrowserAccessibility and | 27 // a platform-specific subclass of BrowserAccessibility and |
| 26 // BrowserAccessibilityManager. | 28 // BrowserAccessibilityManager. |
| 27 #undef PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL | 29 #undef PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL |
| 28 | 30 |
| 29 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 30 #define PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL 1 | 32 #define PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL 1 |
| 31 #endif | 33 #endif |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 bool IsRichTextControl() const; | 352 bool IsRichTextControl() const; |
| 351 | 353 |
| 352 // If an object is focusable but has no accessible name, use this | 354 // If an object is focusable but has no accessible name, use this |
| 353 // to compute a name from its descendants. | 355 // to compute a name from its descendants. |
| 354 std::string ComputeAccessibleNameFromDescendants(); | 356 std::string ComputeAccessibleNameFromDescendants(); |
| 355 | 357 |
| 356 // Gets the text offsets where new lines start. | 358 // Gets the text offsets where new lines start. |
| 357 std::vector<int> GetLineStartOffsets() const; | 359 std::vector<int> GetLineStartOffsets() const; |
| 358 | 360 |
| 359 protected: | 361 protected: |
| 362 using AXPlatformPositionInstance = AXPlatformPosition::AXPositionInstance; |
| 363 using AXPlatformRange = ui::AXRange<AXPlatformPositionInstance::element_type>; |
| 364 |
| 360 BrowserAccessibility(); | 365 BrowserAccessibility(); |
| 361 | 366 |
| 367 // Creates a position rooted at this object. |
| 368 // This is a text position on all platforms except IA2 and ATK, where tree |
| 369 // positions are created for non-text objects representing hypertext offsets. |
| 370 virtual AXPlatformPositionInstance CreatePositionAt(int offset) const; |
| 371 |
| 362 // The manager of this tree of accessibility objects. | 372 // The manager of this tree of accessibility objects. |
| 363 BrowserAccessibilityManager* manager_; | 373 BrowserAccessibilityManager* manager_; |
| 364 | 374 |
| 365 // The underlying node. | 375 // The underlying node. |
| 366 ui::AXNode* node_; | 376 ui::AXNode* node_; |
| 367 | 377 |
| 368 // A unique ID, since node IDs are frame-local. | 378 // A unique ID, since node IDs are frame-local. |
| 369 int32_t unique_id_; | 379 int32_t unique_id_; |
| 370 | 380 |
| 371 private: | 381 private: |
| 372 // |GetInnerText| recursively includes all the text from descendants such as | 382 // |GetInnerText| recursively includes all the text from descendants such as |
| 373 // text found in any embedded object. In contrast, |GetText| might include a | 383 // text found in any embedded object. In contrast, |GetText| might include a |
| 374 // special character in the place of every embedded object instead of its | 384 // special character in the place of every embedded object instead of its |
| 375 // text, depending on the platform. | 385 // text, depending on the platform. |
| 376 base::string16 GetInnerText() const; | 386 base::string16 GetInnerText() const; |
| 377 | 387 |
| 378 // If a bounding rectangle is empty, compute it based on the union of its | 388 // If a bounding rectangle is empty, compute it based on the union of its |
| 379 // children, since most accessibility APIs don't like elements with no | 389 // children, since most accessibility APIs don't like elements with no |
| 380 // bounds, but "virtual" elements in the accessibility tree that don't | 390 // bounds, but "virtual" elements in the accessibility tree that don't |
| 381 // correspond to a layed-out element sometimes don't have bounds. | 391 // correspond to a layed-out element sometimes don't have bounds. |
| 382 void FixEmptyBounds(gfx::RectF* bounds) const; | 392 void FixEmptyBounds(gfx::RectF* bounds) const; |
| 383 | 393 |
| 384 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); | 394 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); |
| 385 }; | 395 }; |
| 386 | 396 |
| 387 } // namespace content | 397 } // namespace content |
| 388 | 398 |
| 389 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ | 399 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_H_ |
| OLD | NEW |