| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 bounds.Union(child_bounds); | 108 bounds.Union(child_bounds); |
| 109 } | 109 } |
| 110 | 110 |
| 111 return bounds; | 111 return bounds; |
| 112 } | 112 } |
| 113 | 113 |
| 114 // Compute the bounding box of a node in global coordinates, walking up the | 114 // Compute the bounding box of a node in global coordinates, walking up the |
| 115 // parent hierarchy to offset by frame offsets and scroll offsets. | 115 // parent hierarchy to offset by frame offsets and scroll offsets. |
| 116 static gfx::Rect ComputeGlobalNodeBounds(TreeCache* cache, ui::AXNode* node) { | 116 static gfx::Rect ComputeGlobalNodeBounds(TreeCache* cache, ui::AXNode* node) { |
| 117 gfx::Rect bounds = ComputeLocalNodeBounds(cache, node); | 117 gfx::Rect bounds = ComputeLocalNodeBounds(cache, node); |
| 118 ui::AXNode* parent = node->parent(); | 118 |
| 119 bool need_to_offset_web_area = node->data().role == ui::AX_ROLE_WEB_AREA || | 119 ui::AXNode* root = cache->tree.root(); |
| 120 node->data().role == ui::AX_ROLE_ROOT_WEB_AREA; | 120 while (root) { |
| 121 while (parent) { | 121 // Apply scroll offsets. |
| 122 if (bounds.IsEmpty()) { | 122 if (root != node) { |
| 123 bounds = parent->data().location; | 123 int sx = 0; |
| 124 } else if (need_to_offset_web_area && parent->data().location.width() > 0 && | 124 int sy = 0; |
| 125 parent->data().location.height() > 0) { | 125 if (root->data().GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && |
| 126 bounds.Offset(parent->data().location.x(), parent->data().location.y()); | 126 root->data().GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { |
| 127 need_to_offset_web_area = false; | 127 bounds.Offset(-sx, -sy); |
| 128 } |
| 128 } | 129 } |
| 129 | 130 |
| 130 if (parent->data().role == ui::AX_ROLE_WEB_AREA || | 131 if (root->data().transform) { |
| 131 parent->data().role == ui::AX_ROLE_ROOT_WEB_AREA) { | 132 gfx::RectF boundsf(bounds); |
| 132 int sx = 0; | 133 root->data().transform->TransformRect(&boundsf); |
| 133 int sy = 0; | 134 bounds = gfx::Rect(boundsf.x(), boundsf.y(), boundsf.width(), |
| 134 if (parent->data().GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && | 135 boundsf.height()); |
| 135 parent->data().GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { | |
| 136 bounds.Offset(-sx, -sy); | |
| 137 } | |
| 138 need_to_offset_web_area = true; | |
| 139 } | 136 } |
| 140 parent = cache->owner->GetParent(parent, &cache); | 137 |
| 138 ui::AXNode* parent = cache->owner->GetParent(root, &cache); |
| 139 if (!parent) |
| 140 break; |
| 141 |
| 142 root = cache->tree.root(); |
| 141 } | 143 } |
| 142 | 144 |
| 143 return bounds; | 145 return bounds; |
| 144 } | 146 } |
| 145 | 147 |
| 146 ui::AXNode* FindNodeWithChildTreeId(ui::AXNode* node, int child_tree_id) { | 148 ui::AXNode* FindNodeWithChildTreeId(ui::AXNode* node, int child_tree_id) { |
| 147 if (child_tree_id == node->data().GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) | 149 if (child_tree_id == node->data().GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) |
| 148 return node; | 150 return node; |
| 149 | 151 |
| 150 for (int i = 0; i < node->child_count(); ++i) { | 152 for (int i = 0; i < node->child_count(); ++i) { |
| (...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); | 1255 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); |
| 1254 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); | 1256 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); |
| 1255 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); | 1257 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); |
| 1256 args->Set(1U, nodes); | 1258 args->Set(1U, nodes); |
| 1257 for (size_t i = 0; i < ids.size(); ++i) | 1259 for (size_t i = 0; i < ids.size(); ++i) |
| 1258 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); | 1260 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); |
| 1259 context()->DispatchEvent("automationInternal.onNodesRemoved", args); | 1261 context()->DispatchEvent("automationInternal.onNodesRemoved", args); |
| 1260 } | 1262 } |
| 1261 | 1263 |
| 1262 } // namespace extensions | 1264 } // namespace extensions |
| OLD | NEW |