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

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

Issue 387353004: Create only a single LegacyRenderWidgetHostHWND per WebContentsViewAura. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render_frame_ax_3
Patch Set: Created 6 years, 5 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/win/scoped_comptr.h" 8 #include "base/win/scoped_comptr.h"
9 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 10 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
11 #include "content/browser/accessibility/browser_accessibility_win.h" 11 #include "content/browser/accessibility/browser_accessibility_win.h"
12 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" 12 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
13 #include "content/common/accessibility_messages.h" 13 #include "content/common/accessibility_messages.h"
14 #include "ui/base/win/atl_module.h" 14 #include "ui/base/win/atl_module.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 // static 18 // static
19 BrowserAccessibilityManager* BrowserAccessibilityManager::Create( 19 BrowserAccessibilityManager* BrowserAccessibilityManager::Create(
20 const ui::AXTreeUpdate& initial_tree, 20 const ui::AXTreeUpdate& initial_tree,
21 BrowserAccessibilityDelegate* delegate, 21 BrowserAccessibilityDelegate* delegate,
22 BrowserAccessibilityFactory* factory) { 22 BrowserAccessibilityFactory* factory) {
23 return new BrowserAccessibilityManagerWin( 23 return new BrowserAccessibilityManagerWin(
24 content::LegacyRenderWidgetHostHWND::Create(GetDesktopWindow()), 24 NULL, NULL, initial_tree, delegate, factory);
25 NULL, initial_tree, delegate, factory);
26 } 25 }
27 26
28 BrowserAccessibilityManagerWin* 27 BrowserAccessibilityManagerWin*
29 BrowserAccessibilityManager::ToBrowserAccessibilityManagerWin() { 28 BrowserAccessibilityManager::ToBrowserAccessibilityManagerWin() {
30 return static_cast<BrowserAccessibilityManagerWin*>(this); 29 return static_cast<BrowserAccessibilityManagerWin*>(this);
31 } 30 }
32 31
33 BrowserAccessibilityManagerWin::BrowserAccessibilityManagerWin( 32 BrowserAccessibilityManagerWin::BrowserAccessibilityManagerWin(
34 LegacyRenderWidgetHostHWND* accessible_hwnd, 33 LegacyRenderWidgetHostHWND* accessible_hwnd,
35 IAccessible* parent_iaccessible, 34 IAccessible* parent_iaccessible,
36 const ui::AXTreeUpdate& initial_tree, 35 const ui::AXTreeUpdate& initial_tree,
37 BrowserAccessibilityDelegate* delegate, 36 BrowserAccessibilityDelegate* delegate,
38 BrowserAccessibilityFactory* factory) 37 BrowserAccessibilityFactory* factory)
39 : BrowserAccessibilityManager(initial_tree, delegate, factory), 38 : BrowserAccessibilityManager(initial_tree, delegate, factory),
40 parent_hwnd_(NULL), 39 parent_hwnd_(NULL),
41 parent_iaccessible_(parent_iaccessible), 40 parent_iaccessible_(parent_iaccessible),
42 tracked_scroll_object_(NULL), 41 tracked_scroll_object_(NULL),
43 accessible_hwnd_(accessible_hwnd), 42 accessible_hwnd_(accessible_hwnd),
44 focus_event_on_root_needed_(false) { 43 focus_event_on_root_needed_(false) {
45 ui::win::CreateATLModuleIfNeeded(); 44 ui::win::CreateATLModuleIfNeeded();
46 if (accessible_hwnd_) { 45 if (!accessible_hwnd_)
47 accessible_hwnd_->set_browser_accessibility_manager(this); 46 accessible_hwnd_ = LegacyRenderWidgetHostHWND::CreateForTesting(this);
48 parent_hwnd_ = accessible_hwnd_->GetParent(); 47 parent_hwnd_ = accessible_hwnd_->GetParent();
49 }
50 } 48 }
51 49
52 BrowserAccessibilityManagerWin::~BrowserAccessibilityManagerWin() { 50 BrowserAccessibilityManagerWin::~BrowserAccessibilityManagerWin() {
53 if (tracked_scroll_object_) { 51 if (tracked_scroll_object_) {
54 tracked_scroll_object_->Release(); 52 tracked_scroll_object_->Release();
55 tracked_scroll_object_ = NULL; 53 tracked_scroll_object_ = NULL;
56 } 54 }
57 if (accessible_hwnd_)
58 accessible_hwnd_->OnManagerDeleted(this);
59 } 55 }
60 56
61 // static 57 // static
62 ui::AXTreeUpdate BrowserAccessibilityManagerWin::GetEmptyDocument() { 58 ui::AXTreeUpdate BrowserAccessibilityManagerWin::GetEmptyDocument() {
63 ui::AXNodeData empty_document; 59 ui::AXNodeData empty_document;
64 empty_document.id = 0; 60 empty_document.id = 0;
65 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; 61 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA;
66 empty_document.state = 62 empty_document.state =
67 (1 << ui::AX_STATE_ENABLED) | 63 (1 << ui::AX_STATE_ENABLED) |
68 (1 << ui::AX_STATE_READ_ONLY) | 64 (1 << ui::AX_STATE_READ_ONLY) |
69 (1 << ui::AX_STATE_BUSY); 65 (1 << ui::AX_STATE_BUSY);
70 66
71 ui::AXTreeUpdate update; 67 ui::AXTreeUpdate update;
72 update.nodes.push_back(empty_document); 68 update.nodes.push_back(empty_document);
73 return update; 69 return update;
74 } 70 }
75 71
76 void BrowserAccessibilityManagerWin::SetAccessibleHWND(
77 LegacyRenderWidgetHostHWND* accessible_hwnd) {
78 if (accessible_hwnd_)
79 accessible_hwnd_->OnManagerDeleted(this);
80
81 accessible_hwnd_ = accessible_hwnd;
82
83 if (accessible_hwnd_) {
84 accessible_hwnd_->set_browser_accessibility_manager(this);
85 parent_hwnd_ = accessible_hwnd_->GetParent();
86 }
87 }
88
89 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event, 72 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event,
90 LONG child_id) { 73 LONG child_id) {
91 // If on Win 7 and complete accessibility is enabled, use the fake child HWND 74 // If on Win 7 and complete accessibility is enabled, use the fake child HWND
92 // to use as the root of the accessibility tree. See comments above 75 // to use as the root of the accessibility tree. See comments above
93 // LegacyRenderWidgetHostHWND for details. 76 // LegacyRenderWidgetHostHWND for details.
94 if (accessible_hwnd_ && 77 if (accessible_hwnd_ &&
95 BrowserAccessibilityStateImpl::GetInstance()->IsAccessibleBrowser()) { 78 BrowserAccessibilityStateImpl::GetInstance()->IsAccessibleBrowser()) {
96 parent_hwnd_ = accessible_hwnd_->hwnd(); 79 parent_hwnd_ = accessible_hwnd_->hwnd();
97 parent_iaccessible_ = accessible_hwnd_->window_accessible(); 80 parent_iaccessible_ = accessible_hwnd_->window_accessible();
98 } 81 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // |parent_iaccessible_| are no longer valid either, since they were 298 // |parent_iaccessible_| are no longer valid either, since they were
316 // derived from AccessibleHWND. We don't have to restore them to 299 // derived from AccessibleHWND. We don't have to restore them to
317 // previous values, though, because this should only happen 300 // previous values, though, because this should only happen
318 // during the destruct sequence for this window. 301 // during the destruct sequence for this window.
319 accessible_hwnd_ = NULL; 302 accessible_hwnd_ = NULL;
320 parent_hwnd_ = NULL; 303 parent_hwnd_ = NULL;
321 parent_iaccessible_ = NULL; 304 parent_iaccessible_ = NULL;
322 } 305 }
323 306
324 } // namespace content 307 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698