ax_tree_data.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_ACCESSIBILITY_AX_TREE_DATA_H_
  5. #define UI_ACCESSIBILITY_AX_TREE_DATA_H_
  6. #include <stdint.h>
  7. #include <map>
  8. #include <string>
  9. #include <vector>
  10. #include "base/strings/string_split.h"
  11. #include "ui/accessibility/ax_action_handler_registry.h"
  12. #include "ui/accessibility/ax_base_export.h"
  13. #include "ui/accessibility/ax_enums.mojom-forward.h"
  14. #include "ui/accessibility/ax_node_data.h"
  15. #include "ui/gfx/geometry/rect.h"
  16. namespace ui {
  17. // The data associated with an accessibility tree that's global to the
  18. // tree and not associated with any particular node in the tree.
  19. struct AX_BASE_EXPORT AXTreeData {
  20. AXTreeData();
  21. AXTreeData(const AXTreeData& other);
  22. virtual ~AXTreeData();
  23. // Return a string representation of this data, for debugging.
  24. virtual std::string ToString() const;
  25. // This is a simple serializable struct. All member variables should be
  26. // public and copyable.
  27. // The globally unique ID of this accessibility tree.
  28. AXTreeID tree_id;
  29. // The ID of the accessibility tree that this tree is contained in, if any.
  30. AXTreeID parent_tree_id;
  31. // The ID of the accessibility tree that has focus. This is typically set
  32. // on the root frame in a frame tree.
  33. AXTreeID focused_tree_id;
  34. // Attributes specific to trees that are web frames.
  35. std::string doctype;
  36. bool loaded = false;
  37. float loading_progress = 0.0f;
  38. std::string mimetype;
  39. std::string title;
  40. std::string url;
  41. // The node with keyboard focus within this tree, if any, or
  42. // kInvalidAXNodeID if no node in this tree has focus.
  43. AXNodeID focus_id = kInvalidAXNodeID;
  44. // The current text selection within this tree, if any, expressed as the
  45. // node ID and character offset of the anchor (selection start) and focus
  46. // (selection end). If the offset could correspond to a position on two
  47. // different lines, sel_upstream_affinity means the cursor is on the first
  48. // line, otherwise it's on the second line.
  49. // Most use cases will want to use ui::OwnerTree::GetUnignoredSelection.
  50. bool sel_is_backward = false;
  51. AXNodeID sel_anchor_object_id = kInvalidAXNodeID;
  52. int32_t sel_anchor_offset = -1;
  53. ax::mojom::TextAffinity sel_anchor_affinity;
  54. AXNodeID sel_focus_object_id = kInvalidAXNodeID;
  55. int32_t sel_focus_offset = -1;
  56. ax::mojom::TextAffinity sel_focus_affinity;
  57. // The node that's used as the root scroller. On some platforms
  58. // like Android we need to ignore accessibility scroll offsets for
  59. // that node and get them from the viewport instead.
  60. AXNodeID root_scroller_id = kInvalidAXNodeID;
  61. // Metadata from an HTML HEAD, such as <meta> tags. Stored here
  62. // unparsed because the only applications that need these just want
  63. // raw strings. Only included if the kHTMLMetadata AXMode is enabled.
  64. std::vector<std::string> metadata;
  65. };
  66. AX_BASE_EXPORT bool operator==(const AXTreeData& lhs, const AXTreeData& rhs);
  67. AX_BASE_EXPORT bool operator!=(const AXTreeData& lhs, const AXTreeData& rhs);
  68. } // namespace ui
  69. #endif // UI_ACCESSIBILITY_AX_TREE_DATA_H_