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

Side by Side Diff: ui/views/controls/textfield/textfield.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: Added property definition 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
« ui/base/ime/input_method_base.cc ('K') | « 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 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 gfx::Range range = GetRenderText()->selection(); 1439 gfx::Range range = GetRenderText()->selection();
1436 DCHECK_GE(range.start(), before); 1440 DCHECK_GE(range.start(), before);
1437 1441
1438 range.set_start(range.start() - before); 1442 range.set_start(range.start() - before);
1439 range.set_end(range.end() + after); 1443 range.set_end(range.end() + after);
1440 gfx::Range text_range; 1444 gfx::Range text_range;
1441 if (GetTextRange(&text_range) && text_range.Contains(range)) 1445 if (GetTextRange(&text_range) && text_range.Contains(range))
1442 DeleteRange(range); 1446 DeleteRange(range);
1443 } 1447 }
1444 1448
1445 void Textfield::EnsureCaretInRect(const gfx::Rect& rect) {} 1449 void Textfield::EnsureCaretInRect(const gfx::Rect& rect) {
1450 #if defined(OS_CHROMEOS)
1451 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
1452 ::switches::kUseNewVKWindowBehavior))
1453 return;
1454
1455 // Only windows in primary display should be moved by virtual keyboard.
1456 display::Screen* screen = display::Screen::GetScreen();
1457 if (screen->GetPrimaryDisplay().id() !=
1458 screen->GetDisplayNearestWindow(GetNativeView()).id())
1459 return;
1460
1461 // Get restore bounds of window.
1462 aura::Window* top_level_window = GetNativeView()->GetToplevelWindow();
1463 gfx::Rect* vk_restore_bounds = top_level_window->GetProperty(
1464 aura::client::kVirtualKeyboardRestoreBoundsKey);
1465
1466 if (vk_restore_bounds) {
1467 // Restore window.
1468 top_level_window->SetBounds(*vk_restore_bounds);
1469 top_level_window->ClearProperty(
1470 aura::client::kVirtualKeyboardRestoreBoundsKey);
1471 } else if (rect != screen->GetPrimaryDisplay().bounds()) {
1472 // Calculate vertical window shift.
1473 gfx::Rect window_bounds = top_level_window->GetBoundsInRootWindow();
1474 int vertical_displacement =
1475 std::max(0, window_bounds.bottom() - rect.bottom());
1476 int shift = std::min(vertical_displacement, window_bounds.y());
1477
1478 // Set restore bounds and move window.
1479 if (shift > 0) {
1480 gfx::Point origin(window_bounds.x(), window_bounds.y() - shift);
1481 top_level_window->SetProperty(
1482 aura::client::kVirtualKeyboardRestoreBoundsKey,
1483 new gfx::Rect(window_bounds));
1484 top_level_window->SetBounds(gfx::Rect(origin, window_bounds.size()));
1485 }
1486 }
1487 #endif
1488 }
1446 1489
1447 bool Textfield::IsTextEditCommandEnabled(ui::TextEditCommand command) const { 1490 bool Textfield::IsTextEditCommandEnabled(ui::TextEditCommand command) const {
1448 base::string16 result; 1491 base::string16 result;
1449 bool editable = !read_only(); 1492 bool editable = !read_only();
1450 bool readable = text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD; 1493 bool readable = text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD;
1451 switch (command) { 1494 switch (command) {
1452 case ui::TextEditCommand::DELETE_BACKWARD: 1495 case ui::TextEditCommand::DELETE_BACKWARD:
1453 case ui::TextEditCommand::DELETE_FORWARD: 1496 case ui::TextEditCommand::DELETE_FORWARD:
1454 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE: 1497 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE:
1455 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH: 1498 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH:
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 RequestFocus(); 2068 RequestFocus();
2026 model_->MoveCursorTo(mouse); 2069 model_->MoveCursorTo(mouse);
2027 if (!selection_clipboard_text.empty()) { 2070 if (!selection_clipboard_text.empty()) {
2028 model_->InsertText(selection_clipboard_text); 2071 model_->InsertText(selection_clipboard_text);
2029 UpdateAfterChange(true, true); 2072 UpdateAfterChange(true, true);
2030 } 2073 }
2031 OnAfterUserAction(); 2074 OnAfterUserAction();
2032 } 2075 }
2033 2076
2034 } // namespace views 2077 } // namespace views
OLDNEW
« ui/base/ime/input_method_base.cc ('K') | « ui/keyboard/keyboard_ui.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698