Migrate BubbleBorder to use ui::ColorVariant
This is required to support ColorId for `BubbleDialogDelegate` and its related classes. Bug: b:261653838 Change-Id: I329ad051444d292c4dc082565bbe5bdb7db3a244 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6222179 Reviewed-by: Elly FJ <ellyjones@chromium.org> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org> Commit-Queue: Zoraiz Naeem <zoraiznaeem@chromium.org> Cr-Commit-Position: refs/heads/main@{#1417060}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
67295932ed
commit
0d20027475
ash/in_session_auth
chrome/browser
ash
arc
nearby_share
ui
views
chromeos/ash/experiences/arc/net
ui/views
@@ -392,8 +392,8 @@ AuthDialogContentsView::AuthDialogContentsView(
|
|||||||
auth_metadata_(auth_metadata) {
|
auth_metadata_(auth_metadata) {
|
||||||
SetLayoutManager(std::make_unique<views::FillLayout>());
|
SetLayoutManager(std::make_unique<views::FillLayout>());
|
||||||
auto border = std::make_unique<views::BubbleBorder>(
|
auto border = std::make_unique<views::BubbleBorder>(
|
||||||
views::BubbleBorder::FLOAT, views::BubbleBorder::STANDARD_SHADOW,
|
views::BubbleBorder::FLOAT, views::BubbleBorder::STANDARD_SHADOW);
|
||||||
ui::kColorPrimaryBackground);
|
border->SetColor(ui::kColorPrimaryBackground);
|
||||||
border->SetCornerRadius(kCornerRadius);
|
border->SetCornerRadius(kCornerRadius);
|
||||||
SetBackground(std::make_unique<views::BubbleBackground>(border.get()));
|
SetBackground(std::make_unique<views::BubbleBackground>(border.get()));
|
||||||
SetBorder(std::move(border));
|
SetBorder(std::move(border));
|
||||||
|
@@ -98,8 +98,8 @@ InSessionAuthDialogContentsView::InSessionAuthDialogContentsView(
|
|||||||
.SetCollapseMargins(true);
|
.SetCollapseMargins(true);
|
||||||
|
|
||||||
auto border = std::make_unique<views::BubbleBorder>(
|
auto border = std::make_unique<views::BubbleBorder>(
|
||||||
views::BubbleBorder::FLOAT, views::BubbleBorder::STANDARD_SHADOW,
|
views::BubbleBorder::FLOAT, views::BubbleBorder::STANDARD_SHADOW);
|
||||||
ui::kColorPrimaryBackground);
|
border->SetColor(ui::kColorPrimaryBackground);
|
||||||
border->SetCornerRadius(kCornerRadius);
|
border->SetCornerRadius(kCornerRadius);
|
||||||
SetBackground(std::make_unique<views::BubbleBackground>(border.get()));
|
SetBackground(std::make_unique<views::BubbleBackground>(border.get()));
|
||||||
SetBorder(std::move(border));
|
SetBorder(std::move(border));
|
||||||
|
@@ -42,8 +42,8 @@ ProgressBarDialogView::ProgressBarDialogView(bool is_multiple_files)
|
|||||||
constexpr int kCornerRadius = 12;
|
constexpr int kCornerRadius = 12;
|
||||||
|
|
||||||
auto border = std::make_unique<views::BubbleBorder>(
|
auto border = std::make_unique<views::BubbleBorder>(
|
||||||
views::BubbleBorder::NONE, views::BubbleBorder::STANDARD_SHADOW,
|
views::BubbleBorder::NONE, views::BubbleBorder::STANDARD_SHADOW);
|
||||||
ash::kColorAshDialogBackgroundColor);
|
border->SetColor(ash::kColorAshDialogBackgroundColor);
|
||||||
border->SetCornerRadius(kCornerRadius);
|
border->SetCornerRadius(kCornerRadius);
|
||||||
SetBackground(std::make_unique<views::BubbleBackground>(border.get()));
|
SetBackground(std::make_unique<views::BubbleBackground>(border.get()));
|
||||||
SetBorder(std::move(border));
|
SetBorder(std::move(border));
|
||||||
|
@@ -75,8 +75,8 @@ constexpr int kMaxPopupWebContentsTopYOverflow = 8;
|
|||||||
// Creates a border for a popup.
|
// Creates a border for a popup.
|
||||||
std::unique_ptr<views::Border> CreateBorder() {
|
std::unique_ptr<views::Border> CreateBorder() {
|
||||||
auto border = std::make_unique<views::BubbleBorder>(
|
auto border = std::make_unique<views::BubbleBorder>(
|
||||||
views::BubbleBorder::NONE, views::BubbleBorder::STANDARD_SHADOW,
|
views::BubbleBorder::NONE, views::BubbleBorder::STANDARD_SHADOW);
|
||||||
ui::kColorDropdownBackground);
|
border->SetColor(ui::kColorDropdownBackground);
|
||||||
border->SetCornerRadius(PopupBaseView::GetCornerRadius());
|
border->SetCornerRadius(PopupBaseView::GetCornerRadius());
|
||||||
border->set_md_shadow_elevation(
|
border->set_md_shadow_elevation(
|
||||||
ChromeLayoutProvider::Get()->GetShadowElevationMetric(
|
ChromeLayoutProvider::Get()->GetShadowElevationMetric(
|
||||||
|
@@ -289,8 +289,8 @@ FindBarView::FindBarView(FindBarHost* host) {
|
|||||||
views::ShapeContextTokens::kFindBarViewRadius);
|
views::ShapeContextTokens::kFindBarViewRadius);
|
||||||
{
|
{
|
||||||
auto border = std::make_unique<views::BubbleBorder>(
|
auto border = std::make_unique<views::BubbleBorder>(
|
||||||
views::BubbleBorder::NONE, views::BubbleBorder::STANDARD_SHADOW,
|
views::BubbleBorder::NONE, views::BubbleBorder::STANDARD_SHADOW);
|
||||||
kColorFindBarBackground);
|
border->SetColor(kColorFindBarBackground);
|
||||||
border->set_md_shadow_elevation(
|
border->set_md_shadow_elevation(
|
||||||
layout_provider->GetCornerRadiusMetric(views::Emphasis::kHigh));
|
layout_provider->GetCornerRadiusMetric(views::Emphasis::kHigh));
|
||||||
border->SetCornerRadius(corner_radius);
|
border->SetCornerRadius(corner_radius);
|
||||||
|
@@ -447,8 +447,8 @@ void SigninViewControllerDelegateViews::DisplayModal() {
|
|||||||
this, host_web_contents);
|
this, host_web_contents);
|
||||||
if (should_show_close_button_) {
|
if (should_show_close_button_) {
|
||||||
auto border = std::make_unique<views::BubbleBorder>(
|
auto border = std::make_unique<views::BubbleBorder>(
|
||||||
views::BubbleBorder::NONE, views::BubbleBorder::STANDARD_SHADOW,
|
views::BubbleBorder::NONE, views::BubbleBorder::STANDARD_SHADOW);
|
||||||
kColorProfilesReauthDialogBorder);
|
border->SetColor(kColorProfilesReauthDialogBorder);
|
||||||
GetBubbleFrameView()->SetBubbleBorder(std::move(border));
|
GetBubbleFrameView()->SetBubbleBorder(std::move(border));
|
||||||
}
|
}
|
||||||
constrained_window::ShowModalDialog(
|
constrained_window::ShowModalDialog(
|
||||||
|
@@ -93,8 +93,8 @@ PasspointDialogView::PasspointDialogView(
|
|||||||
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL));
|
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL));
|
||||||
|
|
||||||
auto border = std::make_unique<views::BubbleBorder>(
|
auto border = std::make_unique<views::BubbleBorder>(
|
||||||
views::BubbleBorder::NONE, views::BubbleBorder::STANDARD_SHADOW,
|
views::BubbleBorder::NONE, views::BubbleBorder::STANDARD_SHADOW);
|
||||||
ash::kColorAshDialogBackgroundColor);
|
border->SetColor(ash::kColorAshDialogBackgroundColor);
|
||||||
border->SetCornerRadius(kCornerRadius);
|
border->SetCornerRadius(kCornerRadius);
|
||||||
SetBackground(std::make_unique<views::BubbleBackground>(border.get()));
|
SetBackground(std::make_unique<views::BubbleBackground>(border.get()));
|
||||||
SetBorder(std::move(border));
|
SetBorder(std::move(border));
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include "cc/paint/paint_flags.h"
|
#include "cc/paint/paint_flags.h"
|
||||||
#include "third_party/skia/include/core/SkBlendMode.h"
|
#include "third_party/skia/include/core/SkBlendMode.h"
|
||||||
#include "third_party/skia/include/core/SkClipOp.h"
|
#include "third_party/skia/include/core/SkClipOp.h"
|
||||||
|
#include "third_party/skia/include/core/SkColor.h"
|
||||||
#include "third_party/skia/include/core/SkPath.h"
|
#include "third_party/skia/include/core/SkPath.h"
|
||||||
#include "third_party/skia/include/core/SkPoint.h"
|
#include "third_party/skia/include/core/SkPoint.h"
|
||||||
#include "third_party/skia/include/core/SkRRect.h"
|
#include "third_party/skia/include/core/SkRRect.h"
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
#include "third_party/skia/include/core/SkScalar.h"
|
#include "third_party/skia/include/core/SkScalar.h"
|
||||||
#include "ui/color/color_id.h"
|
#include "ui/color/color_id.h"
|
||||||
#include "ui/color/color_provider.h"
|
#include "ui/color/color_provider.h"
|
||||||
|
#include "ui/color/color_variant.h"
|
||||||
#include "ui/gfx/canvas.h"
|
#include "ui/gfx/canvas.h"
|
||||||
#include "ui/gfx/color_palette.h"
|
#include "ui/gfx/color_palette.h"
|
||||||
#include "ui/gfx/geometry/rect.h"
|
#include "ui/gfx/geometry/rect.h"
|
||||||
@@ -260,8 +262,8 @@ void DrawBorderAndShadowImpl(
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
BubbleBorder::BubbleBorder(Arrow arrow, Shadow shadow, ui::ColorId color_id)
|
BubbleBorder::BubbleBorder(Arrow arrow, Shadow shadow)
|
||||||
: arrow_(arrow), shadow_(shadow), color_id_(color_id) {
|
: arrow_(arrow), shadow_(shadow) {
|
||||||
DCHECK_LT(shadow_, SHADOW_COUNT);
|
DCHECK_LT(shadow_, SHADOW_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,9 +286,8 @@ void BubbleBorder::SetCornerRadius(int corner_radius) {
|
|||||||
corner_radius_ = corner_radius;
|
corner_radius_ = corner_radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BubbleBorder::SetColor(SkColor color) {
|
void BubbleBorder::SetColor(ui::ColorVariant color) {
|
||||||
requested_color_ = color;
|
color_ = color;
|
||||||
UpdateColor(nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& anchor_rect,
|
gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& anchor_rect,
|
||||||
@@ -502,7 +503,8 @@ gfx::Size BubbleBorder::GetMinimumSize() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BubbleBorder::OnViewThemeChanged(View* view) {
|
void BubbleBorder::OnViewThemeChanged(View* view) {
|
||||||
UpdateColor(view);
|
resolved_color_ = color_.ConvertToSkColor(view->GetColorProvider());
|
||||||
|
view->SchedulePaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Size BubbleBorder::GetSizeForContentsSize(
|
gfx::Size BubbleBorder::GetSizeForContentsSize(
|
||||||
@@ -689,16 +691,6 @@ bool BubbleBorder::ShouldDrawStroke() const {
|
|||||||
shadow_);
|
shadow_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BubbleBorder::UpdateColor(View* view) {
|
|
||||||
const SkColor computed_color =
|
|
||||||
view ? view->GetColorProvider()->GetColor(color_id_)
|
|
||||||
: gfx::kPlaceholderColor;
|
|
||||||
color_ = requested_color_.value_or(computed_color);
|
|
||||||
if (view) {
|
|
||||||
view->SchedulePaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BubbleBorder::PaintNoShadow(const View& view, gfx::Canvas* canvas) {
|
void BubbleBorder::PaintNoShadow(const View& view, gfx::Canvas* canvas) {
|
||||||
gfx::ScopedCanvas scoped(canvas);
|
gfx::ScopedCanvas scoped(canvas);
|
||||||
canvas->sk_canvas()->clipRRect(GetClientRect(view), SkClipOp::kDifference,
|
canvas->sk_canvas()->clipRRect(GetClientRect(view), SkClipOp::kDifference,
|
||||||
|
@@ -15,6 +15,8 @@
|
|||||||
#include "third_party/skia/include/core/SkRRect.h"
|
#include "third_party/skia/include/core/SkRRect.h"
|
||||||
#include "ui/base/metadata/base_type_conversion.h"
|
#include "ui/base/metadata/base_type_conversion.h"
|
||||||
#include "ui/color/color_id.h"
|
#include "ui/color/color_id.h"
|
||||||
|
#include "ui/color/color_variant.h"
|
||||||
|
#include "ui/gfx/color_palette.h"
|
||||||
#include "ui/gfx/geometry/insets.h"
|
#include "ui/gfx/geometry/insets.h"
|
||||||
#include "ui/gfx/geometry/rect.h"
|
#include "ui/gfx/geometry/rect.h"
|
||||||
#include "ui/gfx/geometry/rounded_corners_f.h"
|
#include "ui/gfx/geometry/rounded_corners_f.h"
|
||||||
@@ -111,9 +113,7 @@ class VIEWS_EXPORT BubbleBorder : public Border {
|
|||||||
// arrow if one is present.
|
// arrow if one is present.
|
||||||
static constexpr int kVisibleArrowBuffer = 12;
|
static constexpr int kVisibleArrowBuffer = 12;
|
||||||
|
|
||||||
BubbleBorder(Arrow arrow,
|
BubbleBorder(Arrow arrow, Shadow shadow);
|
||||||
Shadow shadow,
|
|
||||||
ui::ColorId color_id = ui::kColorDialogBackground);
|
|
||||||
|
|
||||||
BubbleBorder(const BubbleBorder&) = delete;
|
BubbleBorder(const BubbleBorder&) = delete;
|
||||||
BubbleBorder& operator=(const BubbleBorder&) = delete;
|
BubbleBorder& operator=(const BubbleBorder&) = delete;
|
||||||
@@ -192,8 +192,10 @@ class VIEWS_EXPORT BubbleBorder : public Border {
|
|||||||
Shadow shadow() const { return shadow_; }
|
Shadow shadow() const { return shadow_; }
|
||||||
|
|
||||||
// Get or set the color for the bubble and arrow body.
|
// Get or set the color for the bubble and arrow body.
|
||||||
void SetColor(SkColor color);
|
// Note: `color()` will not return updated color, until `OnViewThemeChanged()`
|
||||||
SkColor color() const { return color_; }
|
// is called.
|
||||||
|
SkColor color() const { return resolved_color_; }
|
||||||
|
void SetColor(ui::ColorVariant color);
|
||||||
|
|
||||||
// Sets a desired pixel distance between the arrow tip and the outside edge of
|
// Sets a desired pixel distance between the arrow tip and the outside edge of
|
||||||
// the neighboring border image. For example: |----offset----|
|
// the neighboring border image. For example: |----offset----|
|
||||||
@@ -299,10 +301,6 @@ class VIEWS_EXPORT BubbleBorder : public Border {
|
|||||||
// iff there is a visible shadow and it does not have a custom elevation.
|
// iff there is a visible shadow and it does not have a custom elevation.
|
||||||
bool ShouldDrawStroke() const;
|
bool ShouldDrawStroke() const;
|
||||||
|
|
||||||
// Sets `color_` appropriately, using `view` to obtain a ColorProvider.
|
|
||||||
// `view` may be null if `requested_color_` is set.
|
|
||||||
void UpdateColor(View* view);
|
|
||||||
|
|
||||||
// Paint for the NO_SHADOW shadow type. This just paints transparent pixels
|
// Paint for the NO_SHADOW shadow type. This just paints transparent pixels
|
||||||
// to make the window shape based on insets and GetBorderCornerRadius().
|
// to make the window shape based on insets and GetBorderCornerRadius().
|
||||||
void PaintNoShadow(const View& view, gfx::Canvas* canvas);
|
void PaintNoShadow(const View& view, gfx::Canvas* canvas);
|
||||||
@@ -329,9 +327,8 @@ class VIEWS_EXPORT BubbleBorder : public Border {
|
|||||||
std::optional<bool> draw_border_stroke_;
|
std::optional<bool> draw_border_stroke_;
|
||||||
Shadow shadow_;
|
Shadow shadow_;
|
||||||
std::optional<int> md_shadow_elevation_;
|
std::optional<int> md_shadow_elevation_;
|
||||||
ui::ColorId color_id_;
|
SkColor resolved_color_ = gfx::kPlaceholderColor;
|
||||||
std::optional<SkColor> requested_color_;
|
ui::ColorVariant color_{ui::kColorDialogBackground};
|
||||||
SkColor color_ = gfx::kPlaceholderColor;
|
|
||||||
bool avoid_shadow_overlap_ = false;
|
bool avoid_shadow_overlap_ = false;
|
||||||
std::optional<gfx::Insets> insets_;
|
std::optional<gfx::Insets> insets_;
|
||||||
};
|
};
|
||||||
|
@@ -824,6 +824,10 @@ bool BubbleFrameView::GetDisplayVisibleArrow() const {
|
|||||||
|
|
||||||
void BubbleFrameView::SetBackgroundColor(SkColor color) {
|
void BubbleFrameView::SetBackgroundColor(SkColor color) {
|
||||||
bubble_border_->SetColor(color);
|
bubble_border_->SetColor(color);
|
||||||
|
|
||||||
|
// Ensures that border updates the its color. See `BubbleBorder::color()` for
|
||||||
|
// more details.
|
||||||
|
bubble_border_->OnViewThemeChanged(this);
|
||||||
UpdateClientViewBackground();
|
UpdateClientViewBackground();
|
||||||
SchedulePaint();
|
SchedulePaint();
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include "ui/base/metadata/metadata_impl_macros.h"
|
#include "ui/base/metadata/metadata_impl_macros.h"
|
||||||
#include "ui/color/color_id.h"
|
#include "ui/color/color_id.h"
|
||||||
#include "ui/color/color_provider.h"
|
#include "ui/color/color_provider.h"
|
||||||
|
#include "ui/color/color_variant.h"
|
||||||
#include "ui/compositor/layer.h"
|
#include "ui/compositor/layer.h"
|
||||||
#include "ui/compositor/layer_tree_owner.h"
|
#include "ui/compositor/layer_tree_owner.h"
|
||||||
#include "ui/gfx/canvas.h"
|
#include "ui/gfx/canvas.h"
|
||||||
@@ -472,7 +473,10 @@ void MenuScrollViewContainer::CreateBubbleBorder() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
id = border_color_id_.value_or(id);
|
id = border_color_id_.value_or(id);
|
||||||
auto bubble_border = std::make_unique<BubbleBorder>(arrow_, shadow_type, id);
|
|
||||||
|
auto bubble_border = std::make_unique<BubbleBorder>(arrow_, shadow_type);
|
||||||
|
bubble_border->SetColor(id);
|
||||||
|
|
||||||
const MenuConfig& menu_config = MenuConfig::instance();
|
const MenuConfig& menu_config = MenuConfig::instance();
|
||||||
bubble_border->set_md_shadow_elevation(
|
bubble_border->set_md_shadow_elevation(
|
||||||
content_view_->GetMenuItem()->GetParentMenuItem()
|
content_view_->GetMenuItem()->GetParentMenuItem()
|
||||||
|
Reference in New Issue
Block a user