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

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

Issue 341713002: Remove Label::PaintText overrides. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/label_unittest.cc ('k') | no next file » | 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/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "grit/ui_strings.h" 10 #include "grit/ui_strings.h"
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 985
986 //////////////////////////////////////////////////////////////////////////////// 986 ////////////////////////////////////////////////////////////////////////////////
987 // Textfield, DragController overrides: 987 // Textfield, DragController overrides:
988 988
989 void Textfield::WriteDragDataForView(View* sender, 989 void Textfield::WriteDragDataForView(View* sender,
990 const gfx::Point& press_pt, 990 const gfx::Point& press_pt,
991 OSExchangeData* data) { 991 OSExchangeData* data) {
992 const base::string16& selected_text(GetSelectedText()); 992 const base::string16& selected_text(GetSelectedText());
993 data->SetString(selected_text); 993 data->SetString(selected_text);
994 Label label(selected_text, GetFontList()); 994 Label label(selected_text, GetFontList());
995 const SkColor background = GetBackgroundColor(); 995 label.SetBackgroundColor(GetBackgroundColor());
996 label.SetBackgroundColor(SkColorSetA(background, SK_AlphaTRANSPARENT)); 996 label.set_subpixel_rendering_enabled(false);
997 gfx::Size size(label.GetPreferredSize()); 997 gfx::Size size(label.GetPreferredSize());
998 gfx::NativeView native_view = GetWidget()->GetNativeView(); 998 gfx::NativeView native_view = GetWidget()->GetNativeView();
999 gfx::Display display = gfx::Screen::GetScreenFor(native_view)-> 999 gfx::Display display = gfx::Screen::GetScreenFor(native_view)->
1000 GetDisplayNearestWindow(native_view); 1000 GetDisplayNearestWindow(native_view);
1001 size.SetToMin(gfx::Size(display.size().width(), height())); 1001 size.SetToMin(gfx::Size(display.size().width(), height()));
1002 label.SetBoundsRect(gfx::Rect(size)); 1002 label.SetBoundsRect(gfx::Rect(size));
1003 scoped_ptr<gfx::Canvas> canvas( 1003 scoped_ptr<gfx::Canvas> canvas(
1004 GetCanvasForDragImage(GetWidget(), label.size())); 1004 GetCanvasForDragImage(GetWidget(), label.size()));
1005 label.SetEnabledColor(GetTextColor()); 1005 label.SetEnabledColor(GetTextColor());
1006 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 1006 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
1007 // Desktop Linux Aura does not yet support transparency in drag images. 1007 // Desktop Linux Aura does not yet support transparency in drag images.
1008 canvas->DrawColor(background); 1008 canvas->DrawColor(GetBackgroundColor());
1009 #endif 1009 #endif
1010 label.Paint(canvas.get(), views::CullSet()); 1010 label.Paint(canvas.get(), views::CullSet());
1011 const gfx::Vector2d kOffset(-15, 0); 1011 const gfx::Vector2d kOffset(-15, 0);
1012 drag_utils::SetDragImageOnDataObject(*canvas, kOffset, data); 1012 drag_utils::SetDragImageOnDataObject(*canvas, kOffset, data);
1013 if (controller_) 1013 if (controller_)
1014 controller_->OnWriteDragData(data); 1014 controller_->OnWriteDragData(data);
1015 } 1015 }
1016 1016
1017 int Textfield::GetDragOperationsForView(View* sender, const gfx::Point& p) { 1017 int Textfield::GetDragOperationsForView(View* sender, const gfx::Point& p) {
1018 int drag_operations = ui::DragDropTypes::DRAG_COPY; 1018 int drag_operations = ui::DragDropTypes::DRAG_COPY;
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 const size_t length = selection_clipboard_text.length(); 1760 const size_t length = selection_clipboard_text.length();
1761 range = gfx::Range(range.start() + length, range.end() + length); 1761 range = gfx::Range(range.start() + length, range.end() + length);
1762 } 1762 }
1763 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); 1763 model_->MoveCursorTo(gfx::SelectionModel(range, affinity));
1764 UpdateAfterChange(true, true); 1764 UpdateAfterChange(true, true);
1765 OnAfterUserAction(); 1765 OnAfterUserAction();
1766 } 1766 }
1767 } 1767 }
1768 1768
1769 } // namespace views 1769 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698