OLD | NEW |
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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 views::MenuItemView::TOPLEFT, MenuRunner::HAS_MNEMONICS) == | 285 views::MenuItemView::TOPLEFT, MenuRunner::HAS_MNEMONICS) == |
286 MenuRunner::MENU_DELETED) | 286 MenuRunner::MENU_DELETED) |
287 return; | 287 return; |
288 } | 288 } |
289 | 289 |
290 ///////////////////////////////////////////////////////////////// | 290 ///////////////////////////////////////////////////////////////// |
291 // NativeTextfieldViews, views::DragController overrides: | 291 // NativeTextfieldViews, views::DragController overrides: |
292 void NativeTextfieldViews::WriteDragDataForView(views::View* sender, | 292 void NativeTextfieldViews::WriteDragDataForView(views::View* sender, |
293 const gfx::Point& press_pt, | 293 const gfx::Point& press_pt, |
294 OSExchangeData* data) { | 294 OSExchangeData* data) { |
295 #if !defined(TOUCH_UI) | |
296 DCHECK_NE(ui::DragDropTypes::DRAG_NONE, | 295 DCHECK_NE(ui::DragDropTypes::DRAG_NONE, |
297 GetDragOperationsForView(sender, press_pt)); | 296 GetDragOperationsForView(sender, press_pt)); |
298 #endif | |
299 data->SetString(GetSelectedText()); | 297 data->SetString(GetSelectedText()); |
300 } | 298 } |
301 | 299 |
302 int NativeTextfieldViews::GetDragOperationsForView(views::View* sender, | 300 int NativeTextfieldViews::GetDragOperationsForView(views::View* sender, |
303 const gfx::Point& p) { | 301 const gfx::Point& p) { |
304 #if defined(TOUCH_UI) | |
305 return ui::DragDropTypes::DRAG_NONE; | |
306 #else | |
307 if (!textfield_->IsEnabled() || !GetRenderText()->IsPointInSelection(p)) | 302 if (!textfield_->IsEnabled() || !GetRenderText()->IsPointInSelection(p)) |
308 return ui::DragDropTypes::DRAG_NONE; | 303 return ui::DragDropTypes::DRAG_NONE; |
309 if (sender == this && !textfield_->read_only()) | 304 if (sender == this && !textfield_->read_only()) |
310 return ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY; | 305 return ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY; |
311 return ui::DragDropTypes::DRAG_COPY; | 306 return ui::DragDropTypes::DRAG_COPY; |
312 #endif | |
313 } | 307 } |
314 | 308 |
315 bool NativeTextfieldViews::CanStartDragForView(View* sender, | 309 bool NativeTextfieldViews::CanStartDragForView(View* sender, |
316 const gfx::Point& press_pt, | 310 const gfx::Point& press_pt, |
317 const gfx::Point& p) { | 311 const gfx::Point& p) { |
318 #if defined(TOUCH_UI) | |
319 return false; | |
320 #else | |
321 return GetRenderText()->IsPointInSelection(press_pt); | 312 return GetRenderText()->IsPointInSelection(press_pt); |
322 #endif | |
323 } | 313 } |
324 | 314 |
325 ///////////////////////////////////////////////////////////////// | 315 ///////////////////////////////////////////////////////////////// |
326 // NativeTextfieldViews, NativeTextifieldWrapper overrides: | 316 // NativeTextfieldViews, NativeTextifieldWrapper overrides: |
327 | 317 |
328 string16 NativeTextfieldViews::GetText() const { | 318 string16 NativeTextfieldViews::GetText() const { |
329 return model_->GetText(); | 319 return model_->GetText(); |
330 } | 320 } |
331 | 321 |
332 void NativeTextfieldViews::UpdateText() { | 322 void NativeTextfieldViews::UpdateText() { |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 last_click_location_ = event.location(); | 1033 last_click_location_ = event.location(); |
1044 } | 1034 } |
1045 } | 1035 } |
1046 | 1036 |
1047 void NativeTextfieldViews::HandleMousePressEvent(const MouseEvent& event) { | 1037 void NativeTextfieldViews::HandleMousePressEvent(const MouseEvent& event) { |
1048 if (event.IsOnlyLeftMouseButton()) { | 1038 if (event.IsOnlyLeftMouseButton()) { |
1049 textfield_->RequestFocus(); | 1039 textfield_->RequestFocus(); |
1050 | 1040 |
1051 initiating_drag_ = false; | 1041 initiating_drag_ = false; |
1052 bool can_drag = true; | 1042 bool can_drag = true; |
1053 #if defined(TOUCH_UI) | 1043 |
1054 // Temporarily disable drag and drop on touch builds; see crbug.com/97845. | |
1055 can_drag = false; | |
1056 #endif | |
1057 switch(aggregated_clicks_) { | 1044 switch(aggregated_clicks_) { |
1058 case 0: | 1045 case 0: |
1059 if (can_drag && GetRenderText()->IsPointInSelection(event.location())) | 1046 if (can_drag && GetRenderText()->IsPointInSelection(event.location())) |
1060 initiating_drag_ = true; | 1047 initiating_drag_ = true; |
1061 else | 1048 else |
1062 MoveCursorTo(event.location(), event.IsShiftDown()); | 1049 MoveCursorTo(event.location(), event.IsShiftDown()); |
1063 break; | 1050 break; |
1064 case 1: | 1051 case 1: |
1065 model_->SelectWord(); | 1052 model_->SelectWord(); |
1066 OnCaretBoundsChanged(); | 1053 OnCaretBoundsChanged(); |
(...skipping 22 matching lines...) Expand all Loading... |
1089 | 1076 |
1090 #if defined(USE_AURA) | 1077 #if defined(USE_AURA) |
1091 // static | 1078 // static |
1092 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 1079 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
1093 Textfield* field) { | 1080 Textfield* field) { |
1094 return new NativeTextfieldViews(field); | 1081 return new NativeTextfieldViews(field); |
1095 } | 1082 } |
1096 #endif | 1083 #endif |
1097 | 1084 |
1098 } // namespace views | 1085 } // namespace views |
OLD | NEW |