Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: views/controls/textfield/native_textfield_views.cc

Issue 6628037: views: Moves TextfieldController/TextRange into their own headers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/controls/textfield/native_textfield_views.h" 5 #include "views/controls/textfield/native_textfield_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "grit/app_strings.h" 13 #include "grit/app_strings.h"
14 #include "ui/base/clipboard/clipboard.h" 14 #include "ui/base/clipboard/clipboard.h"
15 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/canvas_skia.h" 16 #include "ui/gfx/canvas_skia.h"
17 #include "ui/gfx/insets.h" 17 #include "ui/gfx/insets.h"
18 #include "views/background.h" 18 #include "views/background.h"
19 #include "views/border.h" 19 #include "views/border.h"
20 #include "views/controls/menu/menu_2.h" 20 #include "views/controls/menu/menu_2.h"
21 #include "views/controls/textfield/text_range.h"
21 #include "views/controls/textfield/textfield.h" 22 #include "views/controls/textfield/textfield.h"
23 #include "views/controls/textfield/textfield_controller.h"
22 #include "views/controls/textfield/textfield_views_model.h" 24 #include "views/controls/textfield/textfield_views_model.h"
23 #include "views/events/event.h" 25 #include "views/events/event.h"
24 #include "views/metrics.h" 26 #include "views/metrics.h"
25 #include "views/views_delegate.h" 27 #include "views/views_delegate.h"
26 28
27 #if defined(OS_LINUX) 29 #if defined(OS_LINUX)
28 #include "ui/gfx/gtk_util.h" 30 #include "ui/gfx/gtk_util.h"
29 #endif 31 #endif
30 32
31 namespace { 33 namespace {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 161
160 string16 NativeTextfieldViews::GetText() const { 162 string16 NativeTextfieldViews::GetText() const {
161 return model_->text(); 163 return model_->text();
162 } 164 }
163 165
164 void NativeTextfieldViews::UpdateText() { 166 void NativeTextfieldViews::UpdateText() {
165 bool changed = model_->SetText(textfield_->text()); 167 bool changed = model_->SetText(textfield_->text());
166 UpdateCursorBoundsAndTextOffset(); 168 UpdateCursorBoundsAndTextOffset();
167 SchedulePaint(); 169 SchedulePaint();
168 if (changed) { 170 if (changed) {
169 Textfield::Controller* controller = textfield_->GetController(); 171 TextfieldController* controller = textfield_->GetController();
170 if (controller) 172 if (controller)
171 controller->ContentsChanged(textfield_, GetText()); 173 controller->ContentsChanged(textfield_, GetText());
172 } 174 }
173 } 175 }
174 176
175 void NativeTextfieldViews::AppendText(const string16& text) { 177 void NativeTextfieldViews::AppendText(const string16& text) {
176 if (text.empty()) 178 if (text.empty())
177 return; 179 return;
178 model_->Append(text); 180 model_->Append(text);
179 UpdateCursorBoundsAndTextOffset(); 181 UpdateCursorBoundsAndTextOffset();
180 SchedulePaint(); 182 SchedulePaint();
181 183
182 Textfield::Controller* controller = textfield_->GetController(); 184 TextfieldController* controller = textfield_->GetController();
183 if (controller) 185 if (controller)
184 controller->ContentsChanged(textfield_, GetText()); 186 controller->ContentsChanged(textfield_, GetText());
185 } 187 }
186 188
187 string16 NativeTextfieldViews::GetSelectedText() const { 189 string16 NativeTextfieldViews::GetSelectedText() const {
188 return model_->GetSelectedText(); 190 return model_->GetSelectedText();
189 } 191 }
190 192
191 void NativeTextfieldViews::SelectAll() { 193 void NativeTextfieldViews::SelectAll() {
192 model_->SelectAll(); 194 model_->SelectAll();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 model_->SelectRange(range); 290 model_->SelectRange(range);
289 UpdateCursorBoundsAndTextOffset(); 291 UpdateCursorBoundsAndTextOffset();
290 SchedulePaint(); 292 SchedulePaint();
291 } 293 }
292 294
293 size_t NativeTextfieldViews::GetCursorPosition() const { 295 size_t NativeTextfieldViews::GetCursorPosition() const {
294 return model_->cursor_pos(); 296 return model_->cursor_pos();
295 } 297 }
296 298
297 bool NativeTextfieldViews::HandleKeyPressed(const views::KeyEvent& e) { 299 bool NativeTextfieldViews::HandleKeyPressed(const views::KeyEvent& e) {
298 Textfield::Controller* controller = textfield_->GetController(); 300 TextfieldController* controller = textfield_->GetController();
299 bool handled = false; 301 bool handled = false;
300 if (controller) 302 if (controller)
301 handled = controller->HandleKeyEvent(textfield_, e); 303 handled = controller->HandleKeyEvent(textfield_, e);
302 return handled || HandleKeyEvent(e); 304 return handled || HandleKeyEvent(e);
303 } 305 }
304 306
305 bool NativeTextfieldViews::HandleKeyReleased(const views::KeyEvent& e) { 307 bool NativeTextfieldViews::HandleKeyReleased(const views::KeyEvent& e) {
306 return true; 308 return true;
307 } 309 }
308 310
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 819
818 void NativeTextfieldViews::SetCursorForMouseClick(const views::MouseEvent& e) { 820 void NativeTextfieldViews::SetCursorForMouseClick(const views::MouseEvent& e) {
819 size_t pos = FindCursorPosition(e.location()); 821 size_t pos = FindCursorPosition(e.location());
820 if (model_->MoveCursorTo(pos, false)) { 822 if (model_->MoveCursorTo(pos, false)) {
821 UpdateCursorBoundsAndTextOffset(); 823 UpdateCursorBoundsAndTextOffset();
822 } 824 }
823 } 825 }
824 826
825 void NativeTextfieldViews::PropagateTextChange() { 827 void NativeTextfieldViews::PropagateTextChange() {
826 textfield_->SyncText(); 828 textfield_->SyncText();
827 Textfield::Controller* controller = textfield_->GetController(); 829 TextfieldController* controller = textfield_->GetController();
828 if (controller) 830 if (controller)
829 controller->ContentsChanged(textfield_, GetText()); 831 controller->ContentsChanged(textfield_, GetText());
830 } 832 }
831 833
832 void NativeTextfieldViews::UpdateAfterChange(bool text_changed, 834 void NativeTextfieldViews::UpdateAfterChange(bool text_changed,
833 bool cursor_changed) { 835 bool cursor_changed) {
834 if (text_changed) 836 if (text_changed)
835 PropagateTextChange(); 837 PropagateTextChange();
836 if (cursor_changed) { 838 if (cursor_changed) {
837 is_cursor_visible_ = true; 839 is_cursor_visible_ = true;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 } 907 }
906 908
907 void NativeTextfieldViews::TextfieldBorder::SetInsets(int top, 909 void NativeTextfieldViews::TextfieldBorder::SetInsets(int top,
908 int left, 910 int left,
909 int bottom, 911 int bottom,
910 int right) { 912 int right) {
911 insets_.Set(top, left, bottom, right); 913 insets_.Set(top, left, bottom, right);
912 } 914 }
913 915
914 } // namespace views 916 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698