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

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: 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 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 b4dc9e9c7a5bf097f8290a2430306bb82bbfb72e..d599c6b5eb4fdf2479c655bede8ef71463d1b2c4 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -79,6 +79,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"
@@ -95,6 +96,8 @@
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/skia_util.h"
#include "ui/touch_selection/touch_selection_controller.h"
+#include "ui/wm/core/coordinate_conversion.h"
+#include "ui/wm/core/ime_util.h"
#include "ui/wm/public/activation_client.h"
#include "ui/wm/public/scoped_tooltip_disabler.h"
#include "ui/wm/public/tooltip_client.h"
@@ -579,6 +582,10 @@ void RenderWidgetHostViewAura::Hide() {
#endif
}
+aura::Window* RenderWidgetHostViewAura::GetToplevelWindow() {
+ return window_->GetToplevelWindow();
+}
+
void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
// For a SetSize operation, we don't care what coordinate system the origin
// of the window is in, it's only important to make sure that the origin
@@ -1276,26 +1283,6 @@ gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen(
end.y() - origin.y());
}
-gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen(
- const gfx::Rect& rect) const {
- gfx::Point origin = rect.origin();
- gfx::Point end = gfx::Point(rect.right(), rect.bottom());
-
- aura::Window* root_window = window_->GetRootWindow();
- 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());
- }
-
- return rect;
-}
-
gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
if (!text_input_manager_ || !text_input_manager_->GetActiveWidget())
return gfx::Rect();
@@ -1431,16 +1418,58 @@ void RenderWidgetHostViewAura::ExtendSelectionAndDelete(
rfh->ExtendSelectionAndDelete(before, after);
}
-void RenderWidgetHostViewAura::EnsureCaretNotInRect(const gfx::Rect& rect) {
- gfx::Rect rect_in_local_space = ConvertRectFromScreen(rect);
- gfx::Rect hiding_area_in_this_window =
- gfx::IntersectRects(rect_in_local_space, window_->bounds());
+void RenderWidgetHostViewAura::EnsureCaretNotInRect(
+ const gfx::Rect& rect_in_screen) {
+ aura::Window* top_level_window = GetToplevelWindow();
+ gfx::Rect original_window_bounds = top_level_window->GetBoundsInScreen();
+ if (top_level_window->GetProperty(
+ aura::client::kVirtualKeyboardRestoreBoundsKey)) {
+ original_window_bounds = *top_level_window->GetProperty(
+ aura::client::kVirtualKeyboardRestoreBoundsKey);
+ }
- if (hiding_area_in_this_window.IsEmpty())
+ gfx::Rect hidden_window_bounds_in_screen =
+ gfx::IntersectRects(rect_in_screen, original_window_bounds);
+ if (hidden_window_bounds_in_screen.IsEmpty()) {
+ // The window isn't covered by the keyboard, restore the window position if
+ // necessary.
+ OnClientFocusLost();
+ return;
+ }
+
+#if defined(OS_CHROMEOS)
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ ::switches::kUseNewVirtualKeyboardBehavior))
+ return;
+
+ if (wm::MoveWindowToEnsureCaretNotInRect(top_level_window, rect_in_screen)) {
+ // Recalculate hidden_window_bounds_in_screen after moving up the window.
+ original_window_bounds = top_level_window->GetBoundsInScreen();
+ hidden_window_bounds_in_screen =
+ gfx::IntersectRects(rect_in_screen, original_window_bounds);
+ } else {
+ // No need to move the window or need to restore the window position.
+ OnClientFocusLost();
+ }
+#endif // defined(OS_CHROMEOS)
+
+ // Perform overscroll if the caret is still hidden by the keyboard.
+ gfx::Rect visible_area_in_local_space = gfx::SubtractRects(
+ window_->GetBoundsInScreen(), hidden_window_bounds_in_screen);
+ wm::ConvertRectFromScreen(window_, &visible_area_in_local_space);
+ host_->ScrollFocusedEditableNodeIntoRect(visible_area_in_local_space);
+}
+
+void RenderWidgetHostViewAura::OnClientFocusLost() {
+#if defined(OS_CHROMEOS)
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ ::switches::kUseNewVirtualKeyboardBehavior))
return;
- host_->ScrollFocusedEditableNodeIntoRect(
- gfx::SubtractRects(window_->bounds(), hiding_area_in_this_window));
+ aura::Window* top_level_window = GetToplevelWindow();
+ DCHECK(top_level_window);
+ wm::RestoreWindowBoundsOnClientFocusLost(top_level_window);
+#endif // defined(OS_CHROMEOS)
}
bool RenderWidgetHostViewAura::IsTextEditCommandEnabled(

Powered by Google App Engine
This is Rietveld 408576698