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

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 2259033003: New accessibility virtual keyboard behavior in non-sticky mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_view_aura.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 5991147c90829ff2176083ab224bce3e3859276d..8a3b62485a0ab18153030536ea4a96e631b7f537 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -71,6 +71,7 @@
#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "ui/base/hit_test.h"
#include "ui/base/ime/input_method.h"
+#include "ui/base/ui_base_switches.h"
#include "ui/base/ui_base_types.h"
#include "ui/compositor/compositor_vsync_manager.h"
#include "ui/compositor/dip_util.h"
@@ -1620,14 +1621,71 @@ void RenderWidgetHostViewAura::ExtendSelectionAndDelete(
}
void RenderWidgetHostViewAura::EnsureCaretInRect(const gfx::Rect& rect) {
+ // Perform overscroll.
gfx::Rect intersected_rect(
gfx::IntersectRects(rect, window_->GetBoundsInScreen()));
+ if (!intersected_rect.IsEmpty())
+ host_->ScrollFocusedEditableNodeIntoRect(
+ ConvertRectFromScreen(intersected_rect));
- if (intersected_rect.IsEmpty())
+#if defined(OS_CHROMEOS)
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ ::switches::kUseNewVirtualKeyboardBehavior))
return;
- host_->ScrollFocusedEditableNodeIntoRect(
- ConvertRectFromScreen(intersected_rect));
+ // Only windows in primary display should be moved by virtual keyboard.
+ display::Screen* screen = display::Screen::GetScreen();
+ if (screen->GetPrimaryDisplay().id() !=
+ screen->GetDisplayNearestWindow(window_).id())
+ return;
+
+ aura::Window* top_level_window = window_->GetToplevelWindow();
+ if (rect != screen->GetPrimaryDisplay().bounds()) {
+ // Calculate vertical window shift.
+ gfx::Rect window_bounds = top_level_window->GetBoundsInRootWindow();
+ int vertical_displacement =
+ std::max(0, window_bounds.bottom() - rect.bottom());
+ int shift = std::min(vertical_displacement, window_bounds.y());
+
+ // Set restore bounds and move window.
+ if (shift > 0) {
+ gfx::Point origin(window_bounds.x(), window_bounds.y() - shift);
+ top_level_window->SetProperty(
+ aura::client::kVirtualKeyboardRestoreBoundsKey,
+ new gfx::Rect(window_bounds));
+ top_level_window->SetBounds(gfx::Rect(origin, window_bounds.size()));
+ }
+ } else {
+ // Restore if necessary
+ OnClientFocusLost();
+ }
+#endif
+}
+
+void RenderWidgetHostViewAura::OnClientFocusLost() {
+#if defined(OS_CHROMEOS)
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ ::switches::kUseNewVirtualKeyboardBehavior))
+ return;
+
+ // Only windows in primary display should be moved by virtual keyboard.
+ display::Screen* screen = display::Screen::GetScreen();
+ if (screen->GetPrimaryDisplay().id() !=
+ screen->GetDisplayNearestWindow(window_).id())
+ return;
+
+ // Get restore bounds of window.
+ aura::Window* top_level_window = window_->GetToplevelWindow();
+ gfx::Rect* vk_restore_bounds = top_level_window->GetProperty(
+ aura::client::kVirtualKeyboardRestoreBoundsKey);
+
+ if (vk_restore_bounds) {
+ // Restore window.
+ top_level_window->SetBounds(*vk_restore_bounds);
+ top_level_window->ClearProperty(
+ aura::client::kVirtualKeyboardRestoreBoundsKey);
+ }
+#endif
}
bool RenderWidgetHostViewAura::IsTextEditCommandEnabled(

Powered by Google App Engine
This is Rietveld 408576698