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

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

Issue 11817051: Elide text in the new Autofill UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 11 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 | « chrome/browser/ui/views/autofill/autofill_popup_view_views.h ('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 "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/Source/WebKit/chromium/public/WebAutofillClient.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h"
10 #include "ui/base/keycodes/keyboard_codes.h" 10 #include "ui/base/keycodes/keyboard_codes.h"
11 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/gfx/canvas.h" 12 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/display.h"
14 #include "ui/gfx/image/image.h" 13 #include "ui/gfx/image/image.h"
15 #include "ui/gfx/point.h" 14 #include "ui/gfx/point.h"
16 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
17 #include "ui/gfx/screen.h"
18 #include "ui/views/border.h" 16 #include "ui/views/border.h"
19 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
20 18
21 using WebKit::WebAutofillClient; 19 using WebKit::WebAutofillClient;
22 20
23 namespace { 21 namespace {
24 22
25 const SkColor kBorderColor = SkColorSetARGB(0xFF, 0xC7, 0xCA, 0xCE); 23 const SkColor kBorderColor = SkColorSetARGB(0xFF, 0xC7, 0xCA, 0xCE);
26 const SkColor kHoveredBackgroundColor = SkColorSetARGB(0xFF, 0xCD, 0xCD, 0xCD); 24 const SkColor kHoveredBackgroundColor = SkColorSetARGB(0xFF, 0xCD, 0xCD, 0xCD);
27 const SkColor kItemTextColor = SkColorSetARGB(0xFF, 0x7F, 0x7F, 0x7F); 25 const SkColor kItemTextColor = SkColorSetARGB(0xFF, 0x7F, 0x7F, 0x7F);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 126
129 // Setup an observer to check for when the browser moves or changes size, 127 // Setup an observer to check for when the browser moves or changes size,
130 // since the popup should always be hidden in those cases. 128 // since the popup should always be hidden in those cases.
131 observing_widget_ = views::Widget::GetTopLevelWidgetForNativeView( 129 observing_widget_ = views::Widget::GetTopLevelWidgetForNativeView(
132 controller_->container_view()); 130 controller_->container_view());
133 observing_widget_->AddObserver(this); 131 observing_widget_->AddObserver(this);
134 } 132 }
135 133
136 set_border(views::Border::CreateSolidBorder(kBorderThickness, kBorderColor)); 134 set_border(views::Border::CreateSolidBorder(kBorderThickness, kBorderColor));
137 135
138 SetInitialBounds();
139 UpdateBoundsAndRedrawPopup(); 136 UpdateBoundsAndRedrawPopup();
140 } 137 }
141 138
142 void AutofillPopupViewViews::InvalidateRow(size_t row) { 139 void AutofillPopupViewViews::InvalidateRow(size_t row) {
143 SchedulePaintInRect(controller_->GetRowBounds(row)); 140 SchedulePaintInRect(controller_->GetRowBounds(row));
144 } 141 }
145 142
146 void AutofillPopupViewViews::UpdateBoundsAndRedrawPopup() { 143 void AutofillPopupViewViews::UpdateBoundsAndRedrawPopup() {
147 GetWidget()->SetBounds(controller_->popup_bounds()); 144 GetWidget()->SetBounds(controller_->popup_bounds());
148 SchedulePaint(); 145 SchedulePaint();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 controller_->subtext_font(), 205 controller_->subtext_font(),
209 kItemTextColor, 206 kItemTextColor,
210 x_align_left + kEndPadding, 207 x_align_left + kEndPadding,
211 entry_rect.y(), 208 entry_rect.y(),
212 canvas->GetStringWidth(controller_->subtexts()[index], 209 canvas->GetStringWidth(controller_->subtexts()[index],
213 controller_->subtext_font()), 210 controller_->subtext_font()),
214 entry_rect.height(), 211 entry_rect.height(),
215 gfx::Canvas::TEXT_ALIGN_CENTER); 212 gfx::Canvas::TEXT_ALIGN_CENTER);
216 } 213 }
217 214
218 void AutofillPopupViewViews::SetInitialBounds() {
219 int bottom_of_field = controller_->element_bounds().bottom();
220 int popup_height = controller_->GetPopupRequiredHeight();
221
222 // Find the correct top position of the popup so that it doesn't go off
223 // the screen.
224 int top_of_popup = 0;
225 if (GetScreenSize().height() < bottom_of_field + popup_height) {
226 // The popup must appear above the field.
227 top_of_popup = controller_->element_bounds().y() - popup_height;
228 } else {
229 // The popup can appear below the field.
230 top_of_popup = bottom_of_field;
231 }
232
233 controller_->SetPopupBounds(gfx::Rect(
234 controller_->element_bounds().x(),
235 top_of_popup,
236 controller_->GetPopupRequiredWidth(),
237 popup_height));
238 }
239
240 gfx::Size AutofillPopupViewViews::GetScreenSize() {
241 gfx::Screen* screen =
242 gfx::Screen::GetScreenFor(controller_->container_view());
243 gfx::Display display =
244 screen->GetDisplayNearestPoint(controller_->element_bounds().origin());
245
246 return display.GetSizeInPixel();
247 }
248
249 AutofillPopupView* AutofillPopupView::Create( 215 AutofillPopupView* AutofillPopupView::Create(
250 AutofillPopupController* controller) { 216 AutofillPopupController* controller) {
251 return new AutofillPopupViewViews(controller); 217 return new AutofillPopupViewViews(controller);
252 } 218 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_popup_view_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698