| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "ui/accessibility/ax_action_data.h" | 14 #include "ui/accessibility/ax_action_data.h" |
| 15 #include "ui/accessibility/ax_node_data.h" | 15 #include "ui/accessibility/ax_node_data.h" |
| 16 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 16 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 17 #include "ui/base/cursor/cursor.h" | 17 #include "ui/base/cursor/cursor.h" |
| 18 #include "ui/base/default_style.h" | 18 #include "ui/base/default_style.h" |
| 19 #include "ui/base/dragdrop/drag_drop_types.h" | 19 #include "ui/base/dragdrop/drag_drop_types.h" |
| 20 #include "ui/base/dragdrop/drag_utils.h" | |
| 21 #include "ui/base/ime/input_method.h" | 20 #include "ui/base/ime/input_method.h" |
| 22 #include "ui/base/ime/text_edit_commands.h" | 21 #include "ui/base/ime/text_edit_commands.h" |
| 23 #include "ui/base/material_design/material_design_controller.h" | 22 #include "ui/base/material_design/material_design_controller.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "ui/base/ui_base_switches_util.h" | 24 #include "ui/base/ui_base_switches_util.h" |
| 26 #include "ui/compositor/canvas_painter.h" | 25 #include "ui/compositor/canvas_painter.h" |
| 27 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 26 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 28 #include "ui/display/display.h" | 27 #include "ui/display/display.h" |
| 29 #include "ui/display/screen.h" | 28 #include "ui/display/screen.h" |
| 30 #include "ui/events/base_event_utils.h" | 29 #include "ui/events/base_event_utils.h" |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1082 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 1084 // Desktop Linux Aura does not yet support transparency in drag images. | 1083 // Desktop Linux Aura does not yet support transparency in drag images. |
| 1085 SkColor color = GetBackgroundColor(); | 1084 SkColor color = GetBackgroundColor(); |
| 1086 #else | 1085 #else |
| 1087 SkColor color = SK_ColorTRANSPARENT; | 1086 SkColor color = SK_ColorTRANSPARENT; |
| 1088 #endif | 1087 #endif |
| 1089 label.Paint( | 1088 label.Paint( |
| 1090 ui::CanvasPainter(&bitmap, label.size(), raster_scale, color).context()); | 1089 ui::CanvasPainter(&bitmap, label.size(), raster_scale, color).context()); |
| 1091 const gfx::Vector2d kOffset(-15, 0); | 1090 const gfx::Vector2d kOffset(-15, 0); |
| 1092 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, raster_scale)); | 1091 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, raster_scale)); |
| 1093 drag_utils::SetDragImageOnDataObject(image, kOffset, data); | 1092 data->provider().SetDragImage(image, kOffset); |
| 1094 if (controller_) | 1093 if (controller_) |
| 1095 controller_->OnWriteDragData(data); | 1094 controller_->OnWriteDragData(data); |
| 1096 } | 1095 } |
| 1097 | 1096 |
| 1098 int Textfield::GetDragOperationsForView(View* sender, const gfx::Point& p) { | 1097 int Textfield::GetDragOperationsForView(View* sender, const gfx::Point& p) { |
| 1099 int drag_operations = ui::DragDropTypes::DRAG_COPY; | 1098 int drag_operations = ui::DragDropTypes::DRAG_COPY; |
| 1100 if (!enabled() || text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD || | 1099 if (!enabled() || text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD || |
| 1101 !GetRenderText()->IsPointInSelection(p)) { | 1100 !GetRenderText()->IsPointInSelection(p)) { |
| 1102 drag_operations = ui::DragDropTypes::DRAG_NONE; | 1101 drag_operations = ui::DragDropTypes::DRAG_NONE; |
| 1103 } else if (sender == this && !read_only()) { | 1102 } else if (sender == this && !read_only()) { |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2098 cursor_blink_timer_.Stop(); | 2097 cursor_blink_timer_.Stop(); |
| 2099 } | 2098 } |
| 2100 | 2099 |
| 2101 void Textfield::OnCursorBlinkTimerFired() { | 2100 void Textfield::OnCursorBlinkTimerFired() { |
| 2102 DCHECK(ShouldBlinkCursor()); | 2101 DCHECK(ShouldBlinkCursor()); |
| 2103 cursor_view_.SetVisible(!cursor_view_.visible()); | 2102 cursor_view_.SetVisible(!cursor_view_.visible()); |
| 2104 UpdateCursorViewPosition(); | 2103 UpdateCursorViewPosition(); |
| 2105 } | 2104 } |
| 2106 | 2105 |
| 2107 } // namespace views | 2106 } // namespace views |
| OLD | NEW |