| 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/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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 View::SetBorder(std::move(border)); | 1902 View::SetBorder(std::move(border)); |
| 1903 } | 1903 } |
| 1904 | 1904 |
| 1905 void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) { | 1905 void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) { |
| 1906 if (text_changed) { | 1906 if (text_changed) { |
| 1907 if (controller_) | 1907 if (controller_) |
| 1908 controller_->ContentsChanged(this, text()); | 1908 controller_->ContentsChanged(this, text()); |
| 1909 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); | 1909 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); |
| 1910 } | 1910 } |
| 1911 if (cursor_changed) { | 1911 if (cursor_changed) { |
| 1912 UpdateCursorView(); |
| 1912 cursor_view_.SetVisible(ShouldShowCursor()); | 1913 cursor_view_.SetVisible(ShouldShowCursor()); |
| 1913 UpdateCursorView(); | |
| 1914 if (ShouldBlinkCursor()) | 1914 if (ShouldBlinkCursor()) |
| 1915 StartBlinkingCursor(); | 1915 StartBlinkingCursor(); |
| 1916 else | 1916 else |
| 1917 StopBlinkingCursor(); | 1917 StopBlinkingCursor(); |
| 1918 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_SELECTION_CHANGED, true); | 1918 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_SELECTION_CHANGED, true); |
| 1919 } | 1919 } |
| 1920 if (text_changed || cursor_changed) { | 1920 if (text_changed || cursor_changed) { |
| 1921 OnCaretBoundsChanged(); | 1921 OnCaretBoundsChanged(); |
| 1922 SchedulePaint(); | 1922 SchedulePaint(); |
| 1923 } | 1923 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2060 if (touch_selection_controller_) | 2060 if (touch_selection_controller_) |
| 2061 touch_selection_controller_->SelectionChanged(); | 2061 touch_selection_controller_->SelectionChanged(); |
| 2062 } | 2062 } |
| 2063 | 2063 |
| 2064 void Textfield::OnEditFailed() { | 2064 void Textfield::OnEditFailed() { |
| 2065 PlatformStyle::OnTextfieldEditFailed(); | 2065 PlatformStyle::OnTextfieldEditFailed(); |
| 2066 } | 2066 } |
| 2067 | 2067 |
| 2068 bool Textfield::ShouldShowCursor() const { | 2068 bool Textfield::ShouldShowCursor() const { |
| 2069 return HasFocus() && !HasSelection() && enabled() && !read_only() && | 2069 return HasFocus() && !HasSelection() && enabled() && !read_only() && |
| 2070 !drop_cursor_visible_; | 2070 !drop_cursor_visible_ && GetRenderText()->cursor_enabled(); |
| 2071 } | 2071 } |
| 2072 | 2072 |
| 2073 bool Textfield::ShouldBlinkCursor() const { | 2073 bool Textfield::ShouldBlinkCursor() const { |
| 2074 return ShouldShowCursor() && Textfield::GetCaretBlinkMs() != 0; | 2074 return ShouldShowCursor() && Textfield::GetCaretBlinkMs() != 0; |
| 2075 } | 2075 } |
| 2076 | 2076 |
| 2077 void Textfield::StartBlinkingCursor() { | 2077 void Textfield::StartBlinkingCursor() { |
| 2078 DCHECK(ShouldBlinkCursor()); | 2078 DCHECK(ShouldBlinkCursor()); |
| 2079 cursor_blink_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds( | 2079 cursor_blink_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds( |
| 2080 Textfield::GetCaretBlinkMs()), | 2080 Textfield::GetCaretBlinkMs()), |
| 2081 this, &Textfield::OnCursorBlinkTimerFired); | 2081 this, &Textfield::OnCursorBlinkTimerFired); |
| 2082 } | 2082 } |
| 2083 | 2083 |
| 2084 void Textfield::StopBlinkingCursor() { | 2084 void Textfield::StopBlinkingCursor() { |
| 2085 cursor_blink_timer_.Stop(); | 2085 cursor_blink_timer_.Stop(); |
| 2086 } | 2086 } |
| 2087 | 2087 |
| 2088 void Textfield::OnCursorBlinkTimerFired() { | 2088 void Textfield::OnCursorBlinkTimerFired() { |
| 2089 DCHECK(ShouldBlinkCursor()); | 2089 DCHECK(ShouldBlinkCursor()); |
| 2090 cursor_view_.SetVisible(!cursor_view_.visible()); | 2090 cursor_view_.SetVisible(!cursor_view_.visible()); |
| 2091 UpdateCursorView(); | 2091 UpdateCursorView(); |
| 2092 } | 2092 } |
| 2093 | 2093 |
| 2094 } // namespace views | 2094 } // namespace views |
| OLD | NEW |