Chromium Code Reviews| Index: chrome/renderer/extensions/automation_internal_custom_bindings.cc |
| diff --git a/chrome/renderer/extensions/automation_internal_custom_bindings.cc b/chrome/renderer/extensions/automation_internal_custom_bindings.cc |
| index 9241f859718a90edfbbbf968647db336ae95b772..f10491320638e63b1c0ab17014d35b2d275ed451 100644 |
| --- a/chrome/renderer/extensions/automation_internal_custom_bindings.cc |
| +++ b/chrome/renderer/extensions/automation_internal_custom_bindings.cc |
| @@ -128,6 +128,7 @@ static gfx::Rect ComputeGlobalNodeBounds(TreeCache* cache, |
| if (node->data().transform) |
| node->data().transform->TransformRect(&bounds); |
| + TreeCache* previous_cache = cache; |
|
aboxhall
2017/05/26 01:04:59
Where does cache get mutated?
dmazzoni
2017/05/26 06:41:33
Commented.
|
| ui::AXNode* container = |
| cache->tree.GetFromId(node->data().offset_container_id); |
| if (!container) { |
| @@ -141,6 +142,16 @@ static gfx::Rect ComputeGlobalNodeBounds(TreeCache* cache, |
| if (!container || container == node) |
| break; |
| + // All trees other than the desktop tree are scaled by the device |
| + // scale factor. When crossing out of another tree into the desktop |
| + // tree, unscale the bounds by the device scale factor. |
| + if (previous_cache->tree_id != api::automation::kDesktopTreeID && |
| + cache->tree_id == api::automation::kDesktopTreeID) { |
| + float scale_factor = cache->owner->GetDeviceScaleFactor(); |
| + if (scale_factor > 0) |
| + bounds.Scale(1.0 / scale_factor); |
| + } |
| + |
| gfx::RectF container_bounds = container->data().location; |
| bounds.Offset(container_bounds.x(), container_bounds.y()); |
| @@ -154,17 +165,6 @@ static gfx::Rect ComputeGlobalNodeBounds(TreeCache* cache, |
| node = container; |
| } |
| - // All trees other than the desktop tree are scaled by the device |
| - // scale factor. Unscale them so they're all in consistent units. |
| - if (cache->tree_id != api::automation::kDesktopTreeID) { |
| - float scale_factor = cache->owner->context() |
| - ->GetRenderFrame() |
| - ->GetRenderView() |
| - ->GetDeviceScaleFactor(); |
| - if (scale_factor > 0) |
| - bounds.Scale(1.0 / scale_factor); |
| - } |
| - |
| return gfx::ToEnclosingRect(bounds); |
| } |
| @@ -1093,6 +1093,10 @@ ui::AXNode* AutomationInternalCustomBindings::GetParent( |
| return nullptr; |
| } |
| +float AutomationInternalCustomBindings::GetDeviceScaleFactor() const { |
| + return context()->GetRenderFrame()->GetRenderView()->GetDeviceScaleFactor(); |
| +} |
| + |
| void AutomationInternalCustomBindings::RouteTreeIDFunction( |
| const std::string& name, |
| TreeIDFunction callback) { |