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/native_textfield_views.h" | 5 #include "ui/views/controls/textfield/native_textfield_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 void NativeTextfieldViews::UpdateBorderColor() { | 434 void NativeTextfieldViews::UpdateBorderColor() { |
| 435 if (textfield_->use_default_border_color()) | 435 if (textfield_->use_default_border_color()) |
| 436 text_border_->UseDefaultColor(); | 436 text_border_->UseDefaultColor(); |
| 437 else | 437 else |
| 438 text_border_->SetColor(textfield_->border_color()); | 438 text_border_->SetColor(textfield_->border_color()); |
| 439 | 439 |
| 440 SchedulePaint(); | 440 SchedulePaint(); |
| 441 } | 441 } |
| 442 | 442 |
| 443 void NativeTextfieldViews::UpdateTextColor() { | 443 void NativeTextfieldViews::UpdateTextColor() { |
| 444 gfx::StyleRange default_style(GetRenderText()->default_style()); | 444 GetRenderText()->SetColor(textfield_->GetTextColor()); |
|
Alexei Svitkine (slow)
2013/01/23 16:52:54
Nit: Just call SetColor(textfield_->GetTextColor()
msw
2013/01/25 09:10:02
Done.
| |
| 445 default_style.foreground = textfield_->GetTextColor(); | |
| 446 GetRenderText()->set_default_style(default_style); | |
| 447 GetRenderText()->ApplyDefaultStyle(); | |
| 448 SchedulePaint(); | 445 SchedulePaint(); |
| 449 } | 446 } |
| 450 | 447 |
| 451 void NativeTextfieldViews::UpdateBackgroundColor() { | 448 void NativeTextfieldViews::UpdateBackgroundColor() { |
| 452 const SkColor color = textfield_->GetBackgroundColor(); | 449 const SkColor color = textfield_->GetBackgroundColor(); |
| 453 set_background(Background::CreateSolidBackground(color)); | 450 set_background(Background::CreateSolidBackground(color)); |
| 454 GetRenderText()->set_background_is_transparent(SkColorGetA(color) != 0xFF); | 451 GetRenderText()->set_background_is_transparent(SkColorGetA(color) != 0xFF); |
| 455 SchedulePaint(); | 452 SchedulePaint(); |
| 456 } | 453 } |
| 457 | 454 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 691 controller->ExecuteCommand(command_id); | 688 controller->ExecuteCommand(command_id); |
| 692 break; | 689 break; |
| 693 } | 690 } |
| 694 } | 691 } |
| 695 | 692 |
| 696 // The cursor must have changed if text changed during cut/paste/delete. | 693 // The cursor must have changed if text changed during cut/paste/delete. |
| 697 UpdateAfterChange(text_changed, text_changed); | 694 UpdateAfterChange(text_changed, text_changed); |
| 698 OnAfterUserAction(); | 695 OnAfterUserAction(); |
| 699 } | 696 } |
| 700 | 697 |
| 701 void NativeTextfieldViews::ApplyStyleRange(const gfx::StyleRange& style) { | 698 void NativeTextfieldViews::SetColor(SkColor value) { |
| 702 GetRenderText()->ApplyStyleRange(style); | 699 GetRenderText()->SetColor(value); |
| 703 SchedulePaint(); | 700 SchedulePaint(); |
| 704 } | 701 } |
| 705 | 702 |
| 706 void NativeTextfieldViews::ApplyDefaultStyle() { | 703 void NativeTextfieldViews::ApplyColor(SkColor value, const ui::Range& range) { |
| 707 GetRenderText()->ApplyDefaultStyle(); | 704 GetRenderText()->ApplyColor(value, range); |
| 708 SchedulePaint(); | 705 SchedulePaint(); |
| 709 } | 706 } |
| 710 | 707 |
| 708 void NativeTextfieldViews::SetStyle(gfx::TextStyle style, bool value) { | |
| 709 GetRenderText()->SetStyle(style, value); | |
| 710 SchedulePaint(); | |
| 711 } | |
| 712 | |
| 713 void NativeTextfieldViews::ApplyStyle(gfx::TextStyle style, | |
| 714 bool value, | |
| 715 const ui::Range& range) { | |
| 716 GetRenderText()->ApplyStyle(style, value, range); | |
| 717 SchedulePaint(); | |
| 718 } | |
| 719 | |
| 711 void NativeTextfieldViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 720 void NativeTextfieldViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 712 // Set the RenderText display area. | 721 // Set the RenderText display area. |
| 713 gfx::Insets insets = GetInsets(); | 722 gfx::Insets insets = GetInsets(); |
| 714 gfx::Rect display_rect(insets.left(), | 723 gfx::Rect display_rect(insets.left(), |
| 715 insets.top(), | 724 insets.top(), |
| 716 width() - insets.width(), | 725 width() - insets.width(), |
| 717 height() - insets.height()); | 726 height() - insets.height()); |
| 718 GetRenderText()->SetDisplayRect(display_rect); | 727 GetRenderText()->SetDisplayRect(display_rect); |
| 719 OnCaretBoundsChanged(); | 728 OnCaretBoundsChanged(); |
| 720 } | 729 } |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1285 // Filter out all control characters, including tab and new line characters, | 1294 // Filter out all control characters, including tab and new line characters, |
| 1286 // and all characters with Alt modifier. But we need to allow characters with | 1295 // and all characters with Alt modifier. But we need to allow characters with |
| 1287 // AltGr modifier. | 1296 // AltGr modifier. |
| 1288 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different | 1297 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different |
| 1289 // flag that we don't care about. | 1298 // flag that we don't care about. |
| 1290 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && | 1299 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && |
| 1291 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; | 1300 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; |
| 1292 } | 1301 } |
| 1293 | 1302 |
| 1294 } // namespace views | 1303 } // namespace views |
| OLD | NEW |