OLD | NEW |
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/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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 void NativeTextfieldViews::HandleFocus() { | 501 void NativeTextfieldViews::HandleFocus() { |
502 GetRenderText()->set_focused(true); | 502 GetRenderText()->set_focused(true); |
503 is_cursor_visible_ = true; | 503 is_cursor_visible_ = true; |
504 SchedulePaint(); | 504 SchedulePaint(); |
505 OnCaretBoundsChanged(); | 505 OnCaretBoundsChanged(); |
506 // Start blinking cursor. | 506 // Start blinking cursor. |
507 MessageLoop::current()->PostDelayedTask( | 507 MessageLoop::current()->PostDelayedTask( |
508 FROM_HERE, | 508 FROM_HERE, |
509 base::Bind(&NativeTextfieldViews::UpdateCursor, | 509 base::Bind(&NativeTextfieldViews::UpdateCursor, |
510 cursor_timer_.GetWeakPtr()), | 510 cursor_timer_.GetWeakPtr()), |
511 kCursorVisibleTimeMs); | 511 base::TimeDelta::FromMilliseconds(kCursorVisibleTimeMs)); |
512 } | 512 } |
513 | 513 |
514 void NativeTextfieldViews::HandleBlur() { | 514 void NativeTextfieldViews::HandleBlur() { |
515 GetRenderText()->set_focused(false); | 515 GetRenderText()->set_focused(false); |
516 // Stop blinking cursor. | 516 // Stop blinking cursor. |
517 cursor_timer_.InvalidateWeakPtrs(); | 517 cursor_timer_.InvalidateWeakPtrs(); |
518 if (is_cursor_visible_) { | 518 if (is_cursor_visible_) { |
519 is_cursor_visible_ = false; | 519 is_cursor_visible_ = false; |
520 RepaintCursor(); | 520 RepaintCursor(); |
521 } | 521 } |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 base::i18n::ToLower(text) : text; | 801 base::i18n::ToLower(text) : text; |
802 } | 802 } |
803 | 803 |
804 void NativeTextfieldViews::UpdateCursor() { | 804 void NativeTextfieldViews::UpdateCursor() { |
805 is_cursor_visible_ = !is_cursor_visible_; | 805 is_cursor_visible_ = !is_cursor_visible_; |
806 RepaintCursor(); | 806 RepaintCursor(); |
807 MessageLoop::current()->PostDelayedTask( | 807 MessageLoop::current()->PostDelayedTask( |
808 FROM_HERE, | 808 FROM_HERE, |
809 base::Bind(&NativeTextfieldViews::UpdateCursor, | 809 base::Bind(&NativeTextfieldViews::UpdateCursor, |
810 cursor_timer_.GetWeakPtr()), | 810 cursor_timer_.GetWeakPtr()), |
811 is_cursor_visible_ ? kCursorVisibleTimeMs : kCursorInvisibleTimeMs); | 811 base::TimeDelta::FromMilliseconds( |
| 812 is_cursor_visible_ ? kCursorVisibleTimeMs : kCursorInvisibleTimeMs)); |
812 } | 813 } |
813 | 814 |
814 void NativeTextfieldViews::RepaintCursor() { | 815 void NativeTextfieldViews::RepaintCursor() { |
815 gfx::Rect r(GetCaretBounds()); | 816 gfx::Rect r(GetCaretBounds()); |
816 r.Inset(-1, -1, -1, -1); | 817 r.Inset(-1, -1, -1, -1); |
817 SchedulePaintInRect(r); | 818 SchedulePaintInRect(r); |
818 } | 819 } |
819 | 820 |
820 void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) { | 821 void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) { |
821 TRACE_EVENT0("views", "NativeTextfieldViews::PaintTextAndCursor"); | 822 TRACE_EVENT0("views", "NativeTextfieldViews::PaintTextAndCursor"); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 | 1151 |
1151 #if defined(USE_AURA) | 1152 #if defined(USE_AURA) |
1152 // static | 1153 // static |
1153 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 1154 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
1154 Textfield* field) { | 1155 Textfield* field) { |
1155 return new NativeTextfieldViews(field); | 1156 return new NativeTextfieldViews(field); |
1156 } | 1157 } |
1157 #endif | 1158 #endif |
1158 | 1159 |
1159 } // namespace views | 1160 } // namespace views |
OLD | NEW |