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

Side by Side Diff: ui/views/controls/textfield/textfield.cc

Issue 187483005: Extending the Views-on-Mac experiment: whole app list grid. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: still compiles r263560 + crrev/195793005 Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/native/native_view_host_mac.mm ('k') | ui/views/drag_utils.cc » ('j') | 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 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "grit/ui_strings.h" 10 #include "grit/ui_strings.h"
11 #include "ui/accessibility/ax_view_state.h" 11 #include "ui/accessibility/ax_view_state.h"
12 #include "ui/base/clipboard/scoped_clipboard_writer.h" 12 #include "ui/base/clipboard/scoped_clipboard_writer.h"
13 #include "ui/base/cursor/cursor.h" 13 #include "ui/base/cursor/cursor.h"
14 #include "ui/base/dragdrop/drag_drop_types.h" 14 #include "ui/base/dragdrop/drag_drop_types.h"
15 #include "ui/base/dragdrop/drag_utils.h" 15 #include "ui/base/dragdrop/drag_utils.h"
16 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/base/ui_base_switches_util.h" 17 #include "ui/base/ui_base_switches_util.h"
18 #include "ui/events/event.h" 18 #include "ui/events/event.h"
19 #include "ui/events/keycodes/keyboard_codes.h" 19 #include "ui/events/keycodes/keyboard_codes.h"
20 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/cursor.h"
21 #include "ui/gfx/display.h" 22 #include "ui/gfx/display.h"
22 #include "ui/gfx/insets.h" 23 #include "ui/gfx/insets.h"
23 #include "ui/gfx/screen.h" 24 #include "ui/gfx/screen.h"
24 #include "ui/native_theme/native_theme.h" 25 #include "ui/native_theme/native_theme.h"
25 #include "ui/views/background.h" 26 #include "ui/views/background.h"
26 #include "ui/views/controls/focusable_border.h" 27 #include "ui/views/controls/focusable_border.h"
27 #include "ui/views/controls/label.h" 28 #include "ui/views/controls/label.h"
28 #include "ui/views/controls/menu/menu_item_view.h" 29 #include "ui/views/controls/menu/menu_item_view.h"
29 #include "ui/views/controls/menu/menu_runner.h" 30 #include "ui/views/controls/menu/menu_runner.h"
30 #include "ui/views/controls/native/native_view_host.h" 31 #include "ui/views/controls/native/native_view_host.h"
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 } 484 }
484 485
485 const char* Textfield::GetClassName() const { 486 const char* Textfield::GetClassName() const {
486 return kViewClassName; 487 return kViewClassName;
487 } 488 }
488 489
489 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) { 490 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) {
490 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); 491 bool in_selection = GetRenderText()->IsPointInSelection(event.location());
491 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED; 492 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED;
492 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection); 493 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection);
494 #if defined(OS_MACOSX)
495 return text_cursor ? gfx::GetNativeIBeamCursor()
496 : gfx::GetNativeArrowCursor();
497 #else
493 return text_cursor ? ui::kCursorIBeam : ui::kCursorNull; 498 return text_cursor ? ui::kCursorIBeam : ui::kCursorNull;
499 #endif
494 } 500 }
495
496 bool Textfield::OnMousePressed(const ui::MouseEvent& event) { 501 bool Textfield::OnMousePressed(const ui::MouseEvent& event) {
497 TrackMouseClicks(event); 502 TrackMouseClicks(event);
498 503
499 if (!controller_ || !controller_->HandleMouseEvent(this, event)) { 504 if (!controller_ || !controller_->HandleMouseEvent(this, event)) {
500 if (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) { 505 if (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) {
501 RequestFocus(); 506 RequestFocus();
502 ShowImeIfNeeded(); 507 ShowImeIfNeeded();
503 } 508 }
504 509
505 if (event.IsOnlyLeftMouseButton()) { 510 if (event.IsOnlyLeftMouseButton()) {
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 } 918 }
914 919
915 //////////////////////////////////////////////////////////////////////////////// 920 ////////////////////////////////////////////////////////////////////////////////
916 // Textfield, ContextMenuController overrides: 921 // Textfield, ContextMenuController overrides:
917 922
918 void Textfield::ShowContextMenuForView(View* source, 923 void Textfield::ShowContextMenuForView(View* source,
919 const gfx::Point& point, 924 const gfx::Point& point,
920 ui::MenuSourceType source_type) { 925 ui::MenuSourceType source_type) {
921 UpdateContextMenu(); 926 UpdateContextMenu();
922 ignore_result(context_menu_runner_->RunMenuAt(GetWidget(), NULL, 927 ignore_result(context_menu_runner_->RunMenuAt(GetWidget(), NULL,
923 gfx::Rect(point, gfx::Size()), MenuItemView::TOPLEFT, source_type, 928 gfx::Rect(point, gfx::Size()), ui::TOPLEFT_MENU_ANCHOR, source_type,
924 MenuRunner::HAS_MNEMONICS | MenuRunner::CONTEXT_MENU)); 929 MenuRunner::HAS_MNEMONICS | MenuRunner::CONTEXT_MENU));
925 } 930 }
926 931
927 //////////////////////////////////////////////////////////////////////////////// 932 ////////////////////////////////////////////////////////////////////////////////
928 // Textfield, DragController overrides: 933 // Textfield, DragController overrides:
929 934
930 void Textfield::WriteDragDataForView(View* sender, 935 void Textfield::WriteDragDataForView(View* sender,
931 const gfx::Point& press_pt, 936 const gfx::Point& press_pt,
932 OSExchangeData* data) { 937 OSExchangeData* data) {
933 const base::string16& selected_text(GetSelectedText()); 938 const base::string16& selected_text(GetSelectedText());
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 // [NativeWidget A] - FocusManager 1288 // [NativeWidget A] - FocusManager
1284 // [View] 1289 // [View]
1285 // [NativeWidget B] 1290 // [NativeWidget B]
1286 // [View] 1291 // [View]
1287 // [View X] 1292 // [View X]
1288 // An important thing is that [NativeWidget A] owns Win32 input focus even 1293 // An important thing is that [NativeWidget A] owns Win32 input focus even
1289 // when [View X] is logically focused by FocusManager. As a result, an Win32 1294 // when [View X] is logically focused by FocusManager. As a result, an Win32
1290 // IME may want to interact with the native view of [NativeWidget A] rather 1295 // IME may want to interact with the native view of [NativeWidget A] rather
1291 // than that of [NativeWidget B]. This is why we need to call 1296 // than that of [NativeWidget B]. This is why we need to call
1292 // GetTopLevelWidget() here. 1297 // GetTopLevelWidget() here.
1293 return GetWidget()->GetTopLevelWidget()->GetNativeView(); 1298 return GetWidget()->GetTopLevelWidget()->GetNativeWindow();
1294 } 1299 }
1295 1300
1296 ui::TextInputType Textfield::GetTextInputType() const { 1301 ui::TextInputType Textfield::GetTextInputType() const {
1297 if (read_only() || !enabled()) 1302 if (read_only() || !enabled())
1298 return ui::TEXT_INPUT_TYPE_NONE; 1303 return ui::TEXT_INPUT_TYPE_NONE;
1299 return text_input_type_; 1304 return text_input_type_;
1300 } 1305 }
1301 1306
1302 ui::TextInputMode Textfield::GetTextInputMode() const { 1307 ui::TextInputMode Textfield::GetTextInputMode() const {
1303 return ui::TEXT_INPUT_MODE_DEFAULT; 1308 return ui::TEXT_INPUT_MODE_DEFAULT;
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 const size_t length = selection_clipboard_text.length(); 1685 const size_t length = selection_clipboard_text.length();
1681 range = gfx::Range(range.start() + length, range.end() + length); 1686 range = gfx::Range(range.start() + length, range.end() + length);
1682 } 1687 }
1683 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); 1688 model_->MoveCursorTo(gfx::SelectionModel(range, affinity));
1684 UpdateAfterChange(true, true); 1689 UpdateAfterChange(true, true);
1685 OnAfterUserAction(); 1690 OnAfterUserAction();
1686 } 1691 }
1687 } 1692 }
1688 1693
1689 } // namespace views 1694 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/native/native_view_host_mac.mm ('k') | ui/views/drag_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698