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

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 the build error on Linux and Windows 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 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 if (!screen_position_client) 1278 if (!screen_position_client)
1272 return rect; 1279 return rect;
1273 screen_position_client->ConvertPointToScreen(window_, &origin); 1280 screen_position_client->ConvertPointToScreen(window_, &origin);
1274 screen_position_client->ConvertPointToScreen(window_, &end); 1281 screen_position_client->ConvertPointToScreen(window_, &end);
1275 return gfx::Rect(origin.x(), 1282 return gfx::Rect(origin.x(),
1276 origin.y(), 1283 origin.y(),
1277 end.x() - origin.x(), 1284 end.x() - origin.x(),
1278 end.y() - origin.y()); 1285 end.y() - origin.y());
1279 } 1286 }
1280 1287
1281 gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen(
1282 const gfx::Rect& rect) const {
1283 gfx::Point origin = rect.origin();
1284 gfx::Point end = gfx::Point(rect.right(), rect.bottom());
1285
1286 aura::Window* root_window = window_->GetRootWindow();
1287 if (root_window) {
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 }
1300
1301 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1288 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1302 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget()) 1289 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget())
1303 return gfx::Rect(); 1290 return gfx::Rect();
1304 1291
1305 const TextInputManager::SelectionRegion* region = 1292 const TextInputManager::SelectionRegion* region =
1306 text_input_manager_->GetSelectionRegion(); 1293 text_input_manager_->GetSelectionRegion();
1307 return ConvertRectToScreen( 1294 return ConvertRectToScreen(
1308 gfx::RectBetweenSelectionBounds(region->anchor, region->focus)); 1295 gfx::RectBetweenSelectionBounds(region->anchor, region->focus));
1309 } 1296 }
1310 1297
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 return true; 1413 return true;
1427 } 1414 }
1428 1415
1429 void RenderWidgetHostViewAura::ExtendSelectionAndDelete( 1416 void RenderWidgetHostViewAura::ExtendSelectionAndDelete(
1430 size_t before, size_t after) { 1417 size_t before, size_t after) {
1431 RenderFrameHostImpl* rfh = GetFocusedFrame(); 1418 RenderFrameHostImpl* rfh = GetFocusedFrame();
1432 if (rfh) 1419 if (rfh)
1433 rfh->ExtendSelectionAndDelete(before, after); 1420 rfh->ExtendSelectionAndDelete(before, after);
1434 } 1421 }
1435 1422
1436 void RenderWidgetHostViewAura::EnsureCaretNotInRect(const gfx::Rect& rect) { 1423 void RenderWidgetHostViewAura::EnsureCaretNotInRect(
1437 gfx::Rect rect_in_local_space = ConvertRectFromScreen(rect); 1424 const gfx::Rect& rect_in_screen) {
1438 gfx::Rect hiding_area_in_this_window = 1425 aura::Window* top_level_window = GetToplevelWindow();
1439 gfx::IntersectRects(rect_in_local_space, window_->bounds()); 1426 wm::EnsureWindowNotInRect(top_level_window, rect_in_screen);
1440 1427
1441 if (hiding_area_in_this_window.IsEmpty()) 1428 // Perform overscroll if the caret is still hidden by the keyboard.
1442 return; 1429 const gfx::Rect hidden_window_bounds_in_screen = gfx::IntersectRects(
1443 1430 rect_in_screen, top_level_window->GetBoundsInScreen());
oshima 2017/04/26 18:03:42 don't you have to check if this is empty, and retu
oshima 2017/05/01 21:57:18 ping?
yhanada 2017/05/02 02:19:40 Sorry, I missed the comments. I added early return
1444 host_->ScrollFocusedEditableNodeIntoRect( 1431 gfx::Rect visible_area_in_local_space = gfx::SubtractRects(
1445 gfx::SubtractRects(window_->bounds(), hiding_area_in_this_window)); 1432 window_->GetBoundsInScreen(), hidden_window_bounds_in_screen);
1433 wm::ConvertRectFromScreen(window_, &visible_area_in_local_space);
oshima 2017/04/26 18:03:42 visible area can still be empty in non ash environ
yhanada 2017/05/02 02:19:40 Yes.
1434 host_->ScrollFocusedEditableNodeIntoRect(visible_area_in_local_space);
1446 } 1435 }
1447 1436
1448 bool RenderWidgetHostViewAura::IsTextEditCommandEnabled( 1437 bool RenderWidgetHostViewAura::IsTextEditCommandEnabled(
1449 ui::TextEditCommand command) const { 1438 ui::TextEditCommand command) const {
1450 return false; 1439 return false;
1451 } 1440 }
1452 1441
1453 void RenderWidgetHostViewAura::SetTextEditCommandForNextKeyEvent( 1442 void RenderWidgetHostViewAura::SetTextEditCommandForNextKeyEvent(
1454 ui::TextEditCommand command) {} 1443 ui::TextEditCommand command) {}
1455 1444
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 #if defined(OS_WIN) 2207 #if defined(OS_WIN)
2219 // Update the legacy window's parent temporarily to the hidden window. It 2208 // Update the legacy window's parent temporarily to the hidden window. It
2220 // will eventually get reparented to the right root. 2209 // will eventually get reparented to the right root.
2221 if (legacy_render_widget_host_HWND_) 2210 if (legacy_render_widget_host_HWND_)
2222 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow()); 2211 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow());
2223 #endif 2212 #endif
2224 } 2213 }
2225 2214
2226 void RenderWidgetHostViewAura::DetachFromInputMethod() { 2215 void RenderWidgetHostViewAura::DetachFromInputMethod() {
2227 ui::InputMethod* input_method = GetInputMethod(); 2216 ui::InputMethod* input_method = GetInputMethod();
2228 if (input_method) 2217 if (input_method) {
2229 input_method->DetachTextInputClient(this); 2218 input_method->DetachTextInputClient(this);
2219 wm::RestoreWindowBoundsOnClientFocusLost(GetToplevelWindow());
2220 }
2230 } 2221 }
2231 2222
2232 void RenderWidgetHostViewAura::ForwardKeyboardEvent( 2223 void RenderWidgetHostViewAura::ForwardKeyboardEvent(
2233 const NativeWebKeyboardEvent& event, 2224 const NativeWebKeyboardEvent& event,
2234 bool* update_event) { 2225 bool* update_event) {
2235 RenderWidgetHostImpl* target_host = host_; 2226 RenderWidgetHostImpl* target_host = host_;
2236 2227
2237 // If there are multiple widgets on the page (such as when there are 2228 // 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. 2229 // out-of-process iframes), pick the one that should process this event.
2239 if (host_->delegate()) 2230 if (host_->delegate())
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 } 2368 }
2378 2369
2379 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() { 2370 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() {
2380 if (!delegated_frame_host_) 2371 if (!delegated_frame_host_)
2381 return; 2372 return;
2382 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ || 2373 delegated_frame_host_->SetNeedsBeginFrames(needs_begin_frames_ ||
2383 needs_flush_input_); 2374 needs_flush_input_);
2384 } 2375 }
2385 2376
2386 } // namespace content 2377 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698