| 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 | 8 |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "ui/accessibility/ax_view_state.h" | 10 #include "ui/accessibility/ax_view_state.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 use_default_text_color_(true), | 261 use_default_text_color_(true), |
| 262 use_default_background_color_(true), | 262 use_default_background_color_(true), |
| 263 use_default_selection_text_color_(true), | 263 use_default_selection_text_color_(true), |
| 264 use_default_selection_background_color_(true), | 264 use_default_selection_background_color_(true), |
| 265 text_color_(SK_ColorBLACK), | 265 text_color_(SK_ColorBLACK), |
| 266 background_color_(SK_ColorWHITE), | 266 background_color_(SK_ColorWHITE), |
| 267 selection_text_color_(SK_ColorWHITE), | 267 selection_text_color_(SK_ColorWHITE), |
| 268 selection_background_color_(SK_ColorBLUE), | 268 selection_background_color_(SK_ColorBLUE), |
| 269 placeholder_text_color_(kDefaultPlaceholderTextColor), | 269 placeholder_text_color_(kDefaultPlaceholderTextColor), |
| 270 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT), | 270 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT), |
| 271 text_input_flags_(0), |
| 271 performing_user_action_(false), | 272 performing_user_action_(false), |
| 272 skip_input_method_cancel_composition_(false), | 273 skip_input_method_cancel_composition_(false), |
| 273 cursor_visible_(false), | 274 cursor_visible_(false), |
| 274 drop_cursor_visible_(false), | 275 drop_cursor_visible_(false), |
| 275 initiating_drag_(false), | 276 initiating_drag_(false), |
| 276 aggregated_clicks_(0), | 277 aggregated_clicks_(0), |
| 277 drag_start_display_offset_(0), | 278 drag_start_display_offset_(0), |
| 278 touch_handles_hidden_due_to_scroll_(false), | 279 touch_handles_hidden_due_to_scroll_(false), |
| 279 weak_ptr_factory_(this) { | 280 weak_ptr_factory_(this) { |
| 280 set_context_menu_controller(this); | 281 set_context_menu_controller(this); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 301 | 302 |
| 302 void Textfield::SetTextInputType(ui::TextInputType type) { | 303 void Textfield::SetTextInputType(ui::TextInputType type) { |
| 303 GetRenderText()->SetObscured(type == ui::TEXT_INPUT_TYPE_PASSWORD); | 304 GetRenderText()->SetObscured(type == ui::TEXT_INPUT_TYPE_PASSWORD); |
| 304 text_input_type_ = type; | 305 text_input_type_ = type; |
| 305 OnCaretBoundsChanged(); | 306 OnCaretBoundsChanged(); |
| 306 if (GetInputMethod()) | 307 if (GetInputMethod()) |
| 307 GetInputMethod()->OnTextInputTypeChanged(this); | 308 GetInputMethod()->OnTextInputTypeChanged(this); |
| 308 SchedulePaint(); | 309 SchedulePaint(); |
| 309 } | 310 } |
| 310 | 311 |
| 312 void Textfield::SetTextInputFlags(int flags) { |
| 313 text_input_flags_ = flags; |
| 314 } |
| 315 |
| 311 void Textfield::SetText(const base::string16& new_text) { | 316 void Textfield::SetText(const base::string16& new_text) { |
| 312 model_->SetText(new_text); | 317 model_->SetText(new_text); |
| 313 OnCaretBoundsChanged(); | 318 OnCaretBoundsChanged(); |
| 314 SchedulePaint(); | 319 SchedulePaint(); |
| 315 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); | 320 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); |
| 316 } | 321 } |
| 317 | 322 |
| 318 void Textfield::AppendText(const base::string16& new_text) { | 323 void Textfield::AppendText(const base::string16& new_text) { |
| 319 if (new_text.empty()) | 324 if (new_text.empty()) |
| 320 return; | 325 return; |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1460 if (read_only() || !enabled()) | 1465 if (read_only() || !enabled()) |
| 1461 return ui::TEXT_INPUT_TYPE_NONE; | 1466 return ui::TEXT_INPUT_TYPE_NONE; |
| 1462 return text_input_type_; | 1467 return text_input_type_; |
| 1463 } | 1468 } |
| 1464 | 1469 |
| 1465 ui::TextInputMode Textfield::GetTextInputMode() const { | 1470 ui::TextInputMode Textfield::GetTextInputMode() const { |
| 1466 return ui::TEXT_INPUT_MODE_DEFAULT; | 1471 return ui::TEXT_INPUT_MODE_DEFAULT; |
| 1467 } | 1472 } |
| 1468 | 1473 |
| 1469 int Textfield::GetTextInputFlags() const { | 1474 int Textfield::GetTextInputFlags() const { |
| 1470 return 0; | 1475 return text_input_flags_; |
| 1471 } | 1476 } |
| 1472 | 1477 |
| 1473 bool Textfield::CanComposeInline() const { | 1478 bool Textfield::CanComposeInline() const { |
| 1474 return true; | 1479 return true; |
| 1475 } | 1480 } |
| 1476 | 1481 |
| 1477 gfx::Rect Textfield::GetCaretBounds() const { | 1482 gfx::Rect Textfield::GetCaretBounds() const { |
| 1478 gfx::Rect rect = GetRenderText()->GetUpdatedCursorBounds(); | 1483 gfx::Rect rect = GetRenderText()->GetUpdatedCursorBounds(); |
| 1479 ConvertRectToScreen(this, &rect); | 1484 ConvertRectToScreen(this, &rect); |
| 1480 return rect; | 1485 return rect; |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1880 RequestFocus(); | 1885 RequestFocus(); |
| 1881 model_->MoveCursorTo(mouse); | 1886 model_->MoveCursorTo(mouse); |
| 1882 if (!selection_clipboard_text.empty()) { | 1887 if (!selection_clipboard_text.empty()) { |
| 1883 model_->InsertText(selection_clipboard_text); | 1888 model_->InsertText(selection_clipboard_text); |
| 1884 UpdateAfterChange(true, true); | 1889 UpdateAfterChange(true, true); |
| 1885 } | 1890 } |
| 1886 OnAfterUserAction(); | 1891 OnAfterUserAction(); |
| 1887 } | 1892 } |
| 1888 | 1893 |
| 1889 } // namespace views | 1894 } // namespace views |
| OLD | NEW |