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

Side by Side Diff: chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc

Issue 201037: Fix small pixel glitches in omnibox dropdown corners.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
« no previous file with comments | « chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // 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/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/color_utils.h" 8 #include "app/gfx/color_utils.h"
9 #include "app/gfx/insets.h" 9 #include "app/gfx/insets.h"
10 #include "app/gfx/path.h" 10 #include "app/gfx/path.h"
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 575
576 class PopupBorder : public views::Border { 576 class PopupBorder : public views::Border {
577 public: 577 public:
578 PopupBorder() { 578 PopupBorder() {
579 InitClass(); 579 InitClass();
580 } 580 }
581 virtual ~PopupBorder() {} 581 virtual ~PopupBorder() {}
582 582
583 // Returns the border radius of the edge of the popup. 583 // Returns the border radius of the edge of the popup.
584 static int GetBorderRadius() { 584 static int GetBorderRadius() {
585 InitClass(); 585 // We can't safely calculate a border radius by comparing the sizes of the
586 return dropshadow_topleft_->width() - dropshadow_left_->width() - 1; 586 // side and corner images, because either may have been extended in various
587 // directions in order to do more subtle dropshadow fading or other effects.
588 // So we hardcode the most accurate value.
589 return 4;
587 } 590 }
588 591
589 // Overridden from views::Border: 592 // Overridden from views::Border:
590 virtual void Paint(const views::View& view, gfx::Canvas* canvas) const; 593 virtual void Paint(const views::View& view, gfx::Canvas* canvas) const;
591 virtual void GetInsets(gfx::Insets* insets) const; 594 virtual void GetInsets(gfx::Insets* insets) const;
592 595
593 private: 596 private:
594 // Border graphics. 597 // Border graphics.
595 static SkBitmap* dropshadow_left_; 598 static SkBitmap* dropshadow_left_;
596 static SkBitmap* dropshadow_topleft_; 599 static SkBitmap* dropshadow_topleft_;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 // AutocompletePopupContentsView, AnimationDelegate implementation: 835 // AutocompletePopupContentsView, AnimationDelegate implementation:
833 836
834 void AutocompletePopupContentsView::AnimationProgressed( 837 void AutocompletePopupContentsView::AnimationProgressed(
835 const Animation* animation) { 838 const Animation* animation) {
836 popup_->Show(); 839 popup_->Show();
837 } 840 }
838 841
839 //////////////////////////////////////////////////////////////////////////////// 842 ////////////////////////////////////////////////////////////////////////////////
840 // AutocompletePopupContentsView, views::View overrides: 843 // AutocompletePopupContentsView, views::View overrides:
841 844
842 void AutocompletePopupContentsView::PaintChildren(gfx::Canvas* canvas) { 845 void AutocompletePopupContentsView::Paint(gfx::Canvas* canvas) {
843 // We paint our children in an unconventional way. 846 // We paint our children in an unconventional way.
844 // 847 //
845 // Because the border of this view creates an anti-aliased round-rect region 848 // Because the border of this view creates an anti-aliased round-rect region
846 // for the contents, we need to render our rectangular result child views into 849 // for the contents, we need to render our rectangular result child views into
847 // this round rect region. We can't use a simple clip because clipping is 850 // this round rect region. We can't use a simple clip because clipping is
848 // 1-bit and we get nasty jagged edges. 851 // 1-bit and we get nasty jagged edges.
849 // 852 //
850 // Instead, we paint all our children into a second canvas and use that as a 853 // Instead, we paint all our children into a second canvas and use that as a
851 // shader to fill a path representing the round-rect clipping region. This 854 // shader to fill a path representing the round-rect clipping region. This
852 // yields a nice anti-aliased edge. 855 // yields a nice anti-aliased edge.
(...skipping 13 matching lines...) Expand all
866 SkShader* shader = SkShader::CreateBitmapShader( 869 SkShader* shader = SkShader::CreateBitmapShader(
867 contents_canvas.getDevice()->accessBitmap(false), 870 contents_canvas.getDevice()->accessBitmap(false),
868 SkShader::kClamp_TileMode, 871 SkShader::kClamp_TileMode,
869 SkShader::kClamp_TileMode); 872 SkShader::kClamp_TileMode);
870 paint.setShader(shader); 873 paint.setShader(shader);
871 shader->unref(); 874 shader->unref();
872 875
873 gfx::Path path; 876 gfx::Path path;
874 MakeContentsPath(&path, GetLocalBounds(false)); 877 MakeContentsPath(&path, GetLocalBounds(false));
875 canvas->drawPath(path, paint); 878 canvas->drawPath(path, paint);
879
880 // Now we paint the border, so it will be alpha-blended atop the contents.
881 // This looks slightly better in the corners than drawing the contents atop
882 // the border.
883 PaintBorder(canvas);
876 } 884 }
877 885
878 void AutocompletePopupContentsView::Layout() { 886 void AutocompletePopupContentsView::Layout() {
879 UpdateBlurRegion(); 887 UpdateBlurRegion();
880 888
881 // Size our children to the available content area. 889 // Size our children to the available content area.
882 gfx::Rect contents_rect = GetLocalBounds(false); 890 gfx::Rect contents_rect = GetLocalBounds(false);
883 int child_count = GetChildViewCount(); 891 int child_count = GetChildViewCount();
884 int top = contents_rect.y(); 892 int top = contents_rect.y();
885 for (int i = 0; i < child_count; ++i) { 893 for (int i = 0; i < child_count; ++i) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 // static 967 // static
960 AutocompletePopupView* AutocompletePopupView::CreatePopupView( 968 AutocompletePopupView* AutocompletePopupView::CreatePopupView(
961 const gfx::Font& font, 969 const gfx::Font& font,
962 AutocompleteEditView* edit_view, 970 AutocompleteEditView* edit_view,
963 AutocompleteEditModel* edit_model, 971 AutocompleteEditModel* edit_model,
964 Profile* profile, 972 Profile* profile,
965 AutocompletePopupPositioner* popup_positioner) { 973 AutocompletePopupPositioner* popup_positioner) {
966 return new AutocompletePopupContentsView(font, edit_view, edit_model, 974 return new AutocompletePopupContentsView(font, edit_view, edit_model,
967 profile, popup_positioner); 975 profile, popup_positioner);
968 } 976 }
OLDNEW
« no previous file with comments | « chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698