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 1906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
1924 } | 1924 } |
1925 | 1925 |
1926 void Textfield::UpdateCursorView() { | 1926 void Textfield::UpdateCursorView() { |
1927 cursor_view_.SetBoundsRect(GetRenderText()->GetUpdatedCursorBounds()); | 1927 gfx::Rect location(GetRenderText()->GetUpdatedCursorBounds()); |
| 1928 location.set_x(GetMirroredXForRect(location)); |
| 1929 cursor_view_.SetBoundsRect(location); |
1928 } | 1930 } |
1929 | 1931 |
1930 void Textfield::PaintTextAndCursor(gfx::Canvas* canvas) { | 1932 void Textfield::PaintTextAndCursor(gfx::Canvas* canvas) { |
1931 TRACE_EVENT0("views", "Textfield::PaintTextAndCursor"); | 1933 TRACE_EVENT0("views", "Textfield::PaintTextAndCursor"); |
1932 canvas->Save(); | 1934 canvas->Save(); |
1933 | 1935 |
1934 // Draw placeholder text if needed. | 1936 // Draw placeholder text if needed. |
1935 gfx::RenderText* render_text = GetRenderText(); | 1937 gfx::RenderText* render_text = GetRenderText(); |
1936 if (text().empty() && !GetPlaceholderText().empty()) { | 1938 if (text().empty() && !GetPlaceholderText().empty()) { |
1937 canvas->DrawStringRect(GetPlaceholderText(), GetFontList(), | 1939 canvas->DrawStringRect(GetPlaceholderText(), GetFontList(), |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2083 cursor_blink_timer_.Stop(); | 2085 cursor_blink_timer_.Stop(); |
2084 } | 2086 } |
2085 | 2087 |
2086 void Textfield::OnCursorBlinkTimerFired() { | 2088 void Textfield::OnCursorBlinkTimerFired() { |
2087 DCHECK(ShouldBlinkCursor()); | 2089 DCHECK(ShouldBlinkCursor()); |
2088 cursor_view_.SetVisible(!cursor_view_.visible()); | 2090 cursor_view_.SetVisible(!cursor_view_.visible()); |
2089 UpdateCursorView(); | 2091 UpdateCursorView(); |
2090 } | 2092 } |
2091 | 2093 |
2092 } // namespace views | 2094 } // namespace views |
OLD | NEW |