Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager.cc

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/common/accessibility_messages.h" 9 #include "content/common/accessibility_messages.h"
10 10
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 if (!UpdateNodes(nodes)) 62 if (!UpdateNodes(nodes))
63 return; 63 return;
64 if (!focus_) 64 if (!focus_)
65 SetFocus(root_, false); 65 SetFocus(root_, false);
66 } 66 }
67 67
68 // static 68 // static
69 AccessibilityNodeData BrowserAccessibilityManager::GetEmptyDocument() { 69 AccessibilityNodeData BrowserAccessibilityManager::GetEmptyDocument() {
70 AccessibilityNodeData empty_document; 70 AccessibilityNodeData empty_document;
71 empty_document.id = 0; 71 empty_document.id = 0;
72 empty_document.role = WebKit::WebAXRoleRootWebArea; 72 empty_document.role = blink::WebAXRoleRootWebArea;
73 return empty_document; 73 return empty_document;
74 } 74 }
75 75
76 BrowserAccessibility* BrowserAccessibilityManager::GetRoot() { 76 BrowserAccessibility* BrowserAccessibilityManager::GetRoot() {
77 return root_; 77 return root_;
78 } 78 }
79 79
80 BrowserAccessibility* BrowserAccessibilityManager::GetFromRendererID( 80 BrowserAccessibility* BrowserAccessibilityManager::GetFromRendererID(
81 int32 renderer_id) { 81 int32 renderer_id) {
82 base::hash_map<int32, BrowserAccessibility*>::iterator iter = 82 base::hash_map<int32, BrowserAccessibility*>::iterator iter =
83 renderer_id_map_.find(renderer_id); 83 renderer_id_map_.find(renderer_id);
84 if (iter != renderer_id_map_.end()) 84 if (iter != renderer_id_map_.end())
85 return iter->second; 85 return iter->second;
86 return NULL; 86 return NULL;
87 } 87 }
88 88
89 void BrowserAccessibilityManager::GotFocus(bool touch_event_context) { 89 void BrowserAccessibilityManager::GotFocus(bool touch_event_context) {
90 if (!touch_event_context) 90 if (!touch_event_context)
91 osk_state_ = OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED; 91 osk_state_ = OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED;
92 92
93 if (!focus_) 93 if (!focus_)
94 return; 94 return;
95 95
96 NotifyAccessibilityEvent(WebKit::WebAXEventFocus, focus_); 96 NotifyAccessibilityEvent(blink::WebAXEventFocus, focus_);
97 } 97 }
98 98
99 void BrowserAccessibilityManager::WasHidden() { 99 void BrowserAccessibilityManager::WasHidden() {
100 osk_state_ = OSK_DISALLOWED_BECAUSE_TAB_HIDDEN; 100 osk_state_ = OSK_DISALLOWED_BECAUSE_TAB_HIDDEN;
101 } 101 }
102 102
103 void BrowserAccessibilityManager::GotMouseDown() { 103 void BrowserAccessibilityManager::GotMouseDown() {
104 osk_state_ = OSK_ALLOWED_WITHIN_FOCUSED_OBJECT; 104 osk_state_ = OSK_ALLOWED_WITHIN_FOCUSED_OBJECT;
105 NotifyAccessibilityEvent(WebKit::WebAXEventFocus, focus_); 105 NotifyAccessibilityEvent(blink::WebAXEventFocus, focus_);
106 } 106 }
107 107
108 bool BrowserAccessibilityManager::IsOSKAllowed(const gfx::Rect& bounds) { 108 bool BrowserAccessibilityManager::IsOSKAllowed(const gfx::Rect& bounds) {
109 if (!delegate_ || !delegate_->HasFocus()) 109 if (!delegate_ || !delegate_->HasFocus())
110 return false; 110 return false;
111 111
112 gfx::Point touch_point = delegate_->GetLastTouchEventLocation(); 112 gfx::Point touch_point = delegate_->GetLastTouchEventLocation();
113 return bounds.Contains(touch_point); 113 return bounds.Contains(touch_point);
114 } 114 }
115 115
(...skipping 16 matching lines...) Expand all
132 // Update nodes that changed. 132 // Update nodes that changed.
133 if (!UpdateNodes(param.nodes)) 133 if (!UpdateNodes(param.nodes))
134 return; 134 return;
135 135
136 // Find the node corresponding to the id that's the target of the 136 // Find the node corresponding to the id that's the target of the
137 // event (which may not be the root of the update tree). 137 // event (which may not be the root of the update tree).
138 BrowserAccessibility* node = GetFromRendererID(param.id); 138 BrowserAccessibility* node = GetFromRendererID(param.id);
139 if (!node) 139 if (!node)
140 continue; 140 continue;
141 141
142 WebKit::WebAXEvent event_type = param.event_type; 142 blink::WebAXEvent event_type = param.event_type;
143 if (event_type == WebKit::WebAXEventFocus || 143 if (event_type == blink::WebAXEventFocus ||
144 event_type == WebKit::WebAXEventBlur) { 144 event_type == blink::WebAXEventBlur) {
145 SetFocus(node, false); 145 SetFocus(node, false);
146 146
147 if (osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_HIDDEN && 147 if (osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_HIDDEN &&
148 osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED) 148 osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED)
149 osk_state_ = OSK_ALLOWED; 149 osk_state_ = OSK_ALLOWED;
150 150
151 // Don't send a native focus event if the window itself doesn't 151 // Don't send a native focus event if the window itself doesn't
152 // have focus. 152 // have focus.
153 if (delegate_ && !delegate_->HasFocus()) 153 if (delegate_ && !delegate_->HasFocus())
154 continue; 154 continue;
155 } 155 }
156 156
157 // Send the event event to the operating system. 157 // Send the event event to the operating system.
158 NotifyAccessibilityEvent(event_type, node); 158 NotifyAccessibilityEvent(event_type, node);
159 159
160 // Set initial focus when a page is loaded. 160 // Set initial focus when a page is loaded.
161 if (event_type == WebKit::WebAXEventLoadComplete) { 161 if (event_type == blink::WebAXEventLoadComplete) {
162 if (!focus_) 162 if (!focus_)
163 SetFocus(root_, false); 163 SetFocus(root_, false);
164 if (!delegate_ || delegate_->HasFocus()) 164 if (!delegate_ || delegate_->HasFocus())
165 NotifyAccessibilityEvent(WebKit::WebAXEventFocus, focus_); 165 NotifyAccessibilityEvent(blink::WebAXEventFocus, focus_);
166 } 166 }
167 } 167 }
168 } 168 }
169 169
170 BrowserAccessibility* BrowserAccessibilityManager::GetFocus( 170 BrowserAccessibility* BrowserAccessibilityManager::GetFocus(
171 BrowserAccessibility* root) { 171 BrowserAccessibility* root) {
172 if (focus_ && (!root || focus_->IsDescendantOf(root))) 172 if (focus_ && (!root || focus_->IsDescendantOf(root)))
173 return focus_; 173 return focus_;
174 174
175 return NULL; 175 return NULL;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 if (new_child_ids.find(src.child_ids[i]) != new_child_ids.end()) 326 if (new_child_ids.find(src.child_ids[i]) != new_child_ids.end())
327 return false; 327 return false;
328 new_child_ids.insert(src.child_ids[i]); 328 new_child_ids.insert(src.child_ids[i]);
329 } 329 }
330 330
331 // Look up the node by id. If it's not found, then either the root 331 // Look up the node by id. If it's not found, then either the root
332 // of the tree is being swapped, or we're out of sync with the renderer 332 // of the tree is being swapped, or we're out of sync with the renderer
333 // and this is a serious error. 333 // and this is a serious error.
334 BrowserAccessibility* instance = GetFromRendererID(src.id); 334 BrowserAccessibility* instance = GetFromRendererID(src.id);
335 if (!instance) { 335 if (!instance) {
336 if (src.role != WebKit::WebAXRoleRootWebArea) 336 if (src.role != blink::WebAXRoleRootWebArea)
337 return false; 337 return false;
338 instance = CreateNode(NULL, src.id, 0); 338 instance = CreateNode(NULL, src.id, 0);
339 } 339 }
340 340
341 // TODO(dmazzoni): avoid a linear scan here. 341 // TODO(dmazzoni): avoid a linear scan here.
342 for (size_t i = 0; i < src.bool_attributes.size(); i++) { 342 for (size_t i = 0; i < src.bool_attributes.size(); i++) {
343 if (src.bool_attributes[i].first == 343 if (src.bool_attributes[i].first ==
344 AccessibilityNodeData::ATTR_UPDATE_LOCATION_ONLY) { 344 AccessibilityNodeData::ATTR_UPDATE_LOCATION_ONLY) {
345 instance->SetLocation(src.location); 345 instance->SetLocation(src.location);
346 return true; 346 return true;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } else { 393 } else {
394 child = CreateNode(instance, child_renderer_id, index_in_parent); 394 child = CreateNode(instance, child_renderer_id, index_in_parent);
395 } 395 }
396 new_children.push_back(child); 396 new_children.push_back(child);
397 } 397 }
398 398
399 // Finally, swap in the new children vector for the old. 399 // Finally, swap in the new children vector for the old.
400 instance->SwapChildren(new_children); 400 instance->SwapChildren(new_children);
401 401
402 // Handle the case where this node is the new root of the tree. 402 // Handle the case where this node is the new root of the tree.
403 if (src.role == WebKit::WebAXRoleRootWebArea && 403 if (src.role == blink::WebAXRoleRootWebArea &&
404 (!root_ || root_->renderer_id() != src.id)) { 404 (!root_ || root_->renderer_id() != src.id)) {
405 if (root_) 405 if (root_)
406 root_->Destroy(); 406 root_->Destroy();
407 if (focus_ == root_) 407 if (focus_ == root_)
408 SetFocus(instance, false); 408 SetFocus(instance, false);
409 SetRoot(instance); 409 SetRoot(instance);
410 } 410 }
411 411
412 // Keep track of what node is focused. 412 // Keep track of what node is focused.
413 if (src.role != WebKit::WebAXRoleRootWebArea && 413 if (src.role != blink::WebAXRoleRootWebArea &&
414 src.role != WebKit::WebAXRoleWebArea && 414 src.role != blink::WebAXRoleWebArea &&
415 (src.state >> WebKit::WebAXStateFocused & 1)) { 415 (src.state >> blink::WebAXStateFocused & 1)) {
416 SetFocus(instance, false); 416 SetFocus(instance, false);
417 } 417 }
418 return success; 418 return success;
419 } 419 }
420 420
421 } // namespace content 421 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698