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

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: Remove unused variable 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 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"
99 #include "ui/wm/core/ime_util.h"
97 #include "ui/wm/public/activation_client.h" 100 #include "ui/wm/public/activation_client.h"
98 #include "ui/wm/public/scoped_tooltip_disabler.h" 101 #include "ui/wm/public/scoped_tooltip_disabler.h"
99 #include "ui/wm/public/tooltip_client.h" 102 #include "ui/wm/public/tooltip_client.h"
100 103
101 #if defined(OS_WIN) 104 #if defined(OS_WIN)
102 #include "base/time/time.h" 105 #include "base/time/time.h"
103 #include "content/browser/accessibility/browser_accessibility_manager_win.h" 106 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
104 #include "content/browser/accessibility/browser_accessibility_win.h" 107 #include "content/browser/accessibility/browser_accessibility_win.h"
105 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" 108 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
106 #include "ui/base/win/hidden_window.h" 109 #include "ui/base/win/hidden_window.h"
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 } 570 }
568 #endif 571 #endif
569 } 572 }
570 573
571 #if defined(OS_WIN) 574 #if defined(OS_WIN)
572 if (legacy_render_widget_host_HWND_) 575 if (legacy_render_widget_host_HWND_)
573 legacy_render_widget_host_HWND_->Hide(); 576 legacy_render_widget_host_HWND_->Hide();
574 #endif 577 #endif
575 } 578 }
576 579
580 aura::Window* RenderWidgetHostViewAura::GetToplevelWindow() {
581 return window_->GetToplevelWindow();
582 }
583
577 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 584 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
578 // For a SetSize operation, we don't care what coordinate system the origin 585 // 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 586 // of the window is in, it's only important to make sure that the origin
580 // remains constant after the operation. 587 // remains constant after the operation.
581 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size)); 588 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size));
582 } 589 }
583 590
584 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { 591 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
585 gfx::Point relative_origin(rect.origin()); 592 gfx::Point relative_origin(rect.origin());
586 593
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 if (!screen_position_client) 1274 if (!screen_position_client)
1268 return rect; 1275 return rect;
1269 screen_position_client->ConvertPointToScreen(window_, &origin); 1276 screen_position_client->ConvertPointToScreen(window_, &origin);
1270 screen_position_client->ConvertPointToScreen(window_, &end); 1277 screen_position_client->ConvertPointToScreen(window_, &end);
1271 return gfx::Rect(origin.x(), 1278 return gfx::Rect(origin.x(),
1272 origin.y(), 1279 origin.y(),
1273 end.x() - origin.x(), 1280 end.x() - origin.x(),
1274 end.y() - origin.y()); 1281 end.y() - origin.y());
1275 } 1282 }
1276 1283
1277 gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen(
1278 const gfx::Rect& rect) const {
1279 gfx::Point origin = rect.origin();
1280 gfx::Point end = gfx::Point(rect.right(), rect.bottom());
1281
1282 aura::Window* root_window = window_->GetRootWindow();
1283 if (root_window) {
1284 aura::client::ScreenPositionClient* screen_position_client =
1285 aura::client::GetScreenPositionClient(root_window);
1286 screen_position_client->ConvertPointFromScreen(window_, &origin);
1287 screen_position_client->ConvertPointFromScreen(window_, &end);
1288 return gfx::Rect(origin.x(),
1289 origin.y(),
1290 end.x() - origin.x(),
1291 end.y() - origin.y());
1292 }
1293
1294 return rect;
1295 }
1296
1297 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1284 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1298 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget()) 1285 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget())
1299 return gfx::Rect(); 1286 return gfx::Rect();
1300 1287
1301 const TextInputManager::SelectionRegion* region = 1288 const TextInputManager::SelectionRegion* region =
1302 text_input_manager_->GetSelectionRegion(); 1289 text_input_manager_->GetSelectionRegion();
1303 return ConvertRectToScreen( 1290 return ConvertRectToScreen(
1304 gfx::RectBetweenSelectionBounds(region->anchor, region->focus)); 1291 gfx::RectBetweenSelectionBounds(region->anchor, region->focus));
1305 } 1292 }
1306 1293
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 return true; 1409 return true;
1423 } 1410 }
1424 1411
1425 void RenderWidgetHostViewAura::ExtendSelectionAndDelete( 1412 void RenderWidgetHostViewAura::ExtendSelectionAndDelete(
1426 size_t before, size_t after) { 1413 size_t before, size_t after) {
1427 RenderFrameHostImpl* rfh = GetFocusedFrame(); 1414 RenderFrameHostImpl* rfh = GetFocusedFrame();
1428 if (rfh) 1415 if (rfh)
1429 rfh->ExtendSelectionAndDelete(before, after); 1416 rfh->ExtendSelectionAndDelete(before, after);
1430 } 1417 }
1431 1418
1432 void RenderWidgetHostViewAura::EnsureCaretNotInRect(const gfx::Rect& rect) { 1419 void RenderWidgetHostViewAura::EnsureCaretNotInRect(
1433 gfx::Rect rect_in_local_space = ConvertRectFromScreen(rect); 1420 const gfx::Rect& rect_in_screen) {
1434 gfx::Rect hiding_area_in_this_window = 1421 aura::Window* top_level_window = GetToplevelWindow();
1435 gfx::IntersectRects(rect_in_local_space, window_->bounds()); 1422 gfx::Rect original_window_bounds = top_level_window->GetBoundsInScreen();
1423 if (top_level_window->GetProperty(wm::kVirtualKeyboardRestoreBoundsKey)) {
1424 original_window_bounds =
1425 *top_level_window->GetProperty(wm::kVirtualKeyboardRestoreBoundsKey);
1426 }
1436 1427
1437 if (hiding_area_in_this_window.IsEmpty()) 1428 gfx::Rect hidden_window_bounds_in_screen =
1429 gfx::IntersectRects(rect_in_screen, original_window_bounds);
1430 if (hidden_window_bounds_in_screen.IsEmpty()) {
1431 // The window isn't covered by the keyboard, restore the window position if
1432 // necessary.
1433 wm::RestoreWindowBoundsOnClientFocusLost(top_level_window);
1438 return; 1434 return;
1435 }
1439 1436
1440 host_->ScrollFocusedEditableNodeIntoRect( 1437 #if defined(OS_CHROMEOS)
1441 gfx::SubtractRects(window_->bounds(), hiding_area_in_this_window)); 1438 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1439 ::switches::kUseNewVirtualKeyboardBehavior)) {
1440 if (wm::MoveWindowToEnsureCaretNotInRect(top_level_window,
1441 rect_in_screen)) {
1442 // Recalculate hidden_window_bounds_in_screen after moving up the window.
1443 original_window_bounds = top_level_window->GetBoundsInScreen();
1444 hidden_window_bounds_in_screen =
1445 gfx::IntersectRects(rect_in_screen, original_window_bounds);
1446 } else {
1447 // No need to move the window or need to restore the window position.
1448 wm::RestoreWindowBoundsOnClientFocusLost(top_level_window);
1449 return;
1450 }
1451 }
1452 #endif // defined(OS_CHROMEOS)
1453
1454 // Perform overscroll if the caret is still hidden by the keyboard.
1455 gfx::Rect visible_area_in_local_space = gfx::SubtractRects(
1456 window_->GetBoundsInScreen(), hidden_window_bounds_in_screen);
1457 wm::ConvertRectFromScreen(window_, &visible_area_in_local_space);
1458 host_->ScrollFocusedEditableNodeIntoRect(visible_area_in_local_space);
1442 } 1459 }
1443 1460
1444 bool RenderWidgetHostViewAura::IsTextEditCommandEnabled( 1461 bool RenderWidgetHostViewAura::IsTextEditCommandEnabled(
1445 ui::TextEditCommand command) const { 1462 ui::TextEditCommand command) const {
1446 return false; 1463 return false;
1447 } 1464 }
1448 1465
1449 void RenderWidgetHostViewAura::SetTextEditCommandForNextKeyEvent( 1466 void RenderWidgetHostViewAura::SetTextEditCommandForNextKeyEvent(
1450 ui::TextEditCommand command) {} 1467 ui::TextEditCommand command) {}
1451 1468
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
2210 #if defined(OS_WIN) 2227 #if defined(OS_WIN)
2211 // Update the legacy window's parent temporarily to the hidden window. It 2228 // Update the legacy window's parent temporarily to the hidden window. It
2212 // will eventually get reparented to the right root. 2229 // will eventually get reparented to the right root.
2213 if (legacy_render_widget_host_HWND_) 2230 if (legacy_render_widget_host_HWND_)
2214 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow()); 2231 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow());
2215 #endif 2232 #endif
2216 } 2233 }
2217 2234
2218 void RenderWidgetHostViewAura::DetachFromInputMethod() { 2235 void RenderWidgetHostViewAura::DetachFromInputMethod() {
2219 ui::InputMethod* input_method = GetInputMethod(); 2236 ui::InputMethod* input_method = GetInputMethod();
2220 if (input_method) 2237 if (input_method) {
2221 input_method->DetachTextInputClient(this); 2238 input_method->DetachTextInputClient(this);
2239 wm::RestoreWindowBoundsOnClientFocusLost(GetToplevelWindow());
2240 }
2222 } 2241 }
2223 2242
2224 void RenderWidgetHostViewAura::ForwardKeyboardEvent( 2243 void RenderWidgetHostViewAura::ForwardKeyboardEvent(
2225 const NativeWebKeyboardEvent& event, 2244 const NativeWebKeyboardEvent& event,
2226 bool* update_event) { 2245 bool* update_event) {
2227 RenderWidgetHostImpl* target_host = host_; 2246 RenderWidgetHostImpl* target_host = host_;
2228 2247
2229 // If there are multiple widgets on the page (such as when there are 2248 // If there are multiple widgets on the page (such as when there are
2230 // out-of-process iframes), pick the one that should process this event. 2249 // out-of-process iframes), pick the one that should process this event.
2231 if (host_->delegate()) 2250 if (host_->delegate())
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 } 2388 }
2370 2389
2371 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() { 2390 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() {
2372 if (!delegated_frame_host_) 2391 if (!delegated_frame_host_)
2373 return; 2392 return;
2374 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ || 2393 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ ||
2375 needs_flush_input_); 2394 needs_flush_input_);
2376 } 2395 }
2377 2396
2378 } // namespace content 2397 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698