| 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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "grit/ui_strings.h" | 10 #include "grit/ui_strings.h" |
| (...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 OnAfterUserAction(); | 1092 OnAfterUserAction(); |
| 1093 | 1093 |
| 1094 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD && | 1094 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD && |
| 1095 password_reveal_duration_ != base::TimeDelta()) { | 1095 password_reveal_duration_ != base::TimeDelta()) { |
| 1096 const size_t change_offset = model_->GetCursorPosition(); | 1096 const size_t change_offset = model_->GetCursorPosition(); |
| 1097 DCHECK_GT(change_offset, 0u); | 1097 DCHECK_GT(change_offset, 0u); |
| 1098 RevealPasswordChar(change_offset - 1); | 1098 RevealPasswordChar(change_offset - 1); |
| 1099 } | 1099 } |
| 1100 } | 1100 } |
| 1101 | 1101 |
| 1102 gfx::NativeWindow Textfield::GetAttachedWindow() const { | |
| 1103 // Imagine the following hierarchy. | |
| 1104 // [NativeWidget A] - FocusManager | |
| 1105 // [View] | |
| 1106 // [NativeWidget B] | |
| 1107 // [View] | |
| 1108 // [View X] | |
| 1109 // An important thing is that [NativeWidget A] owns Win32 input focus even | |
| 1110 // when [View X] is logically focused by FocusManager. As a result, an Win32 | |
| 1111 // IME may want to interact with the native view of [NativeWidget A] rather | |
| 1112 // than that of [NativeWidget B]. This is why we need to call | |
| 1113 // GetTopLevelWidget() here. | |
| 1114 return GetWidget()->GetTopLevelWidget()->GetNativeView(); | |
| 1115 } | |
| 1116 | |
| 1117 ui::TextInputType Textfield::GetTextInputType() const { | 1102 ui::TextInputType Textfield::GetTextInputType() const { |
| 1118 if (read_only() || !enabled()) | 1103 if (read_only() || !enabled()) |
| 1119 return ui::TEXT_INPUT_TYPE_NONE; | 1104 return ui::TEXT_INPUT_TYPE_NONE; |
| 1120 return text_input_type_; | 1105 return text_input_type_; |
| 1121 } | 1106 } |
| 1122 | 1107 |
| 1123 ui::TextInputMode Textfield::GetTextInputMode() const { | 1108 ui::TextInputMode Textfield::GetTextInputMode() const { |
| 1124 return ui::TEXT_INPUT_MODE_DEFAULT; | 1109 return ui::TEXT_INPUT_MODE_DEFAULT; |
| 1125 } | 1110 } |
| 1126 | 1111 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 const size_t length = selection_clipboard_text.length(); | 1481 const size_t length = selection_clipboard_text.length(); |
| 1497 range = gfx::Range(range.start() + length, range.end() + length); | 1482 range = gfx::Range(range.start() + length, range.end() + length); |
| 1498 } | 1483 } |
| 1499 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); | 1484 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); |
| 1500 UpdateAfterChange(true, true); | 1485 UpdateAfterChange(true, true); |
| 1501 OnAfterUserAction(); | 1486 OnAfterUserAction(); |
| 1502 } | 1487 } |
| 1503 } | 1488 } |
| 1504 | 1489 |
| 1505 } // namespace views | 1490 } // namespace views |
| OLD | NEW |