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

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

Issue 1413423003: Move some AX attrs from AXNodeData to AXTreeData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months 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
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_win.h" 5 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/win/scoped_comptr.h" 10 #include "base/win/scoped_comptr.h"
11 #include "base/win/windows_version.h" 11 #include "base/win/windows_version.h"
12 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 12 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
13 #include "content/browser/accessibility/browser_accessibility_win.h" 13 #include "content/browser/accessibility/browser_accessibility_win.h"
14 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" 14 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
15 #include "content/common/accessibility_messages.h" 15 #include "content/common/accessibility_messages.h"
16 #include "ui/base/win/atl_module.h" 16 #include "ui/base/win/atl_module.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 // static 20 // static
21 BrowserAccessibilityManager* BrowserAccessibilityManager::Create( 21 BrowserAccessibilityManager* BrowserAccessibilityManager::Create(
22 const SimpleAXTreeUpdate& initial_tree, 22 const ui::AXTreeUpdate& initial_tree,
23 BrowserAccessibilityDelegate* delegate, 23 BrowserAccessibilityDelegate* delegate,
24 BrowserAccessibilityFactory* factory) { 24 BrowserAccessibilityFactory* factory) {
25 return new BrowserAccessibilityManagerWin(initial_tree, delegate, factory); 25 return new BrowserAccessibilityManagerWin(initial_tree, delegate, factory);
26 } 26 }
27 27
28 BrowserAccessibilityManagerWin* 28 BrowserAccessibilityManagerWin*
29 BrowserAccessibilityManager::ToBrowserAccessibilityManagerWin() { 29 BrowserAccessibilityManager::ToBrowserAccessibilityManagerWin() {
30 return static_cast<BrowserAccessibilityManagerWin*>(this); 30 return static_cast<BrowserAccessibilityManagerWin*>(this);
31 } 31 }
32 32
33 BrowserAccessibilityManagerWin::BrowserAccessibilityManagerWin( 33 BrowserAccessibilityManagerWin::BrowserAccessibilityManagerWin(
34 const SimpleAXTreeUpdate& initial_tree, 34 const ui::AXTreeUpdate& initial_tree,
35 BrowserAccessibilityDelegate* delegate, 35 BrowserAccessibilityDelegate* delegate,
36 BrowserAccessibilityFactory* factory) 36 BrowserAccessibilityFactory* factory)
37 : BrowserAccessibilityManager(delegate, factory), 37 : BrowserAccessibilityManager(delegate, factory),
38 tracked_scroll_object_(NULL), 38 tracked_scroll_object_(NULL),
39 focus_event_on_root_needed_(false), 39 focus_event_on_root_needed_(false),
40 inside_on_window_focused_(false) { 40 inside_on_window_focused_(false) {
41 ui::win::CreateATLModuleIfNeeded(); 41 ui::win::CreateATLModuleIfNeeded();
42 Initialize(initial_tree); 42 Initialize(initial_tree);
43 } 43 }
44 44
45 BrowserAccessibilityManagerWin::~BrowserAccessibilityManagerWin() { 45 BrowserAccessibilityManagerWin::~BrowserAccessibilityManagerWin() {
46 if (tracked_scroll_object_) { 46 if (tracked_scroll_object_) {
47 tracked_scroll_object_->Release(); 47 tracked_scroll_object_->Release();
48 tracked_scroll_object_ = NULL; 48 tracked_scroll_object_ = NULL;
49 } 49 }
50 } 50 }
51 51
52 // static 52 // static
53 SimpleAXTreeUpdate 53 ui::AXTreeUpdate
54 BrowserAccessibilityManagerWin::GetEmptyDocument() { 54 BrowserAccessibilityManagerWin::GetEmptyDocument() {
55 ui::AXNodeData empty_document; 55 ui::AXNodeData empty_document;
56 empty_document.id = 0; 56 empty_document.id = 0;
57 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; 57 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA;
58 empty_document.state = 58 empty_document.state =
59 (1 << ui::AX_STATE_ENABLED) | 59 (1 << ui::AX_STATE_ENABLED) |
60 (1 << ui::AX_STATE_READ_ONLY) | 60 (1 << ui::AX_STATE_READ_ONLY) |
61 (1 << ui::AX_STATE_BUSY); 61 (1 << ui::AX_STATE_BUSY);
62 62
63 SimpleAXTreeUpdate update; 63 ui::AXTreeUpdate update;
64 update.nodes.push_back(empty_document); 64 update.nodes.push_back(empty_document);
65 return update; 65 return update;
66 } 66 }
67 67
68 HWND BrowserAccessibilityManagerWin::GetParentHWND() { 68 HWND BrowserAccessibilityManagerWin::GetParentHWND() {
69 if (!delegate_) 69 if (!delegate_)
70 return NULL; 70 return NULL;
71 return delegate_->AccessibilityGetAcceleratedWidget(); 71 return delegate_->AccessibilityGetAcceleratedWidget();
72 } 72 }
73 73
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 (!delegate_->AccessibilityViewHasFocus())) { 115 (!delegate_->AccessibilityViewHasFocus())) {
116 return; 116 return;
117 } 117 }
118 118
119 // NVDA gets confused if we focus the main document element when it hasn't 119 // NVDA gets confused if we focus the main document element when it hasn't
120 // finished loading and it has no children at all, so suppress that event. 120 // finished loading and it has no children at all, so suppress that event.
121 if (event == EVENT_OBJECT_FOCUS && 121 if (event == EVENT_OBJECT_FOCUS &&
122 node == GetRoot() && 122 node == GetRoot() &&
123 node->PlatformChildCount() == 0 && 123 node->PlatformChildCount() == 0 &&
124 !node->HasState(ui::AX_STATE_BUSY) && 124 !node->HasState(ui::AX_STATE_BUSY) &&
125 !node->GetBoolAttribute(ui::AX_ATTR_DOC_LOADED)) { 125 !node->manager()->GetTreeData().loaded) {
126 return; 126 return;
127 } 127 }
128 128
129 // If a focus event is needed on the root, fire that first before 129 // If a focus event is needed on the root, fire that first before
130 // this event. 130 // this event.
131 if (event == EVENT_OBJECT_FOCUS && node == GetRoot()) 131 if (event == EVENT_OBJECT_FOCUS && node == GetRoot())
132 focus_event_on_root_needed_ = false; 132 focus_event_on_root_needed_ = false;
133 else if (focus_event_on_root_needed_) 133 else if (focus_event_on_root_needed_)
134 OnWindowFocused(); 134 OnWindowFocused();
135 135
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 !root_delegate->AccessibilityViewHasFocus()) { 198 !root_delegate->AccessibilityViewHasFocus()) {
199 return; 199 return;
200 } 200 }
201 201
202 // NVDA gets confused if we focus the main document element when it hasn't 202 // NVDA gets confused if we focus the main document element when it hasn't
203 // finished loading and it has no children at all, so suppress that event. 203 // finished loading and it has no children at all, so suppress that event.
204 if (event_type == ui::AX_EVENT_FOCUS && 204 if (event_type == ui::AX_EVENT_FOCUS &&
205 node == GetRoot() && 205 node == GetRoot() &&
206 node->PlatformChildCount() == 0 && 206 node->PlatformChildCount() == 0 &&
207 !node->HasState(ui::AX_STATE_BUSY) && 207 !node->HasState(ui::AX_STATE_BUSY) &&
208 !node->GetBoolAttribute(ui::AX_ATTR_DOC_LOADED)) { 208 !node->manager()->GetTreeData().loaded) {
209 return; 209 return;
210 } 210 }
211 211
212 // If a focus event is needed on the root, fire that first before 212 // If a focus event is needed on the root, fire that first before
213 // this event. 213 // this event.
214 if (event_type == ui::AX_EVENT_FOCUS && node == GetRoot()) 214 if (event_type == ui::AX_EVENT_FOCUS && node == GetRoot())
215 focus_event_on_root_needed_ = false; 215 focus_event_on_root_needed_ = false;
216 else if (focus_event_on_root_needed_) 216 else if (focus_event_on_root_needed_)
217 OnWindowFocused(); 217 OnWindowFocused();
218 218
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 return nullptr; 407 return nullptr;
408 408
409 BrowserAccessibility* result = GetFromID(iter->second); 409 BrowserAccessibility* result = GetFromID(iter->second);
410 if (result && result->IsNative()) 410 if (result && result->IsNative())
411 return result->ToBrowserAccessibilityWin(); 411 return result->ToBrowserAccessibilityWin();
412 412
413 return nullptr; 413 return nullptr;
414 } 414 }
415 415
416 } // namespace content 416 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698