| OLD | NEW |
| 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/autocomplete/autocomplete_popup_contents_view.
h" | 5 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.
h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <commctrl.h> | 8 #include <commctrl.h> |
| 9 #include <dwmapi.h> | 9 #include <dwmapi.h> |
| 10 #include <objidl.h> | 10 #include <objidl.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 15 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 16 #include "chrome/browser/instant/instant_confirm_dialog.h" | 16 #include "chrome/browser/instant/instant_confirm_dialog.h" |
| 17 #include "chrome/browser/instant/promo_counter.h" | 17 #include "chrome/browser/instant/promo_counter.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/themes/theme_service.h" | 19 #include "chrome/browser/themes/theme_service.h" |
| 20 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 20 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 21 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view.h" | 21 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view.h" |
| 22 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 22 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 23 #include "grit/chromium_strings.h" | 23 #include "grit/chromium_strings.h" |
| 24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 25 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
| 26 #include "third_party/skia/include/core/SkShader.h" | 26 #include "third_party/skia/include/core/SkShader.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
| 29 #include "ui/base/theme_provider.h" | 29 #include "ui/base/theme_provider.h" |
| 30 #include "ui/gfx/canvas_skia.h" | 30 #include "ui/gfx/canvas.h" |
| 31 #include "ui/gfx/insets.h" | 31 #include "ui/gfx/insets.h" |
| 32 #include "ui/gfx/path.h" | 32 #include "ui/gfx/path.h" |
| 33 #include "ui/views/bubble/bubble_border.h" | 33 #include "ui/views/bubble/bubble_border.h" |
| 34 #include "ui/views/controls/button/text_button.h" | 34 #include "ui/views/controls/button/text_button.h" |
| 35 #include "ui/views/controls/label.h" | 35 #include "ui/views/controls/label.h" |
| 36 #include "ui/views/layout/grid_layout.h" | 36 #include "ui/views/layout/grid_layout.h" |
| 37 #include "ui/views/layout/layout_constants.h" | 37 #include "ui/views/layout/layout_constants.h" |
| 38 #include "ui/views/painter.h" | 38 #include "ui/views/painter.h" |
| 39 #include "ui/views/widget/widget.h" | 39 #include "ui/views/widget/widget.h" |
| 40 #include "unicode/ubidi.h" | 40 #include "unicode/ubidi.h" |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 } | 509 } |
| 510 | 510 |
| 511 void AutocompletePopupContentsView::OnMouseExited( | 511 void AutocompletePopupContentsView::OnMouseExited( |
| 512 const views::MouseEvent& event) { | 512 const views::MouseEvent& event) { |
| 513 model_->SetHoveredLine(AutocompletePopupModel::kNoMatch); | 513 model_->SetHoveredLine(AutocompletePopupModel::kNoMatch); |
| 514 } | 514 } |
| 515 | 515 |
| 516 //////////////////////////////////////////////////////////////////////////////// | 516 //////////////////////////////////////////////////////////////////////////////// |
| 517 // AutocompletePopupContentsView, protected: | 517 // AutocompletePopupContentsView, protected: |
| 518 | 518 |
| 519 void AutocompletePopupContentsView::PaintResultViews(gfx::CanvasSkia* canvas) { | 519 void AutocompletePopupContentsView::PaintResultViews(gfx::Canvas* canvas) { |
| 520 canvas->sk_canvas()->drawColor(AutocompleteResultView::GetColor( | 520 canvas->sk_canvas()->drawColor(AutocompleteResultView::GetColor( |
| 521 AutocompleteResultView::NORMAL, AutocompleteResultView::BACKGROUND)); | 521 AutocompleteResultView::NORMAL, AutocompleteResultView::BACKGROUND)); |
| 522 View::PaintChildren(canvas); | 522 View::PaintChildren(canvas); |
| 523 } | 523 } |
| 524 | 524 |
| 525 int AutocompletePopupContentsView::CalculatePopupHeight() { | 525 int AutocompletePopupContentsView::CalculatePopupHeight() { |
| 526 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size()); | 526 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size()); |
| 527 int popup_height = 0; | 527 int popup_height = 0; |
| 528 for (size_t i = 0; i < model_->result().size(); ++i) | 528 for (size_t i = 0; i < model_->result().size(); ++i) |
| 529 popup_height += child_at(i)->GetPreferredSize().height(); | 529 popup_height += child_at(i)->GetPreferredSize().height(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 546 // We paint our children in an unconventional way. | 546 // We paint our children in an unconventional way. |
| 547 // | 547 // |
| 548 // Because the border of this view creates an anti-aliased round-rect region | 548 // Because the border of this view creates an anti-aliased round-rect region |
| 549 // for the contents, we need to render our rectangular result child views into | 549 // for the contents, we need to render our rectangular result child views into |
| 550 // this round rect region. We can't use a simple clip because clipping is | 550 // this round rect region. We can't use a simple clip because clipping is |
| 551 // 1-bit and we get nasty jagged edges. | 551 // 1-bit and we get nasty jagged edges. |
| 552 // | 552 // |
| 553 // Instead, we paint all our children into a second canvas and use that as a | 553 // Instead, we paint all our children into a second canvas and use that as a |
| 554 // shader to fill a path representing the round-rect clipping region. This | 554 // shader to fill a path representing the round-rect clipping region. This |
| 555 // yields a nice anti-aliased edge. | 555 // yields a nice anti-aliased edge. |
| 556 gfx::CanvasSkia contents_canvas(size(), true); | 556 gfx::Canvas contents_canvas(size(), true); |
| 557 PaintResultViews(&contents_canvas); | 557 PaintResultViews(&contents_canvas); |
| 558 | 558 |
| 559 // We want the contents background to be slightly transparent so we can see | 559 // We want the contents background to be slightly transparent so we can see |
| 560 // the blurry glass effect on DWM systems behind. We do this _after_ we paint | 560 // the blurry glass effect on DWM systems behind. We do this _after_ we paint |
| 561 // the children since they paint text, and GDI will reset this alpha data if | 561 // the children since they paint text, and GDI will reset this alpha data if |
| 562 // we paint text after this call. | 562 // we paint text after this call. |
| 563 MakeCanvasTransparent(&contents_canvas); | 563 MakeCanvasTransparent(&contents_canvas); |
| 564 | 564 |
| 565 // Now paint the contents of the contents canvas into the actual canvas. | 565 // Now paint the contents of the contents canvas into the actual canvas. |
| 566 SkPaint paint; | 566 SkPaint paint; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 opt_in_view_ = NULL; | 705 opt_in_view_ = NULL; |
| 706 PromoCounter* counter = profile_->GetInstantPromoCounter(); | 706 PromoCounter* counter = profile_->GetInstantPromoCounter(); |
| 707 DCHECK(counter); | 707 DCHECK(counter); |
| 708 counter->Hide(); | 708 counter->Hide(); |
| 709 if (opt_in) { | 709 if (opt_in) { |
| 710 browser::ShowInstantConfirmDialogIfNecessary( | 710 browser::ShowInstantConfirmDialogIfNecessary( |
| 711 location_bar_->GetWidget()->GetNativeWindow(), profile_); | 711 location_bar_->GetWidget()->GetNativeWindow(), profile_); |
| 712 } | 712 } |
| 713 UpdatePopupAppearance(); | 713 UpdatePopupAppearance(); |
| 714 } | 714 } |
| OLD | NEW |