| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 UI_ACCESSIBILITY_AX_TREE_COMBINER_H_ | 5 #ifndef UI_ACCESSIBILITY_AX_TREE_COMBINER_H_ |
| 6 #define UI_ACCESSIBILITY_AX_TREE_COMBINER_H_ | 6 #define UI_ACCESSIBILITY_AX_TREE_COMBINER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ui/accessibility/ax_export.h" | 10 #include "ui/accessibility/ax_export.h" |
| 11 #include "ui/accessibility/ax_tree_update.h" | 11 #include "ui/accessibility/ax_tree_update.h" |
| 12 #include "ui/gfx/transform.h" | |
| 13 | 12 |
| 14 namespace ui { | 13 namespace ui { |
| 15 | 14 |
| 16 // This helper class takes multiple accessibility trees that reference each | 15 // This helper class takes multiple accessibility trees that reference each |
| 17 // other via tree IDs, and combines them into a single accessibility tree | 16 // other via tree IDs, and combines them into a single accessibility tree |
| 18 // that spans all of them. | 17 // that spans all of them. |
| 19 // | 18 // |
| 20 // Since node IDs are relative to each ID, it has to renumber all of the IDs | 19 // Since node IDs are relative to each ID, it has to renumber all of the IDs |
| 21 // and update all of the attributes that reference IDs of other nodes to | 20 // and update all of the attributes that reference IDs of other nodes to |
| 22 // ensure they point to the right node. It also applies transformations to | 21 // ensure they point to the right node. |
| 23 // local bounding rectangles to make them global. | |
| 24 // | 22 // |
| 25 // It also makes sure the final combined tree points to the correct focused | 23 // It also makes sure the final combined tree points to the correct focused |
| 26 // node across all of the trees based on the focused tree ID of the root tree. | 24 // node across all of the trees based on the focused tree ID of the root tree. |
| 27 class AX_EXPORT AXTreeCombiner { | 25 class AX_EXPORT AXTreeCombiner { |
| 28 public: | 26 public: |
| 29 AXTreeCombiner(); | 27 AXTreeCombiner(); |
| 30 ~AXTreeCombiner(); | 28 ~AXTreeCombiner(); |
| 31 | 29 |
| 32 void AddTree(const AXTreeUpdate& tree, bool is_root); | 30 void AddTree(const AXTreeUpdate& tree, bool is_root); |
| 33 bool Combine(); | 31 bool Combine(); |
| 34 | 32 |
| 35 const AXTreeUpdate& combined() { return combined_; } | 33 const AXTreeUpdate& combined() { return combined_; } |
| 36 | 34 |
| 37 private: | 35 private: |
| 38 int32_t MapId(int32_t tree_id, int32_t node_id); | 36 int32_t MapId(int32_t tree_id, int32_t node_id); |
| 39 | 37 |
| 40 void ProcessTree(const AXTreeUpdate* tree); | 38 void ProcessTree(const AXTreeUpdate* tree); |
| 41 | 39 |
| 42 std::vector<ui::AXTreeUpdate> trees_; | 40 std::vector<ui::AXTreeUpdate> trees_; |
| 43 int32_t root_tree_id_ = -1; | 41 int32_t root_tree_id_ = -1; |
| 44 int32_t next_id_ = 1; | 42 int32_t next_id_ = 1; |
| 45 std::map<int32_t, const AXTreeUpdate*> tree_id_map_; | 43 std::map<int32_t, const AXTreeUpdate*> tree_id_map_; |
| 46 std::map<std::pair<int32_t, int32_t>, int32_t> tree_id_node_id_map_; | 44 std::map<std::pair<int32_t, int32_t>, int32_t> tree_id_node_id_map_; |
| 47 AXTreeUpdate combined_; | 45 AXTreeUpdate combined_; |
| 48 gfx::Transform transform_; | |
| 49 }; | 46 }; |
| 50 | 47 |
| 51 | 48 |
| 52 } // namespace ui | 49 } // namespace ui |
| 53 | 50 |
| 54 #endif // UI_ACCESSIBILITY_AX_TREE_COMBINER_H_ | 51 #endif // UI_ACCESSIBILITY_AX_TREE_COMBINER_H_ |
| OLD | NEW |