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

Side by Side Diff: content/browser/renderer_host/legacy_render_widget_host_win.cc

Issue 2781613003: Added a class acting as a fake caret for accessibility. (Closed)
Patch Set: Created 3 years, 8 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) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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/renderer_host/legacy_render_widget_host_win.h" 5 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
6 6
7 #include <atlcom.h>
8
7 #include <memory> 9 #include <memory>
8 10
9 #include "base/command_line.h" 11 #include "base/command_line.h"
10 #include "base/win/win_util.h" 12 #include "base/win/win_util.h"
11 #include "base/win/windows_version.h" 13 #include "base/win/windows_version.h"
12 #include "content/browser/accessibility/browser_accessibility_manager_win.h" 14 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
13 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 15 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
14 #include "content/browser/accessibility/browser_accessibility_win.h" 16 #include "content/browser/accessibility/browser_accessibility_win.h"
15 #include "content/browser/renderer_host/render_widget_host_impl.h" 17 #include "content/browser/renderer_host/render_widget_host_impl.h"
16 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 18 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
17 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
20 #include "ui/accessibility/platform/ax_fake_caret_win.h"
18 #include "ui/base/view_prop.h" 21 #include "ui/base/view_prop.h"
19 #include "ui/base/win/internal_constants.h" 22 #include "ui/base/win/internal_constants.h"
20 #include "ui/base/win/window_event_target.h" 23 #include "ui/base/win/window_event_target.h"
21 #include "ui/display/win/screen_win.h" 24 #include "ui/display/win/screen_win.h"
22 #include "ui/gfx/geometry/rect.h" 25 #include "ui/gfx/geometry/rect.h"
23 #include "ui/gfx/win/direct_manipulation.h" 26 #include "ui/gfx/win/direct_manipulation.h"
24 27
25 namespace content { 28 namespace content {
26 29
27 // A custom MSAA object id used to determine if a screen reader or some 30 // A custom MSAA object id used to determine if a screen reader or some
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 166
164 if (kIdScreenReaderHoneyPot == obj_id) { 167 if (kIdScreenReaderHoneyPot == obj_id) {
165 // When an MSAA client has responded to our fake event on this id, 168 // When an MSAA client has responded to our fake event on this id,
166 // enable basic accessibility support. (Full screen reader support is 169 // enable basic accessibility support. (Full screen reader support is
167 // detected later when specific more advanced APIs are accessed.) 170 // detected later when specific more advanced APIs are accessed.)
168 BrowserAccessibilityStateImpl::GetInstance()->AddAccessibilityModeFlags( 171 BrowserAccessibilityStateImpl::GetInstance()->AddAccessibilityModeFlags(
169 AccessibilityMode::kNativeAPIs | AccessibilityMode::kWebContents); 172 AccessibilityMode::kNativeAPIs | AccessibilityMode::kWebContents);
170 return static_cast<LRESULT>(0L); 173 return static_cast<LRESULT>(0L);
171 } 174 }
172 175
173 if (static_cast<DWORD>(OBJID_CLIENT) != obj_id || !host_) 176 if (static_cast<DWORD>(OBJID_CLIENT) == obj_id && host_) {
174 return static_cast<LRESULT>(0L); 177 RenderWidgetHostImpl* rwhi =
178 RenderWidgetHostImpl::From(host_->GetRenderWidgetHost());
179 if (!rwhi)
180 return static_cast<LRESULT>(0L);
175 181
176 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From( 182 BrowserAccessibilityManagerWin* manager =
177 host_->GetRenderWidgetHost()); 183 static_cast<BrowserAccessibilityManagerWin*>(
178 if (!rwhi) 184 rwhi->GetRootBrowserAccessibilityManager());
179 return static_cast<LRESULT>(0L); 185 if (!manager)
186 return static_cast<LRESULT>(0L);
180 187
181 BrowserAccessibilityManagerWin* manager = 188 base::win::ScopedComPtr<IAccessible> root(
182 static_cast<BrowserAccessibilityManagerWin*>( 189 ToBrowserAccessibilityWin(manager->GetRoot()));
183 rwhi->GetRootBrowserAccessibilityManager()); 190 return LresultFromObject(IID_IAccessible, w_param,
184 if (!manager) 191 static_cast<IAccessible*>(root.Detach()));
185 return static_cast<LRESULT>(0L); 192 } else if (static_cast<DWORD>(OBJID_CARET) == obj_id) {
dougt 2017/03/28 15:23:44 nit: the above if-stmt returns making the followi
193 // Used by some assistive software to retrieve the location of the caret.
194 CComObjectStack<ui::AXFakeCaretWin> fake_caret;
195 DCHECK_EQ(fake_caret.m_hResFinalConstruct, S_OK);
dougt 2017/03/28 15:23:44 I am confused by this DCHECK. Are you concerned wi
196 return LresultFromObject(IID_IAccessible, w_param,
197 static_cast<IAccessible*>(&fake_caret));
198 }
186 199
187 base::win::ScopedComPtr<IAccessible> root( 200 return static_cast<LRESULT>(0L);
188 ToBrowserAccessibilityWin(manager->GetRoot()));
189 return LresultFromObject(IID_IAccessible, w_param,
190 static_cast<IAccessible*>(root.Detach()));
191 } 201 }
192 202
193 // We send keyboard/mouse/touch messages to the parent window via SendMessage. 203 // We send keyboard/mouse/touch messages to the parent window via SendMessage.
194 // While this works, this has the side effect of converting input messages into 204 // While this works, this has the side effect of converting input messages into
195 // sent messages which changes their priority and could technically result 205 // sent messages which changes their priority and could technically result
196 // in these messages starving other messages in the queue. Additionally 206 // in these messages starving other messages in the queue. Additionally
197 // keyboard/mouse hooks would not see these messages. The alternative approach 207 // keyboard/mouse hooks would not see these messages. The alternative approach
198 // is to set and release capture as needed on the parent to ensure that it 208 // is to set and release capture as needed on the parent to ensure that it
199 // receives all mouse events. However that was shelved due to possible issues 209 // receives all mouse events. However that was shelved due to possible issues
200 // with capture changes. 210 // with capture changes.
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 direct_manipulation_helper_->Activate(hwnd()); 418 direct_manipulation_helper_->Activate(hwnd());
409 } else if (window_pos->flags & SWP_HIDEWINDOW) { 419 } else if (window_pos->flags & SWP_HIDEWINDOW) {
410 direct_manipulation_helper_->Deactivate(hwnd()); 420 direct_manipulation_helper_->Deactivate(hwnd());
411 } 421 }
412 } 422 }
413 SetMsgHandled(FALSE); 423 SetMsgHandled(FALSE);
414 return 0; 424 return 0;
415 } 425 }
416 426
417 } // namespace content 427 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698