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

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

Issue 2781613003: Added a class acting as a fake caret for accessibility. (Closed)
Patch Set: Activate the fake caret only when Windows is focused. 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) 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/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 #include "ui/touch_selection/touch_selection_controller.h" 96 #include "ui/touch_selection/touch_selection_controller.h"
97 #include "ui/wm/public/activation_client.h" 97 #include "ui/wm/public/activation_client.h"
98 #include "ui/wm/public/scoped_tooltip_disabler.h" 98 #include "ui/wm/public/scoped_tooltip_disabler.h"
99 #include "ui/wm/public/tooltip_client.h" 99 #include "ui/wm/public/tooltip_client.h"
100 100
101 #if defined(OS_WIN) 101 #if defined(OS_WIN)
102 #include "base/time/time.h" 102 #include "base/time/time.h"
103 #include "content/browser/accessibility/browser_accessibility_manager_win.h" 103 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
104 #include "content/browser/accessibility/browser_accessibility_win.h" 104 #include "content/browser/accessibility/browser_accessibility_win.h"
105 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" 105 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
106 #include "ui/accessibility/platform/ax_fake_caret_win.h"
106 #include "ui/base/win/hidden_window.h" 107 #include "ui/base/win/hidden_window.h"
107 #include "ui/base/win/osk_display_manager.h" 108 #include "ui/base/win/osk_display_manager.h"
108 #include "ui/base/win/osk_display_observer.h" 109 #include "ui/base/win/osk_display_observer.h"
109 #include "ui/display/win/screen_win.h" 110 #include "ui/display/win/screen_win.h"
110 #include "ui/gfx/gdi_util.h" 111 #include "ui/gfx/gdi_util.h"
111 #endif 112 #endif
112 113
113 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11) 114 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11)
114 #include "content/browser/accessibility/browser_accessibility_auralinux.h" 115 #include "content/browser/accessibility/browser_accessibility_auralinux.h"
115 #endif 116 #endif
(...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 void RenderWidgetHostViewAura::OnSelectionBoundsChanged( 2327 void RenderWidgetHostViewAura::OnSelectionBoundsChanged(
2327 TextInputManager* text_input_manager, 2328 TextInputManager* text_input_manager,
2328 RenderWidgetHostViewBase* updated_view) { 2329 RenderWidgetHostViewBase* updated_view) {
2329 if (GetInputMethod()) 2330 if (GetInputMethod())
2330 GetInputMethod()->OnCaretBoundsChanged(this); 2331 GetInputMethod()->OnCaretBoundsChanged(this);
2331 } 2332 }
2332 2333
2333 void RenderWidgetHostViewAura::OnTextSelectionChanged( 2334 void RenderWidgetHostViewAura::OnTextSelectionChanged(
2334 TextInputManager* text_input_manager, 2335 TextInputManager* text_input_manager,
2335 RenderWidgetHostViewBase* updated_view) { 2336 RenderWidgetHostViewBase* updated_view) {
2336 #if defined(USE_X11) && !defined(OS_CHROMEOS)
2337 if (!GetTextInputManager()) 2337 if (!GetTextInputManager())
2338 return; 2338 return;
2339 2339
2340 // We obtain the TextSelection from focused RWH which is obtained from the 2340 // We obtain the TextSelection from focused RWH which is obtained from the
2341 // frame tree. BrowserPlugin-based guests' RWH is not part of the frame tree 2341 // frame tree. BrowserPlugin-based guests' RWH is not part of the frame tree
2342 // and the focused RWH will be that of the embedder which is incorrect. In 2342 // and the focused RWH will be that of the embedder which is incorrect. In
2343 // this case we should use TextSelection for |this| since RWHV for guest 2343 // this case we should use TextSelection for |this| since RWHV for guest
2344 // forwards text selection information to its platform view. 2344 // forwards text selection information to its platform view.
2345 RenderWidgetHostViewBase* focused_view = 2345 RenderWidgetHostViewBase* focused_view =
2346 is_guest_view_hack_ ? this : GetFocusedWidget() 2346 is_guest_view_hack_ ? this : GetFocusedWidget()
2347 ? GetFocusedWidget()->GetView() 2347 ? GetFocusedWidget()->GetView()
2348 : nullptr; 2348 : nullptr;
2349 2349
2350 if (!focused_view) 2350 if (!focused_view)
2351 return; 2351 return;
2352 2352
2353 #if defined(USE_X11) && !defined(OS_CHROMEOS)
2353 const TextInputManager::TextSelection* selection = 2354 const TextInputManager::TextSelection* selection =
2354 GetTextInputManager()->GetTextSelection(focused_view); 2355 GetTextInputManager()->GetTextSelection(focused_view);
2355 if (selection->selected_text().length()) { 2356 if (selection->selected_text().length()) {
2356 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 2357 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
2357 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 2358 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
2358 clipboard_writer.WriteText(selection->selected_text()); 2359 clipboard_writer.WriteText(selection->selected_text());
2359 } 2360 }
2360 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 2361
2362 // #endif defined(USE_X11) && !defined(OS_CHROMEOS)
2363 #elseif defined(OS_WIN)
2364 // Some assistive software need to track the location of the caret.
2365 if (!GetRenderWidgetHost())
2366 return;
2367
2368 // Not using |GetCaretBounds| because it includes the whole of the selection,
2369 // not just the focus.
2370 const TextInputManager::SelectionRegion* region =
2371 GetTextInputManager()->GetSelectionRegion(focused_view);
2372 if (!region)
2373 return;
2374 gfx::Rect caret_rect = ConvertRectToScreen(gfx::Rect(
2375 region->focus.edge_top_rounded().x(),
2376 region->focus.edge_top_rounded().y(), 1, region->focus.GetHeight()));
2377 ui::AXFakeCaretWin::g_fake_caret->SetBounds(caret_rect);
dmazzoni 2017/04/17 05:07:35 I'd call something like ui::AXFakeCaretWin::Get()
2378 #endif // defined(OS_WIN)
2361 } 2379 }
2362 2380
2363 void RenderWidgetHostViewAura::SetPopupChild( 2381 void RenderWidgetHostViewAura::SetPopupChild(
2364 RenderWidgetHostViewAura* popup_child_host_view) { 2382 RenderWidgetHostViewAura* popup_child_host_view) {
2365 popup_child_host_view_ = popup_child_host_view; 2383 popup_child_host_view_ = popup_child_host_view;
2366 event_handler_->SetPopupChild( 2384 event_handler_->SetPopupChild(
2367 popup_child_host_view, 2385 popup_child_host_view,
2368 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); 2386 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr);
2369 } 2387 }
2370 2388
2371 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() { 2389 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() {
2372 if (!delegated_frame_host_) 2390 if (!delegated_frame_host_)
2373 return; 2391 return;
2374 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ || 2392 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ ||
2375 needs_flush_input_); 2393 needs_flush_input_);
2376 } 2394 }
2377 2395
2378 } // namespace content 2396 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698