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

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: fix test crashes Created 4 years 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "ui/aura/client/transient_window_client.h" 66 #include "ui/aura/client/transient_window_client.h"
67 #include "ui/aura/client/window_parenting_client.h" 67 #include "ui/aura/client/window_parenting_client.h"
68 #include "ui/aura/env.h" 68 #include "ui/aura/env.h"
69 #include "ui/aura/window.h" 69 #include "ui/aura/window.h"
70 #include "ui/aura/window_event_dispatcher.h" 70 #include "ui/aura/window_event_dispatcher.h"
71 #include "ui/aura/window_observer.h" 71 #include "ui/aura/window_observer.h"
72 #include "ui/aura/window_tree_host.h" 72 #include "ui/aura/window_tree_host.h"
73 #include "ui/base/clipboard/scoped_clipboard_writer.h" 73 #include "ui/base/clipboard/scoped_clipboard_writer.h"
74 #include "ui/base/hit_test.h" 74 #include "ui/base/hit_test.h"
75 #include "ui/base/ime/input_method.h" 75 #include "ui/base/ime/input_method.h"
76 #include "ui/base/ui_base_switches.h"
76 #include "ui/base/ui_base_types.h" 77 #include "ui/base/ui_base_types.h"
77 #include "ui/compositor/compositor_vsync_manager.h" 78 #include "ui/compositor/compositor_vsync_manager.h"
78 #include "ui/compositor/dip_util.h" 79 #include "ui/compositor/dip_util.h"
79 #include "ui/display/display.h" 80 #include "ui/display/display.h"
80 #include "ui/display/screen.h" 81 #include "ui/display/screen.h"
81 #include "ui/events/blink/blink_event_util.h" 82 #include "ui/events/blink/blink_event_util.h"
82 #include "ui/events/blink/web_input_event.h" 83 #include "ui/events/blink/web_input_event.h"
83 #include "ui/events/event.h" 84 #include "ui/events/event.h"
84 #include "ui/events/event_utils.h" 85 #include "ui/events/event_utils.h"
85 #include "ui/events/gesture_detection/gesture_configuration.h" 86 #include "ui/events/gesture_detection/gesture_configuration.h"
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 1272
1272 gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen( 1273 gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen(
1273 const gfx::Rect& rect) const { 1274 const gfx::Rect& rect) const {
1274 gfx::Point origin = rect.origin(); 1275 gfx::Point origin = rect.origin();
1275 gfx::Point end = gfx::Point(rect.right(), rect.bottom()); 1276 gfx::Point end = gfx::Point(rect.right(), rect.bottom());
1276 1277
1277 aura::Window* root_window = window_->GetRootWindow(); 1278 aura::Window* root_window = window_->GetRootWindow();
1278 if (root_window) { 1279 if (root_window) {
1279 aura::client::ScreenPositionClient* screen_position_client = 1280 aura::client::ScreenPositionClient* screen_position_client =
1280 aura::client::GetScreenPositionClient(root_window); 1281 aura::client::GetScreenPositionClient(root_window);
1281 screen_position_client->ConvertPointFromScreen(window_, &origin); 1282 if (screen_position_client) {
1282 screen_position_client->ConvertPointFromScreen(window_, &end); 1283 screen_position_client->ConvertPointFromScreen(window_, &origin);
1283 return gfx::Rect(origin.x(), 1284 screen_position_client->ConvertPointFromScreen(window_, &end);
1284 origin.y(), 1285 return gfx::Rect(origin.x(),
1285 end.x() - origin.x(), 1286 origin.y(),
1286 end.y() - origin.y()); 1287 end.x() - origin.x(),
1288 end.y() - origin.y());
1289 }
1287 } 1290 }
1288 1291
1289 return rect; 1292 return rect;
1290 } 1293 }
1291 1294
1292 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1295 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1293 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget()) 1296 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget())
1294 return gfx::Rect(); 1297 return gfx::Rect();
1295 1298
1296 const TextInputManager::SelectionRegion* region = 1299 const TextInputManager::SelectionRegion* region =
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 RenderFrameHostImpl* rfh = GetFocusedFrame(); 1425 RenderFrameHostImpl* rfh = GetFocusedFrame();
1423 if (rfh) 1426 if (rfh)
1424 rfh->ExtendSelectionAndDelete(before, after); 1427 rfh->ExtendSelectionAndDelete(before, after);
1425 } 1428 }
1426 1429
1427 void RenderWidgetHostViewAura::EnsureCaretNotInRect(const gfx::Rect& rect) { 1430 void RenderWidgetHostViewAura::EnsureCaretNotInRect(const gfx::Rect& rect) {
1428 gfx::Rect rect_in_local_space = ConvertRectFromScreen(rect); 1431 gfx::Rect rect_in_local_space = ConvertRectFromScreen(rect);
1429 gfx::Rect hiding_area_in_this_window = 1432 gfx::Rect hiding_area_in_this_window =
1430 gfx::IntersectRects(rect_in_local_space, window_->bounds()); 1433 gfx::IntersectRects(rect_in_local_space, window_->bounds());
1431 1434
1432 if (hiding_area_in_this_window.IsEmpty()) 1435 if (hiding_area_in_this_window.IsEmpty()) {
1436 OnClientFocusLost();
oshima 2016/12/13 18:15:07 Can this be called when VK size changed for some r
yhanada 2017/01/12 02:19:56 Yes. Changed to use the original window bounds if
1437 return;
1438 }
1439
1440 const gfx::Rect visible_area_in_this_window(
1441 gfx::SubtractRects(window_->bounds(), hiding_area_in_this_window));
1442
1443 #if defined(OS_CHROMEOS)
1444 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
1445 ::switches::kUseNewVirtualKeyboardBehavior))
1433 return; 1446 return;
1434 1447
1435 host_->ScrollFocusedEditableNodeIntoRect( 1448 aura::Window* top_level_window = window_->GetToplevelWindow();
1436 gfx::SubtractRects(window_->bounds(), hiding_area_in_this_window)); 1449 // Calculate vertical window shift.
1450 const gfx::Rect window_bounds = top_level_window->GetBoundsInRootWindow();
1451 const int vertical_displacement =
1452 std::max(0, top_level_window->GetBoundsInScreen().bottom() -
1453 visible_area_in_this_window.bottom());
1454 const int shift = std::min(vertical_displacement, window_bounds.y());
1455
1456 // Set restore bounds and move window.
1457 if (shift > 0) {
1458 const gfx::Point origin(window_bounds.x(), window_bounds.y() - shift);
1459 top_level_window->SetProperty(
1460 aura::client::kVirtualKeyboardRestoreBoundsKey,
1461 new gfx::Rect(window_bounds));
1462 top_level_window->SetBounds(gfx::Rect(origin, window_bounds.size()));
1463 }
oshima 2016/12/13 18:15:07 This moving/restoring logic should be almost same
yhanada 2017/01/12 02:19:56 ui/chromeos/ime depends on ui/views, so this logic
oshima 2017/01/18 02:37:19 ui/base shouldn't depend on aura. How about ui/wm/
yhanada 2017/01/30 13:02:47 I understand. sky@: I intend to create a utility
1464 #endif // defined(OS_CHROMEOS)
1465
1466 // Perform overscroll.
1467 host_->ScrollFocusedEditableNodeIntoRect(visible_area_in_this_window);
1468 }
1469
1470 void RenderWidgetHostViewAura::OnClientFocusLost() {
1471 #if defined(OS_CHROMEOS)
1472 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
1473 ::switches::kUseNewVirtualKeyboardBehavior))
1474 return;
1475
1476 // Get restore bounds of window.
1477 aura::Window* top_level_window = window_->GetToplevelWindow();
1478 gfx::Rect* vk_restore_bounds = top_level_window->GetProperty(
1479 aura::client::kVirtualKeyboardRestoreBoundsKey);
1480
1481 if (vk_restore_bounds) {
1482 // Restore window.
1483 top_level_window->SetBounds(*vk_restore_bounds);
1484 top_level_window->ClearProperty(
1485 aura::client::kVirtualKeyboardRestoreBoundsKey);
oshima 2016/12/13 18:15:07 a user might have moved a window, and in that case
yhanada 2017/01/12 02:19:56 Done.
1486 }
1487 #endif // defined(OS_CHROMEOS)
1437 } 1488 }
1438 1489
1439 bool RenderWidgetHostViewAura::IsTextEditCommandEnabled( 1490 bool RenderWidgetHostViewAura::IsTextEditCommandEnabled(
1440 ui::TextEditCommand command) const { 1491 ui::TextEditCommand command) const {
1441 return false; 1492 return false;
1442 } 1493 }
1443 1494
1444 void RenderWidgetHostViewAura::SetTextEditCommandForNextKeyEvent( 1495 void RenderWidgetHostViewAura::SetTextEditCommandForNextKeyEvent(
1445 ui::TextEditCommand command) {} 1496 ui::TextEditCommand command) {}
1446 1497
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 2440
2390 void RenderWidgetHostViewAura::SetPopupChild( 2441 void RenderWidgetHostViewAura::SetPopupChild(
2391 RenderWidgetHostViewAura* popup_child_host_view) { 2442 RenderWidgetHostViewAura* popup_child_host_view) {
2392 popup_child_host_view_ = popup_child_host_view; 2443 popup_child_host_view_ = popup_child_host_view;
2393 event_handler_->SetPopupChild( 2444 event_handler_->SetPopupChild(
2394 popup_child_host_view, 2445 popup_child_host_view,
2395 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); 2446 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr);
2396 } 2447 }
2397 2448
2398 } // namespace content 2449 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698