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

Side by Side Diff: chrome/browser/ui/views/autocomplete/autocomplete_result_view.cc

Issue 6731036: Enabled pressing TAB to cycle through the Omnibox results. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // For WinDDK ATL compatibility, these ATL headers must come first. 5 // For WinDDK ATL compatibility, these ATL headers must come first.
6 #include "build/build_config.h" 6 #include "build/build_config.h"
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <atlbase.h> // NOLINT 8 #include <atlbase.h> // NOLINT
9 #include <atlwin.h> // NOLINT 9 #include <atlwin.h> // NOLINT
10 #endif 10 #endif
(...skipping 27 matching lines...) Expand all
38 const int kMinimumIconVerticalPadding = 2; 38 const int kMinimumIconVerticalPadding = 2;
39 39
40 #if defined(TOUCH_UI) 40 #if defined(TOUCH_UI)
41 const int kMinimumTextVerticalPadding = 15; 41 const int kMinimumTextVerticalPadding = 15;
42 #else 42 #else
43 const int kMinimumTextVerticalPadding = 3; 43 const int kMinimumTextVerticalPadding = 3;
44 #endif 44 #endif
45 45
46 } // namespace 46 } // namespace
47 47
48 const char AutocompleteResultView::kViewClassName[] =
49 "browser/ui/views/autocomplete/AutocompleteResultView";
50
48 //////////////////////////////////////////////////////////////////////////////// 51 ////////////////////////////////////////////////////////////////////////////////
49 // AutocompleteResultView, public: 52 // AutocompleteResultView, public:
50 53
51 // Precalculated data used to draw the portion of a match classification that 54 // Precalculated data used to draw the portion of a match classification that
52 // fits entirely within one run. 55 // fits entirely within one run.
53 struct AutocompleteResultView::ClassificationData { 56 struct AutocompleteResultView::ClassificationData {
54 string16 text; 57 string16 text;
55 const gfx::Font* font; 58 const gfx::Font* font;
56 SkColor color; 59 SkColor color;
57 int pixel_width; 60 int pixel_width;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 172 }
170 173
171 return colors[state][kind]; 174 return colors[state][kind];
172 } 175 }
173 176
174 void AutocompleteResultView::SetMatch(const AutocompleteMatch& match) { 177 void AutocompleteResultView::SetMatch(const AutocompleteMatch& match) {
175 match_ = match; 178 match_ = match;
176 Layout(); 179 Layout();
177 } 180 }
178 181
182
183 gfx::Size AutocompleteResultView::GetCollapsedSize() {
184 return gfx::Size(icon_bounds_.right() + LocationBarView::kItemPadding +
185 ellipsis_width_ + LocationBarView::kItemPadding, height());
186 }
187
188 gfx::Size AutocompleteResultView::GetPreferredSize() {
189 return gfx::Size(0, std::max(
190 default_icon_size_ + (kMinimumIconVerticalPadding * 2),
191 GetTextHeight() + (kMinimumTextVerticalPadding * 2)));
192 }
193
194 std::string AutocompleteResultView::GetClassName() const {
195 return kViewClassName;
196 }
197
179 //////////////////////////////////////////////////////////////////////////////// 198 ////////////////////////////////////////////////////////////////////////////////
180 // AutocompleteResultView, protected: 199 // AutocompleteResultView, protected:
181 200
182 void AutocompleteResultView::PaintMatch(gfx::Canvas* canvas, 201 void AutocompleteResultView::PaintMatch(gfx::Canvas* canvas,
183 const AutocompleteMatch& match, 202 const AutocompleteMatch& match,
184 int x) { 203 int x) {
185 x = DrawString(canvas, match.contents, match.contents_class, false, x, 204 x = DrawString(canvas, match.contents, match.contents_class, false, x,
186 text_bounds_.y()); 205 text_bounds_.y());
187 206
188 // Paint the description. 207 // Paint the description.
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 // ellipsis we'll append to it, or 505 // ellipsis we'll append to it, or
487 // * It is also bold, in which case we don't want to fall back 506 // * It is also bold, in which case we don't want to fall back
488 // to a normal ellipsis anyway (see comment above). 507 // to a normal ellipsis anyway (see comment above).
489 } 508 }
490 } 509 }
491 510
492 // We couldn't draw anything. 511 // We couldn't draw anything.
493 runs->clear(); 512 runs->clear();
494 } 513 }
495 514
496 gfx::Size AutocompleteResultView::GetPreferredSize() {
497 return gfx::Size(0, std::max(
498 default_icon_size_ + (kMinimumIconVerticalPadding * 2),
499 GetTextHeight() + (kMinimumTextVerticalPadding * 2)));
500 }
501
502 void AutocompleteResultView::Layout() { 515 void AutocompleteResultView::Layout() {
503 const SkBitmap* icon = GetIcon(); 516 const SkBitmap* icon = GetIcon();
504 icon_bounds_.SetRect(LocationBarView::kEdgeItemPadding + 517 icon_bounds_.SetRect(LocationBarView::kEdgeItemPadding +
505 ((icon->width() == default_icon_size_) ? 518 ((icon->width() == default_icon_size_) ?
506 0 : LocationBarView::kIconInternalPadding), 519 0 : LocationBarView::kIconInternalPadding),
507 (height() - icon->height()) / 2, icon->width(), icon->height()); 520 (height() - icon->height()) / 2, icon->width(), icon->height());
508 521
509 int text_x = LocationBarView::kEdgeItemPadding + default_icon_size_ + 522 int text_x = LocationBarView::kEdgeItemPadding + default_icon_size_ +
510 LocationBarView::kItemPadding; 523 LocationBarView::kItemPadding;
511 int text_height = GetTextHeight(); 524 int text_height = GetTextHeight();
512 text_bounds_.SetRect(text_x, std::max(0, (height() - text_height) / 2), 525 text_bounds_.SetRect(text_x, std::max(0, (height() - text_height) / 2),
513 std::max(bounds().width() - text_x - LocationBarView::kEdgeItemPadding, 526 std::max(bounds().width() - text_x - LocationBarView::kEdgeItemPadding,
514 0), text_height); 527 0), text_height);
515 } 528 }
516 529
517 void AutocompleteResultView::OnPaint(gfx::Canvas* canvas) { 530 void AutocompleteResultView::OnPaint(gfx::Canvas* canvas) {
518 const ResultViewState state = GetState(); 531 const ResultViewState state = GetState();
519 if (state != NORMAL) 532 if (state != NORMAL)
520 canvas->AsCanvasSkia()->drawColor(GetColor(state, BACKGROUND)); 533 canvas->AsCanvasSkia()->drawColor(GetColor(state, BACKGROUND));
521 534
522 // Paint the icon. 535 // Paint the icon.
523 canvas->DrawBitmapInt(*GetIcon(), GetMirroredXForRect(icon_bounds_), 536 canvas->DrawBitmapInt(*GetIcon(), GetMirroredXForRect(icon_bounds_),
524 icon_bounds_.y()); 537 icon_bounds_.y());
525 538
526 // Paint the text. 539 // Paint the text.
527 int x = GetMirroredXForRect(text_bounds_); 540 int x = GetMirroredXForRect(text_bounds_);
528 mirroring_context_->Initialize(x, text_bounds_.width()); 541 mirroring_context_->Initialize(x, text_bounds_.width());
529 PaintMatch(canvas, match_, x); 542 PaintMatch(canvas, match_, x);
530 } 543 }
544
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698