Chromium Code Reviews| 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 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 972 SchedulePaint(); | 972 SchedulePaint(); |
| 973 } | 973 } |
| 974 | 974 |
| 975 void Textfield::OnPaint(gfx::Canvas* canvas) { | 975 void Textfield::OnPaint(gfx::Canvas* canvas) { |
| 976 OnPaintBackground(canvas); | 976 OnPaintBackground(canvas); |
| 977 PaintTextAndCursor(canvas); | 977 PaintTextAndCursor(canvas); |
| 978 OnPaintBorder(canvas); | 978 OnPaintBorder(canvas); |
| 979 } | 979 } |
| 980 | 980 |
| 981 void Textfield::OnFocus() { | 981 void Textfield::OnFocus() { |
| 982 GetRenderText()->set_focused(true); | 982 gfx::RenderText* render_text = GetRenderText(); |
| 983 render_text->set_focused(true); | |
| 983 if (ShouldShowCursor()) { | 984 if (ShouldShowCursor()) { |
|
sadrul
2017/03/01 20:51:24
Can you look at whether ShouldShowCursor() should
yiyix
2017/03/01 22:18:58
ShouldShowCursor() does not check render_text->cur
| |
| 984 UpdateCursorView(); | 985 UpdateCursorView(); |
| 985 cursor_view_.SetVisible(true); | 986 cursor_view_.SetVisible(render_text->cursor_enabled()); |
| 986 } | 987 } |
| 987 if (GetInputMethod()) | 988 if (GetInputMethod()) |
| 988 GetInputMethod()->SetFocusedTextInputClient(this); | 989 GetInputMethod()->SetFocusedTextInputClient(this); |
| 989 OnCaretBoundsChanged(); | 990 OnCaretBoundsChanged(); |
| 990 if (ShouldBlinkCursor()) | 991 if (ShouldBlinkCursor()) |
| 991 StartBlinkingCursor(); | 992 StartBlinkingCursor(); |
| 992 if (use_focus_ring_) { | 993 if (use_focus_ring_) { |
| 993 FocusRing::Install(this, invalid_ | 994 FocusRing::Install(this, invalid_ |
| 994 ? ui::NativeTheme::kColorId_AlertSeverityHigh | 995 ? ui::NativeTheme::kColorId_AlertSeverityHigh |
| 995 : ui::NativeTheme::kColorId_NumColors); | 996 : ui::NativeTheme::kColorId_NumColors); |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1902 View::SetBorder(std::move(border)); | 1903 View::SetBorder(std::move(border)); |
| 1903 } | 1904 } |
| 1904 | 1905 |
| 1905 void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) { | 1906 void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) { |
| 1906 if (text_changed) { | 1907 if (text_changed) { |
| 1907 if (controller_) | 1908 if (controller_) |
| 1908 controller_->ContentsChanged(this, text()); | 1909 controller_->ContentsChanged(this, text()); |
| 1909 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); | 1910 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); |
| 1910 } | 1911 } |
| 1911 if (cursor_changed) { | 1912 if (cursor_changed) { |
| 1912 cursor_view_.SetVisible(ShouldShowCursor()); | |
| 1913 UpdateCursorView(); | 1913 UpdateCursorView(); |
| 1914 cursor_view_.SetVisible(GetRenderText()->cursor_enabled() && | |
| 1915 ShouldShowCursor()); | |
| 1914 if (ShouldBlinkCursor()) | 1916 if (ShouldBlinkCursor()) |
| 1915 StartBlinkingCursor(); | 1917 StartBlinkingCursor(); |
| 1916 else | 1918 else |
| 1917 StopBlinkingCursor(); | 1919 StopBlinkingCursor(); |
| 1918 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_SELECTION_CHANGED, true); | 1920 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_SELECTION_CHANGED, true); |
| 1919 } | 1921 } |
| 1920 if (text_changed || cursor_changed) { | 1922 if (text_changed || cursor_changed) { |
| 1921 OnCaretBoundsChanged(); | 1923 OnCaretBoundsChanged(); |
| 1922 SchedulePaint(); | 1924 SchedulePaint(); |
| 1923 } | 1925 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2080 Textfield::GetCaretBlinkMs()), | 2082 Textfield::GetCaretBlinkMs()), |
| 2081 this, &Textfield::OnCursorBlinkTimerFired); | 2083 this, &Textfield::OnCursorBlinkTimerFired); |
| 2082 } | 2084 } |
| 2083 | 2085 |
| 2084 void Textfield::StopBlinkingCursor() { | 2086 void Textfield::StopBlinkingCursor() { |
| 2085 cursor_blink_timer_.Stop(); | 2087 cursor_blink_timer_.Stop(); |
| 2086 } | 2088 } |
| 2087 | 2089 |
| 2088 void Textfield::OnCursorBlinkTimerFired() { | 2090 void Textfield::OnCursorBlinkTimerFired() { |
| 2089 DCHECK(ShouldBlinkCursor()); | 2091 DCHECK(ShouldBlinkCursor()); |
| 2090 cursor_view_.SetVisible(!cursor_view_.visible()); | 2092 cursor_view_.SetVisible(GetRenderText()->cursor_enabled() && |
| 2093 !cursor_view_.visible()); | |
|
sadrul
2017/03/01 20:51:24
If cursor is disabled in RenderText, is there a re
yiyix
2017/03/01 22:18:58
After the modification, this function is only call
| |
| 2091 UpdateCursorView(); | 2094 UpdateCursorView(); |
| 2092 } | 2095 } |
| 2093 | 2096 |
| 2094 } // namespace views | 2097 } // namespace views |
| OLD | NEW |