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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "chrome/browser/search/search.h" | 9 #include "chrome/browser/search/search.h" |
10 #include "chrome/browser/themes/theme_properties.h" | 10 #include "chrome/browser/themes/theme_properties.h" |
11 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 11 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
13 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" | 13 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" |
14 #include "ui/base/theme_provider.h" | 14 #include "ui/base/theme_provider.h" |
| 15 #include "ui/compositor/clip_transform_recorder.h" |
15 #include "ui/compositor/paint_context.h" | 16 #include "ui/compositor/paint_context.h" |
| 17 #include "ui/compositor/paint_recorder.h" |
16 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
17 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
18 #include "ui/gfx/path.h" | 20 #include "ui/gfx/path.h" |
19 #include "ui/resources/grit/ui_resources.h" | 21 #include "ui/resources/grit/ui_resources.h" |
20 #include "ui/views/controls/image_view.h" | 22 #include "ui/views/controls/image_view.h" |
21 #include "ui/views/view_targeter.h" | 23 #include "ui/views/view_targeter.h" |
22 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
23 #include "ui/views/window/non_client_view.h" | 25 #include "ui/views/window/non_client_view.h" |
24 | 26 |
25 namespace { | 27 namespace { |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 // Bottom border. | 415 // Bottom border. |
414 canvas->TileImageInt(*bottom_shadow_, 0, height() - bottom_shadow_->height(), | 416 canvas->TileImageInt(*bottom_shadow_, 0, height() - bottom_shadow_->height(), |
415 width(), bottom_shadow_->height()); | 417 width(), bottom_shadow_->height()); |
416 } | 418 } |
417 | 419 |
418 void OmniboxPopupContentsView::PaintChildren(const ui::PaintContext& context) { | 420 void OmniboxPopupContentsView::PaintChildren(const ui::PaintContext& context) { |
419 gfx::Rect contents_bounds = GetContentsBounds(); | 421 gfx::Rect contents_bounds = GetContentsBounds(); |
420 contents_bounds.Inset(0, views::NonClientFrameView::kClientEdgeThickness, 0, | 422 contents_bounds.Inset(0, views::NonClientFrameView::kClientEdgeThickness, 0, |
421 bottom_shadow_->height() - kBorderInterior); | 423 bottom_shadow_->height() - kBorderInterior); |
422 | 424 |
423 gfx::Canvas* canvas = context.canvas(); | 425 ui::ClipTransformRecorder clip_transform_recorder(context); |
424 canvas->Save(); | 426 clip_transform_recorder.ClipRect(contents_bounds); |
425 canvas->ClipRect(contents_bounds); | 427 { |
426 canvas->DrawColor(result_view_at(0)->GetColor(OmniboxResultView::NORMAL, | 428 ui::PaintRecorder recorder(context); |
427 OmniboxResultView::BACKGROUND)); | 429 SkColor background_color = result_view_at(0)->GetColor( |
| 430 OmniboxResultView::NORMAL, OmniboxResultView::BACKGROUND); |
| 431 recorder.canvas()->DrawColor(background_color); |
| 432 } |
428 View::PaintChildren(context); | 433 View::PaintChildren(context); |
429 canvas->Restore(); | |
430 } | 434 } |
431 | 435 |
432 //////////////////////////////////////////////////////////////////////////////// | 436 //////////////////////////////////////////////////////////////////////////////// |
433 // OmniboxPopupContentsView, private: | 437 // OmniboxPopupContentsView, private: |
434 | 438 |
435 views::View* OmniboxPopupContentsView::TargetForRect(views::View* root, | 439 views::View* OmniboxPopupContentsView::TargetForRect(views::View* root, |
436 const gfx::Rect& rect) { | 440 const gfx::Rect& rect) { |
437 CHECK_EQ(root, this); | 441 CHECK_EQ(root, this); |
438 return this; | 442 return this; |
439 } | 443 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 size_t index = GetIndexForPoint(event.location()); | 483 size_t index = GetIndexForPoint(event.location()); |
480 if (!HasMatchAt(index)) | 484 if (!HasMatchAt(index)) |
481 return; | 485 return; |
482 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, | 486 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, |
483 GURL(), base::string16(), index); | 487 GURL(), base::string16(), index); |
484 } | 488 } |
485 | 489 |
486 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { | 490 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { |
487 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); | 491 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); |
488 } | 492 } |
OLD | NEW |