| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "content/browser/accessibility/accessibility_tree_formatter_blink.h" | 9 #include "content/browser/accessibility/accessibility_tree_formatter_blink.h" |
| 10 #include "ui/gfx/transform.h" |
| 10 | 11 |
| 11 namespace content { | 12 namespace content { |
| 12 | 13 |
| 13 AccessibilityTreeFormatterBlink::AccessibilityTreeFormatterBlink() | 14 AccessibilityTreeFormatterBlink::AccessibilityTreeFormatterBlink() |
| 14 : AccessibilityTreeFormatter() { | 15 : AccessibilityTreeFormatter() { |
| 15 } | 16 } |
| 16 | 17 |
| 17 AccessibilityTreeFormatterBlink::~AccessibilityTreeFormatterBlink() { | 18 AccessibilityTreeFormatterBlink::~AccessibilityTreeFormatterBlink() { |
| 18 } | 19 } |
| 19 | 20 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 34 return node.InternalGetChild(i); | 35 return node.InternalGetChild(i); |
| 35 } | 36 } |
| 36 | 37 |
| 37 void AccessibilityTreeFormatterBlink::AddProperties( | 38 void AccessibilityTreeFormatterBlink::AddProperties( |
| 38 const BrowserAccessibility& node, | 39 const BrowserAccessibility& node, |
| 39 base::DictionaryValue* dict) { | 40 base::DictionaryValue* dict) { |
| 40 dict->SetInteger("id", node.GetId()); | 41 dict->SetInteger("id", node.GetId()); |
| 41 | 42 |
| 42 dict->SetString("internalRole", ui::ToString(node.GetData().role)); | 43 dict->SetString("internalRole", ui::ToString(node.GetData().role)); |
| 43 | 44 |
| 44 dict->SetInteger("boundsX", node.GetData().location.x()); | 45 gfx::Rect bounds = node.GetData().location; |
| 45 dict->SetInteger("boundsY", node.GetData().location.y()); | 46 dict->SetInteger("boundsX", bounds.x()); |
| 46 dict->SetInteger("boundsWidth", node.GetData().location.width()); | 47 dict->SetInteger("boundsY", bounds.y()); |
| 47 dict->SetInteger("boundsHeight", node.GetData().location.height()); | 48 dict->SetInteger("boundsWidth", bounds.width()); |
| 49 dict->SetInteger("boundsHeight", bounds.height()); |
| 50 |
| 51 gfx::Rect page_bounds = node.GetLocalBoundsRect(); |
| 52 dict->SetInteger("pageBoundsX", page_bounds.x()); |
| 53 dict->SetInteger("pageBoundsY", page_bounds.y()); |
| 54 dict->SetInteger("pageBoundsWidth", page_bounds.width()); |
| 55 dict->SetInteger("pageBoundsHeight", page_bounds.height()); |
| 56 |
| 57 dict->SetBoolean("transform", |
| 58 node.GetData().transform && |
| 59 !node.GetData().transform->IsIdentity()); |
| 48 | 60 |
| 49 for (int state_index = ui::AX_STATE_NONE; | 61 for (int state_index = ui::AX_STATE_NONE; |
| 50 state_index <= ui::AX_STATE_LAST; | 62 state_index <= ui::AX_STATE_LAST; |
| 51 ++state_index) { | 63 ++state_index) { |
| 52 auto state = static_cast<ui::AXState>(state_index); | 64 auto state = static_cast<ui::AXState>(state_index); |
| 53 if (node.HasState(state)) | 65 if (node.HasState(state)) |
| 54 dict->SetBoolean(ui::ToString(state), true); | 66 dict->SetBoolean(ui::ToString(state), true); |
| 55 } | 67 } |
| 56 | 68 |
| 57 for (int attr_index = ui::AX_STRING_ATTRIBUTE_NONE; | 69 for (int attr_index = ui::AX_STRING_ATTRIBUTE_NONE; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 WriteAttribute(false, ui::ToString(state), &line); | 138 WriteAttribute(false, ui::ToString(state), &line); |
| 127 } | 139 } |
| 128 | 140 |
| 129 WriteAttribute(false, | 141 WriteAttribute(false, |
| 130 FormatCoordinates("location", "boundsX", "boundsY", dict), | 142 FormatCoordinates("location", "boundsX", "boundsY", dict), |
| 131 &line); | 143 &line); |
| 132 WriteAttribute(false, | 144 WriteAttribute(false, |
| 133 FormatCoordinates("size", "boundsWidth", "boundsHeight", dict), | 145 FormatCoordinates("size", "boundsWidth", "boundsHeight", dict), |
| 134 &line); | 146 &line); |
| 135 | 147 |
| 148 WriteAttribute(false, |
| 149 FormatCoordinates("pageLocation", |
| 150 "pageBoundsX", "pageBoundsY", dict), |
| 151 &line); |
| 152 WriteAttribute(false, |
| 153 FormatCoordinates("pageSize", |
| 154 "pageBoundsWidth", "pageBoundsHeight", dict), |
| 155 &line); |
| 156 |
| 157 bool transform; |
| 158 if (dict.GetBoolean("transform", &transform) && transform) |
| 159 WriteAttribute(false, "transform", &line); |
| 160 |
| 136 for (int attr_index = ui::AX_STRING_ATTRIBUTE_NONE; | 161 for (int attr_index = ui::AX_STRING_ATTRIBUTE_NONE; |
| 137 attr_index <= ui::AX_STRING_ATTRIBUTE_LAST; | 162 attr_index <= ui::AX_STRING_ATTRIBUTE_LAST; |
| 138 ++attr_index) { | 163 ++attr_index) { |
| 139 auto attr = static_cast<ui::AXStringAttribute>(attr_index); | 164 auto attr = static_cast<ui::AXStringAttribute>(attr_index); |
| 140 std::string string_value; | 165 std::string string_value; |
| 141 if (!dict.GetString(ui::ToString(attr), &string_value)) | 166 if (!dict.GetString(ui::ToString(attr), &string_value)) |
| 142 continue; | 167 continue; |
| 143 WriteAttribute(false, | 168 WriteAttribute(false, |
| 144 base::StringPrintf( | 169 base::StringPrintf( |
| 145 "%s='%s'", | 170 "%s='%s'", |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 235 |
| 211 const std::string AccessibilityTreeFormatterBlink::GetAllowString() { | 236 const std::string AccessibilityTreeFormatterBlink::GetAllowString() { |
| 212 return "@BLINK-ALLOW:"; | 237 return "@BLINK-ALLOW:"; |
| 213 } | 238 } |
| 214 | 239 |
| 215 const std::string AccessibilityTreeFormatterBlink::GetDenyString() { | 240 const std::string AccessibilityTreeFormatterBlink::GetDenyString() { |
| 216 return "@BLINK-DENY:"; | 241 return "@BLINK-DENY:"; |
| 217 } | 242 } |
| 218 | 243 |
| 219 } // namespace content | 244 } // namespace content |
| OLD | NEW |