Skip to content

Commit

Permalink
Revert "cros: blur ChromeOS system context menu backrgound"
Browse files Browse the repository at this point in the history
This reverts commit e137b66.

Reason for revert: This change may cause the crash: go/crash/f6d17889235dca20

Original change's description:
> cros: blur ChromeOS system context menu backrgound
>
> This cl makes a blurry background for ChromeOS system context menu.
>
> To enable background blur, we should paint the content of system context
> menu to layer. However, since MenuScrollViewContainer uses BubbleBorder,
> its layer contains the regions of menu contents, border, and border
> shadow. In order to only blur the contents region, we should separate
> the contents from the border and move the contents to a background view.
> The the background blur is applied to the background view.
>
> The final effects are shown in the bug comments.
>
> Bug: 1311843
> Change-Id: Ib17d03a34744cd0e586dbcc1913a858a89decd28
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3584784
> Reviewed-by: Scott Violet <sky@chromium.org>
> Commit-Queue: Xiaodan Zhu <zxdan@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#992716}

Bug: 1311843
Change-Id: I6ba58bba581f0e0aac823bf74ebc7815abc3e19a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3597773
Owners-Override: Prudhvikumar Bommana <pbommana@google.com>
Reviewed-by: Xiaodan Zhu <zxdan@chromium.org>
Commit-Queue: Srinivas Sista <srinivassista@chromium.org>
Auto-Submit: Srinivas Sista <srinivassista@chromium.org>
Cr-Commit-Position: refs/branch-heads/5005@{#58}
Cr-Branched-From: 5b4d945-refs/heads/main@{#992738}
  • Loading branch information
Xiaodan Zhu authored and Chromium LUCI CQ committed Apr 20, 2022
1 parent 66eea4d commit feb8b8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 53 deletions.
56 changes: 9 additions & 47 deletions ui/views/controls/menu/menu_scroll_view_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/rounded_corners_f.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/controls/menu/menu_config.h"
Expand All @@ -43,8 +40,6 @@ namespace views {
namespace {

static constexpr int kBorderPaddingDueToRoundedCorners = 1;
static constexpr float kBackgroundBlurSigma = 30.f;
static constexpr float kBackgroundBlurQuality = 0.33f;

// MenuScrollButton ------------------------------------------------------------

Expand Down Expand Up @@ -224,33 +219,21 @@ END_METADATA

MenuScrollViewContainer::MenuScrollViewContainer(SubmenuView* content_view)
: content_view_(content_view) {
background_view_ = AddChildView(std::make_unique<View>());

if (UseAshSystemUILayout()) {
// Enable background blur for ChromeOS system context menu.
background_view_->SetPaintToLayer();
auto* background_layer = background_view_->layer();
background_layer->SetFillsBoundsOpaquely(false);
background_layer->SetBackgroundBlur(kBackgroundBlurSigma);
background_layer->SetBackdropFilterQuality(kBackgroundBlurQuality);
}

auto* layout =
background_view_->SetLayoutManager(std::make_unique<views::FlexLayout>());
auto* layout = SetLayoutManager(std::make_unique<views::FlexLayout>());
layout->SetOrientation(views::LayoutOrientation::kVertical);

scroll_up_button_ = background_view_->AddChildView(
std::make_unique<MenuScrollButton>(content_view, true));
scroll_up_button_ =
AddChildView(std::make_unique<MenuScrollButton>(content_view, true));

scroll_view_ = background_view_->AddChildView(
std::make_unique<MenuScrollView>(content_view, this));
scroll_view_ =
AddChildView(std::make_unique<MenuScrollView>(content_view, this));
scroll_view_->SetProperty(
views::kFlexBehaviorKey,
views::FlexSpecification(views::MinimumFlexSizeRule::kScaleToMinimum,
views::MaximumFlexSizeRule::kUnbounded));

scroll_down_button_ = background_view_->AddChildView(
std::make_unique<MenuScrollButton>(content_view, false));
scroll_down_button_ =
AddChildView(std::make_unique<MenuScrollButton>(content_view, false));

arrow_ = BubbleBorderTypeFromAnchor(
content_view_->GetMenuItem()->GetMenuController()->GetAnchorPosition());
Expand Down Expand Up @@ -296,11 +279,6 @@ void MenuScrollViewContainer::OnPaintBackground(gfx::Canvas* canvas) {
return;
}

// ChromeOS system UI menu uses 'background_view_' to paint background.
if (UseAshSystemUILayout() && background_view_->background()) {
return;
}

gfx::Rect bounds(0, 0, width(), height());
ui::NativeTheme::ExtraParams extra;
const MenuConfig& menu_config = MenuConfig::instance();
Expand Down Expand Up @@ -342,8 +320,6 @@ void MenuScrollViewContainer::OnBoundsChanged(
if (footnote)
footnote->SetCornerRadius(any_scroll_button_visible ? 0 : corner_radius_);
InvalidateLayout();

background_view_->SetBoundsRect(GetContentsBounds());
}

void MenuScrollViewContainer::DidScrollToTop() {
Expand Down Expand Up @@ -444,16 +420,8 @@ void MenuScrollViewContainer::CreateBubbleBorder() {
}

corner_radius_ = bubble_border->corner_radius();
// If the menu uses Ash system UI layout, use `background_view` to build a
// blurry background. Otherwise, use default BubbleBackground.
if (use_ash_system_ui_layout) {
background_view_->layer()->SetRoundedCornerRadius(
gfx::RoundedCornersF(corner_radius_));
background_view_->SetBackground(CreateRoundedRectBackground(
bubble_border->background_color(), corner_radius_));
} else {
SetBackground(std::make_unique<BubbleBackground>(bubble_border.get()));
}

SetBackground(std::make_unique<BubbleBackground>(bubble_border.get()));
SetBorder(std::move(bubble_border));
}

Expand All @@ -474,12 +442,6 @@ BubbleBorder::Arrow MenuScrollViewContainer::BubbleBorderTypeFromAnchor(
}
}

bool MenuScrollViewContainer::UseAshSystemUILayout() const {
return content_view_->GetMenuItem()
->GetMenuController()
->use_ash_system_ui_layout();
}

BEGIN_METADATA(MenuScrollViewContainer, View)
END_METADATA

Expand Down
6 changes: 0 additions & 6 deletions ui/views/controls/menu/menu_scroll_view_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,8 @@ class MenuScrollViewContainer : public View {
// Returns the last item in the menu if it is of type HIGHLIGHTED.
MenuItemView* GetFootnote() const;

// Check if the menu uses Ash system UI layout.
bool UseAshSystemUILayout() const;

class MenuScrollView;

// The background view.
raw_ptr<View> background_view_;

// The scroll buttons.
raw_ptr<View> scroll_up_button_;
raw_ptr<View> scroll_down_button_;
Expand Down

0 comments on commit feb8b8d

Please sign in to comment.