Chromium Code Reviews| 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 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 988 TreeCache* cache = GetTreeCacheFromTreeID(tree_id); | 988 TreeCache* cache = GetTreeCacheFromTreeID(tree_id); |
| 989 if (!cache) | 989 if (!cache) |
| 990 return; | 990 return; |
| 991 | 991 |
| 992 ui::AXNode* node = cache->tree.GetFromId(node_id); | 992 ui::AXNode* node = cache->tree.GetFromId(node_id); |
| 993 if (!node) | 993 if (!node) |
| 994 return; | 994 return; |
| 995 | 995 |
| 996 v8::Local<v8::Object> state(v8::Object::New(isolate)); | 996 v8::Local<v8::Object> state(v8::Object::New(isolate)); |
| 997 uint32_t state_pos = 0, state_shifter = node->data().state; | 997 uint32_t state_pos = 0, state_shifter = node->data().state; |
| 998 while (state_shifter) { | 998 while (state_shifter && state_shifter <= ui::AX_STATE_LAST) { |
|
dmazzoni
2016/11/22 18:11:42
Is this related?
David Tseng
2016/11/22 18:26:28
Somewhat. When toggling off/on, we get incomplete
| |
| 999 if (state_shifter & 1) { | 999 if (state_shifter & 1) { |
| 1000 std::string key = ToString(static_cast<ui::AXState>(state_pos)); | 1000 std::string key = ToString(static_cast<ui::AXState>(state_pos)); |
| 1001 state->Set(CreateV8String(isolate, key), v8::Boolean::New(isolate, true)); | 1001 state->Set(CreateV8String(isolate, key), v8::Boolean::New(isolate, true)); |
| 1002 } | 1002 } |
| 1003 state_shifter = state_shifter >> 1; | 1003 state_shifter = state_shifter >> 1; |
| 1004 state_pos++; | 1004 state_pos++; |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 TreeCache* top_cache = GetTreeCacheFromTreeID(0); | 1007 TreeCache* top_cache = GetTreeCacheFromTreeID(0); |
| 1008 if (!top_cache) | 1008 if (!top_cache) |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1150 cache->owner = this; | 1150 cache->owner = this; |
| 1151 tree_id_to_tree_cache_map_.insert(std::make_pair(tree_id, cache)); | 1151 tree_id_to_tree_cache_map_.insert(std::make_pair(tree_id, cache)); |
| 1152 axtree_to_tree_cache_map_.insert(std::make_pair(&cache->tree, cache)); | 1152 axtree_to_tree_cache_map_.insert(std::make_pair(&cache->tree, cache)); |
| 1153 } else { | 1153 } else { |
| 1154 cache = iter->second; | 1154 cache = iter->second; |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 // Update the internal state whether it's the active profile or not. | 1157 // Update the internal state whether it's the active profile or not. |
| 1158 cache->location_offset = params.location_offset; | 1158 cache->location_offset = params.location_offset; |
| 1159 deleted_node_ids_.clear(); | 1159 deleted_node_ids_.clear(); |
| 1160 v8::Isolate* isolate = GetIsolate(); | |
| 1161 v8::HandleScope handle_scope(isolate); | |
| 1162 v8::Context::Scope context_scope(context()->v8_context()); | |
| 1163 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 1U)); | |
| 1160 if (!cache->tree.Unserialize(params.update)) { | 1164 if (!cache->tree.Unserialize(params.update)) { |
| 1161 LOG(ERROR) << cache->tree.error(); | 1165 LOG(ERROR) << cache->tree.error(); |
| 1166 args->Set(0U, | |
| 1167 v8::Number::New(isolate, tree_id)); | |
|
dmazzoni
2016/11/22 18:11:42
nit: fits on one line
David Tseng
2016/11/22 18:26:28
Done.
| |
| 1168 context()->DispatchEvent( | |
| 1169 "automationInternal.onAccessibilityTreeSerializationError", args); | |
| 1162 return; | 1170 return; |
| 1163 } | 1171 } |
| 1164 | 1172 |
| 1165 // Don't send any events if it's not the active profile. | 1173 // Don't send any events if it's not the active profile. |
| 1166 if (!is_active_profile) | 1174 if (!is_active_profile) |
| 1167 return; | 1175 return; |
| 1168 | 1176 |
| 1169 SendNodesRemovedEvent(&cache->tree, deleted_node_ids_); | 1177 SendNodesRemovedEvent(&cache->tree, deleted_node_ids_); |
| 1170 deleted_node_ids_.clear(); | 1178 deleted_node_ids_.clear(); |
| 1171 | 1179 |
| 1172 v8::Isolate* isolate = GetIsolate(); | |
| 1173 v8::HandleScope handle_scope(isolate); | |
| 1174 v8::Context::Scope context_scope(context()->v8_context()); | |
| 1175 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 1U)); | |
| 1176 v8::Local<v8::Object> event_params(v8::Object::New(GetIsolate())); | 1180 v8::Local<v8::Object> event_params(v8::Object::New(GetIsolate())); |
| 1177 event_params->Set(CreateV8String(isolate, "treeID"), | 1181 event_params->Set(CreateV8String(isolate, "treeID"), |
| 1178 v8::Integer::New(GetIsolate(), params.tree_id)); | 1182 v8::Integer::New(GetIsolate(), params.tree_id)); |
| 1179 event_params->Set(CreateV8String(isolate, "targetID"), | 1183 event_params->Set(CreateV8String(isolate, "targetID"), |
| 1180 v8::Integer::New(GetIsolate(), params.id)); | 1184 v8::Integer::New(GetIsolate(), params.id)); |
| 1181 event_params->Set(CreateV8String(isolate, "eventType"), | 1185 event_params->Set(CreateV8String(isolate, "eventType"), |
| 1182 CreateV8String(isolate, ToString(params.event_type))); | 1186 CreateV8String(isolate, ToString(params.event_type))); |
| 1183 event_params->Set(CreateV8String(isolate, "eventFrom"), | 1187 event_params->Set(CreateV8String(isolate, "eventFrom"), |
| 1184 CreateV8String(isolate, ToString(params.event_from))); | 1188 CreateV8String(isolate, ToString(params.event_from))); |
| 1185 event_params->Set(CreateV8String(isolate, "mouseX"), | 1189 event_params->Set(CreateV8String(isolate, "mouseX"), |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1412 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); | 1416 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); |
| 1413 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); | 1417 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); |
| 1414 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); | 1418 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); |
| 1415 args->Set(1U, nodes); | 1419 args->Set(1U, nodes); |
| 1416 for (size_t i = 0; i < ids.size(); ++i) | 1420 for (size_t i = 0; i < ids.size(); ++i) |
| 1417 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); | 1421 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); |
| 1418 context()->DispatchEvent("automationInternal.onNodesRemoved", args); | 1422 context()->DispatchEvent("automationInternal.onNodesRemoved", args); |
| 1419 } | 1423 } |
| 1420 | 1424 |
| 1421 } // namespace extensions | 1425 } // namespace extensions |
| OLD | NEW |