Skip to content

Commit

Permalink
Remove InkDropHost, since in practice all implementations used InkDro…
Browse files Browse the repository at this point in the history
…pHostView.

This removes a footgun, since InkDropHostView's View overrides provided a lot of
functionality that any InkDropHost implementation would want.

Also does various other cleanups:
* IWYU fixes
* Remove unnecessary qualifiers
* Reorder InkDropHostView declarations and definitions to match each other and
  be in a more logical order
* Initialize InkDropHostView members in declaration

Bug: none
Change-Id: Iaf067fbb6361324fbf2da1a82f6658a4b564775e
Reviewed-on: https://chromium-review.googlesource.com/c/1282216
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Mohsen Izadi <mohsen@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601387}
  • Loading branch information
pkasting authored and Commit Bot committed Oct 20, 2018
1 parent 29ae1a9 commit 816d9b6
Show file tree
Hide file tree
Showing 48 changed files with 203 additions and 267 deletions.
2 changes: 1 addition & 1 deletion ash/app_list/views/expand_arrow_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ ExpandArrowView::ExpandArrowView(ContentsView* contents_view,
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);

SetInkDropMode(InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);

SetAccessibleName(l10n_util::GetStringUTF16(IDS_APP_LIST_EXPAND_BUTTON));

Expand Down
2 changes: 1 addition & 1 deletion ash/app_list/views/suggestion_chip_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ SuggestionChipView::SuggestionChipView(const Params& params,
text_view_(new views::Label()),
assistant_style_(params.assistant_style) {
SetFocusBehavior(FocusBehavior::ALWAYS);
SetInkDropMode(InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);

// Set background blur for the chip and use mask layer to clip it into
// rounded rect.
Expand Down
2 changes: 1 addition & 1 deletion ash/assistant/ui/base/assistant_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ AssistantButton::AssistantButton(views::ButtonListener* listener)
views::ImageButton::ALIGN_MIDDLE);

// Ink drop.
SetInkDropMode(views::ImageButton::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);
set_has_ink_drop_action_on_click(true);
set_ink_drop_base_color(kInkDropBaseColor);
set_ink_drop_visible_opacity(kInkDropVisibleOpacity);
Expand Down
4 changes: 3 additions & 1 deletion ash/lock_screen_action/lock_screen_action_background_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ class LockScreenActionBackgroundView::NoteBackground
gfx::Point center = base::i18n::IsRTL() ? GetLocalBounds().origin()
: GetLocalBounds().top_right();
auto ink_drop_ripple = std::make_unique<views::FloodFillInkDropRipple>(
size(), gfx::Insets(), center, SK_ColorBLACK, 1);
size(), gfx::Insets(), center, GetInkDropBaseColor(), 1);
ink_drop_ripple->set_use_hide_transform_duration_for_hide_fade_out(true);
ink_drop_ripple->set_duration_factor(1.5);
return ink_drop_ripple;
}

SkColor GetInkDropBaseColor() const override { return SK_ColorBLACK; }

private:
views::InkDropObserver* observer_;

Expand Down
2 changes: 1 addition & 1 deletion ash/login/ui/login_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ LoginButton::LoginButton(views::ButtonListener* listener)
views::ImageButton::ALIGN_MIDDLE);
SetFocusPainter(views::Painter::CreateSolidFocusPainter(
kFocusBorderColor, kFocusBorderThickness, gfx::InsetsF()));
SetInkDropMode(InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);
set_has_ink_drop_action_on_click(true);
}

Expand Down
2 changes: 1 addition & 1 deletion ash/login/ui/login_expanded_public_account_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class SelectionButtonView : public LoginButton {
layer()->SetFillsBoundsOpaquely(false);
SetFocusBehavior(FocusBehavior::ALWAYS);
SetLayoutManager(std::make_unique<views::FillLayout>());
SetInkDropMode(InkDropHostView::InkDropMode::OFF);
SetInkDropMode(InkDropMode::OFF);

auto add_horizontal_margin = [&](int width,
views::View* parent) -> views::View* {
Expand Down
8 changes: 4 additions & 4 deletions ash/login/ui/login_pin_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
namespace ash {
namespace {

// Color of the ink drop ripple.
constexpr SkColor kInkDropRippleColor = SkColorSetARGB(0x0F, 0xFF, 0xFF, 0xFF);

// Color of the ink drop highlight.
constexpr SkColor kInkDropHighlightColor =
SkColorSetARGB(0x14, 0xFF, 0xFF, 0xFF);
Expand Down Expand Up @@ -154,7 +151,7 @@ class BasePinButton : public views::InkDropHostView {

return std::make_unique<views::FloodFillInkDropRipple>(
size(), GetLocalBounds().InsetsFrom(bounds),
GetInkDropCenterBasedOnLastEvent(), kInkDropRippleColor,
GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(),
1.f /*visible_opacity*/);
}
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
Expand All @@ -164,6 +161,9 @@ class BasePinButton : public views::InkDropHostView {
std::make_unique<views::CircleLayerDelegate>(kInkDropHighlightColor,
GetInkDropRadius()));
}
SkColor GetInkDropBaseColor() const override {
return SkColorSetA(SK_ColorWHITE, 0x0F);
}

int GetInkDropRadius() const { return kRippleSizeDp / 2; }

Expand Down
4 changes: 1 addition & 3 deletions ash/public/cpp/caption_buttons/frame_caption_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@ class ASH_PUBLIC_EXPORT FrameCaptionButton : public views::Button {
// Sets the alpha to use for painting. Used to animate visibility changes.
void SetAlpha(int alpha);

// views::View overrides:
// views::Button:
const char* GetClassName() const override;
void OnGestureEvent(ui::GestureEvent* event) override;
views::PaintInfo::ScaleType GetPaintScaleType() const override;

// views::InkDropHostView:
std::unique_ptr<views::InkDrop> CreateInkDrop() override;
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override;
Expand Down
1 change: 1 addition & 0 deletions ash/rotator/screen_rotation_animator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "base/run_loop.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/frame_sinks/copy_output_result.h"
#include "ui/compositor/layer_tree_owner.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/display/display.h"
#include "ui/display/manager/display_manager.h"
Expand Down
34 changes: 15 additions & 19 deletions ash/shelf/login_shelf_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,12 @@ class LoginShelfButton : public views::LabelButton {
kButtonBackgroundMarginBottomDp, kButtonBackgroundMarginRightDp);
}

// views::View:
// views::LabelButton:
gfx::Insets GetInsets() const override {
return gfx::Insets(kButtonMarginTopDp, kButtonMarginLeftDp,
kButtonMarginBottomDp, kButtonMarginRightDp);
}

// views::Button:
void PaintButtonContents(gfx::Canvas* canvas) override {
cc::PaintFlags flags;
flags.setAntiAlias(true);
Expand All @@ -171,7 +170,6 @@ class LoginShelfButton : public views::LabelButton {
canvas->DrawRoundRect(bounds, kButtonRoundedBorderRadiusDp, flags);
}

// views::InkDropHostView:
std::unique_ptr<views::InkDrop> CreateInkDrop() override {
auto ink_drop = std::make_unique<views::InkDropImpl>(this, size());
ink_drop->SetShowHighlightOnHover(false);
Expand Down Expand Up @@ -244,13 +242,12 @@ class KioskAppsButton : public views::MenuButton,
kButtonBackgroundMarginBottomDp, kButtonBackgroundMarginRightDp);
}

// views::View:
// views::MenuButton:
gfx::Insets GetInsets() const override {
return gfx::Insets(kButtonMarginTopDp, kButtonMarginLeftDp,
kButtonMarginBottomDp, kButtonMarginRightDp);
}

// views::Button:
void PaintButtonContents(gfx::Canvas* canvas) override {
cc::PaintFlags flags;
flags.setAntiAlias(true);
Expand All @@ -261,13 +258,24 @@ class KioskAppsButton : public views::MenuButton,
canvas->DrawRoundRect(bounds, kButtonRoundedBorderRadiusDp, flags);
}

// views::MenuButton:
void SetVisible(bool visible) override {
MenuButton::SetVisible(visible);
if (visible)
is_launch_enabled_ = true;
}

std::unique_ptr<views::InkDrop> CreateInkDrop() override {
auto ink_drop = std::make_unique<views::InkDropImpl>(this, size());
ink_drop->SetShowHighlightOnHover(false);
ink_drop->SetShowHighlightOnFocus(false);
return ink_drop;
}

std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override {
return std::make_unique<views::RoundRectInkDropMask>(
size(), GetBackgroundInsets(), kButtonRoundedBorderRadiusDp);
}

// views::MenuButtonListener:
void OnMenuButtonClicked(MenuButton* source,
const gfx::Point& point,
Expand All @@ -285,7 +293,7 @@ class KioskAppsButton : public views::MenuButton,
views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_NONE);
}

// ui::MenuModel:
// ui::SimpleMenuModel:
void ExecuteCommand(int command_id, int event_flags) override {
DCHECK(command_id >= 0 &&
base::checked_cast<size_t>(command_id) < kiosk_apps_.size());
Expand Down Expand Up @@ -313,18 +321,6 @@ class KioskAppsButton : public views::MenuButton,

bool IsCommandIdEnabled(int command_id) const override { return true; }

// views::InkDropHostView:
std::unique_ptr<views::InkDrop> CreateInkDrop() override {
auto ink_drop = std::make_unique<views::InkDropImpl>(this, size());
ink_drop->SetShowHighlightOnHover(false);
ink_drop->SetShowHighlightOnFocus(false);
return ink_drop;
}
std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override {
return std::make_unique<views::RoundRectInkDropMask>(
size(), GetBackgroundInsets(), kButtonRoundedBorderRadiusDp);
}

private:
std::unique_ptr<views::MenuRunner> menu_runner_;
std::vector<mojom::KioskAppInfoPtr> kiosk_apps_;
Expand Down
1 change: 1 addition & 0 deletions ash/shelf/shelf_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "ui/gfx/geometry/point.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/views/animation/bounds_animator.h"
#include "ui/views/animation/ink_drop.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/menu/menu_model_adapter.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/system/date/date_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void DateView::SetAction(DateAction action) {
// Disable |this| when not clickable so that the ripple is not shown.
SetEnabled(action_ != DateAction::NONE);
if (action_ != DateAction::NONE)
SetInkDropMode(views::InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);
}

void DateView::UpdateTextInternal(const base::Time& now) {
Expand Down
2 changes: 1 addition & 1 deletion ash/system/ime_menu/ime_list_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ImeListItemView : public ActionableView {
: ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS),
ime_list_view_(list_view),
selected_(selected) {
SetInkDropMode(InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);

TriView* tri_view = TrayPopupUtils::CreateDefaultRowView();
AddChildView(tri_view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/layer_tree_owner.h"
#include "ui/events/event_handler.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/insets.h"
Expand Down
1 change: 1 addition & 0 deletions ash/system/overview/overview_button_tray_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "services/ws/public/cpp/input_devices/input_device_client_test_api.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer_tree_owner.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/display/display_switches.h"
#include "ui/display/manager/display_manager.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/system/rotation/tray_rotation_lock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ RotationLockDefaultView::RotationLockDefaultView(SystemTrayItem* owner)

Update();

SetInkDropMode(InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);

SetVisible(IsTabletModeWindowManagerEnabled());
Shell::Get()->tablet_mode_controller()->AddObserver(this);
Expand Down
2 changes: 1 addition & 1 deletion ash/system/tray/hover_highlight_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ HoverHighlightView::HoverHighlightView(ViewClickListener* listener,
listener_(listener),
use_unified_theme_(use_unified_theme) {
set_notify_enter_exit_on_child(true);
SetInkDropMode(InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);
}

HoverHighlightView::~HoverHighlightView() = default;
Expand Down
4 changes: 2 additions & 2 deletions ash/system/tray/tray_info_label.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ void TrayInfoLabel::Update(int message_id) {
TrayPopupItemStyle::FontStyle font_style;

if (IsClickable()) {
SetInkDropMode(InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);
font_style = TrayPopupItemStyle::FontStyle::CLICKABLE_SYSTEM_INFO;
} else {
SetInkDropMode(InkDropHostView::InkDropMode::OFF);
SetInkDropMode(InkDropMode::OFF);
font_style = TrayPopupItemStyle::FontStyle::SYSTEM_INFO;
}

Expand Down
2 changes: 1 addition & 1 deletion ash/system/tray/tray_item_more.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TrayItemMore::TrayItemMore(SystemTrayItem* owner)
tri_view_->AddView(TriView::Container::CENTER, label_);
tri_view_->AddView(TriView::Container::END, more_);

SetInkDropMode(InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);
}

TrayItemMore::~TrayItemMore() = default;
Expand Down
2 changes: 1 addition & 1 deletion ash/system/tray_caps_lock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CapsLockDefaultView : public ActionableView {
TrayPopupItemStyle caption_style(TrayPopupItemStyle::FontStyle::CAPTION);
caption_style.SetupLabel(shortcut_label_);

SetInkDropMode(InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);

tri_view->AddView(TriView::Container::START, image);
tri_view->AddView(TriView::Container::CENTER, text_label_);
Expand Down
2 changes: 1 addition & 1 deletion ash/system/tray_tracing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class DefaultTracingView : public ActionableView {
image->SetImage(
gfx::CreateVectorIcon(kSystemMenuTracingIcon, style.GetIconColor()));

SetInkDropMode(InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);
}

~DefaultTracingView() override = default;
Expand Down
2 changes: 1 addition & 1 deletion ash/system/update/tray_update.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class TrayUpdate::UpdateView : public ActionableView {
style.SetupLabel(update_label_);
tri_view->AddView(TriView::Container::CENTER, update_label_);

SetInkDropMode(InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);
}

~UpdateView() override = default;
Expand Down
2 changes: 1 addition & 1 deletion ash/system/user/button_from_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ButtonFromView::ButtonFromView(views::View* content,
ink_drop_container_ = new views::InkDropContainerView();
AddChildView(ink_drop_container_);
SetLayoutManager(std::make_unique<views::FillLayout>());
SetInkDropMode(InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);
AddChildView(content_);
// Only make it focusable when we are active/interested in clicks.
if (listener)
Expand Down
1 change: 1 addition & 0 deletions ash/system/user/user_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/animation/ink_drop_mask.h"
#include "ui/views/animation/ink_drop_ripple.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "ui/display/types/display_constants.h"
#include "ui/events/event_constants.h"
#include "ui/events/test/event_generator.h"
#include "ui/views/animation/ink_drop.h"

namespace mojo {

Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/views/frame/hosted_app_menu_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/animation/ink_drop.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/window/hit_test_utils.h"
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/frame/hosted_app_menu_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class HostedAppMenuButton : public AppMenuButton,
const gfx::Point& point,
const ui::Event* event) override;

// InkDropHostView:
// AppMenuButton:
SkColor GetInkDropBaseColor() const override;

private:
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/hover_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ HoverButton::HoverButton(views::ButtonListener* button_listener,
DISTANCE_CONTROL_LIST_VERTICAL);
SetBorder(CreateBorderWithVerticalSpacing(vert_spacing));

SetInkDropMode(views::InkDropHostView::InkDropMode::ON);
SetInkDropMode(InkDropMode::ON);
}

HoverButton::HoverButton(views::ButtonListener* button_listener,
Expand Down
4 changes: 0 additions & 4 deletions chrome/browser/ui/views/hover_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,8 @@ class HoverButton : public views::MenuButton, public views::MenuButtonListener {
// views::MenuButton:
KeyClickAction GetKeyClickActionForEvent(const ui::KeyEvent& event) override;
void StateChanged(ButtonState old_state) override;

// views::InkDropHostView:
SkColor GetInkDropBaseColor() const override;
std::unique_ptr<views::InkDrop> CreateInkDrop() override;

// views::View:
void Layout() override;
views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override;
void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/views/location_bar/find_bar_icon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "chrome/grit/generated_resources.h"
#include "components/toolbar/vector_icons.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/animation/ink_drop.h"

FindBarIcon::FindBarIcon(Browser* browser,
PageActionIconView::Delegate* delegate)
Expand Down
Loading

0 comments on commit 816d9b6

Please sign in to comment.