| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 ALLOW_THIS_IN_INITIALIZER_LIST(cursor_timer_(this)), | 74 ALLOW_THIS_IN_INITIALIZER_LIST(cursor_timer_(this)), |
| 75 aggregated_clicks_(0), | 75 aggregated_clicks_(0), |
| 76 ALLOW_THIS_IN_INITIALIZER_LIST(touch_selection_controller_( | 76 ALLOW_THIS_IN_INITIALIZER_LIST(touch_selection_controller_( |
| 77 TouchSelectionController::create(this))) { | 77 TouchSelectionController::create(this))) { |
| 78 set_border(text_border_); | 78 set_border(text_border_); |
| 79 | 79 |
| 80 #if defined(OS_CHROMEOS) | 80 #if defined(OS_CHROMEOS) |
| 81 GetRenderText()->SetFontList(gfx::FontList(l10n_util::GetStringUTF8( | 81 GetRenderText()->SetFontList(gfx::FontList(l10n_util::GetStringUTF8( |
| 82 IDS_UI_FONT_FAMILY_CROS))); | 82 IDS_UI_FONT_FAMILY_CROS))); |
| 83 #else | 83 #else |
| 84 GetRenderText()->SetFontList(gfx::FontList(textfield_->font())); | 84 GetRenderText()->SetFont(textfield_->font()); |
| 85 #endif | 85 #endif |
| 86 // Set the default text style. | 86 // Set the default text style. |
| 87 gfx::StyleRange default_style; | 87 gfx::StyleRange default_style; |
| 88 default_style.foreground = textfield_->text_color(); | 88 default_style.foreground = textfield_->text_color(); |
| 89 GetRenderText()->set_default_style(default_style); | 89 GetRenderText()->set_default_style(default_style); |
| 90 GetRenderText()->ApplyDefaultStyle(); | 90 GetRenderText()->ApplyDefaultStyle(); |
| 91 | 91 |
| 92 set_context_menu_controller(this); | 92 set_context_menu_controller(this); |
| 93 set_drag_controller(this); | 93 set_drag_controller(this); |
| 94 } | 94 } |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 SchedulePaint(); | 428 SchedulePaint(); |
| 429 OnTextInputTypeChanged(); | 429 OnTextInputTypeChanged(); |
| 430 } | 430 } |
| 431 | 431 |
| 432 void NativeTextfieldViews::UpdateFont() { | 432 void NativeTextfieldViews::UpdateFont() { |
| 433 #if defined(OS_CHROMEOS) | 433 #if defined(OS_CHROMEOS) |
| 434 // For ChromeOS, we support a pre-defined font list per locale. UpdateFont() | 434 // For ChromeOS, we support a pre-defined font list per locale. UpdateFont() |
| 435 // only changes the font size, not the font family names. | 435 // only changes the font size, not the font family names. |
| 436 GetRenderText()->SetFontSize(textfield_->font().GetFontSize()); | 436 GetRenderText()->SetFontSize(textfield_->font().GetFontSize()); |
| 437 #else | 437 #else |
| 438 GetRenderText()->SetFontList(gfx::FontList(textfield_->font())); | 438 GetRenderText()->SetFont(textfield_->font()); |
| 439 #endif | 439 #endif |
| 440 OnCaretBoundsChanged(); | 440 OnCaretBoundsChanged(); |
| 441 } | 441 } |
| 442 | 442 |
| 443 void NativeTextfieldViews::UpdateIsObscured() { | 443 void NativeTextfieldViews::UpdateIsObscured() { |
| 444 GetRenderText()->SetObscured(textfield_->IsObscured()); | 444 GetRenderText()->SetObscured(textfield_->IsObscured()); |
| 445 OnCaretBoundsChanged(); | 445 OnCaretBoundsChanged(); |
| 446 SchedulePaint(); | 446 SchedulePaint(); |
| 447 OnTextInputTypeChanged(); | 447 OnTextInputTypeChanged(); |
| 448 } | 448 } |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 // Filter out all control characters, including tab and new line characters, | 1227 // Filter out all control characters, including tab and new line characters, |
| 1228 // and all characters with Alt modifier. But we need to allow characters with | 1228 // and all characters with Alt modifier. But we need to allow characters with |
| 1229 // AltGr modifier. | 1229 // AltGr modifier. |
| 1230 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different | 1230 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different |
| 1231 // flag that we don't care about. | 1231 // flag that we don't care about. |
| 1232 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && | 1232 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && |
| 1233 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; | 1233 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; |
| 1234 } | 1234 } |
| 1235 | 1235 |
| 1236 } // namespace views | 1236 } // namespace views |
| OLD | NEW |