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

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

Issue 1053143002: Make View::Paint use ui::PaintRecorder to access PaintContext's canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: paintrecorder: . Created 5 years, 8 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
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/scoped_animation_duration_scale_mode.h" 18 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
18 #include "ui/events/event.h" 19 #include "ui/events/event.h"
19 #include "ui/events/keycodes/keyboard_codes.h" 20 #include "ui/events/keycodes/keyboard_codes.h"
20 #include "ui/gfx/canvas.h" 21 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/display.h" 22 #include "ui/gfx/display.h"
22 #include "ui/gfx/geometry/insets.h" 23 #include "ui/gfx/geometry/insets.h"
23 #include "ui/gfx/screen.h" 24 #include "ui/gfx/screen.h"
24 #include "ui/native_theme/native_theme.h" 25 #include "ui/native_theme/native_theme.h"
25 #include "ui/strings/grit/ui_strings.h" 26 #include "ui/strings/grit/ui_strings.h"
26 #include "ui/views/background.h" 27 #include "ui/views/background.h"
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 GetDisplayNearestWindow(native_view); 1064 GetDisplayNearestWindow(native_view);
1064 size.SetToMin(gfx::Size(display.size().width(), height())); 1065 size.SetToMin(gfx::Size(display.size().width(), height()));
1065 label.SetBoundsRect(gfx::Rect(size)); 1066 label.SetBoundsRect(gfx::Rect(size));
1066 scoped_ptr<gfx::Canvas> canvas( 1067 scoped_ptr<gfx::Canvas> canvas(
1067 GetCanvasForDragImage(GetWidget(), label.size())); 1068 GetCanvasForDragImage(GetWidget(), label.size()));
1068 label.SetEnabledColor(GetTextColor()); 1069 label.SetEnabledColor(GetTextColor());
1069 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 1070 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
1070 // Desktop Linux Aura does not yet support transparency in drag images. 1071 // Desktop Linux Aura does not yet support transparency in drag images.
1071 canvas->DrawColor(GetBackgroundColor()); 1072 canvas->DrawColor(GetBackgroundColor());
1072 #endif 1073 #endif
1073 label.Paint(PaintContext(canvas.get())); 1074 label.Paint(ui::PaintContext(canvas.get()));
1074 const gfx::Vector2d kOffset(-15, 0); 1075 const gfx::Vector2d kOffset(-15, 0);
1075 drag_utils::SetDragImageOnDataObject(*canvas, kOffset, data); 1076 drag_utils::SetDragImageOnDataObject(*canvas, kOffset, data);
1076 if (controller_) 1077 if (controller_)
1077 controller_->OnWriteDragData(data); 1078 controller_->OnWriteDragData(data);
1078 } 1079 }
1079 1080
1080 int Textfield::GetDragOperationsForView(View* sender, const gfx::Point& p) { 1081 int Textfield::GetDragOperationsForView(View* sender, const gfx::Point& p) {
1081 int drag_operations = ui::DragDropTypes::DRAG_COPY; 1082 int drag_operations = ui::DragDropTypes::DRAG_COPY;
1082 if (!enabled() || text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD || 1083 if (!enabled() || text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD ||
1083 !GetRenderText()->IsPointInSelection(p)) { 1084 !GetRenderText()->IsPointInSelection(p)) {
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 RequestFocus(); 1887 RequestFocus();
1887 model_->MoveCursorTo(mouse); 1888 model_->MoveCursorTo(mouse);
1888 if (!selection_clipboard_text.empty()) { 1889 if (!selection_clipboard_text.empty()) {
1889 model_->InsertText(selection_clipboard_text); 1890 model_->InsertText(selection_clipboard_text);
1890 UpdateAfterChange(true, true); 1891 UpdateAfterChange(true, true);
1891 } 1892 }
1892 OnAfterUserAction(); 1893 OnAfterUserAction();
1893 } 1894 }
1894 1895
1895 } // namespace views 1896 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698