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

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

Issue 1161933007: ui: Introduce CanvasPainter, remove PaintContext(gfx::Canvas*). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: canvaspainter: . Created 5 years, 6 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
« no previous file with comments | « ui/views/controls/label_unittest.cc ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "ui/accessibility/ax_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
11 #include "ui/base/clipboard/scoped_clipboard_writer.h" 11 #include "ui/base/clipboard/scoped_clipboard_writer.h"
12 #include "ui/base/cursor/cursor.h" 12 #include "ui/base/cursor/cursor.h"
13 #include "ui/base/dragdrop/drag_drop_types.h" 13 #include "ui/base/dragdrop/drag_drop_types.h"
14 #include "ui/base/dragdrop/drag_utils.h" 14 #include "ui/base/dragdrop/drag_utils.h"
15 #include "ui/base/touch/selection_bound.h" 15 #include "ui/base/touch/selection_bound.h"
16 #include "ui/base/ui_base_switches_util.h" 16 #include "ui/base/ui_base_switches_util.h"
17 #include "ui/compositor/paint_context.h" 17 #include "ui/compositor/canvas_painter.h"
18 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 18 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
19 #include "ui/events/event.h" 19 #include "ui/events/event.h"
20 #include "ui/events/keycodes/keyboard_codes.h" 20 #include "ui/events/keycodes/keyboard_codes.h"
21 #include "ui/gfx/canvas.h" 21 #include "ui/gfx/canvas.h"
22 #include "ui/gfx/display.h" 22 #include "ui/gfx/display.h"
23 #include "ui/gfx/geometry/insets.h" 23 #include "ui/gfx/geometry/insets.h"
24 #include "ui/gfx/screen.h" 24 #include "ui/gfx/screen.h"
25 #include "ui/native_theme/native_theme.h" 25 #include "ui/native_theme/native_theme.h"
26 #include "ui/strings/grit/ui_strings.h" 26 #include "ui/strings/grit/ui_strings.h"
27 #include "ui/views/background.h" 27 #include "ui/views/background.h"
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 GetDisplayNearestWindow(native_view); 1075 GetDisplayNearestWindow(native_view);
1076 size.SetToMin(gfx::Size(display.size().width(), height())); 1076 size.SetToMin(gfx::Size(display.size().width(), height()));
1077 label.SetBoundsRect(gfx::Rect(size)); 1077 label.SetBoundsRect(gfx::Rect(size));
1078 scoped_ptr<gfx::Canvas> canvas( 1078 scoped_ptr<gfx::Canvas> canvas(
1079 GetCanvasForDragImage(GetWidget(), label.size())); 1079 GetCanvasForDragImage(GetWidget(), label.size()));
1080 label.SetEnabledColor(GetTextColor()); 1080 label.SetEnabledColor(GetTextColor());
1081 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 1081 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
1082 // Desktop Linux Aura does not yet support transparency in drag images. 1082 // Desktop Linux Aura does not yet support transparency in drag images.
1083 canvas->DrawColor(GetBackgroundColor()); 1083 canvas->DrawColor(GetBackgroundColor());
1084 #endif 1084 #endif
1085 label.Paint(ui::PaintContext(canvas.get())); 1085 label.Paint(ui::CanvasPainter(canvas.get(), 1.f).context());
1086 const gfx::Vector2d kOffset(-15, 0); 1086 const gfx::Vector2d kOffset(-15, 0);
1087 drag_utils::SetDragImageOnDataObject(*canvas, kOffset, data); 1087 drag_utils::SetDragImageOnDataObject(*canvas, kOffset, data);
1088 if (controller_) 1088 if (controller_)
1089 controller_->OnWriteDragData(data); 1089 controller_->OnWriteDragData(data);
1090 } 1090 }
1091 1091
1092 int Textfield::GetDragOperationsForView(View* sender, const gfx::Point& p) { 1092 int Textfield::GetDragOperationsForView(View* sender, const gfx::Point& p) {
1093 int drag_operations = ui::DragDropTypes::DRAG_COPY; 1093 int drag_operations = ui::DragDropTypes::DRAG_COPY;
1094 if (!enabled() || text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD || 1094 if (!enabled() || text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD ||
1095 !GetRenderText()->IsPointInSelection(p)) { 1095 !GetRenderText()->IsPointInSelection(p)) {
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 RequestFocus(); 1892 RequestFocus();
1893 model_->MoveCursorTo(mouse); 1893 model_->MoveCursorTo(mouse);
1894 if (!selection_clipboard_text.empty()) { 1894 if (!selection_clipboard_text.empty()) {
1895 model_->InsertText(selection_clipboard_text); 1895 model_->InsertText(selection_clipboard_text);
1896 UpdateAfterChange(true, true); 1896 UpdateAfterChange(true, true);
1897 } 1897 }
1898 OnAfterUserAction(); 1898 OnAfterUserAction();
1899 } 1899 }
1900 1900
1901 } // namespace views 1901 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label_unittest.cc ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698