| 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 SetColor(textfield_->GetTextColor()); |
| 445 default_style.foreground = textfield_->GetTextColor(); | |
| 446 GetRenderText()->set_default_style(default_style); | |
| 447 GetRenderText()->ApplyDefaultStyle(); | |
| 448 SchedulePaint(); | |
| 449 } | 445 } |
| 450 | 446 |
| 451 void NativeTextfieldViews::UpdateBackgroundColor() { | 447 void NativeTextfieldViews::UpdateBackgroundColor() { |
| 452 const SkColor color = textfield_->GetBackgroundColor(); | 448 const SkColor color = textfield_->GetBackgroundColor(); |
| 453 set_background(Background::CreateSolidBackground(color)); | 449 set_background(Background::CreateSolidBackground(color)); |
| 454 GetRenderText()->set_background_is_transparent(SkColorGetA(color) != 0xFF); | 450 GetRenderText()->set_background_is_transparent(SkColorGetA(color) != 0xFF); |
| 455 SchedulePaint(); | 451 SchedulePaint(); |
| 456 } | 452 } |
| 457 | 453 |
| 458 void NativeTextfieldViews::UpdateReadOnly() { | 454 void NativeTextfieldViews::UpdateReadOnly() { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 controller->ExecuteCommand(command_id); | 687 controller->ExecuteCommand(command_id); |
| 692 break; | 688 break; |
| 693 } | 689 } |
| 694 } | 690 } |
| 695 | 691 |
| 696 // The cursor must have changed if text changed during cut/paste/delete. | 692 // The cursor must have changed if text changed during cut/paste/delete. |
| 697 UpdateAfterChange(text_changed, text_changed); | 693 UpdateAfterChange(text_changed, text_changed); |
| 698 OnAfterUserAction(); | 694 OnAfterUserAction(); |
| 699 } | 695 } |
| 700 | 696 |
| 701 void NativeTextfieldViews::ApplyStyleRange(const gfx::StyleRange& style) { | 697 void NativeTextfieldViews::SetColor(SkColor value) { |
| 702 GetRenderText()->ApplyStyleRange(style); | 698 GetRenderText()->SetColor(value); |
| 703 SchedulePaint(); | 699 SchedulePaint(); |
| 704 } | 700 } |
| 705 | 701 |
| 706 void NativeTextfieldViews::ApplyDefaultStyle() { | 702 void NativeTextfieldViews::ApplyColor(SkColor value, const ui::Range& range) { |
| 707 GetRenderText()->ApplyDefaultStyle(); | 703 GetRenderText()->ApplyColor(value, range); |
| 708 SchedulePaint(); | 704 SchedulePaint(); |
| 709 } | 705 } |
| 710 | 706 |
| 707 void NativeTextfieldViews::SetStyle(gfx::TextStyle style, bool value) { |
| 708 GetRenderText()->SetStyle(style, value); |
| 709 SchedulePaint(); |
| 710 } |
| 711 |
| 712 void NativeTextfieldViews::ApplyStyle(gfx::TextStyle style, |
| 713 bool value, |
| 714 const ui::Range& range) { |
| 715 GetRenderText()->ApplyStyle(style, value, range); |
| 716 SchedulePaint(); |
| 717 } |
| 718 |
| 711 void NativeTextfieldViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 719 void NativeTextfieldViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 712 // Set the RenderText display area. | 720 // Set the RenderText display area. |
| 713 gfx::Insets insets = GetInsets(); | 721 gfx::Insets insets = GetInsets(); |
| 714 gfx::Rect display_rect(insets.left(), | 722 gfx::Rect display_rect(insets.left(), |
| 715 insets.top(), | 723 insets.top(), |
| 716 width() - insets.width(), | 724 width() - insets.width(), |
| 717 height() - insets.height()); | 725 height() - insets.height()); |
| 718 GetRenderText()->SetDisplayRect(display_rect); | 726 GetRenderText()->SetDisplayRect(display_rect); |
| 719 OnCaretBoundsChanged(); | 727 OnCaretBoundsChanged(); |
| 720 } | 728 } |
| (...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, | 1293 // 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 | 1294 // and all characters with Alt modifier. But we need to allow characters with |
| 1287 // AltGr modifier. | 1295 // AltGr modifier. |
| 1288 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different | 1296 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different |
| 1289 // flag that we don't care about. | 1297 // flag that we don't care about. |
| 1290 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && | 1298 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && |
| 1291 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; | 1299 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; |
| 1292 } | 1300 } |
| 1293 | 1301 |
| 1294 } // namespace views | 1302 } // namespace views |
| OLD | NEW |