Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Side by Side Diff: ui/views/controls/textfield/textfield.cc

Issue 259073004: Revert of retry r266042: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "grit/ui_strings.h" 10 #include "grit/ui_strings.h"
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 OnCaretBoundsChanged(); 839 OnCaretBoundsChanged();
840 } 840 }
841 841
842 void Textfield::OnEnabledChanged() { 842 void Textfield::OnEnabledChanged() {
843 View::OnEnabledChanged(); 843 View::OnEnabledChanged();
844 if (GetInputMethod()) 844 if (GetInputMethod())
845 GetInputMethod()->OnTextInputTypeChanged(this); 845 GetInputMethod()->OnTextInputTypeChanged(this);
846 SchedulePaint(); 846 SchedulePaint();
847 } 847 }
848 848
849 void Textfield::ViewHierarchyChanged(
850 const ViewHierarchyChangedDetails& details) {
851 if (details.is_add && details.child == this)
852 UpdateColorsFromTheme(GetNativeTheme());
853 }
854
849 void Textfield::OnPaint(gfx::Canvas* canvas) { 855 void Textfield::OnPaint(gfx::Canvas* canvas) {
850 OnPaintBackground(canvas); 856 OnPaintBackground(canvas);
851 PaintTextAndCursor(canvas); 857 PaintTextAndCursor(canvas);
852 OnPaintBorder(canvas); 858 OnPaintBorder(canvas);
853 } 859 }
854 860
855 void Textfield::OnFocus() { 861 void Textfield::OnFocus() {
856 GetRenderText()->set_focused(true); 862 GetRenderText()->set_focused(true);
857 cursor_visible_ = true; 863 cursor_visible_ = true;
858 SchedulePaint(); 864 SchedulePaint();
(...skipping 24 matching lines...) Expand all
883 889
884 // Border typically draws focus indicator. 890 // Border typically draws focus indicator.
885 SchedulePaint(); 891 SchedulePaint();
886 } 892 }
887 893
888 gfx::Point Textfield::GetKeyboardContextMenuLocation() { 894 gfx::Point Textfield::GetKeyboardContextMenuLocation() {
889 return GetCaretBounds().bottom_right(); 895 return GetCaretBounds().bottom_right();
890 } 896 }
891 897
892 void Textfield::OnNativeThemeChanged(const ui::NativeTheme* theme) { 898 void Textfield::OnNativeThemeChanged(const ui::NativeTheme* theme) {
893 gfx::RenderText* render_text = GetRenderText(); 899 UpdateColorsFromTheme(theme);
894 render_text->SetColor(GetTextColor());
895 UpdateBackgroundColor();
896 render_text->set_cursor_color(GetTextColor());
897 render_text->set_selection_color(theme->GetSystemColor(
898 ui::NativeTheme::kColorId_TextfieldSelectionColor));
899 render_text->set_selection_background_focused_color(theme->GetSystemColor(
900 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused));
901
902 } 900 }
903 901
904 //////////////////////////////////////////////////////////////////////////////// 902 ////////////////////////////////////////////////////////////////////////////////
905 // Textfield, TextfieldModel::Delegate overrides: 903 // Textfield, TextfieldModel::Delegate overrides:
906 904
907 void Textfield::OnCompositionTextConfirmedOrCleared() { 905 void Textfield::OnCompositionTextConfirmedOrCleared() {
908 if (!skip_input_method_cancel_composition_) 906 if (!skip_input_method_cancel_composition_)
909 GetInputMethod()->CancelComposition(this); 907 GetInputMethod()->CancelComposition(this);
910 } 908 }
911 909
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 } 1455 }
1458 } 1456 }
1459 1457
1460 void Textfield::UpdateBackgroundColor() { 1458 void Textfield::UpdateBackgroundColor() {
1461 const SkColor color = GetBackgroundColor(); 1459 const SkColor color = GetBackgroundColor();
1462 set_background(Background::CreateSolidBackground(color)); 1460 set_background(Background::CreateSolidBackground(color));
1463 GetRenderText()->set_background_is_transparent(SkColorGetA(color) != 0xFF); 1461 GetRenderText()->set_background_is_transparent(SkColorGetA(color) != 0xFF);
1464 SchedulePaint(); 1462 SchedulePaint();
1465 } 1463 }
1466 1464
1465 void Textfield::UpdateColorsFromTheme(const ui::NativeTheme* theme) {
1466 gfx::RenderText* render_text = GetRenderText();
1467 render_text->SetColor(GetTextColor());
1468 UpdateBackgroundColor();
1469 render_text->set_cursor_color(GetTextColor());
1470 render_text->set_selection_color(theme->GetSystemColor(
1471 ui::NativeTheme::kColorId_TextfieldSelectionColor));
1472 render_text->set_selection_background_focused_color(theme->GetSystemColor(
1473 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused));
1474 }
1475
1467 void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) { 1476 void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) {
1468 if (text_changed) { 1477 if (text_changed) {
1469 if (controller_) 1478 if (controller_)
1470 controller_->ContentsChanged(this, text()); 1479 controller_->ContentsChanged(this, text());
1471 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); 1480 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true);
1472 } 1481 }
1473 if (cursor_changed) { 1482 if (cursor_changed) {
1474 cursor_visible_ = true; 1483 cursor_visible_ = true;
1475 RepaintCursor(); 1484 RepaintCursor();
1476 if (cursor_repaint_timer_.IsRunning()) 1485 if (cursor_repaint_timer_.IsRunning())
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 const size_t length = selection_clipboard_text.length(); 1675 const size_t length = selection_clipboard_text.length();
1667 range = gfx::Range(range.start() + length, range.end() + length); 1676 range = gfx::Range(range.start() + length, range.end() + length);
1668 } 1677 }
1669 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); 1678 model_->MoveCursorTo(gfx::SelectionModel(range, affinity));
1670 UpdateAfterChange(true, true); 1679 UpdateAfterChange(true, true);
1671 OnAfterUserAction(); 1680 OnAfterUserAction();
1672 } 1681 }
1673 } 1682 }
1674 1683
1675 } // namespace views 1684 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698