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

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: rebase Created 3 years, 9 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "ui/aura/client/window_parenting_client.h" 72 #include "ui/aura/client/window_parenting_client.h"
73 #include "ui/aura/env.h" 73 #include "ui/aura/env.h"
74 #include "ui/aura/mus/window_port_mus.h" 74 #include "ui/aura/mus/window_port_mus.h"
75 #include "ui/aura/window.h" 75 #include "ui/aura/window.h"
76 #include "ui/aura/window_event_dispatcher.h" 76 #include "ui/aura/window_event_dispatcher.h"
77 #include "ui/aura/window_observer.h" 77 #include "ui/aura/window_observer.h"
78 #include "ui/aura/window_tree_host.h" 78 #include "ui/aura/window_tree_host.h"
79 #include "ui/base/clipboard/scoped_clipboard_writer.h" 79 #include "ui/base/clipboard/scoped_clipboard_writer.h"
80 #include "ui/base/hit_test.h" 80 #include "ui/base/hit_test.h"
81 #include "ui/base/ime/input_method.h" 81 #include "ui/base/ime/input_method.h"
82 #include "ui/base/ui_base_switches.h"
82 #include "ui/base/ui_base_types.h" 83 #include "ui/base/ui_base_types.h"
83 #include "ui/compositor/compositor_vsync_manager.h" 84 #include "ui/compositor/compositor_vsync_manager.h"
84 #include "ui/compositor/dip_util.h" 85 #include "ui/compositor/dip_util.h"
85 #include "ui/display/screen.h" 86 #include "ui/display/screen.h"
86 #include "ui/events/blink/blink_event_util.h" 87 #include "ui/events/blink/blink_event_util.h"
87 #include "ui/events/blink/web_input_event.h" 88 #include "ui/events/blink/web_input_event.h"
88 #include "ui/events/event.h" 89 #include "ui/events/event.h"
89 #include "ui/events/event_utils.h" 90 #include "ui/events/event_utils.h"
90 #include "ui/events/gesture_detection/gesture_configuration.h" 91 #include "ui/events/gesture_detection/gesture_configuration.h"
91 #include "ui/events/gestures/gesture_recognizer.h" 92 #include "ui/events/gestures/gesture_recognizer.h"
92 #include "ui/gfx/canvas.h" 93 #include "ui/gfx/canvas.h"
93 #include "ui/gfx/geometry/dip_util.h" 94 #include "ui/gfx/geometry/dip_util.h"
94 #include "ui/gfx/geometry/rect_conversions.h" 95 #include "ui/gfx/geometry/rect_conversions.h"
95 #include "ui/gfx/geometry/size_conversions.h" 96 #include "ui/gfx/geometry/size_conversions.h"
96 #include "ui/gfx/skia_util.h" 97 #include "ui/gfx/skia_util.h"
97 #include "ui/touch_selection/touch_selection_controller.h" 98 #include "ui/touch_selection/touch_selection_controller.h"
99 #include "ui/wm/core/coordinate_conversion.h"
100 #include "ui/wm/core/ime_util.h"
98 #include "ui/wm/public/activation_client.h" 101 #include "ui/wm/public/activation_client.h"
99 #include "ui/wm/public/scoped_tooltip_disabler.h" 102 #include "ui/wm/public/scoped_tooltip_disabler.h"
100 #include "ui/wm/public/tooltip_client.h" 103 #include "ui/wm/public/tooltip_client.h"
101 104
102 #if defined(OS_WIN) 105 #if defined(OS_WIN)
103 #include "base/time/time.h" 106 #include "base/time/time.h"
104 #include "content/browser/accessibility/browser_accessibility_manager_win.h" 107 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
105 #include "content/browser/accessibility/browser_accessibility_win.h" 108 #include "content/browser/accessibility/browser_accessibility_win.h"
106 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" 109 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
107 #include "ui/base/win/hidden_window.h" 110 #include "ui/base/win/hidden_window.h"
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 } 575 }
573 #endif 576 #endif
574 } 577 }
575 578
576 #if defined(OS_WIN) 579 #if defined(OS_WIN)
577 if (legacy_render_widget_host_HWND_) 580 if (legacy_render_widget_host_HWND_)
578 legacy_render_widget_host_HWND_->Hide(); 581 legacy_render_widget_host_HWND_->Hide();
579 #endif 582 #endif
580 } 583 }
581 584
585 aura::Window* RenderWidgetHostViewAura::GetToplevelWindow() {
586 return window_->GetToplevelWindow();
587 }
588
582 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 589 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
583 // For a SetSize operation, we don't care what coordinate system the origin 590 // For a SetSize operation, we don't care what coordinate system the origin
584 // of the window is in, it's only important to make sure that the origin 591 // of the window is in, it's only important to make sure that the origin
585 // remains constant after the operation. 592 // remains constant after the operation.
586 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size)); 593 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size));
587 } 594 }
588 595
589 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { 596 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
590 gfx::Point relative_origin(rect.origin()); 597 gfx::Point relative_origin(rect.origin());
591 598
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 if (!screen_position_client) 1276 if (!screen_position_client)
1270 return rect; 1277 return rect;
1271 screen_position_client->ConvertPointToScreen(window_, &origin); 1278 screen_position_client->ConvertPointToScreen(window_, &origin);
1272 screen_position_client->ConvertPointToScreen(window_, &end); 1279 screen_position_client->ConvertPointToScreen(window_, &end);
1273 return gfx::Rect(origin.x(), 1280 return gfx::Rect(origin.x(),
1274 origin.y(), 1281 origin.y(),
1275 end.x() - origin.x(), 1282 end.x() - origin.x(),
1276 end.y() - origin.y()); 1283 end.y() - origin.y());
1277 } 1284 }
1278 1285
1279 gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen(
1280 const gfx::Rect& rect) const {
1281 gfx::Point origin = rect.origin();
1282 gfx::Point end = gfx::Point(rect.right(), rect.bottom());
1283
1284 aura::Window* root_window = window_->GetRootWindow();
1285 if (root_window) {
1286 aura::client::ScreenPositionClient* screen_position_client =
1287 aura::client::GetScreenPositionClient(root_window);
1288 screen_position_client->ConvertPointFromScreen(window_, &origin);
1289 screen_position_client->ConvertPointFromScreen(window_, &end);
1290 return gfx::Rect(origin.x(),
1291 origin.y(),
1292 end.x() - origin.x(),
1293 end.y() - origin.y());
1294 }
1295
1296 return rect;
1297 }
1298
1299 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1286 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1300 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget()) 1287 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget())
1301 return gfx::Rect(); 1288 return gfx::Rect();
1302 1289
1303 const TextInputManager::SelectionRegion* region = 1290 const TextInputManager::SelectionRegion* region =
1304 text_input_manager_->GetSelectionRegion(); 1291 text_input_manager_->GetSelectionRegion();
1305 return ConvertRectToScreen( 1292 return ConvertRectToScreen(
1306 gfx::RectBetweenSelectionBounds(region->anchor, region->focus)); 1293 gfx::RectBetweenSelectionBounds(region->anchor, region->focus));
1307 } 1294 }
1308 1295
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 return true; 1411 return true;
1425 } 1412 }
1426 1413
1427 void RenderWidgetHostViewAura::ExtendSelectionAndDelete( 1414 void RenderWidgetHostViewAura::ExtendSelectionAndDelete(
1428 size_t before, size_t after) { 1415 size_t before, size_t after) {
1429 RenderFrameHostImpl* rfh = GetFocusedFrame(); 1416 RenderFrameHostImpl* rfh = GetFocusedFrame();
1430 if (rfh) 1417 if (rfh)
1431 rfh->ExtendSelectionAndDelete(before, after); 1418 rfh->ExtendSelectionAndDelete(before, after);
1432 } 1419 }
1433 1420
1434 void RenderWidgetHostViewAura::EnsureCaretNotInRect(const gfx::Rect& rect) { 1421 void RenderWidgetHostViewAura::EnsureCaretNotInRect(
1435 gfx::Rect rect_in_local_space = ConvertRectFromScreen(rect); 1422 const gfx::Rect& rect_in_screen) {
1436 gfx::Rect hiding_area_in_this_window = 1423 aura::Window* top_level_window = GetToplevelWindow();
1437 gfx::IntersectRects(rect_in_local_space, window_->bounds()); 1424 gfx::Rect original_window_bounds = top_level_window->GetBoundsInScreen();
1425 if (top_level_window->GetProperty(
1426 aura::client::kVirtualKeyboardRestoreBoundsKey)) {
1427 original_window_bounds = *top_level_window->GetProperty(
1428 aura::client::kVirtualKeyboardRestoreBoundsKey);
1429 }
1438 1430
1439 if (hiding_area_in_this_window.IsEmpty()) 1431 gfx::Rect hidden_window_bounds_in_screen =
1432 gfx::IntersectRects(rect_in_screen, original_window_bounds);
1433 if (hidden_window_bounds_in_screen.IsEmpty()) {
1434 // The window isn't covered by the keyboard, restore the window position if
1435 // necessary.
1436 OnClientFocusLost();
1437 return;
1438 }
1439
1440 #if defined(OS_CHROMEOS)
1441 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
1442 ::switches::kUseNewVirtualKeyboardBehavior))
1440 return; 1443 return;
1441 1444
1442 host_->ScrollFocusedEditableNodeIntoRect( 1445 if (wm::MoveWindowToEnsureCaretNotInRect(top_level_window, rect_in_screen)) {
1443 gfx::SubtractRects(window_->bounds(), hiding_area_in_this_window)); 1446 // Recalculate hidden_window_bounds_in_screen after moving up the window.
1447 original_window_bounds = top_level_window->GetBoundsInScreen();
1448 hidden_window_bounds_in_screen =
1449 gfx::IntersectRects(rect_in_screen, original_window_bounds);
1450 } else {
1451 // No need to move the window or need to restore the window position.
1452 OnClientFocusLost();
1453 }
1454 #endif // defined(OS_CHROMEOS)
1455
1456 // Perform overscroll if the caret is still hidden by the keyboard.
1457 gfx::Rect visible_area_in_local_space = gfx::SubtractRects(
1458 window_->GetBoundsInScreen(), hidden_window_bounds_in_screen);
1459 wm::ConvertRectFromScreen(window_, &visible_area_in_local_space);
1460 host_->ScrollFocusedEditableNodeIntoRect(visible_area_in_local_space);
1461 }
1462
1463 void RenderWidgetHostViewAura::OnClientFocusLost() {
1464 #if defined(OS_CHROMEOS)
1465 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
1466 ::switches::kUseNewVirtualKeyboardBehavior))
1467 return;
1468
1469 aura::Window* top_level_window = GetToplevelWindow();
1470 DCHECK(top_level_window);
1471 wm::RestoreWindowBoundsOnClientFocusLost(top_level_window);
1472 #endif // defined(OS_CHROMEOS)
1444 } 1473 }
1445 1474
1446 bool RenderWidgetHostViewAura::IsTextEditCommandEnabled( 1475 bool RenderWidgetHostViewAura::IsTextEditCommandEnabled(
1447 ui::TextEditCommand command) const { 1476 ui::TextEditCommand command) const {
1448 return false; 1477 return false;
1449 } 1478 }
1450 1479
1451 void RenderWidgetHostViewAura::SetTextEditCommandForNextKeyEvent( 1480 void RenderWidgetHostViewAura::SetTextEditCommandForNextKeyEvent(
1452 ui::TextEditCommand command) {} 1481 ui::TextEditCommand command) {}
1453 1482
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 2398
2370 void RenderWidgetHostViewAura::SetPopupChild( 2399 void RenderWidgetHostViewAura::SetPopupChild(
2371 RenderWidgetHostViewAura* popup_child_host_view) { 2400 RenderWidgetHostViewAura* popup_child_host_view) {
2372 popup_child_host_view_ = popup_child_host_view; 2401 popup_child_host_view_ = popup_child_host_view;
2373 event_handler_->SetPopupChild( 2402 event_handler_->SetPopupChild(
2374 popup_child_host_view, 2403 popup_child_host_view,
2375 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); 2404 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr);
2376 } 2405 }
2377 2406
2378 } // namespace content 2407 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698