| 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_manager.h" | 5 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/browser/accessibility/browser_accessibility.h" | 8 #include "content/browser/accessibility/browser_accessibility.h" |
| 9 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 9 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| 10 #include "content/common/accessibility_messages.h" | 10 #include "content/common/accessibility_messages.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 BrowserAccessibility* BrowserAccessibilityFactory::Create() { | 14 BrowserAccessibility* BrowserAccessibilityFactory::Create() { |
| 15 return BrowserAccessibility::Create(); | 15 return BrowserAccessibility::Create(); |
| 16 } | 16 } |
| 17 | 17 |
| 18 #if !defined(OS_MACOSX) && \ | 18 #if !defined(OS_MACOSX) && \ |
| 19 !defined(OS_WIN) && \ | 19 !defined(OS_WIN) && \ |
| 20 !defined(TOOLKIT_GTK) | 20 !defined(TOOLKIT_GTK) && \ |
| 21 !defined(OS_ANDROID) \ |
| 21 // We have subclassess of BrowserAccessibilityManager on Mac, Linux/GTK, | 22 // We have subclassess of BrowserAccessibilityManager on Mac, Linux/GTK, |
| 22 // and Win. For any other platform, instantiate the base class. | 23 // and Win. For any other platform, instantiate the base class. |
| 23 // static | 24 // static |
| 24 BrowserAccessibilityManager* BrowserAccessibilityManager::Create( | 25 BrowserAccessibilityManager* BrowserAccessibilityManager::Create( |
| 25 const AccessibilityNodeData& src, | 26 const AccessibilityNodeData& src, |
| 26 BrowserAccessibilityDelegate* delegate, | 27 BrowserAccessibilityDelegate* delegate, |
| 27 BrowserAccessibilityFactory* factory) { | 28 BrowserAccessibilityFactory* factory) { |
| 28 return new BrowserAccessibilityManager(src, delegate, factory); | 29 return new BrowserAccessibilityManager(src, delegate, factory); |
| 29 } | 30 } |
| 30 #endif | 31 #endif |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 85 } |
| 85 | 86 |
| 86 bool BrowserAccessibilityManager::IsOSKAllowed(const gfx::Rect& bounds) { | 87 bool BrowserAccessibilityManager::IsOSKAllowed(const gfx::Rect& bounds) { |
| 87 if (!delegate_ || !delegate_->HasFocus()) | 88 if (!delegate_ || !delegate_->HasFocus()) |
| 88 return false; | 89 return false; |
| 89 | 90 |
| 90 gfx::Point touch_point = delegate_->GetLastTouchEventLocation(); | 91 gfx::Point touch_point = delegate_->GetLastTouchEventLocation(); |
| 91 return bounds.Contains(touch_point); | 92 return bounds.Contains(touch_point); |
| 92 } | 93 } |
| 93 | 94 |
| 95 bool BrowserAccessibilityManager::UseRootScrollOffsetsWhenComputingBounds() { |
| 96 return true; |
| 97 } |
| 98 |
| 94 void BrowserAccessibilityManager::RemoveNode(BrowserAccessibility* node) { | 99 void BrowserAccessibilityManager::RemoveNode(BrowserAccessibility* node) { |
| 95 if (node == focus_) | 100 if (node == focus_) |
| 96 SetFocus(root_, false); | 101 SetFocus(root_, false); |
| 97 int renderer_id = node->renderer_id(); | 102 int renderer_id = node->renderer_id(); |
| 98 renderer_id_map_.erase(renderer_id); | 103 renderer_id_map_.erase(renderer_id); |
| 99 } | 104 } |
| 100 | 105 |
| 101 void BrowserAccessibilityManager::OnAccessibilityNotifications( | 106 void BrowserAccessibilityManager::OnAccessibilityNotifications( |
| 102 const std::vector<AccessibilityHostMsg_NotificationParams>& params) { | 107 const std::vector<AccessibilityHostMsg_NotificationParams>& params) { |
| 103 for (uint32 index = 0; index < params.size(); index++) { | 108 for (uint32 index = 0; index < params.size(); index++) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 156 |
| 152 void BrowserAccessibilityManager::SetFocus( | 157 void BrowserAccessibilityManager::SetFocus( |
| 153 BrowserAccessibility* node, bool notify) { | 158 BrowserAccessibility* node, bool notify) { |
| 154 if (focus_ != node) | 159 if (focus_ != node) |
| 155 focus_ = node; | 160 focus_ = node; |
| 156 | 161 |
| 157 if (notify && node && delegate_) | 162 if (notify && node && delegate_) |
| 158 delegate_->SetAccessibilityFocus(node->renderer_id()); | 163 delegate_->SetAccessibilityFocus(node->renderer_id()); |
| 159 } | 164 } |
| 160 | 165 |
| 166 void BrowserAccessibilityManager::SetRoot(BrowserAccessibility* node) { |
| 167 root_ = node; |
| 168 NotifyRootChanged(); |
| 169 } |
| 170 |
| 161 void BrowserAccessibilityManager::DoDefaultAction( | 171 void BrowserAccessibilityManager::DoDefaultAction( |
| 162 const BrowserAccessibility& node) { | 172 const BrowserAccessibility& node) { |
| 163 if (delegate_) | 173 if (delegate_) |
| 164 delegate_->AccessibilityDoDefaultAction(node.renderer_id()); | 174 delegate_->AccessibilityDoDefaultAction(node.renderer_id()); |
| 165 } | 175 } |
| 166 | 176 |
| 167 void BrowserAccessibilityManager::ScrollToMakeVisible( | 177 void BrowserAccessibilityManager::ScrollToMakeVisible( |
| 168 const BrowserAccessibility& node, gfx::Rect subfocus) { | 178 const BrowserAccessibility& node, gfx::Rect subfocus) { |
| 169 if (delegate_) { | 179 if (delegate_) { |
| 170 delegate_->AccessibilityScrollToMakeVisible(node.renderer_id(), subfocus); | 180 delegate_->AccessibilityScrollToMakeVisible(node.renderer_id(), subfocus); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 375 |
| 366 // Finally, swap in the new children vector for the old. | 376 // Finally, swap in the new children vector for the old. |
| 367 instance->SwapChildren(new_children); | 377 instance->SwapChildren(new_children); |
| 368 | 378 |
| 369 // Handle the case where this node is the new root of the tree. | 379 // Handle the case where this node is the new root of the tree. |
| 370 if (src.role == AccessibilityNodeData::ROLE_ROOT_WEB_AREA && | 380 if (src.role == AccessibilityNodeData::ROLE_ROOT_WEB_AREA && |
| 371 (!root_ || root_->renderer_id() != src.id)) { | 381 (!root_ || root_->renderer_id() != src.id)) { |
| 372 if (root_) | 382 if (root_) |
| 373 root_->Destroy(); | 383 root_->Destroy(); |
| 374 if (focus_ == root_) | 384 if (focus_ == root_) |
| 375 focus_ = instance; | 385 SetFocus(instance, false); |
| 376 root_ = instance; | 386 SetRoot(instance); |
| 377 } | 387 } |
| 378 | 388 |
| 379 // Keep track of what node is focused. | 389 // Keep track of what node is focused. |
| 380 if ((src.state >> AccessibilityNodeData::STATE_FOCUSED) & 1) | 390 if (src.role != AccessibilityNodeData::ROLE_ROOT_WEB_AREA && |
| 391 src.role != AccessibilityNodeData::ROLE_WEB_AREA && |
| 392 (src.state >> AccessibilityNodeData::STATE_FOCUSED & 1)) { |
| 381 SetFocus(instance, false); | 393 SetFocus(instance, false); |
| 382 | 394 } |
| 383 return success; | 395 return success; |
| 384 } | 396 } |
| 385 | 397 |
| 386 } // namespace content | 398 } // namespace content |
| OLD | NEW |