OLD | NEW |
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 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 is_cursor_visible_ = !is_cursor_visible_; | 1099 is_cursor_visible_ = !is_cursor_visible_; |
1100 RepaintCursor(); | 1100 RepaintCursor(); |
1101 base::MessageLoop::current()->PostDelayedTask( | 1101 base::MessageLoop::current()->PostDelayedTask( |
1102 FROM_HERE, | 1102 FROM_HERE, |
1103 base::Bind(&NativeTextfieldViews::UpdateCursor, | 1103 base::Bind(&NativeTextfieldViews::UpdateCursor, |
1104 cursor_timer_.GetWeakPtr()), | 1104 cursor_timer_.GetWeakPtr()), |
1105 base::TimeDelta::FromMilliseconds(kCursorBlinkCycleMs / 2)); | 1105 base::TimeDelta::FromMilliseconds(kCursorBlinkCycleMs / 2)); |
1106 } | 1106 } |
1107 | 1107 |
1108 void NativeTextfieldViews::RepaintCursor() { | 1108 void NativeTextfieldViews::RepaintCursor() { |
1109 gfx::Rect r(GetCaretBounds()); | 1109 gfx::Rect r(GetRenderText()->GetUpdatedCursorBounds()); |
1110 r.Inset(-1, -1, -1, -1); | 1110 r.Inset(-1, -1, -1, -1); |
1111 SchedulePaintInRect(r); | 1111 SchedulePaintInRect(r); |
1112 } | 1112 } |
1113 | 1113 |
1114 void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) { | 1114 void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) { |
1115 TRACE_EVENT0("views", "NativeTextfieldViews::PaintTextAndCursor"); | 1115 TRACE_EVENT0("views", "NativeTextfieldViews::PaintTextAndCursor"); |
1116 canvas->Save(); | 1116 canvas->Save(); |
1117 GetRenderText()->set_cursor_visible(!is_drop_cursor_visible_ && | 1117 GetRenderText()->set_cursor_visible(!is_drop_cursor_visible_ && |
1118 is_cursor_visible_ && !model_->HasSelection()); | 1118 is_cursor_visible_ && !model_->HasSelection()); |
1119 // Draw the text, cursor, and selection. | 1119 // Draw the text, cursor, and selection. |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 | 1452 |
1453 void NativeTextfieldViews::PlatformGestureEventHandling( | 1453 void NativeTextfieldViews::PlatformGestureEventHandling( |
1454 const ui::GestureEvent* event) { | 1454 const ui::GestureEvent* event) { |
1455 #if defined(OS_WIN) && defined(USE_AURA) | 1455 #if defined(OS_WIN) && defined(USE_AURA) |
1456 if (event->type() == ui::ET_GESTURE_TAP_DOWN && !textfield_->read_only()) | 1456 if (event->type() == ui::ET_GESTURE_TAP_DOWN && !textfield_->read_only()) |
1457 base::win::DisplayVirtualKeyboard(); | 1457 base::win::DisplayVirtualKeyboard(); |
1458 #endif | 1458 #endif |
1459 } | 1459 } |
1460 | 1460 |
1461 } // namespace views | 1461 } // namespace views |
OLD | NEW |