OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ax_tree.h" | 5 #include "ui/accessibility/ax_tree.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // conditions. | 150 // conditions. |
151 | 151 |
152 // Look up the node by id. If it's not found, then either the root | 152 // Look up the node by id. If it's not found, then either the root |
153 // of the tree is being swapped, or we're out of sync with the source | 153 // of the tree is being swapped, or we're out of sync with the source |
154 // and this is a serious error. | 154 // and this is a serious error. |
155 AXNode* node = GetFromId(src.id); | 155 AXNode* node = GetFromId(src.id); |
156 AXNode* new_node = NULL; | 156 AXNode* new_node = NULL; |
157 if (node) { | 157 if (node) { |
158 update_state->pending_nodes.erase(node); | 158 update_state->pending_nodes.erase(node); |
159 node->SetData(src); | 159 node->SetData(src); |
160 if (delegate_) | |
161 delegate_->OnNodeChanged(node); | |
162 } else { | 160 } else { |
163 if (src.role != AX_ROLE_ROOT_WEB_AREA) { | 161 if (src.role != AX_ROLE_ROOT_WEB_AREA) { |
164 error_ = base::StringPrintf( | 162 error_ = base::StringPrintf( |
165 "%d is not in the tree and not the new root", src.id); | 163 "%d is not in the tree and not the new root", src.id); |
166 return false; | 164 return false; |
167 } | 165 } |
168 new_node = CreateNode(NULL, src.id, 0); | 166 new_node = CreateNode(NULL, src.id, 0); |
169 node = new_node; | 167 node = new_node; |
170 update_state->new_nodes.insert(node); | 168 update_state->new_nodes.insert(node); |
171 node->SetData(src); | 169 node->SetData(src); |
172 } | 170 } |
173 | 171 |
| 172 if (delegate_) |
| 173 delegate_->OnNodeChanged(node); |
| 174 |
174 // First, delete nodes that used to be children of this node but aren't | 175 // First, delete nodes that used to be children of this node but aren't |
175 // anymore. | 176 // anymore. |
176 if (!DeleteOldChildren(node, src.child_ids)) { | 177 if (!DeleteOldChildren(node, src.child_ids)) { |
177 if (new_node) | 178 if (new_node) |
178 DestroyNodeAndSubtree(new_node); | 179 DestroyNodeAndSubtree(new_node); |
179 return false; | 180 return false; |
180 } | 181 } |
181 | 182 |
182 // Now build a new children vector, reusing nodes when possible, | 183 // Now build a new children vector, reusing nodes when possible, |
183 // and swap it in. | 184 // and swap it in. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 update_state->pending_nodes.insert(child); | 260 update_state->pending_nodes.insert(child); |
260 update_state->new_nodes.insert(child); | 261 update_state->new_nodes.insert(child); |
261 } | 262 } |
262 new_children->push_back(child); | 263 new_children->push_back(child); |
263 } | 264 } |
264 | 265 |
265 return success; | 266 return success; |
266 } | 267 } |
267 | 268 |
268 } // namespace ui | 269 } // namespace ui |
OLD | NEW |