Commit 8de1e07f authored by Wei Li's avatar Wei Li Committed by Commit Bot

Use views border for ExtensionPopup

ExtensionPopup used native windows server to draw its border beforei
this change in the same way as Cocoa did. However, through hiding and
showing the bubble, the shadow was not reliably drawn. Now we change
to use views to draw its shadow. Other bubbles on Mac, as well as the
extension popup on Cocoa, will still use native windows server to draw
their shadows.

BUG=821739

Change-Id: Ie4fa4f4499e9feed1f266eb79ab878e7fee92ab4
Reviewed-on: https://chromium-review.googlesource.com/1003046Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Reviewed-by: default avatarLeonard Grey <lgrey@chromium.org>
Commit-Queue: Wei Li <weili@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549561}
parent fa5a991d
......@@ -44,7 +44,10 @@ ExtensionPopup::ExtensionPopup(extensions::ExtensionViewHost* host,
views::View* anchor_view,
views::BubbleBorder::Arrow arrow,
ShowAction show_action)
: BubbleDialogDelegateView(anchor_view, arrow), host_(host) {
: BubbleDialogDelegateView(anchor_view,
arrow,
views::BubbleBorder::SMALL_SHADOW),
host_(host) {
inspect_with_devtools_ = show_action == SHOW_AND_INSPECT;
set_margins(gfx::Insets());
SetLayoutManager(std::make_unique<views::FillLayout>());
......
......@@ -38,6 +38,10 @@ Widget* CreateBubbleWidget(BubbleDialogDelegateView* bubble) {
bubble_params.delegate = bubble;
bubble_params.opacity = Widget::InitParams::TRANSLUCENT_WINDOW;
bubble_params.accept_events = bubble->accept_events();
// Use a window default shadow if the bubble doesn't provides its own.
bubble_params.shadow_type = bubble->shadow() == BubbleBorder::NO_ASSETS
? Widget::InitParams::SHADOW_TYPE_DEFAULT
: Widget::InitParams::SHADOW_TYPE_NONE;
if (bubble->parent_window())
bubble_params.parent = bubble->parent_window();
else if (bubble->anchor_widget())
......@@ -219,14 +223,15 @@ BubbleDialogDelegateView::BubbleDialogDelegateView()
: BubbleDialogDelegateView(nullptr, BubbleBorder::TOP_LEFT) {}
BubbleDialogDelegateView::BubbleDialogDelegateView(View* anchor_view,
BubbleBorder::Arrow arrow)
BubbleBorder::Arrow arrow,
BubbleBorder::Shadow shadow)
: close_on_deactivate_(true),
anchor_view_tracker_(std::make_unique<ViewTracker>()),
anchor_widget_(nullptr),
arrow_(arrow),
mirror_arrow_in_rtl_(
ViewsDelegate::GetInstance()->ShouldMirrorArrowsInRTL()),
shadow_(BubbleBorder::DIALOG_SHADOW),
shadow_(shadow),
color_explicitly_set_(false),
accept_events_(true),
adjust_if_offscreen_(true),
......
......@@ -128,7 +128,13 @@ class VIEWS_EXPORT BubbleDialogDelegateView : public DialogDelegateView,
protected:
BubbleDialogDelegateView();
BubbleDialogDelegateView(View* anchor_view, BubbleBorder::Arrow arrow);
// |shadow| usually doesn't need to be explicitly set, just uses the default
// argument. Unless on Mac when the bubble needs to use Views base shadow,
// override it with suitable bubble border type.
BubbleDialogDelegateView(
View* anchor_view,
BubbleBorder::Arrow arrow,
BubbleBorder::Shadow shadow = BubbleBorder::DIALOG_SHADOW);
// Get bubble bounds from the anchor rect and client view's preferred size.
virtual gfx::Rect GetBubbleBounds();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment