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

Side by Side Diff: chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_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 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h" 5 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
10 #include "chrome/browser/instant/instant_confirm_dialog.h" 10 #include "chrome/browser/instant/instant_confirm_dialog.h"
11 #include "chrome/browser/instant/promo_counter.h" 11 #include "chrome/browser/instant/promo_counter.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/omnibox/omnibox_view.h" 13 #include "chrome/browser/ui/omnibox/omnibox_view.h"
14 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view.h" 14 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view.h"
15 #include "chrome/browser/ui/views/bubble/bubble_border.h" 15 #include "chrome/browser/ui/views/bubble/bubble_border.h"
16 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 16 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
17 #include "grit/chromium_strings.h" 17 #include "grit/chromium_strings.h"
18 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
19 #include "grit/theme_resources.h" 19 #include "grit/theme_resources.h"
20 #include "third_party/skia/include/core/SkShader.h" 20 #include "third_party/skia/include/core/SkShader.h"
21 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/base/theme_provider.h" 23 #include "ui/base/theme_provider.h"
24 #include "ui/gfx/canvas_skia.h" 24 #include "ui/gfx/canvas_skia.h"
25 #include "ui/gfx/insets.h" 25 #include "ui/gfx/insets.h"
26 #include "ui/gfx/path.h" 26 #include "ui/gfx/path.h"
27 #include "ui/gfx/rect.h"
27 #include "unicode/ubidi.h" 28 #include "unicode/ubidi.h"
28 #include "views/controls/button/text_button.h" 29 #include "views/controls/button/text_button.h"
29 #include "views/controls/label.h" 30 #include "views/controls/label.h"
30 #include "views/layout/grid_layout.h" 31 #include "views/layout/grid_layout.h"
31 #include "views/layout/layout_constants.h" 32 #include "views/layout/layout_constants.h"
32 #include "views/painter.h" 33 #include "views/painter.h"
33 #include "views/widget/widget.h" 34 #include "views/widget/widget.h"
34 35
35 #if defined(OS_WIN) 36 #if defined(OS_WIN)
36 #include <commctrl.h> 37 #include <commctrl.h>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } // namespace 136 } // namespace
136 137
137 class AutocompletePopupContentsView::AutocompletePopupWidget 138 class AutocompletePopupContentsView::AutocompletePopupWidget
138 : public views::Widget, 139 : public views::Widget,
139 public base::SupportsWeakPtr<AutocompletePopupWidget> { 140 public base::SupportsWeakPtr<AutocompletePopupWidget> {
140 public: 141 public:
141 AutocompletePopupWidget() {} 142 AutocompletePopupWidget() {}
142 virtual ~AutocompletePopupWidget() {} 143 virtual ~AutocompletePopupWidget() {}
143 144
144 private: 145 private:
145 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget); 146 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget);
146 }; 147 };
147 148
148 class AutocompletePopupContentsView::InstantOptInView 149 class AutocompletePopupContentsView::InstantOptInView
149 : public views::View, 150 : public views::View,
150 public views::ButtonListener { 151 public views::ButtonListener {
151 public: 152 public:
152 InstantOptInView(AutocompletePopupContentsView* contents_view, 153 InstantOptInView(AutocompletePopupContentsView* contents_view,
153 const gfx::Font& label_font, 154 const gfx::Font& label_font,
154 const gfx::Font& button_font) 155 const gfx::Font& button_font)
155 : contents_view_(contents_view), 156 : contents_view_(contents_view),
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 int current_height_delta = static_cast<int>( 267 int current_height_delta = static_cast<int>(
267 size_animation_.GetCurrentValue() * total_height_delta - 0.5); 268 size_animation_.GetCurrentValue() * total_height_delta - 0.5);
268 current_frame_bounds.set_height( 269 current_frame_bounds.set_height(
269 current_frame_bounds.height() + current_height_delta); 270 current_frame_bounds.height() + current_height_delta);
270 return current_frame_bounds; 271 return current_frame_bounds;
271 } 272 }
272 273
273 void AutocompletePopupContentsView::LayoutChildren() { 274 void AutocompletePopupContentsView::LayoutChildren() {
274 gfx::Rect contents_rect = GetContentsBounds(); 275 gfx::Rect contents_rect = GetContentsBounds();
275 int top = contents_rect.y(); 276 int top = contents_rect.y();
276 for (int i = 0; i < child_count(); ++i) { 277 size_t child_rv_count = child_count();
277 View* v = child_at(i); 278
278 if (v->IsVisible()) { 279 for (size_t i = 0; i < child_rv_count; i += 2) {
279 v->SetBounds(contents_rect.x(), top, contents_rect.width(), 280 View* result = child_at(i);
280 v->GetPreferredSize().height()); 281 if (!result->IsVisible())
281 top = v->bounds().bottom(); 282 continue;
283
284 AutocompleteResultView* keyword =
285 static_cast<AutocompleteResultView*>(child_at(i + 1));
286 if (keyword->IsVisible()) {
287 const float collapsed_width = static_cast<float>(
288 keyword->GetCollapsedSize().width() + LocationBarView::kItemPadding);
289 const float kw_collapsed_x = static_cast<float>(contents_rect.width() -
290 collapsed_width);
291 const int kw_x = static_cast<int>(kw_collapsed_x - ((kw_collapsed_x -
292 collapsed_width) * keyword_animations_[i / 2]->GetCurrentValue()));
293
294 result->SetBounds(contents_rect.x(), top, kw_x,
295 result->GetPreferredSize().height());
296 keyword->SetBounds(kw_x + LocationBarView::kItemPadding, top,
297 contents_rect.width() - (kw_x - LocationBarView::kItemPadding),
298 keyword->GetPreferredSize().height());
299 } else {
300 result->SetBounds(contents_rect.x(), top, contents_rect.width(),
301 result->GetPreferredSize().height());
282 } 302 }
303 top = result->bounds().bottom();
283 } 304 }
305
306 if (opt_in_view_ && opt_in_view_->IsVisible())
Peter Kasting 2011/07/27 20:18:25 How come we didn't use to have this? Was it an er
aaron.randolph 2011/07/28 16:01:55 The old loop adjusted all children, implicitly inc
307 opt_in_view_->SetBounds(contents_rect.x(), top, contents_rect.width(),
308 opt_in_view_->GetPreferredSize().height());
284 } 309 }
285 310
286 //////////////////////////////////////////////////////////////////////////////// 311 ////////////////////////////////////////////////////////////////////////////////
287 // AutocompletePopupContentsView, AutocompletePopupView overrides: 312 // AutocompletePopupContentsView, AutocompletePopupView overrides:
288 313
289 bool AutocompletePopupContentsView::IsOpen() const { 314 bool AutocompletePopupContentsView::IsOpen() const {
290 return (popup_ != NULL); 315 return (popup_ != NULL);
291 } 316 }
292 317
293 void AutocompletePopupContentsView::InvalidateLine(size_t line) { 318 void AutocompletePopupContentsView::InvalidateLine(size_t line) {
294 child_at(static_cast<int>(line))->SchedulePaint(); 319 child_at(static_cast<int>(line * 2))->SchedulePaint();
320 child_at(static_cast<int>(line * 2 + 1))->SchedulePaint();
321
322 if (line == model_->selected_line() && model_->keyword_selected()) {
Peter Kasting 2011/07/27 20:18:25 Nit: No need for {}
323 keyword_animations_[line]->Show();
324 } else {
325 keyword_animations_[line]->Hide();
326 }
295 } 327 }
296 328
297 void AutocompletePopupContentsView::UpdatePopupAppearance() { 329 void AutocompletePopupContentsView::UpdatePopupAppearance() {
298 if (model_->result().empty()) { 330 if (model_->result().empty()) {
299 // No matches, close any existing popup. 331 // No matches, close any existing popup.
300 if (popup_ != NULL) { 332 if (popup_ != NULL) {
301 size_animation_.Stop(); 333 size_animation_.Stop();
334
335 for (SlideAnimations::iterator i(keyword_animations_.begin());
336 i != keyword_animations_.end(); ++i)
337 (*i)->Stop();
338
302 // NOTE: Do NOT use CloseNow() here, as we may be deep in a callstack 339 // NOTE: Do NOT use CloseNow() here, as we may be deep in a callstack
303 // triggered by the popup receiving a message (e.g. LBUTTONUP), and 340 // triggered by the popup receiving a message (e.g. LBUTTONUP), and
304 // destroying the popup would cause us to read garbage when we unwind back 341 // destroying the popup would cause us to read garbage when we unwind back
305 // to that level. 342 // to that level.
306 popup_->Close(); // This will eventually delete the popup. 343 popup_->Close(); // This will eventually delete the popup.
307 popup_.reset(); 344 popup_.reset();
308 } 345 }
309 return; 346 return;
310 } 347 }
311 348
312 // Update the match cached by each row, in the process of doing so make sure 349 // Update the match cached by each row, in the process of doing so make sure
313 // we have enough row views. 350 // we have enough row views.
314 size_t child_rv_count = child_count(); 351 size_t child_rv_count = child_count();
315 if (opt_in_view_) { 352 if (opt_in_view_) {
316 DCHECK(child_rv_count > 0); 353 DCHECK(child_rv_count > 0);
317 child_rv_count--; 354 child_rv_count--;
318 } 355 }
319 for (size_t i = 0; i < model_->result().size(); ++i) { 356 const size_t result_size = model_->result().size();
320 AutocompleteResultView* result_view; 357 CreateCachedViews(child_rv_count, result_size * 2);
Peter Kasting 2011/07/27 20:18:25 Nit: It's always bugged me that we create child vi
aaron.randolph 2011/07/28 16:01:55 I agree. I'll make that change for the next updat
321 if (i >= child_rv_count) { 358 for (size_t i = 0; i < result_size; ++i) {
322 result_view = 359 const AutocompleteMatch& match = GetMatchAtIndex(i);
323 CreateResultView(this, i, result_font_, result_bold_font_); 360 AutocompleteResultView* view = static_cast<AutocompleteResultView*>(
324 AddChildViewAt(result_view, static_cast<int>(i)); 361 child_at(i * 2));
362 view->SetMatch(match);
363 view->SetVisible(true);
364
365 // Create a view and animation for an associated keyword, even if
366 // the match doesn't have a keyword.
367 view = static_cast<AutocompleteResultView*>(child_at(i * 2 + 1));
368 if (match.associated_keyword.get()) {
Peter Kasting 2011/07/27 20:18:25 Nit: Shorter: view->SetVisible(match.associat
369 view->SetMatch(*match.associated_keyword);
370 view->SetVisible(true);
325 } else { 371 } else {
326 result_view = static_cast<AutocompleteResultView*>(child_at(i)); 372 view->SetVisible(false);
327 result_view->SetVisible(true);
328 } 373 }
329 result_view->SetMatch(GetMatchAtIndex(i)); 374
375 if (keyword_animations_.size() <= i) {
376 ui::SlideAnimation* anim = new ui::SlideAnimation(this);
Peter Kasting 2011/07/27 20:18:25 Nit: Instead of using a ScopedVector and allocatin
377 anim->SetSlideDuration(500);
378 keyword_animations_.push_back(anim);
379 }
380 keyword_animations_[i]->Reset();
330 } 381 }
331 for (size_t i = model_->result().size(); i < child_rv_count; ++i) 382 for (size_t i = result_size * 2; i < child_rv_count; ++i)
332 child_at(i)->SetVisible(false); 383 child_at(i)->SetVisible(false);
333 384
334 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); 385 PromoCounter* counter = model_->profile()->GetInstantPromoCounter();
335 if (!opt_in_view_ && counter && counter->ShouldShow(base::Time::Now())) { 386 if (!opt_in_view_ && counter && counter->ShouldShow(base::Time::Now())) {
336 opt_in_view_ = new InstantOptInView(this, result_bold_font_, result_font_); 387 opt_in_view_ = new InstantOptInView(this, result_bold_font_, result_font_);
337 AddChildView(opt_in_view_); 388 AddChildView(opt_in_view_);
338 } else if (opt_in_view_ && (!counter || 389 } else if (opt_in_view_ && (!counter ||
339 !counter->ShouldShow(base::Time::Now()))) { 390 !counter->ShouldShow(base::Time::Now()))) {
340 delete opt_in_view_; 391 delete opt_in_view_;
341 opt_in_view_ = NULL; 392 opt_in_view_ = NULL;
(...skipping 26 matching lines...) Expand all
368 // Animate the popup shrinking, but don't animate growing larger since that 419 // Animate the popup shrinking, but don't animate growing larger since that
369 // would make the popup feel less responsive. 420 // would make the popup feel less responsive.
370 start_bounds_ = GetWidget()->GetWindowScreenBounds(); 421 start_bounds_ = GetWidget()->GetWindowScreenBounds();
371 if (target_bounds_.height() < start_bounds_.height()) 422 if (target_bounds_.height() < start_bounds_.height())
372 size_animation_.Show(); 423 size_animation_.Show();
373 else 424 else
374 start_bounds_ = target_bounds_; 425 start_bounds_ = target_bounds_;
375 popup_->SetBounds(GetPopupBounds()); 426 popup_->SetBounds(GetPopupBounds());
376 } 427 }
377 428
429 LayoutChildren();
Peter Kasting 2011/07/27 20:18:25 Is this call necessary? It seems like it ought no
aaron.randolph 2011/07/28 16:01:55 It's necessary so the result views will resize to
378 SchedulePaint(); 430 SchedulePaint();
379 } 431 }
380 432
433 void AutocompletePopupContentsView::CreateCachedViews(
434 size_t child_count,
435 size_t required_count) {
436 for (size_t i = child_count; i < required_count; ++i) {
437 AutocompleteResultView* result_view =
438 CreateResultView(this, i, result_font_, result_bold_font_);
439 AddChildViewAt(result_view, static_cast<int>(i));
440 }
441 }
442
381 gfx::Rect AutocompletePopupContentsView::GetTargetBounds() { 443 gfx::Rect AutocompletePopupContentsView::GetTargetBounds() {
382 return target_bounds_; 444 return target_bounds_;
383 } 445 }
384 446
385 void AutocompletePopupContentsView::PaintUpdatesNow() { 447 void AutocompletePopupContentsView::PaintUpdatesNow() {
386 // TODO(beng): remove this from the interface. 448 // TODO(beng): remove this from the interface.
387 } 449 }
388 450
389 void AutocompletePopupContentsView::OnDragCanceled() { 451 void AutocompletePopupContentsView::OnDragCanceled() {
390 ignore_mouse_drag_ = true; 452 ignore_mouse_drag_ = true;
391 } 453 }
392 454
393 //////////////////////////////////////////////////////////////////////////////// 455 ////////////////////////////////////////////////////////////////////////////////
394 // AutocompletePopupContentsView, AutocompleteResultViewModel implementation: 456 // AutocompletePopupContentsView, AutocompleteResultViewModel implementation:
395 457
396 bool AutocompletePopupContentsView::IsSelectedIndex(size_t index) const { 458 bool AutocompletePopupContentsView::IsSelectedIndex(size_t index) const {
397 return HasMatchAt(index) ? index == model_->selected_line() : false; 459 size_t selected_line = model_->selected_line() * 2;
460
461 if (model_->keyword_selected())
462 selected_line++;
463
464 return index == selected_line;
398 } 465 }
399 466
400 bool AutocompletePopupContentsView::IsHoveredIndex(size_t index) const { 467 bool AutocompletePopupContentsView::IsHoveredIndex(size_t index) const {
401 return HasMatchAt(index) ? index == model_->hovered_line() : false; 468 return index == model_->hovered_line() * 2;
402 } 469 }
403 470
404 const SkBitmap* AutocompletePopupContentsView::GetIconIfExtensionMatch( 471 const SkBitmap* AutocompletePopupContentsView::GetIconIfExtensionMatch(
405 size_t index) const { 472 size_t index) const {
406 if (!HasMatchAt(index)) 473 if (!HasMatchAt(index))
407 return NULL; 474 return NULL;
408 return model_->GetIconIfExtensionMatch(GetMatchAtIndex(index)); 475 return model_->GetIconIfExtensionMatch(GetMatchAtIndex(index));
409 } 476 }
410 477
411 //////////////////////////////////////////////////////////////////////////////// 478 ////////////////////////////////////////////////////////////////////////////////
412 // AutocompletePopupContentsView, AnimationDelegate implementation: 479 // AutocompletePopupContentsView, AnimationDelegate implementation:
413 480
414 void AutocompletePopupContentsView::AnimationProgressed( 481 void AutocompletePopupContentsView::AnimationProgressed(
415 const ui::Animation* animation) { 482 const ui::Animation* animation) {
416 // We should only be running the animation when the popup is already visible. 483 // We should only be running the animation when the popup is already visible.
417 DCHECK(popup_ != NULL); 484 DCHECK(popup_ != NULL);
418 popup_->SetBounds(GetPopupBounds()); 485 popup_->SetBounds(GetPopupBounds());
486
487 Layout();
419 } 488 }
420 489
421 //////////////////////////////////////////////////////////////////////////////// 490 ////////////////////////////////////////////////////////////////////////////////
422 // AutocompletePopupContentsView, views::View overrides: 491 // AutocompletePopupContentsView, views::View overrides:
423 492
424 void AutocompletePopupContentsView::Layout() { 493 void AutocompletePopupContentsView::Layout() {
425 UpdateBlurRegion(); 494 UpdateBlurRegion();
426 495
427 // Size our children to the available content area. 496 // Size our children to the available content area.
428 LayoutChildren(); 497 LayoutChildren();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 model_->SetHoveredLine(AutocompletePopupModel::kNoMatch); 571 model_->SetHoveredLine(AutocompletePopupModel::kNoMatch);
503 } 572 }
504 573
505 //////////////////////////////////////////////////////////////////////////////// 574 ////////////////////////////////////////////////////////////////////////////////
506 // AutocompletePopupContentsView, protected: 575 // AutocompletePopupContentsView, protected:
507 576
508 void AutocompletePopupContentsView::PaintResultViews(gfx::CanvasSkia* canvas) { 577 void AutocompletePopupContentsView::PaintResultViews(gfx::CanvasSkia* canvas) {
509 canvas->drawColor(AutocompleteResultView::GetColor( 578 canvas->drawColor(AutocompleteResultView::GetColor(
510 AutocompleteResultView::NORMAL, AutocompleteResultView::BACKGROUND)); 579 AutocompleteResultView::NORMAL, AutocompleteResultView::BACKGROUND));
511 View::PaintChildren(canvas); 580 View::PaintChildren(canvas);
581
582 // Draw dividing lines between results and keyword views
Peter Kasting 2011/07/27 20:18:25 Nit: Trailing period
583 SkPaint paint;
584 paint.setColor(AutocompleteResultView::GetColor(
585 AutocompleteResultView::NORMAL, AutocompleteResultView::DIMMED_TEXT));
586 paint.setStrokeWidth(SkIntToScalar(1));
587 paint.setAntiAlias(true);
588
589 for (size_t i = 0; i < model_->result().size(); ++i) {
590 views::View* kw_child = child_at(i * 2 + 1);
591 if (kw_child->IsVisible()) {
592 gfx::Rect bounds = kw_child->bounds();
593
594 canvas->drawLine(
Peter Kasting 2011/07/27 20:18:25 If I'm reading this right, it draws the line in th
595 SkIntToScalar(bounds.x()),
596 SkIntToScalar(bounds.y() +
597 LocationBarView::kNormalHorizontalEdgeThickness),
598 SkIntToScalar(bounds.x()),
599 SkIntToScalar(bounds.y() + bounds.height() -
600 LocationBarView::kNormalHorizontalEdgeThickness * 2),
601 paint);
602 }
603 }
512 } 604 }
513 605
514 int AutocompletePopupContentsView::CalculatePopupHeight() { 606 int AutocompletePopupContentsView::CalculatePopupHeight() {
515 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size()); 607 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size());
516 int popup_height = 0; 608 int popup_height = 0;
517 for (size_t i = 0; i < model_->result().size(); ++i) 609 for (size_t i = 0; i < model_->result().size(); ++i)
518 popup_height += child_at(i)->GetPreferredSize().height(); 610 popup_height += child_at(i)->GetPreferredSize().height();
519 return popup_height + 611 return popup_height +
520 (opt_in_view_ ? opt_in_view_->GetPreferredSize().height() : 0); 612 (opt_in_view_ ? opt_in_view_->GetPreferredSize().height() : 0);
521 } 613 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 void AutocompletePopupContentsView::OpenIndex( 730 void AutocompletePopupContentsView::OpenIndex(
639 size_t index, 731 size_t index,
640 WindowOpenDisposition disposition) { 732 WindowOpenDisposition disposition) {
641 if (!HasMatchAt(index)) 733 if (!HasMatchAt(index))
642 return; 734 return;
643 735
644 // OpenMatch() may close the popup, which will clear the result set and, by 736 // OpenMatch() may close the popup, which will clear the result set and, by
645 // extension, |match| and its contents. So copy the relevant match out to 737 // extension, |match| and its contents. So copy the relevant match out to
646 // make sure it stays alive until the call completes. 738 // make sure it stays alive until the call completes.
647 AutocompleteMatch match = model_->result().match_at(index); 739 AutocompleteMatch match = model_->result().match_at(index);
648 string16 keyword;
649 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword);
650 omnibox_view_->OpenMatch(match, disposition, GURL(), index, 740 omnibox_view_->OpenMatch(match, disposition, GURL(), index,
651 is_keyword_hint ? string16() : keyword); 741 match.keyword);
652 } 742 }
653 743
654 size_t AutocompletePopupContentsView::GetIndexForPoint( 744 size_t AutocompletePopupContentsView::GetIndexForPoint(
655 const gfx::Point& point) { 745 const gfx::Point& point) {
656 if (!HitTest(point)) 746 if (!HitTest(point))
657 return AutocompletePopupModel::kNoMatch; 747 return AutocompletePopupModel::kNoMatch;
658 748
659 int nb_match = model_->result().size(); 749 int nb_match = model_->result().size();
660 DCHECK(nb_match <= child_count()); 750 DCHECK(nb_match <= child_count());
661 for (int i = 0; i < nb_match; ++i) { 751 for (int i = 0; i < nb_match; ++i) {
662 views::View* child = child_at(i); 752 views::View* child = child_at(i * 2);
663 gfx::Point point_in_child_coords(point); 753 gfx::Point point_in_child_coords(point);
664 View::ConvertPointToView(this, child, &point_in_child_coords); 754 View::ConvertPointToView(this, child, &point_in_child_coords);
665 if (child->HitTest(point_in_child_coords)) 755 if (child->HitTest(point_in_child_coords))
666 return i; 756 return i;
667 } 757 }
668 return AutocompletePopupModel::kNoMatch; 758 return AutocompletePopupModel::kNoMatch;
669 } 759 }
670 760
671 gfx::Rect AutocompletePopupContentsView::CalculateTargetBounds(int h) { 761 gfx::Rect AutocompletePopupContentsView::CalculateTargetBounds(int h) {
672 gfx::Rect location_bar_bounds(location_bar_->GetContentsBounds()); 762 gfx::Rect location_bar_bounds(location_bar_->GetContentsBounds());
(...skipping 23 matching lines...) Expand all
696 opt_in_view_ = NULL; 786 opt_in_view_ = NULL;
697 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); 787 PromoCounter* counter = model_->profile()->GetInstantPromoCounter();
698 DCHECK(counter); 788 DCHECK(counter);
699 counter->Hide(); 789 counter->Hide();
700 if (opt_in) { 790 if (opt_in) {
701 browser::ShowInstantConfirmDialogIfNecessary( 791 browser::ShowInstantConfirmDialogIfNecessary(
702 location_bar_->GetWidget()->GetNativeWindow(), model_->profile()); 792 location_bar_->GetWidget()->GetNativeWindow(), model_->profile());
703 } 793 }
704 UpdatePopupAppearance(); 794 UpdatePopupAppearance();
705 } 795 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698