| 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> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/common/extensions/api/automation_api_constants.h" |
| 16 #include "chrome/common/extensions/chrome_extension_messages.h" | 17 #include "chrome/common/extensions/chrome_extension_messages.h" |
| 17 #include "chrome/common/extensions/manifest_handlers/automation.h" | 18 #include "chrome/common/extensions/manifest_handlers/automation.h" |
| 18 #include "content/public/renderer/render_frame.h" | 19 #include "content/public/renderer/render_frame.h" |
| 19 #include "content/public/renderer/render_thread.h" | 20 #include "content/public/renderer/render_thread.h" |
| 20 #include "content/public/renderer/render_view.h" | 21 #include "content/public/renderer/render_view.h" |
| 21 #include "extensions/common/extension.h" | 22 #include "extensions/common/extension.h" |
| 22 #include "extensions/common/manifest.h" | 23 #include "extensions/common/manifest.h" |
| 23 #include "extensions/renderer/script_context.h" | 24 #include "extensions/renderer/script_context.h" |
| 24 #include "ipc/message_filter.h" | 25 #include "ipc/message_filter.h" |
| 25 #include "ui/accessibility/ax_enums.h" | 26 #include "ui/accessibility/ax_enums.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 int scroll_x = 0; | 143 int scroll_x = 0; |
| 143 int scroll_y = 0; | 144 int scroll_y = 0; |
| 144 if (container->data().GetIntAttribute(ui::AX_ATTR_SCROLL_X, &scroll_x) && | 145 if (container->data().GetIntAttribute(ui::AX_ATTR_SCROLL_X, &scroll_x) && |
| 145 container->data().GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &scroll_y)) { | 146 container->data().GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &scroll_y)) { |
| 146 bounds.Offset(-scroll_x, -scroll_y); | 147 bounds.Offset(-scroll_x, -scroll_y); |
| 147 } | 148 } |
| 148 | 149 |
| 149 node = container; | 150 node = container; |
| 150 } | 151 } |
| 151 | 152 |
| 153 // All trees other than the desktop tree are scaled by the device |
| 154 // scale factor. Unscale them so they're all in consistent units. |
| 155 if (cache->tree_id != api::automation::kDesktopTreeID) { |
| 156 float scale_factor = cache->owner->context() |
| 157 ->GetRenderFrame() |
| 158 ->GetRenderView() |
| 159 ->GetDeviceScaleFactor(); |
| 160 if (scale_factor > 0) |
| 161 bounds.Scale(1.0 / scale_factor); |
| 162 } |
| 163 |
| 152 return gfx::ToEnclosingRect(bounds); | 164 return gfx::ToEnclosingRect(bounds); |
| 153 } | 165 } |
| 154 | 166 |
| 155 ui::AXNode* FindNodeWithChildTreeId(ui::AXNode* node, int child_tree_id) { | 167 ui::AXNode* FindNodeWithChildTreeId(ui::AXNode* node, int child_tree_id) { |
| 156 if (child_tree_id == node->data().GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) | 168 if (child_tree_id == node->data().GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) |
| 157 return node; | 169 return node; |
| 158 | 170 |
| 159 for (int i = 0; i < node->child_count(); ++i) { | 171 for (int i = 0; i < node->child_count(); ++i) { |
| 160 ui::AXNode* result = | 172 ui::AXNode* result = |
| 161 FindNodeWithChildTreeId(node->ChildAtIndex(i), child_tree_id); | 173 FindNodeWithChildTreeId(node->ChildAtIndex(i), child_tree_id); |
| (...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); | 1396 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); |
| 1385 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); | 1397 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); |
| 1386 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); | 1398 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); |
| 1387 args->Set(1U, nodes); | 1399 args->Set(1U, nodes); |
| 1388 for (size_t i = 0; i < ids.size(); ++i) | 1400 for (size_t i = 0; i < ids.size(); ++i) |
| 1389 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); | 1401 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); |
| 1390 context()->DispatchEvent("automationInternal.onNodesRemoved", args); | 1402 context()->DispatchEvent("automationInternal.onNodesRemoved", args); |
| 1391 } | 1403 } |
| 1392 | 1404 |
| 1393 } // namespace extensions | 1405 } // namespace extensions |
| OLD | NEW |