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

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

Issue 14061025: ui: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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/slider.cc ('k') | ui/views/examples/examples_window.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/native_textfield_views.h" 5 #include "ui/views/controls/textfield/native_textfield_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 bool NativeTextfieldViews::HandleKeyReleased(const ui::KeyEvent& e) { 671 bool NativeTextfieldViews::HandleKeyReleased(const ui::KeyEvent& e) {
672 return false; // crbug.com/127520 672 return false; // crbug.com/127520
673 } 673 }
674 674
675 void NativeTextfieldViews::HandleFocus() { 675 void NativeTextfieldViews::HandleFocus() {
676 GetRenderText()->set_focused(true); 676 GetRenderText()->set_focused(true);
677 is_cursor_visible_ = true; 677 is_cursor_visible_ = true;
678 SchedulePaint(); 678 SchedulePaint();
679 OnCaretBoundsChanged(); 679 OnCaretBoundsChanged();
680 // Start blinking cursor. 680 // Start blinking cursor.
681 MessageLoop::current()->PostDelayedTask( 681 base::MessageLoop::current()->PostDelayedTask(
682 FROM_HERE, 682 FROM_HERE,
683 base::Bind(&NativeTextfieldViews::UpdateCursor, 683 base::Bind(&NativeTextfieldViews::UpdateCursor,
684 cursor_timer_.GetWeakPtr()), 684 cursor_timer_.GetWeakPtr()),
685 base::TimeDelta::FromMilliseconds(kCursorBlinkCycleMs / 2)); 685 base::TimeDelta::FromMilliseconds(kCursorBlinkCycleMs / 2));
686 } 686 }
687 687
688 void NativeTextfieldViews::HandleBlur() { 688 void NativeTextfieldViews::HandleBlur() {
689 GetRenderText()->set_focused(false); 689 GetRenderText()->set_focused(false);
690 // Stop blinking cursor. 690 // Stop blinking cursor.
691 cursor_timer_.InvalidateWeakPtrs(); 691 cursor_timer_.InvalidateWeakPtrs();
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 ui::NativeTheme::kColorId_TextfieldSelectionColor)); 1067 ui::NativeTheme::kColorId_TextfieldSelectionColor));
1068 render_text->set_selection_background_focused_color(theme->GetSystemColor( 1068 render_text->set_selection_background_focused_color(theme->GetSystemColor(
1069 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused)); 1069 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused));
1070 render_text->set_selection_background_unfocused_color(theme->GetSystemColor( 1070 render_text->set_selection_background_unfocused_color(theme->GetSystemColor(
1071 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundUnfocused)); 1071 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundUnfocused));
1072 } 1072 }
1073 1073
1074 void NativeTextfieldViews::UpdateCursor() { 1074 void NativeTextfieldViews::UpdateCursor() {
1075 is_cursor_visible_ = !is_cursor_visible_; 1075 is_cursor_visible_ = !is_cursor_visible_;
1076 RepaintCursor(); 1076 RepaintCursor();
1077 MessageLoop::current()->PostDelayedTask( 1077 base::MessageLoop::current()->PostDelayedTask(
1078 FROM_HERE, 1078 FROM_HERE,
1079 base::Bind(&NativeTextfieldViews::UpdateCursor, 1079 base::Bind(&NativeTextfieldViews::UpdateCursor,
1080 cursor_timer_.GetWeakPtr()), 1080 cursor_timer_.GetWeakPtr()),
1081 base::TimeDelta::FromMilliseconds(kCursorBlinkCycleMs / 2)); 1081 base::TimeDelta::FromMilliseconds(kCursorBlinkCycleMs / 2));
1082 } 1082 }
1083 1083
1084 void NativeTextfieldViews::RepaintCursor() { 1084 void NativeTextfieldViews::RepaintCursor() {
1085 gfx::Rect r(GetCaretBounds()); 1085 gfx::Rect r(GetCaretBounds());
1086 r.Inset(-1, -1, -1, -1); 1086 r.Inset(-1, -1, -1, -1);
1087 SchedulePaintInRect(r); 1087 SchedulePaintInRect(r);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 1426
1427 void NativeTextfieldViews::PlatformGestureEventHandling( 1427 void NativeTextfieldViews::PlatformGestureEventHandling(
1428 const ui::GestureEvent* event) { 1428 const ui::GestureEvent* event) {
1429 #if defined(OS_WIN) && defined(USE_AURA) 1429 #if defined(OS_WIN) && defined(USE_AURA)
1430 if (event->type() == ui::ET_GESTURE_TAP_DOWN && !textfield_->read_only()) 1430 if (event->type() == ui::ET_GESTURE_TAP_DOWN && !textfield_->read_only())
1431 base::win::DisplayVirtualKeyboard(); 1431 base::win::DisplayVirtualKeyboard();
1432 #endif 1432 #endif
1433 } 1433 }
1434 1434
1435 } // namespace views 1435 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/slider.cc ('k') | ui/views/examples/examples_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698