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

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

Issue 302453002: New animation for the origin chip URL showing/hiding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bugfixes and more animations Created 6 years, 6 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
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 238
239 Textfield::Textfield() 239 Textfield::Textfield()
240 : model_(new TextfieldModel(this)), 240 : model_(new TextfieldModel(this)),
241 controller_(NULL), 241 controller_(NULL),
242 read_only_(false), 242 read_only_(false),
243 default_width_in_chars_(0), 243 default_width_in_chars_(0),
244 text_color_(SK_ColorBLACK), 244 text_color_(SK_ColorBLACK),
245 use_default_text_color_(true), 245 use_default_text_color_(true),
246 background_color_(SK_ColorWHITE), 246 background_color_(SK_ColorWHITE),
247 use_default_background_color_(true), 247 use_default_background_color_(true),
248 selection_text_color_(SK_ColorWHITE),
249 use_default_selection_text_color_(true),
250 selection_background_color_(SK_ColorBLUE),
251 use_default_selection_background_color_(true),
248 placeholder_text_color_(kDefaultPlaceholderTextColor), 252 placeholder_text_color_(kDefaultPlaceholderTextColor),
249 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT), 253 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
250 performing_user_action_(false), 254 performing_user_action_(false),
251 skip_input_method_cancel_composition_(false), 255 skip_input_method_cancel_composition_(false),
252 cursor_visible_(false), 256 cursor_visible_(false),
253 drop_cursor_visible_(false), 257 drop_cursor_visible_(false),
254 initiating_drag_(false), 258 initiating_drag_(false),
255 aggregated_clicks_(0), 259 aggregated_clicks_(0),
256 weak_ptr_factory_(this) { 260 weak_ptr_factory_(this) {
257 set_context_menu_controller(this); 261 set_context_menu_controller(this);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 background_color_ = color; 368 background_color_ = color;
365 use_default_background_color_ = false; 369 use_default_background_color_ = false;
366 UpdateBackgroundColor(); 370 UpdateBackgroundColor();
367 } 371 }
368 372
369 void Textfield::UseDefaultBackgroundColor() { 373 void Textfield::UseDefaultBackgroundColor() {
370 use_default_background_color_ = true; 374 use_default_background_color_ = true;
371 UpdateBackgroundColor(); 375 UpdateBackgroundColor();
372 } 376 }
373 377
378 SkColor Textfield::GetSelectionTextColor() const {
379 return use_default_selection_text_color_ ?
380 GetNativeTheme()->GetSystemColor(
381 ui::NativeTheme::kColorId_TextfieldSelectionColor) :
382 selection_text_color_;
383 }
384
385 void Textfield::SetSelectionTextColor(SkColor color) {
386 selection_text_color_ = color;
387 use_default_selection_text_color_ = false;
388 GetRenderText()->set_selection_color(GetSelectionTextColor());
389 SchedulePaint();
390 }
391
392 void Textfield::UseDefaultSelectionTextColor() {
393 use_default_selection_text_color_ = true;
394 GetRenderText()->set_selection_color(GetSelectionTextColor());
395 SchedulePaint();
396 }
397
398 SkColor Textfield::GetSelectionBackgroundColor() const {
399 return use_default_selection_background_color_ ?
400 GetNativeTheme()->GetSystemColor(
401 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused) :
402 selection_background_color_;
403 }
404
405 void Textfield::SetSelectionBackgroundColor(SkColor color) {
406 selection_background_color_ = color;
407 use_default_selection_background_color_ = false;
408 GetRenderText()->set_selection_background_focused_color(
409 GetSelectionBackgroundColor());
410 SchedulePaint();
411 }
412
413 void Textfield::UseDefaultSelectionBackgroundColor() {
414 use_default_selection_background_color_ = true;
415 GetRenderText()->set_selection_background_focused_color(
416 GetSelectionBackgroundColor());
417 SchedulePaint();
418 }
419
374 bool Textfield::GetCursorEnabled() const { 420 bool Textfield::GetCursorEnabled() const {
375 return GetRenderText()->cursor_enabled(); 421 return GetRenderText()->cursor_enabled();
376 } 422 }
377 423
378 void Textfield::SetCursorEnabled(bool enabled) { 424 void Textfield::SetCursorEnabled(bool enabled) {
379 GetRenderText()->SetCursorEnabled(enabled); 425 GetRenderText()->SetCursorEnabled(enabled);
380 } 426 }
381 427
382 const gfx::FontList& Textfield::GetFontList() const { 428 const gfx::FontList& Textfield::GetFontList() const {
383 return GetRenderText()->font_list(); 429 return GetRenderText()->font_list();
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 940
895 gfx::Point Textfield::GetKeyboardContextMenuLocation() { 941 gfx::Point Textfield::GetKeyboardContextMenuLocation() {
896 return GetCaretBounds().bottom_right(); 942 return GetCaretBounds().bottom_right();
897 } 943 }
898 944
899 void Textfield::OnNativeThemeChanged(const ui::NativeTheme* theme) { 945 void Textfield::OnNativeThemeChanged(const ui::NativeTheme* theme) {
900 gfx::RenderText* render_text = GetRenderText(); 946 gfx::RenderText* render_text = GetRenderText();
901 render_text->SetColor(GetTextColor()); 947 render_text->SetColor(GetTextColor());
902 UpdateBackgroundColor(); 948 UpdateBackgroundColor();
903 render_text->set_cursor_color(GetTextColor()); 949 render_text->set_cursor_color(GetTextColor());
904 render_text->set_selection_color(theme->GetSystemColor( 950 render_text->set_selection_color(GetSelectionTextColor());
905 ui::NativeTheme::kColorId_TextfieldSelectionColor)); 951 render_text->set_selection_background_focused_color(
906 render_text->set_selection_background_focused_color(theme->GetSystemColor( 952 GetSelectionBackgroundColor());
907 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused));
908
909 } 953 }
910 954
911 //////////////////////////////////////////////////////////////////////////////// 955 ////////////////////////////////////////////////////////////////////////////////
912 // Textfield, TextfieldModel::Delegate overrides: 956 // Textfield, TextfieldModel::Delegate overrides:
913 957
914 void Textfield::OnCompositionTextConfirmedOrCleared() { 958 void Textfield::OnCompositionTextConfirmedOrCleared() {
915 if (!skip_input_method_cancel_composition_) 959 if (!skip_input_method_cancel_composition_)
916 GetInputMethod()->CancelComposition(this); 960 GetInputMethod()->CancelComposition(this);
917 } 961 }
918 962
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 const size_t length = selection_clipboard_text.length(); 1725 const size_t length = selection_clipboard_text.length();
1682 range = gfx::Range(range.start() + length, range.end() + length); 1726 range = gfx::Range(range.start() + length, range.end() + length);
1683 } 1727 }
1684 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); 1728 model_->MoveCursorTo(gfx::SelectionModel(range, affinity));
1685 UpdateAfterChange(true, true); 1729 UpdateAfterChange(true, true);
1686 OnAfterUserAction(); 1730 OnAfterUserAction();
1687 } 1731 }
1688 } 1732 }
1689 1733
1690 } // namespace views 1734 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698