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

Unified Diff: ui/views/controls/textfield/textfield.cc

Issue 2240353002: move switch Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Virtual keyboard non-sticky mode changes. 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
« no previous file with comments | « ui/keyboard/keyboard_ui.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index 1f940c5e476d76a626c87e4a09caa5b0d229b7c8..5ae330752b0f1391b471c3047c19cec710c82a4e 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -7,9 +7,12 @@
#include <string>
#include <utility>
+#include "base/command_line.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "ui/accessibility/ax_view_state.h"
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/window.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/default_style.h"
@@ -19,6 +22,7 @@
#include "ui/base/ime/text_edit_commands.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_switches.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/compositor/canvas_painter.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
@@ -1430,7 +1434,31 @@ void Textfield::ExtendSelectionAndDelete(size_t before, size_t after) {
DeleteRange(range);
}
-void Textfield::EnsureCaretInRect(const gfx::Rect& rect) {}
+void Textfield::EnsureCaretInRect(const gfx::Rect& rect) {
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ ::switches::kUseNewVKWindowBehavior))
+ return;
+
+ display::Screen* screen = display::Screen::GetScreen();
+ if (screen->GetPrimaryDisplay().id() !=
+ screen->GetDisplayNearestWindow(GetNativeView()).id())
+ return;
+
+ aura::Window* top_level_window = GetNativeView()->GetToplevelWindow();
+
+ if (top_level_window->GetProperty(aura::client::kVKNewBoundsKey)) {
+ top_level_window->ClearProperty(aura::client::kVKNewBoundsKey);
+ } else if (rect != screen->GetPrimaryDisplay().bounds()) {
+ 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());
+
+ gfx::Point origin(window_bounds.x(), window_bounds.y() - shift);
+ top_level_window->SetProperty(aura::client::kVKNewBoundsKey,
+ new gfx::Rect(origin, window_bounds.size()));
+ }
+}
bool Textfield::IsTextEditCommandEnabled(ui::TextEditCommand command) const {
base::string16 result;
« no previous file with comments | « ui/keyboard/keyboard_ui.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698