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

Unified 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 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 508ae90e472c19683073aa2263ec6d6b8b3ce764..1ed097df0213d7f3bfef5d6a5b1978534657ad83 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -73,6 +73,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"
@@ -1278,12 +1279,14 @@ gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen(
if (root_window) {
aura::client::ScreenPositionClient* screen_position_client =
aura::client::GetScreenPositionClient(root_window);
- screen_position_client->ConvertPointFromScreen(window_, &origin);
- screen_position_client->ConvertPointFromScreen(window_, &end);
- return gfx::Rect(origin.x(),
- origin.y(),
- end.x() - origin.x(),
- end.y() - origin.y());
+ if (screen_position_client) {
+ screen_position_client->ConvertPointFromScreen(window_, &origin);
+ screen_position_client->ConvertPointFromScreen(window_, &end);
+ return gfx::Rect(origin.x(),
+ origin.y(),
+ end.x() - origin.x(),
+ end.y() - origin.y());
+ }
}
return rect;
@@ -1429,11 +1432,59 @@ void RenderWidgetHostViewAura::EnsureCaretNotInRect(const gfx::Rect& rect) {
gfx::Rect hiding_area_in_this_window =
gfx::IntersectRects(rect_in_local_space, window_->bounds());
- if (hiding_area_in_this_window.IsEmpty())
+ if (hiding_area_in_this_window.IsEmpty()) {
+ 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
return;
+ }
- host_->ScrollFocusedEditableNodeIntoRect(
+ const gfx::Rect visible_area_in_this_window(
gfx::SubtractRects(window_->bounds(), hiding_area_in_this_window));
+
+#if defined(OS_CHROMEOS)
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ ::switches::kUseNewVirtualKeyboardBehavior))
+ return;
+
+ aura::Window* top_level_window = window_->GetToplevelWindow();
+ // Calculate vertical window shift.
+ const gfx::Rect window_bounds = top_level_window->GetBoundsInRootWindow();
+ const int vertical_displacement =
+ std::max(0, top_level_window->GetBoundsInScreen().bottom() -
+ visible_area_in_this_window.bottom());
+ const int shift = std::min(vertical_displacement, window_bounds.y());
+
+ // Set restore bounds and move window.
+ if (shift > 0) {
+ const 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()));
+ }
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
+#endif // defined(OS_CHROMEOS)
+
+ // Perform overscroll.
+ host_->ScrollFocusedEditableNodeIntoRect(visible_area_in_this_window);
+}
+
+void RenderWidgetHostViewAura::OnClientFocusLost() {
+#if defined(OS_CHROMEOS)
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ ::switches::kUseNewVirtualKeyboardBehavior))
+ 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);
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.
+ }
+#endif // defined(OS_CHROMEOS)
}
bool RenderWidgetHostViewAura::IsTextEditCommandEnabled(

Powered by Google App Engine
This is Rietveld 408576698