diff options
author | wittman@chromium.org <wittman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-07 03:12:16 +0000 |
---|---|---|
committer | wittman@chromium.org <wittman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-07 03:12:16 +0000 |
commit | a62df1eb0aca499423473b447efe3a1af1e3f44f (patch) | |
tree | f1dadae3b8de491be443d0f6c999e299dcfb95c2 /ui/views/bubble | |
parent | 6daa272bf41ee745af05f7e76ad096a9b571bffe (diff) | |
download | chromium_src-a62df1eb0aca499423473b447efe3a1af1e3f44f.zip chromium_src-a62df1eb0aca499423473b447efe3a1af1e3f44f.tar.gz chromium_src-a62df1eb0aca499423473b447efe3a1af1e3f44f.tar.bz2 |
Render opaque border with no shadow for web contents modal dialogs under Views/Win32
This is a temporary kludge to get web contents modal dialog frames
displaying acceptably under Views/Win32. It's not possible to use
transparency in the frames on Win7 and earlier OSes unless the web
contents modal dialogs are top-level windows, which is undesirable.
Making web contents modal dialogs top-level imposes additional
complexities and burdens on managing focus, activation, and window
position relative to the browser window, soley for the View/Win32 case.
It's best to avoid this since we won't need it once we transition
to Aura.
See screenshots at http://crbug.com/231012#c6.
BUG=231012, 166075
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=198491
Review URL: https://chromiumcodereview.appspot.com/14742002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198604 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/bubble')
-rw-r--r-- | ui/views/bubble/bubble_border.cc | 4 | ||||
-rw-r--r-- | ui/views/bubble/bubble_border.h | 1 | ||||
-rw-r--r-- | ui/views/bubble/bubble_frame_view.cc | 40 |
3 files changed, 44 insertions, 1 deletions
diff --git a/ui/views/bubble/bubble_border.cc b/ui/views/bubble/bubble_border.cc index 1b6ceed..37a8eb1 100644 --- a/ui/views/bubble/bubble_border.cc +++ b/ui/views/bubble/bubble_border.cc @@ -112,6 +112,7 @@ BorderImages* GetBorderImages(BubbleBorder::Shadow shadow) { set = new BorderImages(kShadowImages, kShadowArrows, 0, 0, 3); break; case BubbleBorder::NO_SHADOW: + case BubbleBorder::NO_SHADOW_OPAQUE_BORDER: set = new BorderImages(kNoShadowImages, kNoShadowArrows, 6, 7, 4); break; case BubbleBorder::BIG_SHADOW: @@ -332,6 +333,9 @@ void BubbleBorder::DrawArrow(gfx::Canvas* canvas, } void BubbleBackground::Paint(gfx::Canvas* canvas, views::View* view) const { + if (border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER) + canvas->DrawColor(border_->background_color()); + // Clip out the client bounds to prevent overlapping transparent widgets. if (!border_->client_bounds().IsEmpty()) { SkRect client_rect(gfx::RectToSkRect(border_->client_bounds())); diff --git a/ui/views/bubble/bubble_border.h b/ui/views/bubble/bubble_border.h index 55e303d..f1b58c6 100644 --- a/ui/views/bubble/bubble_border.h +++ b/ui/views/bubble/bubble_border.h @@ -56,6 +56,7 @@ class VIEWS_EXPORT BubbleBorder : public Border { enum Shadow { SHADOW = 0, NO_SHADOW, + NO_SHADOW_OPAQUE_BORDER, BIG_SHADOW, SMALL_SHADOW, SHADOW_COUNT, diff --git a/ui/views/bubble/bubble_frame_view.cc b/ui/views/bubble/bubble_frame_view.cc index c1ae46d..07a8208 100644 --- a/ui/views/bubble/bubble_frame_view.cc +++ b/ui/views/bubble/bubble_frame_view.cc @@ -9,6 +9,7 @@ #include "grit/ui_resources.h" #include "ui/base/hit_test.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/path.h" #include "ui/gfx/screen.h" #include "ui/views/bubble/bubble_border.h" #include "ui/views/controls/button/label_button.h" @@ -96,7 +97,44 @@ int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { } void BubbleFrameView::GetWindowMask(const gfx::Size& size, - gfx::Path* window_mask) {} + gfx::Path* window_mask) { + if (bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER) + return; + + // Use a window mask roughly matching the border in the image assets. + + // Stroke size in pixels of borders in image assets. + static const int kBorderStrokeSize = 1; + + gfx::Insets border_insets = bubble_border_->GetInsets(); + SkRect rect = {SkIntToScalar(border_insets.left() - kBorderStrokeSize), + SkIntToScalar(border_insets.top() - kBorderStrokeSize), + SkIntToScalar(size.width() - border_insets.right() + + kBorderStrokeSize), + SkIntToScalar(size.height() - border_insets.bottom() + + kBorderStrokeSize)}; + + // Approximate rounded corners matching the border. + SkPoint polygon[] = { + {rect.left() + SkIntToScalar(2), rect.top()}, + {rect.left() + SkIntToScalar(1), rect.top() + SkIntToScalar(1)}, + {rect.left(), rect.top() + SkIntToScalar(2)}, + + {rect.left(), rect.bottom() - SkIntToScalar(3)}, + {rect.left() + SkIntToScalar(1), rect.bottom() - SkIntToScalar(2)}, + {rect.left() + SkIntToScalar(2), rect.bottom()}, + + {rect.right() - SkIntToScalar(3), rect.bottom()}, + {rect.right() - SkIntToScalar(1), rect.bottom() - SkIntToScalar(2)}, + {rect.right(), rect.bottom() - SkIntToScalar(3)}, + + {rect.right(), rect.top() + SkIntToScalar(2)}, + {rect.right() - SkIntToScalar(1), rect.top() + SkIntToScalar(1)}, + {rect.right() - SkIntToScalar(2), rect.top()} + }; + + window_mask->addPoly(polygon, sizeof(polygon)/sizeof(polygon[0]), true); +} void BubbleFrameView::ResetWindowControls() {} |