| 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/textfield.h" | 5 #include "ui/views/controls/textfield/textfield.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "ui/accessibility/ax_view_state.h" | 12 #include "ui/accessibility/ax_view_state.h" |
| 13 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 13 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 14 #include "ui/base/cursor/cursor.h" | 14 #include "ui/base/cursor/cursor.h" |
| 15 #include "ui/base/default_style.h" |
| 15 #include "ui/base/dragdrop/drag_drop_types.h" | 16 #include "ui/base/dragdrop/drag_drop_types.h" |
| 16 #include "ui/base/dragdrop/drag_utils.h" | 17 #include "ui/base/dragdrop/drag_utils.h" |
| 17 #include "ui/base/ime/input_method.h" | 18 #include "ui/base/ime/input_method.h" |
| 19 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/base/touch/selection_bound.h" | 20 #include "ui/base/touch/selection_bound.h" |
| 19 #include "ui/base/ui_base_switches_util.h" | 21 #include "ui/base/ui_base_switches_util.h" |
| 20 #include "ui/compositor/canvas_painter.h" | 22 #include "ui/compositor/canvas_painter.h" |
| 21 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 23 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 22 #include "ui/events/base_event_utils.h" | 24 #include "ui/events/base_event_utils.h" |
| 23 #include "ui/events/event.h" | 25 #include "ui/events/event.h" |
| 24 #include "ui/events/keycodes/keyboard_codes.h" | 26 #include "ui/events/keycodes/keyboard_codes.h" |
| 25 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
| 26 #include "ui/gfx/display.h" | 28 #include "ui/gfx/display.h" |
| 27 #include "ui/gfx/geometry/insets.h" | 29 #include "ui/gfx/geometry/insets.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 return IDS_APP_SELECT_ALL; | 234 return IDS_APP_SELECT_ALL; |
| 233 case ui::TextEditCommandAuraLinux::SET_MARK: | 235 case ui::TextEditCommandAuraLinux::SET_MARK: |
| 234 case ui::TextEditCommandAuraLinux::UNSELECT: | 236 case ui::TextEditCommandAuraLinux::UNSELECT: |
| 235 case ui::TextEditCommandAuraLinux::INVALID_COMMAND: | 237 case ui::TextEditCommandAuraLinux::INVALID_COMMAND: |
| 236 return kNoCommand; | 238 return kNoCommand; |
| 237 } | 239 } |
| 238 return kNoCommand; | 240 return kNoCommand; |
| 239 } | 241 } |
| 240 #endif | 242 #endif |
| 241 | 243 |
| 244 const gfx::FontList& GetDefaultFontList() { |
| 245 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 246 return rb.GetFontListWithDelta(ui::kLabelFontSizeDelta); |
| 247 } |
| 248 |
| 242 } // namespace | 249 } // namespace |
| 243 | 250 |
| 244 // static | 251 // static |
| 245 const char Textfield::kViewClassName[] = "Textfield"; | 252 const char Textfield::kViewClassName[] = "Textfield"; |
| 246 const int Textfield::kTextPadding = 3; | 253 const int Textfield::kTextPadding = 3; |
| 247 | 254 |
| 248 // static | 255 // static |
| 249 size_t Textfield::GetCaretBlinkMs() { | 256 size_t Textfield::GetCaretBlinkMs() { |
| 250 static const size_t default_value = 500; | 257 static const size_t default_value = 500; |
| 251 #if defined(OS_WIN) | 258 #if defined(OS_WIN) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 277 skip_input_method_cancel_composition_(false), | 284 skip_input_method_cancel_composition_(false), |
| 278 cursor_visible_(false), | 285 cursor_visible_(false), |
| 279 drop_cursor_visible_(false), | 286 drop_cursor_visible_(false), |
| 280 initiating_drag_(false), | 287 initiating_drag_(false), |
| 281 aggregated_clicks_(0), | 288 aggregated_clicks_(0), |
| 282 drag_start_display_offset_(0), | 289 drag_start_display_offset_(0), |
| 283 touch_handles_hidden_due_to_scroll_(false), | 290 touch_handles_hidden_due_to_scroll_(false), |
| 284 weak_ptr_factory_(this) { | 291 weak_ptr_factory_(this) { |
| 285 set_context_menu_controller(this); | 292 set_context_menu_controller(this); |
| 286 set_drag_controller(this); | 293 set_drag_controller(this); |
| 294 GetRenderText()->SetFontList(GetDefaultFontList()); |
| 287 SetBorder(scoped_ptr<Border>(new FocusableBorder())); | 295 SetBorder(scoped_ptr<Border>(new FocusableBorder())); |
| 288 SetFocusable(true); | 296 SetFocusable(true); |
| 289 | 297 |
| 290 if (ViewsDelegate::GetInstance()) { | 298 if (ViewsDelegate::GetInstance()) { |
| 291 password_reveal_duration_ = | 299 password_reveal_duration_ = |
| 292 ViewsDelegate::GetInstance() | 300 ViewsDelegate::GetInstance() |
| 293 ->GetDefaultTextfieldObscuredRevealDuration(); | 301 ->GetDefaultTextfieldObscuredRevealDuration(); |
| 294 } | 302 } |
| 295 | 303 |
| 296 // These allow BrowserView to pass edit commands from the Chrome menu to us | 304 // These allow BrowserView to pass edit commands from the Chrome menu to us |
| (...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1893 RequestFocus(); | 1901 RequestFocus(); |
| 1894 model_->MoveCursorTo(mouse); | 1902 model_->MoveCursorTo(mouse); |
| 1895 if (!selection_clipboard_text.empty()) { | 1903 if (!selection_clipboard_text.empty()) { |
| 1896 model_->InsertText(selection_clipboard_text); | 1904 model_->InsertText(selection_clipboard_text); |
| 1897 UpdateAfterChange(true, true); | 1905 UpdateAfterChange(true, true); |
| 1898 } | 1906 } |
| 1899 OnAfterUserAction(); | 1907 OnAfterUserAction(); |
| 1900 } | 1908 } |
| 1901 | 1909 |
| 1902 } // namespace views | 1910 } // namespace views |
| OLD | NEW |