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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_popup_view_views.cc

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More fixes per feedback Created 7 years, 2 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
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 "chrome/browser/ui/views/autofill/autofill_popup_view_views.h" 5 #include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h"
6 6
7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" 7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "third_party/WebKit/public/web/WebAutofillClient.h" 9 #include "third_party/WebKit/public/web/WebAutofillClient.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/events/keycodes/keyboard_codes.h" 11 #include "ui/events/keycodes/keyboard_codes.h"
12 #include "ui/gfx/canvas.h" 12 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/image/image.h" 13 #include "ui/gfx/image/image.h"
14 #include "ui/gfx/native_widget_types.h" 14 #include "ui/gfx/native_widget_types.h"
15 #include "ui/gfx/point.h" 15 #include "ui/gfx/point.h"
16 #include "ui/gfx/rect.h" 16 #include "ui/gfx/rect.h"
17 #include "ui/gfx/rect_conversions.h"
17 #include "ui/gfx/screen.h" 18 #include "ui/gfx/screen.h"
18 #include "ui/views/border.h" 19 #include "ui/views/border.h"
19 #include "ui/views/event_utils.h" 20 #include "ui/views/event_utils.h"
20 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
21 22
22 using WebKit::WebAutofillClient; 23 using WebKit::WebAutofillClient;
23 24
24 namespace { 25 namespace {
25 26
26 const SkColor kBorderColor = SkColorSetARGB(0xFF, 0xC7, 0xCA, 0xCE); 27 const SkColor kBorderColor = SkColorSetARGB(0xFF, 0xC7, 0xCA, 0xCE);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 66 }
66 67
67 void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) { 68 void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
68 if (!controller_) 69 if (!controller_)
69 return; 70 return;
70 71
71 canvas->DrawColor(kPopupBackground); 72 canvas->DrawColor(kPopupBackground);
72 OnPaintBorder(canvas); 73 OnPaintBorder(canvas);
73 74
74 for (size_t i = 0; i < controller_->names().size(); ++i) { 75 for (size_t i = 0; i < controller_->names().size(); ++i) {
75 gfx::Rect line_rect = controller_->GetRowBounds(i); 76 gfx::Rect line_rect = gfx::ToEnclosingRect(controller_->GetRowBounds(i));
76 77
77 if (controller_->identifiers()[i] == 78 if (controller_->identifiers()[i] ==
78 WebAutofillClient::MenuItemIDSeparator) { 79 WebAutofillClient::MenuItemIDSeparator) {
79 canvas->DrawRect(line_rect, kItemTextColor); 80 canvas->DrawRect(line_rect, kItemTextColor);
80 } else { 81 } else {
81 DrawAutofillEntry(canvas, i, line_rect); 82 DrawAutofillEntry(canvas, i, line_rect);
82 } 83 }
83 } 84 }
84 } 85 }
85 86
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 set_border(views::Border::CreateSolidBorder(kBorderThickness, kBorderColor)); 188 set_border(views::Border::CreateSolidBorder(kBorderThickness, kBorderColor));
188 189
189 UpdateBoundsAndRedrawPopup(); 190 UpdateBoundsAndRedrawPopup();
190 GetWidget()->Show(); 191 GetWidget()->Show();
191 192
192 if (controller_->hide_on_outside_click()) 193 if (controller_->hide_on_outside_click())
193 GetWidget()->SetCapture(this); 194 GetWidget()->SetCapture(this);
194 } 195 }
195 196
196 void AutofillPopupViewViews::InvalidateRow(size_t row) { 197 void AutofillPopupViewViews::InvalidateRow(size_t row) {
197 SchedulePaintInRect(controller_->GetRowBounds(row)); 198 SchedulePaintInRect(gfx::ToEnclosingRect(controller_->GetRowBounds(row)));
198 } 199 }
199 200
200 void AutofillPopupViewViews::UpdateBoundsAndRedrawPopup() { 201 void AutofillPopupViewViews::UpdateBoundsAndRedrawPopup() {
201 GetWidget()->SetBounds(controller_->popup_bounds()); 202 GetWidget()->SetBounds(gfx::ToEnclosingRect(controller_->popup_bounds()));
202 SchedulePaint(); 203 SchedulePaint();
203 } 204 }
204 205
205 void AutofillPopupViewViews::HideInternal() { 206 void AutofillPopupViewViews::HideInternal() {
206 observing_widget_->RemoveObserver(this); 207 observing_widget_->RemoveObserver(this);
207 } 208 }
208 209
209 void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas, 210 void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
210 int index, 211 int index,
211 const gfx::Rect& entry_rect) { 212 const gfx::Rect& entry_rect) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 274
274 // If the top level widget can't be found, cancel the popup since we can't 275 // If the top level widget can't be found, cancel the popup since we can't
275 // fully set it up. 276 // fully set it up.
276 if (!observing_widget) 277 if (!observing_widget)
277 return NULL; 278 return NULL;
278 279
279 return new AutofillPopupViewViews(controller, observing_widget); 280 return new AutofillPopupViewViews(controller, observing_widget);
280 } 281 }
281 282
282 } // namespace autofill 283 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698