Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: ui/accessibility/tree_generator.cc

Issue 2860883003: A11y: Add/refactor methods for manipulating bitfields on AXNodeData. (Closed)
Patch Set: Delete AXNodeData::Init() and clear bitfields in AXNodeData() instead. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "ui/accessibility/tree_generator.h" 5 #include "ui/accessibility/tree_generator.h"
6 6
7 #include "ui/accessibility/ax_serializable_tree.h" 7 #include "ui/accessibility/ax_serializable_tree.h"
8 #include "ui/accessibility/ax_tree.h" 8 #include "ui/accessibility/ax_tree.h"
9 9
10 namespace ui { 10 namespace ui {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 for (int i = 0; i < node_count; ++i) 81 for (int i = 0; i < node_count; ++i)
82 permuted.push_back(i + 1); 82 permuted.push_back(i + 1);
83 } 83 }
84 84
85 // Build an AXTreeUpdate. The first two nodes of the tree always 85 // Build an AXTreeUpdate. The first two nodes of the tree always
86 // go in the same place. 86 // go in the same place.
87 AXTreeUpdate update; 87 AXTreeUpdate update;
88 update.root_id = permuted[0]; 88 update.root_id = permuted[0];
89 update.nodes.resize(node_count); 89 update.nodes.resize(node_count);
90 update.nodes[0].id = permuted[0]; 90 update.nodes[0].id = permuted[0];
91 update.nodes[0].state = AX_STATE_NONE;
92 if (node_count > 1) { 91 if (node_count > 1) {
93 update.nodes[0].child_ids.push_back(permuted[1]); 92 update.nodes[0].child_ids.push_back(permuted[1]);
94 update.nodes[1].id = permuted[1]; 93 update.nodes[1].id = permuted[1];
95 update.nodes[1].state = AX_STATE_NONE;
96 } 94 }
97 95
98 // The remaining nodes are assigned based on their parent 96 // The remaining nodes are assigned based on their parent
99 // selected from the next bits from |tree_index|. 97 // selected from the next bits from |tree_index|.
100 for (int i = 2; i < node_count; ++i) { 98 for (int i = 2; i < node_count; ++i) {
101 update.nodes[i].id = permuted[i]; 99 update.nodes[i].id = permuted[i];
102 update.nodes[i].state = AX_STATE_NONE;
103 int parent_index = (tree_index % i); 100 int parent_index = (tree_index % i);
104 tree_index /= i; 101 tree_index /= i;
105 update.nodes[parent_index].child_ids.push_back(permuted[i]); 102 update.nodes[parent_index].child_ids.push_back(permuted[i]);
106 } 103 }
107 104
108 // Unserialize the tree update into the destination tree. 105 // Unserialize the tree update into the destination tree.
109 CHECK(out_tree->Unserialize(update)) << out_tree->error(); 106 CHECK(out_tree->Unserialize(update)) << out_tree->error();
110 }; 107 };
111 108
112 } // namespace ui 109 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698