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

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

Issue 2553603002: New accessibility virtual keyboard behavior in non-sticky mode. (Closed)
Patch Set: Renamed to ime_util_chromeos and added the unittests Created 3 years, 7 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 #include "ui/aura/client/window_parenting_client.h" 71 #include "ui/aura/client/window_parenting_client.h"
72 #include "ui/aura/env.h" 72 #include "ui/aura/env.h"
73 #include "ui/aura/mus/window_port_mus.h" 73 #include "ui/aura/mus/window_port_mus.h"
74 #include "ui/aura/window.h" 74 #include "ui/aura/window.h"
75 #include "ui/aura/window_event_dispatcher.h" 75 #include "ui/aura/window_event_dispatcher.h"
76 #include "ui/aura/window_observer.h" 76 #include "ui/aura/window_observer.h"
77 #include "ui/aura/window_tree_host.h" 77 #include "ui/aura/window_tree_host.h"
78 #include "ui/base/clipboard/scoped_clipboard_writer.h" 78 #include "ui/base/clipboard/scoped_clipboard_writer.h"
79 #include "ui/base/hit_test.h" 79 #include "ui/base/hit_test.h"
80 #include "ui/base/ime/input_method.h" 80 #include "ui/base/ime/input_method.h"
81 #include "ui/base/ui_base_switches.h"
81 #include "ui/base/ui_base_types.h" 82 #include "ui/base/ui_base_types.h"
82 #include "ui/compositor/compositor_vsync_manager.h" 83 #include "ui/compositor/compositor_vsync_manager.h"
83 #include "ui/compositor/dip_util.h" 84 #include "ui/compositor/dip_util.h"
84 #include "ui/display/screen.h" 85 #include "ui/display/screen.h"
85 #include "ui/events/blink/blink_event_util.h" 86 #include "ui/events/blink/blink_event_util.h"
86 #include "ui/events/blink/web_input_event.h" 87 #include "ui/events/blink/web_input_event.h"
87 #include "ui/events/event.h" 88 #include "ui/events/event.h"
88 #include "ui/events/event_utils.h" 89 #include "ui/events/event_utils.h"
89 #include "ui/events/gesture_detection/gesture_configuration.h" 90 #include "ui/events/gesture_detection/gesture_configuration.h"
90 #include "ui/events/gestures/gesture_recognizer.h" 91 #include "ui/events/gestures/gesture_recognizer.h"
91 #include "ui/gfx/canvas.h" 92 #include "ui/gfx/canvas.h"
92 #include "ui/gfx/geometry/dip_util.h" 93 #include "ui/gfx/geometry/dip_util.h"
93 #include "ui/gfx/geometry/rect_conversions.h" 94 #include "ui/gfx/geometry/rect_conversions.h"
94 #include "ui/gfx/geometry/size_conversions.h" 95 #include "ui/gfx/geometry/size_conversions.h"
95 #include "ui/gfx/skia_util.h" 96 #include "ui/gfx/skia_util.h"
96 #include "ui/touch_selection/touch_selection_controller.h" 97 #include "ui/touch_selection/touch_selection_controller.h"
98 #include "ui/wm/core/coordinate_conversion.h"
97 #include "ui/wm/public/activation_client.h" 99 #include "ui/wm/public/activation_client.h"
98 #include "ui/wm/public/scoped_tooltip_disabler.h" 100 #include "ui/wm/public/scoped_tooltip_disabler.h"
99 #include "ui/wm/public/tooltip_client.h" 101 #include "ui/wm/public/tooltip_client.h"
100 102
101 #if defined(OS_WIN) 103 #if defined(OS_WIN)
102 #include "base/time/time.h" 104 #include "base/time/time.h"
103 #include "content/browser/accessibility/browser_accessibility_manager_win.h" 105 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
104 #include "content/browser/accessibility/browser_accessibility_win.h" 106 #include "content/browser/accessibility/browser_accessibility_win.h"
105 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" 107 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
106 #include "ui/base/win/hidden_window.h" 108 #include "ui/base/win/hidden_window.h"
107 #include "ui/base/win/osk_display_manager.h" 109 #include "ui/base/win/osk_display_manager.h"
108 #include "ui/base/win/osk_display_observer.h" 110 #include "ui/base/win/osk_display_observer.h"
109 #include "ui/display/win/screen_win.h" 111 #include "ui/display/win/screen_win.h"
110 #include "ui/gfx/gdi_util.h" 112 #include "ui/gfx/gdi_util.h"
111 #endif 113 #endif
112 114
113 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11) 115 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11)
114 #include "content/browser/accessibility/browser_accessibility_auralinux.h" 116 #include "content/browser/accessibility/browser_accessibility_auralinux.h"
115 #endif 117 #endif
116 118
117 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 119 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
118 #include "ui/base/ime/linux/text_edit_command_auralinux.h" 120 #include "ui/base/ime/linux/text_edit_command_auralinux.h"
119 #include "ui/base/ime/linux/text_edit_key_bindings_delegate_auralinux.h" 121 #include "ui/base/ime/linux/text_edit_key_bindings_delegate_auralinux.h"
120 #endif 122 #endif
121 123
124 #if defined(OS_CHROMEOS)
125 #include "ui/wm/core/ime_util_chromeos.h"
126 #endif
127
122 using gfx::RectToSkIRect; 128 using gfx::RectToSkIRect;
123 using gfx::SkIRectToRect; 129 using gfx::SkIRectToRect;
124 130
125 using blink::WebInputEvent; 131 using blink::WebInputEvent;
126 using blink::WebGestureEvent; 132 using blink::WebGestureEvent;
127 using blink::WebTouchEvent; 133 using blink::WebTouchEvent;
128 134
129 namespace content { 135 namespace content {
130 136
131 namespace { 137 namespace {
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 } 573 }
568 #endif 574 #endif
569 } 575 }
570 576
571 #if defined(OS_WIN) 577 #if defined(OS_WIN)
572 if (legacy_render_widget_host_HWND_) 578 if (legacy_render_widget_host_HWND_)
573 legacy_render_widget_host_HWND_->Hide(); 579 legacy_render_widget_host_HWND_->Hide();
574 #endif 580 #endif
575 } 581 }
576 582
583 aura::Window* RenderWidgetHostViewAura::GetToplevelWindow() {
584 return window_->GetToplevelWindow();
585 }
586
577 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 587 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
578 // For a SetSize operation, we don't care what coordinate system the origin 588 // For a SetSize operation, we don't care what coordinate system the origin
579 // of the window is in, it's only important to make sure that the origin 589 // of the window is in, it's only important to make sure that the origin
580 // remains constant after the operation. 590 // remains constant after the operation.
581 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size)); 591 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size));
582 } 592 }
583 593
584 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { 594 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
585 gfx::Point relative_origin(rect.origin()); 595 gfx::Point relative_origin(rect.origin());
586 596
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 screen_position_client->ConvertPointToScreen(window_, &origin); 1283 screen_position_client->ConvertPointToScreen(window_, &origin);
1274 screen_position_client->ConvertPointToScreen(window_, &end); 1284 screen_position_client->ConvertPointToScreen(window_, &end);
1275 return gfx::Rect(origin.x(), 1285 return gfx::Rect(origin.x(),
1276 origin.y(), 1286 origin.y(),
1277 end.x() - origin.x(), 1287 end.x() - origin.x(),
1278 end.y() - origin.y()); 1288 end.y() - origin.y());
1279 } 1289 }
1280 1290
1281 gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen( 1291 gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen(
1282 const gfx::Rect& rect) const { 1292 const gfx::Rect& rect) const {
1283 gfx::Point origin = rect.origin(); 1293 gfx::Rect result = rect;
1284 gfx::Point end = gfx::Point(rect.right(), rect.bottom()); 1294 if (window_->GetRootWindow() &&
1285 1295 aura::client::GetScreenPositionClient(window_->GetRootWindow()))
1286 aura::Window* root_window = window_->GetRootWindow(); 1296 wm::ConvertRectFromScreen(window_, &result);
1287 if (root_window) { 1297 return result;
1288 aura::client::ScreenPositionClient* screen_position_client =
1289 aura::client::GetScreenPositionClient(root_window);
1290 screen_position_client->ConvertPointFromScreen(window_, &origin);
1291 screen_position_client->ConvertPointFromScreen(window_, &end);
1292 return gfx::Rect(origin.x(),
1293 origin.y(),
1294 end.x() - origin.x(),
1295 end.y() - origin.y());
1296 }
1297
1298 return rect;
1299 } 1298 }
1300 1299
1301 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1300 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1302 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget()) 1301 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget())
1303 return gfx::Rect(); 1302 return gfx::Rect();
1304 1303
1305 const TextInputManager::SelectionRegion* region = 1304 const TextInputManager::SelectionRegion* region =
1306 text_input_manager_->GetSelectionRegion(); 1305 text_input_manager_->GetSelectionRegion();
1307 return ConvertRectToScreen( 1306 return ConvertRectToScreen(
1308 gfx::RectBetweenSelectionBounds(region->anchor, region->focus)); 1307 gfx::RectBetweenSelectionBounds(region->anchor, region->focus));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 return true; 1425 return true;
1427 } 1426 }
1428 1427
1429 void RenderWidgetHostViewAura::ExtendSelectionAndDelete( 1428 void RenderWidgetHostViewAura::ExtendSelectionAndDelete(
1430 size_t before, size_t after) { 1429 size_t before, size_t after) {
1431 RenderFrameHostImpl* rfh = GetFocusedFrame(); 1430 RenderFrameHostImpl* rfh = GetFocusedFrame();
1432 if (rfh) 1431 if (rfh)
1433 rfh->ExtendSelectionAndDelete(before, after); 1432 rfh->ExtendSelectionAndDelete(before, after);
1434 } 1433 }
1435 1434
1436 void RenderWidgetHostViewAura::EnsureCaretNotInRect(const gfx::Rect& rect) { 1435 void RenderWidgetHostViewAura::EnsureCaretNotInRect(
1437 gfx::Rect rect_in_local_space = ConvertRectFromScreen(rect); 1436 const gfx::Rect& rect_in_screen) {
1438 gfx::Rect hiding_area_in_this_window = 1437 aura::Window* top_level_window = GetToplevelWindow();
1439 gfx::IntersectRects(rect_in_local_space, window_->bounds()); 1438 #if defined(OS_CHROMEOS)
1439 wm::EnsureWindowNotInRect(top_level_window, rect_in_screen);
1440 #endif
1440 1441
1441 if (hiding_area_in_this_window.IsEmpty()) 1442 // Perform overscroll if the caret is still hidden by the keyboard.
1442 return; 1443 const gfx::Rect hidden_window_bounds_in_screen = gfx::IntersectRects(
1443 1444 rect_in_screen, top_level_window->GetBoundsInScreen());
1444 host_->ScrollFocusedEditableNodeIntoRect( 1445 gfx::Rect visible_area_in_local_space = gfx::SubtractRects(
1445 gfx::SubtractRects(window_->bounds(), hiding_area_in_this_window)); 1446 window_->GetBoundsInScreen(), hidden_window_bounds_in_screen);
1447 visible_area_in_local_space =
1448 ConvertRectFromScreen(visible_area_in_local_space);
1449 host_->ScrollFocusedEditableNodeIntoRect(visible_area_in_local_space);
1446 } 1450 }
1447 1451
1448 bool RenderWidgetHostViewAura::IsTextEditCommandEnabled( 1452 bool RenderWidgetHostViewAura::IsTextEditCommandEnabled(
1449 ui::TextEditCommand command) const { 1453 ui::TextEditCommand command) const {
1450 return false; 1454 return false;
1451 } 1455 }
1452 1456
1453 void RenderWidgetHostViewAura::SetTextEditCommandForNextKeyEvent( 1457 void RenderWidgetHostViewAura::SetTextEditCommandForNextKeyEvent(
1454 ui::TextEditCommand command) {} 1458 ui::TextEditCommand command) {}
1455 1459
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 #if defined(OS_WIN) 2222 #if defined(OS_WIN)
2219 // Update the legacy window's parent temporarily to the hidden window. It 2223 // Update the legacy window's parent temporarily to the hidden window. It
2220 // will eventually get reparented to the right root. 2224 // will eventually get reparented to the right root.
2221 if (legacy_render_widget_host_HWND_) 2225 if (legacy_render_widget_host_HWND_)
2222 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow()); 2226 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow());
2223 #endif 2227 #endif
2224 } 2228 }
2225 2229
2226 void RenderWidgetHostViewAura::DetachFromInputMethod() { 2230 void RenderWidgetHostViewAura::DetachFromInputMethod() {
2227 ui::InputMethod* input_method = GetInputMethod(); 2231 ui::InputMethod* input_method = GetInputMethod();
2228 if (input_method) 2232 if (input_method) {
2229 input_method->DetachTextInputClient(this); 2233 input_method->DetachTextInputClient(this);
2234 #if defined(OS_CHROMEOS)
2235 wm::RestoreWindowBoundsOnClientFocusLost(GetToplevelWindow());
2236 #endif // defined(OS_CHROMEOS)
2237 }
2230 } 2238 }
2231 2239
2232 void RenderWidgetHostViewAura::ForwardKeyboardEvent( 2240 void RenderWidgetHostViewAura::ForwardKeyboardEvent(
2233 const NativeWebKeyboardEvent& event, 2241 const NativeWebKeyboardEvent& event,
2234 bool* update_event) { 2242 bool* update_event) {
2235 RenderWidgetHostImpl* target_host = host_; 2243 RenderWidgetHostImpl* target_host = host_;
2236 2244
2237 // If there are multiple widgets on the page (such as when there are 2245 // If there are multiple widgets on the page (such as when there are
2238 // out-of-process iframes), pick the one that should process this event. 2246 // out-of-process iframes), pick the one that should process this event.
2239 if (host_->delegate()) 2247 if (host_->delegate())
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 } 2385 }
2378 2386
2379 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() { 2387 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() {
2380 if (!delegated_frame_host_) 2388 if (!delegated_frame_host_)
2381 return; 2389 return;
2382 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ || 2390 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ ||
2383 needs_flush_input_); 2391 needs_flush_input_);
2384 } 2392 }
2385 2393
2386 } // namespace content 2394 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698