| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 // NativeTextfieldViews, NativeTextifieldWrapper overrides: | 467 // NativeTextfieldViews, NativeTextifieldWrapper overrides: |
| 468 | 468 |
| 469 string16 NativeTextfieldViews::GetText() const { | 469 string16 NativeTextfieldViews::GetText() const { |
| 470 return model_->GetText(); | 470 return model_->GetText(); |
| 471 } | 471 } |
| 472 | 472 |
| 473 void NativeTextfieldViews::UpdateText() { | 473 void NativeTextfieldViews::UpdateText() { |
| 474 model_->SetText(GetTextForDisplay(textfield_->text())); | 474 model_->SetText(GetTextForDisplay(textfield_->text())); |
| 475 OnCaretBoundsChanged(); | 475 OnCaretBoundsChanged(); |
| 476 SchedulePaint(); | 476 SchedulePaint(); |
| 477 textfield_->GetWidget()->NotifyAccessibilityEvent( | 477 textfield_->NotifyAccessibilityEvent( |
| 478 textfield_, ui::AccessibilityTypes::EVENT_TEXT_CHANGED, true); | 478 ui::AccessibilityTypes::EVENT_TEXT_CHANGED, true); |
| 479 } | 479 } |
| 480 | 480 |
| 481 void NativeTextfieldViews::AppendText(const string16& text) { | 481 void NativeTextfieldViews::AppendText(const string16& text) { |
| 482 if (text.empty()) | 482 if (text.empty()) |
| 483 return; | 483 return; |
| 484 model_->Append(GetTextForDisplay(text)); | 484 model_->Append(GetTextForDisplay(text)); |
| 485 OnCaretBoundsChanged(); | 485 OnCaretBoundsChanged(); |
| 486 SchedulePaint(); | 486 SchedulePaint(); |
| 487 } | 487 } |
| 488 | 488 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 } | 614 } |
| 615 | 615 |
| 616 ui::Range NativeTextfieldViews::GetSelectedRange() const { | 616 ui::Range NativeTextfieldViews::GetSelectedRange() const { |
| 617 return GetRenderText()->selection(); | 617 return GetRenderText()->selection(); |
| 618 } | 618 } |
| 619 | 619 |
| 620 void NativeTextfieldViews::SelectRange(const ui::Range& range) { | 620 void NativeTextfieldViews::SelectRange(const ui::Range& range) { |
| 621 model_->SelectRange(range); | 621 model_->SelectRange(range); |
| 622 OnCaretBoundsChanged(); | 622 OnCaretBoundsChanged(); |
| 623 SchedulePaint(); | 623 SchedulePaint(); |
| 624 textfield_->GetWidget()->NotifyAccessibilityEvent( | 624 textfield_->NotifyAccessibilityEvent( |
| 625 textfield_, ui::AccessibilityTypes::EVENT_SELECTION_CHANGED, true); | 625 ui::AccessibilityTypes::EVENT_SELECTION_CHANGED, true); |
| 626 } | 626 } |
| 627 | 627 |
| 628 gfx::SelectionModel NativeTextfieldViews::GetSelectionModel() const { | 628 gfx::SelectionModel NativeTextfieldViews::GetSelectionModel() const { |
| 629 return GetRenderText()->selection_model(); | 629 return GetRenderText()->selection_model(); |
| 630 } | 630 } |
| 631 | 631 |
| 632 void NativeTextfieldViews::SelectSelectionModel( | 632 void NativeTextfieldViews::SelectSelectionModel( |
| 633 const gfx::SelectionModel& sel) { | 633 const gfx::SelectionModel& sel) { |
| 634 model_->SelectSelectionModel(sel); | 634 model_->SelectSelectionModel(sel); |
| 635 OnCaretBoundsChanged(); | 635 OnCaretBoundsChanged(); |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 } | 1215 } |
| 1216 | 1216 |
| 1217 void NativeTextfieldViews::PropagateTextChange() { | 1217 void NativeTextfieldViews::PropagateTextChange() { |
| 1218 textfield_->SyncText(); | 1218 textfield_->SyncText(); |
| 1219 } | 1219 } |
| 1220 | 1220 |
| 1221 void NativeTextfieldViews::UpdateAfterChange(bool text_changed, | 1221 void NativeTextfieldViews::UpdateAfterChange(bool text_changed, |
| 1222 bool cursor_changed) { | 1222 bool cursor_changed) { |
| 1223 if (text_changed) { | 1223 if (text_changed) { |
| 1224 PropagateTextChange(); | 1224 PropagateTextChange(); |
| 1225 textfield_->GetWidget()->NotifyAccessibilityEvent( | 1225 textfield_->NotifyAccessibilityEvent( |
| 1226 textfield_, ui::AccessibilityTypes::EVENT_TEXT_CHANGED, true); | 1226 ui::AccessibilityTypes::EVENT_TEXT_CHANGED, true); |
| 1227 } | 1227 } |
| 1228 if (cursor_changed) { | 1228 if (cursor_changed) { |
| 1229 is_cursor_visible_ = true; | 1229 is_cursor_visible_ = true; |
| 1230 RepaintCursor(); | 1230 RepaintCursor(); |
| 1231 if (!text_changed) { | 1231 if (!text_changed) { |
| 1232 // TEXT_CHANGED implies SELECTION_CHANGED, so we only need to fire | 1232 // TEXT_CHANGED implies SELECTION_CHANGED, so we only need to fire |
| 1233 // this if only the selection changed. | 1233 // this if only the selection changed. |
| 1234 textfield_->GetWidget()->NotifyAccessibilityEvent( | 1234 textfield_->NotifyAccessibilityEvent( |
| 1235 textfield_, ui::AccessibilityTypes::EVENT_SELECTION_CHANGED, true); | 1235 ui::AccessibilityTypes::EVENT_SELECTION_CHANGED, true); |
| 1236 } | 1236 } |
| 1237 } | 1237 } |
| 1238 if (text_changed || cursor_changed) { | 1238 if (text_changed || cursor_changed) { |
| 1239 OnCaretBoundsChanged(); | 1239 OnCaretBoundsChanged(); |
| 1240 SchedulePaint(); | 1240 SchedulePaint(); |
| 1241 } | 1241 } |
| 1242 } | 1242 } |
| 1243 | 1243 |
| 1244 void NativeTextfieldViews::UpdateContextMenu() { | 1244 void NativeTextfieldViews::UpdateContextMenu() { |
| 1245 if (!context_menu_contents_.get()) { | 1245 if (!context_menu_contents_.get()) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 | 1405 |
| 1406 void NativeTextfieldViews::PlatformGestureEventHandling( | 1406 void NativeTextfieldViews::PlatformGestureEventHandling( |
| 1407 const ui::GestureEvent* event) { | 1407 const ui::GestureEvent* event) { |
| 1408 #if defined(OS_WIN) && defined(USE_AURA) | 1408 #if defined(OS_WIN) && defined(USE_AURA) |
| 1409 if (event->type() == ui::ET_GESTURE_TAP_DOWN && !textfield_->read_only()) | 1409 if (event->type() == ui::ET_GESTURE_TAP_DOWN && !textfield_->read_only()) |
| 1410 base::win::DisplayVirtualKeyboard(); | 1410 base::win::DisplayVirtualKeyboard(); |
| 1411 #endif | 1411 #endif |
| 1412 } | 1412 } |
| 1413 | 1413 |
| 1414 } // namespace views | 1414 } // namespace views |
| OLD | NEW |