| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/accessibility/browser_accessibility.h" | 5 #include "content/browser/accessibility/browser_accessibility.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "content/browser/accessibility/browser_accessibility_manager.h" | 10 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 index_in_parent_ < static_cast<int>(parent_->children_.size() - 1)) { | 126 index_in_parent_ < static_cast<int>(parent_->children_.size() - 1)) { |
| 127 return parent_->children_[index_in_parent_ + 1]; | 127 return parent_->children_[index_in_parent_ + 1]; |
| 128 } | 128 } |
| 129 | 129 |
| 130 return NULL; | 130 return NULL; |
| 131 } | 131 } |
| 132 | 132 |
| 133 gfx::Rect BrowserAccessibility::GetLocalBoundsRect() { | 133 gfx::Rect BrowserAccessibility::GetLocalBoundsRect() { |
| 134 gfx::Rect bounds = location_; | 134 gfx::Rect bounds = location_; |
| 135 | 135 |
| 136 // Adjust top left position by the root document's scroll offset. | 136 // Walk up the parent chain. Every time we encounter a Web Area, offset |
| 137 BrowserAccessibility* root = manager_->GetRoot(); | 137 // based on the scroll bars and then offset based on the origin of that |
| 138 int scroll_x = 0; | 138 // nested web area. |
| 139 int scroll_y = 0; | 139 BrowserAccessibility* parent = parent_; |
| 140 if (!root->GetIntAttribute(AccessibilityNodeData::ATTR_SCROLL_X, &scroll_x) || | 140 bool need_to_offset_web_area = |
| 141 !root->GetIntAttribute(AccessibilityNodeData::ATTR_SCROLL_Y, &scroll_y)) { | 141 (role_ == AccessibilityNodeData::ROLE_WEB_AREA); |
| 142 return bounds; | 142 while (parent) { |
| 143 if (need_to_offset_web_area && |
| 144 parent->location().width() > 0 && |
| 145 parent->location().height() > 0) { |
| 146 bounds.Offset(parent->location().x(), parent->location().y()); |
| 147 need_to_offset_web_area = false; |
| 148 } |
| 149 if (parent->role() == AccessibilityNodeData::ROLE_WEB_AREA) { |
| 150 int sx = 0; |
| 151 int sy = 0; |
| 152 if (parent->GetIntAttribute(AccessibilityNodeData::ATTR_SCROLL_X, &sx) && |
| 153 parent->GetIntAttribute(AccessibilityNodeData::ATTR_SCROLL_Y, &sy)) { |
| 154 bounds.Offset(-sx, -sy); |
| 155 } |
| 156 need_to_offset_web_area = true; |
| 157 } |
| 158 parent = parent->parent(); |
| 143 } | 159 } |
| 144 bounds.Offset(-scroll_x, -scroll_y); | |
| 145 | 160 |
| 146 return bounds; | 161 return bounds; |
| 147 } | 162 } |
| 148 | 163 |
| 149 gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() { | 164 gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() { |
| 150 gfx::Rect bounds = GetLocalBoundsRect(); | 165 gfx::Rect bounds = GetLocalBoundsRect(); |
| 151 | 166 |
| 152 // Adjust the bounds by the top left corner of the containing view's bounds | 167 // Adjust the bounds by the top left corner of the containing view's bounds |
| 153 // in screen coordinates. | 168 // in screen coordinates. |
| 154 bounds.Offset(manager_->GetViewBounds().OffsetFromOrigin()); | 169 bounds.Offset(manager_->GetViewBounds().OffsetFromOrigin()); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 for (size_t i = 0; i < children_.size(); ++i) | 330 for (size_t i = 0; i < children_.size(); ++i) |
| 316 result += children_[i]->GetTextRecursive(); | 331 result += children_[i]->GetTextRecursive(); |
| 317 return result; | 332 return result; |
| 318 } | 333 } |
| 319 | 334 |
| 320 void BrowserAccessibility::PreInitialize() { | 335 void BrowserAccessibility::PreInitialize() { |
| 321 instance_active_ = true; | 336 instance_active_ = true; |
| 322 } | 337 } |
| 323 | 338 |
| 324 } // namespace content | 339 } // namespace content |
| OLD | NEW |