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/omnibox/omnibox_popup_contents_view.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" |
6 | 6 |
7 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 7 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
9 #include "chrome/browser/ui/views/omnibox/omnibox_popup_non_view.h" | 9 #include "chrome/browser/ui/views/omnibox/omnibox_popup_non_view.h" |
10 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" | 10 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 return ui::ER_UNHANDLED; | 376 return ui::ER_UNHANDLED; |
377 } | 377 } |
378 return ui::ER_CONSUMED; | 378 return ui::ER_CONSUMED; |
379 } | 379 } |
380 | 380 |
381 //////////////////////////////////////////////////////////////////////////////// | 381 //////////////////////////////////////////////////////////////////////////////// |
382 // OmniboxPopupContentsView, protected: | 382 // OmniboxPopupContentsView, protected: |
383 | 383 |
384 void OmniboxPopupContentsView::PaintResultViews(gfx::Canvas* canvas) { | 384 void OmniboxPopupContentsView::PaintResultViews(gfx::Canvas* canvas) { |
385 canvas->DrawColor(OmniboxResultView::GetColor( | 385 canvas->DrawColor(OmniboxResultView::GetColor( |
386 OmniboxResultView::NORMAL, OmniboxResultView::BACKGROUND)); | 386 GetNativeTheme(), OmniboxResultView::NORMAL, |
| 387 OmniboxResultView::BACKGROUND)); |
387 View::PaintChildren(canvas); | 388 View::PaintChildren(canvas); |
388 } | 389 } |
389 | 390 |
390 int OmniboxPopupContentsView::CalculatePopupHeight() { | 391 int OmniboxPopupContentsView::CalculatePopupHeight() { |
391 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size()); | 392 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size()); |
392 int popup_height = 0; | 393 int popup_height = 0; |
393 for (size_t i = 0; i < model_->result().size(); ++i) | 394 for (size_t i = 0; i < model_->result().size(); ++i) |
394 popup_height += child_at(i)->GetPreferredSize().height(); | 395 popup_height += child_at(i)->GetPreferredSize().height(); |
395 return popup_height; | 396 return popup_height; |
396 } | 397 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 bb.hRgnBlur = popup_region.Get(); | 480 bb.hRgnBlur = popup_region.Get(); |
480 DwmEnableBlurBehindWindow(GetWidget()->GetNativeView(), &bb); | 481 DwmEnableBlurBehindWindow(GetWidget()->GetNativeView(), &bb); |
481 #endif | 482 #endif |
482 } | 483 } |
483 | 484 |
484 void OmniboxPopupContentsView::MakeCanvasTransparent(gfx::Canvas* canvas) { | 485 void OmniboxPopupContentsView::MakeCanvasTransparent(gfx::Canvas* canvas) { |
485 // Allow the window blur effect to show through the popup background. | 486 // Allow the window blur effect to show through the popup background. |
486 SkAlpha alpha = GetThemeProvider()->ShouldUseNativeFrame() ? | 487 SkAlpha alpha = GetThemeProvider()->ShouldUseNativeFrame() ? |
487 kGlassPopupAlpha : kOpaquePopupAlpha; | 488 kGlassPopupAlpha : kOpaquePopupAlpha; |
488 canvas->DrawColor(SkColorSetA( | 489 canvas->DrawColor(SkColorSetA( |
489 OmniboxResultView::GetColor(OmniboxResultView::NORMAL, | 490 OmniboxResultView::GetColor(GetNativeTheme(), OmniboxResultView::NORMAL, |
490 OmniboxResultView::BACKGROUND), alpha), SkXfermode::kDstIn_Mode); | 491 OmniboxResultView::BACKGROUND), alpha), SkXfermode::kDstIn_Mode); |
491 } | 492 } |
492 | 493 |
493 void OmniboxPopupContentsView::OpenIndex(size_t index, | 494 void OmniboxPopupContentsView::OpenIndex(size_t index, |
494 WindowOpenDisposition disposition) { | 495 WindowOpenDisposition disposition) { |
495 if (!HasMatchAt(index)) | 496 if (!HasMatchAt(index)) |
496 return; | 497 return; |
497 | 498 |
498 // OpenMatch() may close the popup, which will clear the result set and, by | 499 // OpenMatch() may close the popup, which will clear the result set and, by |
499 // extension, |match| and its contents. So copy the relevant match out to | 500 // extension, |match| and its contents. So copy the relevant match out to |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 if (HasMatchAt(index) && should_set_selected_line) | 551 if (HasMatchAt(index) && should_set_selected_line) |
551 model_->SetSelectedLine(index, false, false); | 552 model_->SetSelectedLine(index, false, false); |
552 } | 553 } |
553 | 554 |
554 void OmniboxPopupContentsView::OpenSelectedLine( | 555 void OmniboxPopupContentsView::OpenSelectedLine( |
555 const ui::LocatedEvent& event, | 556 const ui::LocatedEvent& event, |
556 WindowOpenDisposition disposition) { | 557 WindowOpenDisposition disposition) { |
557 size_t index = GetIndexForPoint(event.location()); | 558 size_t index = GetIndexForPoint(event.location()); |
558 OpenIndex(index, disposition); | 559 OpenIndex(index, disposition); |
559 } | 560 } |
OLD | NEW |