ax_assistant_structure.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright 2018 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_ASSISTANT_STRUCTURE_H_
  5. #define UI_ACCESSIBILITY_AX_ASSISTANT_STRUCTURE_H_
  6. #include <stdint.h>
  7. #include <memory>
  8. #include <string>
  9. #include <vector>
  10. #include "base/strings/string_split.h"
  11. #include "third_party/abseil-cpp/absl/types/optional.h"
  12. #include "ui/accessibility/ax_enums.mojom-forward.h"
  13. #include "ui/gfx/geometry/rect.h"
  14. #include "ui/gfx/range/range.h"
  15. namespace ui {
  16. struct AXTreeUpdate;
  17. struct AssistantNode {
  18. AssistantNode();
  19. AssistantNode(const AssistantNode& other);
  20. AssistantNode& operator=(const AssistantNode&) = delete;
  21. ~AssistantNode();
  22. std::vector<int32_t> children_indices;
  23. // Geometry of the view in pixels
  24. gfx::Rect rect;
  25. // Text of the view.
  26. std::u16string text;
  27. // Text properties
  28. float text_size;
  29. uint32_t color;
  30. uint32_t bgcolor;
  31. bool bold;
  32. bool italic;
  33. bool underline;
  34. bool line_through;
  35. // Selected portion of the text.
  36. absl::optional<gfx::Range> selection;
  37. // Fake Android view class name of the element. Each node is assigned
  38. // a closest approximation of Android's views to keep the server happy.
  39. std::string class_name;
  40. // HTML and CSS attributes.
  41. std::string html_tag;
  42. std::string css_display;
  43. // HTML attributes: map from lowercase ASCII HTML attribute name to value.
  44. base::StringPairs html_attributes;
  45. // Accessibility functionality of the node inferred from DOM or based on HTML
  46. // role attribute.
  47. absl::optional<std::string> role;
  48. };
  49. struct AssistantTree {
  50. AssistantTree();
  51. AssistantTree(const AssistantTree& other);
  52. AssistantTree& operator=(const AssistantTree&) = delete;
  53. ~AssistantTree();
  54. std::vector<std::unique_ptr<AssistantNode>> nodes;
  55. };
  56. std::unique_ptr<AssistantTree> CreateAssistantTree(const AXTreeUpdate& update);
  57. std::u16string AXUrlBaseText(std::u16string url);
  58. const char* AXRoleToAndroidClassName(ax::mojom::Role role, bool has_parent);
  59. } // namespace ui
  60. #endif // UI_ACCESSIBILITY_AX_ASSISTANT_STRUCTURE_H_