Commit 0467ba26 authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Add trivial highlight-path generators to chrome/

Removes manual highlight-path setting for bookmarks_bar_view.cc and
custom_tab_bar_view.cc.

Bug: chromium:1007546
Change-Id: I6023231a9f8ae9871b00e673dda4647d11328240
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1842499Reviewed-by: default avatarTaylor Bergquist <tbergquist@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703434}
parent cf13aac9
......@@ -98,11 +98,11 @@
#include "ui/views/controls/button/label_button_border.h"
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/button/menu_button_controller.h"
#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/controls/label.h"
#include "ui/views/drag_utils.h"
#include "ui/views/metrics.h"
#include "ui/views/style/platform_style.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/view_constants.h"
#include "ui/views/widget/tooltip_manager.h"
#include "ui/views/widget/widget.h"
......@@ -147,16 +147,6 @@ gfx::ImageSkia* GetImageSkiaNamed(int id) {
return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id);
}
// Set the highlight path for inkdrops and focus rings.
void SetBookmarkHighlightPath(views::View* host_view) {
auto path = std::make_unique<SkPath>();
const int radius = ChromeLayoutProvider::Get()->GetCornerRadiusMetric(
views::EMPHASIS_MAXIMUM, host_view->size());
path->addRoundRect(gfx::RectToSkRect(gfx::Rect(host_view->size())), radius,
radius);
host_view->SetProperty(views::kHighlightPathKey, path.release());
}
std::unique_ptr<views::InkDrop> CreateBookmarkButtonInkDrop(
std::unique_ptr<views::InkDropImpl> ink_drop) {
ink_drop->SetShowHighlightOnFocus(!views::PlatformStyle::kPreferFocusRings);
......@@ -182,6 +172,7 @@ class BookmarkButtonBase : public views::LabelButton {
: LabelButton(listener, title) {
SetImageLabelSpacing(ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_RELATED_LABEL_HORIZONTAL_LIST));
views::InstallPillHighlightPathGenerator(this);
SetInkDropMode(InkDropMode::ON);
set_has_ink_drop_action_on_click(true);
set_ink_drop_visible_opacity(kToolbarInkDropVisibleOpacity);
......@@ -207,11 +198,6 @@ class BookmarkButtonBase : public views::LabelButton {
}
// LabelButton:
void OnBoundsChanged(const gfx::Rect& previous_bounds) override {
SetBookmarkHighlightPath(this);
LabelButton::OnBoundsChanged(previous_bounds);
}
std::unique_ptr<views::InkDrop> CreateInkDrop() override {
return CreateBookmarkButtonInkDrop(CreateDefaultFloodFillInkDropImpl());
}
......@@ -318,16 +304,12 @@ class BookmarkMenuButtonBase : public views::MenuButton {
: MenuButton(title, menu_button_listener) {
SetImageLabelSpacing(ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_RELATED_LABEL_HORIZONTAL_LIST));
views::InstallPillHighlightPathGenerator(this);
SetInkDropMode(InkDropMode::ON);
set_ink_drop_visible_opacity(kToolbarInkDropVisibleOpacity);
}
// MenuButton:
void OnBoundsChanged(const gfx::Rect& previous_bounds) override {
SetBookmarkHighlightPath(this);
MenuButton::OnBoundsChanged(previous_bounds);
}
std::unique_ptr<views::InkDrop> CreateInkDrop() override {
return CreateBookmarkButtonInkDrop(CreateDefaultFloodFillInkDropImpl());
}
......
......@@ -36,6 +36,7 @@
#include "ui/views/background.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/image_button_factory.h"
#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/layout/flex_layout_types.h"
......@@ -77,10 +78,7 @@ std::unique_ptr<views::ImageButton> CreateCloseButton(
gfx::Insets(GetLayoutConstant(LOCATION_BAR_CHILD_INTERIOR_PADDING))));
close_button->SizeToPreferredSize();
// Use a circular ink drop.
auto highlight_path = std::make_unique<SkPath>();
highlight_path->addOval(gfx::RectToSkRect(gfx::Rect(close_button->size())));
close_button->SetProperty(views::kHighlightPathKey, highlight_path.release());
views::InstallCircleHighlightPathGenerator(close_button.get());
return close_button;
}
......
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