OLD | NEW |
---|---|
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 "chrome/renderer/extensions/automation_internal_custom_bindings.h" | 5 #include "chrome/renderer/extensions/automation_internal_custom_bindings.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1090 const ui::AXNodeData& new_node_data) { | 1090 const ui::AXNodeData& new_node_data) { |
1091 if (old_node_data.GetStringAttribute(ui::AX_ATTR_NAME) != | 1091 if (old_node_data.GetStringAttribute(ui::AX_ATTR_NAME) != |
1092 new_node_data.GetStringAttribute(ui::AX_ATTR_NAME)) | 1092 new_node_data.GetStringAttribute(ui::AX_ATTR_NAME)) |
1093 text_changed_node_ids_.push_back(new_node_data.id); | 1093 text_changed_node_ids_.push_back(new_node_data.id); |
1094 } | 1094 } |
1095 | 1095 |
1096 void AutomationInternalCustomBindings::OnTreeDataChanged(ui::AXTree* tree) {} | 1096 void AutomationInternalCustomBindings::OnTreeDataChanged(ui::AXTree* tree) {} |
1097 | 1097 |
1098 void AutomationInternalCustomBindings::OnNodeWillBeDeleted(ui::AXTree* tree, | 1098 void AutomationInternalCustomBindings::OnNodeWillBeDeleted(ui::AXTree* tree, |
1099 ui::AXNode* node) { | 1099 ui::AXNode* node) { |
1100 SendTreeChangeEvent( | |
1101 api::automation::TREE_CHANGE_TYPE_NODEREMOVED, | |
dmazzoni
2016/06/20 22:47:23
I think you still need to call this, otherwise we
| |
1102 tree, node); | |
1103 deleted_node_ids_.push_back(node->id()); | 1100 deleted_node_ids_.push_back(node->id()); |
1101 | |
1102 // Don't do anything here because the update may reparent and not delete this | |
1103 // node. | |
1104 } | 1104 } |
1105 | 1105 |
1106 void AutomationInternalCustomBindings::OnSubtreeWillBeDeleted( | 1106 void AutomationInternalCustomBindings::OnSubtreeWillBeDeleted( |
1107 ui::AXTree* tree, | 1107 ui::AXTree* tree, |
1108 ui::AXNode* node) { | 1108 ui::AXNode* node) { |
1109 // This isn't strictly needed, as OnNodeWillBeDeleted will already be | 1109 // Don't do anything here because the update may reparent and not delete this |
1110 // called. We could send a JS event for this only if it turns out to | 1110 // subtree. |
1111 // be needed for something. | |
1112 } | 1111 } |
1113 | 1112 |
1114 void AutomationInternalCustomBindings::OnNodeCreated(ui::AXTree* tree, | 1113 void AutomationInternalCustomBindings::OnNodeCreated(ui::AXTree* tree, |
1115 ui::AXNode* node) { | 1114 ui::AXNode* node) { |
1116 // Not needed, this is called in the middle of an update so it's not | 1115 // Not needed, this is called in the middle of an update so it's not |
1117 // safe to trigger JS from here. Wait for the notification in | 1116 // safe to trigger JS from here. Wait for the notification in |
1118 // OnAtomicUpdateFinished instead. | 1117 // OnAtomicUpdateFinished instead. |
1119 } | 1118 } |
1120 | 1119 |
1121 void AutomationInternalCustomBindings::OnNodeChanged(ui::AXTree* tree, | 1120 void AutomationInternalCustomBindings::OnNodeChanged(ui::AXTree* tree, |
(...skipping 22 matching lines...) Expand all Loading... | |
1144 case SUBTREE_CREATED: | 1143 case SUBTREE_CREATED: |
1145 SendTreeChangeEvent( | 1144 SendTreeChangeEvent( |
1146 api::automation::TREE_CHANGE_TYPE_SUBTREECREATED, | 1145 api::automation::TREE_CHANGE_TYPE_SUBTREECREATED, |
1147 tree, node); | 1146 tree, node); |
1148 break; | 1147 break; |
1149 case NODE_CHANGED: | 1148 case NODE_CHANGED: |
1150 SendTreeChangeEvent( | 1149 SendTreeChangeEvent( |
1151 api::automation::TREE_CHANGE_TYPE_NODECHANGED, | 1150 api::automation::TREE_CHANGE_TYPE_NODECHANGED, |
1152 tree, node); | 1151 tree, node); |
1153 break; | 1152 break; |
1154 // Unhandled. | |
1155 case NODE_REPARENTED: | 1153 case NODE_REPARENTED: |
1156 case SUBTREE_REPARENTED: | 1154 case SUBTREE_REPARENTED: |
1155 auto iter = std::find(deleted_node_ids_.begin(), | |
1156 deleted_node_ids_.end(), node->id()); | |
1157 if (iter != deleted_node_ids_.end()) | |
1158 deleted_node_ids_.erase(iter); | |
1157 break; | 1159 break; |
1158 } | 1160 } |
1159 } | 1161 } |
1160 | 1162 |
1161 for (int id : text_changed_node_ids_) { | 1163 for (int id : text_changed_node_ids_) { |
1162 SendTreeChangeEvent(api::automation::TREE_CHANGE_TYPE_TEXTCHANGED, tree, | 1164 SendTreeChangeEvent(api::automation::TREE_CHANGE_TYPE_TEXTCHANGED, tree, |
1163 tree->GetFromId(id)); | 1165 tree->GetFromId(id)); |
1164 } | 1166 } |
1165 text_changed_node_ids_.clear(); | 1167 text_changed_node_ids_.clear(); |
1166 } | 1168 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1259 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); | 1261 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); |
1260 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); | 1262 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); |
1261 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); | 1263 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); |
1262 args->Set(1U, nodes); | 1264 args->Set(1U, nodes); |
1263 for (size_t i = 0; i < ids.size(); ++i) | 1265 for (size_t i = 0; i < ids.size(); ++i) |
1264 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); | 1266 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); |
1265 context()->DispatchEvent("automationInternal.onNodesRemoved", args); | 1267 context()->DispatchEvent("automationInternal.onNodesRemoved", args); |
1266 } | 1268 } |
1267 | 1269 |
1268 } // namespace extensions | 1270 } // namespace extensions |
OLD | NEW |