| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/autocomplete/autocomplete_popup_contents_view.h" | 5 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" |
| 6 | 6 |
| 7 #include "app/bidi_line_iterator.h" | 7 #include "app/bidi_line_iterator.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "app/theme_provider.h" | 10 #include "app/theme_provider.h" |
| 11 #include "app/text_elider.h" | 11 #include "app/text_elider.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 14 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 15 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 16 #include "chrome/browser/views/bubble_border.h" | 16 #include "chrome/browser/views/bubble_border.h" |
| 17 #include "chrome/browser/views/location_bar/location_bar_view.h" | 17 #include "chrome/browser/views/location_bar/location_bar_view.h" |
| 18 #include "gfx/canvas.h" | 18 #include "gfx/canvas.h" |
| 19 #include "gfx/canvas_skia.h" |
| 19 #include "gfx/color_utils.h" | 20 #include "gfx/color_utils.h" |
| 20 #include "gfx/insets.h" | 21 #include "gfx/insets.h" |
| 21 #include "gfx/path.h" | 22 #include "gfx/path.h" |
| 22 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 23 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
| 24 #include "third_party/skia/include/core/SkShader.h" | 25 #include "third_party/skia/include/core/SkShader.h" |
| 25 #include "third_party/icu/public/common/unicode/ubidi.h" | 26 #include "third_party/icu/public/common/unicode/ubidi.h" |
| 26 #include "views/widget/widget.h" | 27 #include "views/widget/widget.h" |
| 27 | 28 |
| 28 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 // We paint our children in an unconventional way. | 758 // We paint our children in an unconventional way. |
| 758 // | 759 // |
| 759 // Because the border of this view creates an anti-aliased round-rect region | 760 // Because the border of this view creates an anti-aliased round-rect region |
| 760 // for the contents, we need to render our rectangular result child views into | 761 // for the contents, we need to render our rectangular result child views into |
| 761 // this round rect region. We can't use a simple clip because clipping is | 762 // this round rect region. We can't use a simple clip because clipping is |
| 762 // 1-bit and we get nasty jagged edges. | 763 // 1-bit and we get nasty jagged edges. |
| 763 // | 764 // |
| 764 // Instead, we paint all our children into a second canvas and use that as a | 765 // Instead, we paint all our children into a second canvas and use that as a |
| 765 // shader to fill a path representing the round-rect clipping region. This | 766 // shader to fill a path representing the round-rect clipping region. This |
| 766 // yields a nice anti-aliased edge. | 767 // yields a nice anti-aliased edge. |
| 767 gfx::Canvas contents_canvas(width(), height(), true); | 768 gfx::CanvasSkia contents_canvas(width(), height(), true); |
| 768 contents_canvas.drawColor(GetColor(NORMAL, BACKGROUND)); | 769 contents_canvas.drawColor(GetColor(NORMAL, BACKGROUND)); |
| 769 View::PaintChildren(&contents_canvas); | 770 View::PaintChildren(contents_canvas.AsCanvas()); |
| 770 // We want the contents background to be slightly transparent so we can see | 771 // We want the contents background to be slightly transparent so we can see |
| 771 // the blurry glass effect on DWM systems behind. We do this _after_ we paint | 772 // the blurry glass effect on DWM systems behind. We do this _after_ we paint |
| 772 // the children since they paint text, and GDI will reset this alpha data if | 773 // the children since they paint text, and GDI will reset this alpha data if |
| 773 // we paint text after this call. | 774 // we paint text after this call. |
| 774 MakeCanvasTransparent(&contents_canvas); | 775 MakeCanvasTransparent(contents_canvas.AsCanvas()); |
| 775 | 776 |
| 776 // Now paint the contents of the contents canvas into the actual canvas. | 777 // Now paint the contents of the contents canvas into the actual canvas. |
| 777 SkPaint paint; | 778 SkPaint paint; |
| 778 paint.setAntiAlias(true); | 779 paint.setAntiAlias(true); |
| 779 | 780 |
| 780 SkShader* shader = SkShader::CreateBitmapShader( | 781 SkShader* shader = SkShader::CreateBitmapShader( |
| 781 contents_canvas.getDevice()->accessBitmap(false), | 782 contents_canvas.getDevice()->accessBitmap(false), |
| 782 SkShader::kClamp_TileMode, | 783 SkShader::kClamp_TileMode, |
| 783 SkShader::kClamp_TileMode); | 784 SkShader::kClamp_TileMode); |
| 784 paint.setShader(shader); | 785 paint.setShader(shader); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 DCHECK(nb_match <= GetChildViewCount()); | 964 DCHECK(nb_match <= GetChildViewCount()); |
| 964 for (int i = 0; i < nb_match; ++i) { | 965 for (int i = 0; i < nb_match; ++i) { |
| 965 views::View* child = GetChildViewAt(i); | 966 views::View* child = GetChildViewAt(i); |
| 966 gfx::Point point_in_child_coords(point); | 967 gfx::Point point_in_child_coords(point); |
| 967 View::ConvertPointToView(this, child, &point_in_child_coords); | 968 View::ConvertPointToView(this, child, &point_in_child_coords); |
| 968 if (child->HitTest(point_in_child_coords)) | 969 if (child->HitTest(point_in_child_coords)) |
| 969 return i; | 970 return i; |
| 970 } | 971 } |
| 971 return AutocompletePopupModel::kNoMatch; | 972 return AutocompletePopupModel::kNoMatch; |
| 972 } | 973 } |
| OLD | NEW |