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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « ui/keyboard/keyboard_ui.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/views/controls/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h"
10 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
11 #include "build/build_config.h" 12 #include "build/build_config.h"
12 #include "ui/accessibility/ax_view_state.h" 13 #include "ui/accessibility/ax_view_state.h"
14 #include "ui/aura/client/aura_constants.h"
15 #include "ui/aura/window.h"
13 #include "ui/base/clipboard/scoped_clipboard_writer.h" 16 #include "ui/base/clipboard/scoped_clipboard_writer.h"
14 #include "ui/base/cursor/cursor.h" 17 #include "ui/base/cursor/cursor.h"
15 #include "ui/base/default_style.h" 18 #include "ui/base/default_style.h"
16 #include "ui/base/dragdrop/drag_drop_types.h" 19 #include "ui/base/dragdrop/drag_drop_types.h"
17 #include "ui/base/dragdrop/drag_utils.h" 20 #include "ui/base/dragdrop/drag_utils.h"
18 #include "ui/base/ime/input_method.h" 21 #include "ui/base/ime/input_method.h"
19 #include "ui/base/ime/text_edit_commands.h" 22 #include "ui/base/ime/text_edit_commands.h"
20 #include "ui/base/material_design/material_design_controller.h" 23 #include "ui/base/material_design/material_design_controller.h"
21 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
25 #include "ui/base/ui_base_switches.h"
22 #include "ui/base/ui_base_switches_util.h" 26 #include "ui/base/ui_base_switches_util.h"
23 #include "ui/compositor/canvas_painter.h" 27 #include "ui/compositor/canvas_painter.h"
24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 28 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
25 #include "ui/display/display.h" 29 #include "ui/display/display.h"
26 #include "ui/display/screen.h" 30 #include "ui/display/screen.h"
27 #include "ui/events/base_event_utils.h" 31 #include "ui/events/base_event_utils.h"
28 #include "ui/events/event.h" 32 #include "ui/events/event.h"
29 #include "ui/events/keycodes/keyboard_codes.h" 33 #include "ui/events/keycodes/keyboard_codes.h"
30 #include "ui/gfx/canvas.h" 34 #include "ui/gfx/canvas.h"
31 #include "ui/gfx/geometry/insets.h" 35 #include "ui/gfx/geometry/insets.h"
(...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 gfx::Range range = GetRenderText()->selection(); 1427 gfx::Range range = GetRenderText()->selection();
1424 DCHECK_GE(range.start(), before); 1428 DCHECK_GE(range.start(), before);
1425 1429
1426 range.set_start(range.start() - before); 1430 range.set_start(range.start() - before);
1427 range.set_end(range.end() + after); 1431 range.set_end(range.end() + after);
1428 gfx::Range text_range; 1432 gfx::Range text_range;
1429 if (GetTextRange(&text_range) && text_range.Contains(range)) 1433 if (GetTextRange(&text_range) && text_range.Contains(range))
1430 DeleteRange(range); 1434 DeleteRange(range);
1431 } 1435 }
1432 1436
1433 void Textfield::EnsureCaretInRect(const gfx::Rect& rect) {} 1437 void Textfield::EnsureCaretInRect(const gfx::Rect& rect) {
1438 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
1439 ::switches::kUseNewVKWindowBehavior))
1440 return;
1441
1442 display::Screen* screen = display::Screen::GetScreen();
1443 if (screen->GetPrimaryDisplay().id() !=
1444 screen->GetDisplayNearestWindow(GetNativeView()).id())
1445 return;
1446
1447 aura::Window* top_level_window = GetNativeView()->GetToplevelWindow();
1448
1449 if (top_level_window->GetProperty(aura::client::kVKNewBoundsKey)) {
1450 top_level_window->ClearProperty(aura::client::kVKNewBoundsKey);
1451 } else if (rect != screen->GetPrimaryDisplay().bounds()) {
1452 gfx::Rect window_bounds = top_level_window->GetBoundsInRootWindow();
1453 int vertical_displacement =
1454 std::max(0, window_bounds.bottom() - rect.bottom());
1455 int shift = std::min(vertical_displacement, window_bounds.y());
1456
1457 gfx::Point origin(window_bounds.x(), window_bounds.y() - shift);
1458 top_level_window->SetProperty(aura::client::kVKNewBoundsKey,
1459 new gfx::Rect(origin, window_bounds.size()));
1460 }
1461 }
1434 1462
1435 bool Textfield::IsTextEditCommandEnabled(ui::TextEditCommand command) const { 1463 bool Textfield::IsTextEditCommandEnabled(ui::TextEditCommand command) const {
1436 base::string16 result; 1464 base::string16 result;
1437 bool editable = !read_only(); 1465 bool editable = !read_only();
1438 bool readable = text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD; 1466 bool readable = text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD;
1439 switch (command) { 1467 switch (command) {
1440 case ui::TextEditCommand::DELETE_BACKWARD: 1468 case ui::TextEditCommand::DELETE_BACKWARD:
1441 case ui::TextEditCommand::DELETE_FORWARD: 1469 case ui::TextEditCommand::DELETE_FORWARD:
1442 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE: 1470 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE:
1443 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH: 1471 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH:
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 RequestFocus(); 2011 RequestFocus();
1984 model_->MoveCursorTo(mouse); 2012 model_->MoveCursorTo(mouse);
1985 if (!selection_clipboard_text.empty()) { 2013 if (!selection_clipboard_text.empty()) {
1986 model_->InsertText(selection_clipboard_text); 2014 model_->InsertText(selection_clipboard_text);
1987 UpdateAfterChange(true, true); 2015 UpdateAfterChange(true, true);
1988 } 2016 }
1989 OnAfterUserAction(); 2017 OnAfterUserAction();
1990 } 2018 }
1991 2019
1992 } // namespace views 2020 } // namespace views
OLDNEW
« 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