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

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

Issue 10824295: Rid the world of the last of views::Event types: TouchEvent, GestureEvent, MouseWheelEvent, ScrollE… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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) 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/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 17 matching lines...) Expand all
28 #include "ui/gfx/text_constants.h" 28 #include "ui/gfx/text_constants.h"
29 #include "ui/views/background.h" 29 #include "ui/views/background.h"
30 #include "ui/views/border.h" 30 #include "ui/views/border.h"
31 #include "ui/views/controls/focusable_border.h" 31 #include "ui/views/controls/focusable_border.h"
32 #include "ui/views/controls/menu/menu_item_view.h" 32 #include "ui/views/controls/menu/menu_item_view.h"
33 #include "ui/views/controls/menu/menu_model_adapter.h" 33 #include "ui/views/controls/menu/menu_model_adapter.h"
34 #include "ui/views/controls/menu/menu_runner.h" 34 #include "ui/views/controls/menu/menu_runner.h"
35 #include "ui/views/controls/textfield/textfield.h" 35 #include "ui/views/controls/textfield/textfield.h"
36 #include "ui/views/controls/textfield/textfield_controller.h" 36 #include "ui/views/controls/textfield/textfield_controller.h"
37 #include "ui/views/controls/textfield/textfield_views_model.h" 37 #include "ui/views/controls/textfield/textfield_views_model.h"
38 #include "ui/views/events/event.h"
39 #include "ui/views/ime/input_method.h" 38 #include "ui/views/ime/input_method.h"
40 #include "ui/views/metrics.h" 39 #include "ui/views/metrics.h"
41 #include "ui/views/views_delegate.h" 40 #include "ui/views/views_delegate.h"
42 #include "ui/views/widget/widget.h" 41 #include "ui/views/widget/widget.h"
43 #include "unicode/uchar.h" 42 #include "unicode/uchar.h"
44 43
45 #if defined(USE_AURA) 44 #if defined(USE_AURA)
46 #include "ui/base/cursor/cursor.h" 45 #include "ui/base/cursor/cursor.h"
47 #endif 46 #endif
48 47
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // Textfield. 140 // Textfield.
142 textfield_->OnMouseReleased(event); 141 textfield_->OnMouseReleased(event);
143 // Cancel suspected drag initiations, the user was clicking in the selection. 142 // Cancel suspected drag initiations, the user was clicking in the selection.
144 if (initiating_drag_ && MoveCursorTo(event.location(), false)) 143 if (initiating_drag_ && MoveCursorTo(event.location(), false))
145 SchedulePaint(); 144 SchedulePaint();
146 initiating_drag_ = false; 145 initiating_drag_ = false;
147 OnAfterUserAction(); 146 OnAfterUserAction();
148 } 147 }
149 148
150 ui::GestureStatus NativeTextfieldViews::OnGestureEvent( 149 ui::GestureStatus NativeTextfieldViews::OnGestureEvent(
151 const GestureEvent& event) { 150 const ui::GestureEvent& event) {
152 ui::GestureStatus status = textfield_->OnGestureEvent(event); 151 ui::GestureStatus status = textfield_->OnGestureEvent(event);
153 if (status != ui::GESTURE_STATUS_UNKNOWN) 152 if (status != ui::GESTURE_STATUS_UNKNOWN)
154 return status; 153 return status;
155 154
156 switch (event.type()) { 155 switch (event.type()) {
157 case ui::ET_GESTURE_TAP_DOWN: 156 case ui::ET_GESTURE_TAP_DOWN:
158 OnBeforeUserAction(); 157 OnBeforeUserAction();
159 textfield_->RequestFocus(); 158 textfield_->RequestFocus();
160 // We don't deselect if the point is in the selection 159 // We don't deselect if the point is in the selection
161 // because TAP_DOWN may turn into a LONG_PRESS. 160 // because TAP_DOWN may turn into a LONG_PRESS.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 return false; 197 return false;
199 // TODO(msw): Can we support URL, FILENAME, etc.? 198 // TODO(msw): Can we support URL, FILENAME, etc.?
200 *formats = ui::OSExchangeData::STRING; 199 *formats = ui::OSExchangeData::STRING;
201 return true; 200 return true;
202 } 201 }
203 202
204 bool NativeTextfieldViews::CanDrop(const OSExchangeData& data) { 203 bool NativeTextfieldViews::CanDrop(const OSExchangeData& data) {
205 return textfield_->enabled() && !textfield_->read_only() && data.HasString(); 204 return textfield_->enabled() && !textfield_->read_only() && data.HasString();
206 } 205 }
207 206
208 int NativeTextfieldViews::OnDragUpdated(const DropTargetEvent& event) { 207 int NativeTextfieldViews::OnDragUpdated(const ui::DropTargetEvent& event) {
209 DCHECK(CanDrop(event.data())); 208 DCHECK(CanDrop(event.data()));
210 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); 209 bool in_selection = GetRenderText()->IsPointInSelection(event.location());
211 is_drop_cursor_visible_ = !in_selection; 210 is_drop_cursor_visible_ = !in_selection;
212 // TODO(msw): Pan over text when the user drags to the visible text edge. 211 // TODO(msw): Pan over text when the user drags to the visible text edge.
213 OnCaretBoundsChanged(); 212 OnCaretBoundsChanged();
214 SchedulePaint(); 213 SchedulePaint();
215 214
216 if (initiating_drag_) { 215 if (initiating_drag_) {
217 if (in_selection) 216 if (in_selection)
218 return ui::DragDropTypes::DRAG_NONE; 217 return ui::DragDropTypes::DRAG_NONE;
219 return event.IsControlDown() ? ui::DragDropTypes::DRAG_COPY : 218 return event.IsControlDown() ? ui::DragDropTypes::DRAG_COPY :
220 ui::DragDropTypes::DRAG_MOVE; 219 ui::DragDropTypes::DRAG_MOVE;
221 } 220 }
222 return ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_MOVE; 221 return ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_MOVE;
223 } 222 }
224 223
225 int NativeTextfieldViews::OnPerformDrop(const DropTargetEvent& event) { 224 int NativeTextfieldViews::OnPerformDrop(const ui::DropTargetEvent& event) {
226 DCHECK(CanDrop(event.data())); 225 DCHECK(CanDrop(event.data()));
227 DCHECK(!initiating_drag_ || 226 DCHECK(!initiating_drag_ ||
228 !GetRenderText()->IsPointInSelection(event.location())); 227 !GetRenderText()->IsPointInSelection(event.location()));
229 OnBeforeUserAction(); 228 OnBeforeUserAction();
230 skip_input_method_cancel_composition_ = true; 229 skip_input_method_cancel_composition_ = true;
231 230
232 gfx::SelectionModel drop_destination_model = 231 gfx::SelectionModel drop_destination_model =
233 GetRenderText()->FindCursorPosition(event.location()); 232 GetRenderText()->FindCursorPosition(event.location());
234 string16 text; 233 string16 text;
235 event.data().GetString(&text); 234 event.data().GetString(&text);
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 // Filter out all control characters, including tab and new line characters, 1219 // Filter out all control characters, including tab and new line characters,
1221 // and all characters with Alt modifier. But we need to allow characters with 1220 // and all characters with Alt modifier. But we need to allow characters with
1222 // AltGr modifier. 1221 // AltGr modifier.
1223 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different 1222 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different
1224 // flag that we don't care about. 1223 // flag that we don't care about.
1225 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && 1224 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) &&
1226 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; 1225 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN;
1227 } 1226 }
1228 1227
1229 } // namespace views 1228 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views.h ('k') | ui/views/controls/textfield/native_textfield_views_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698