Commit 7ef0274c authored by siyua's avatar siyua Committed by Commit Bot

[AF][Status Chip] Fix PageActionIconView::UpdateBorder()

Currently it overrides the function in IconLabelBubbleViews(), but the
base class method is called in constructor, so the derived class method
is never called in this case. Calling virtual method in constructor
should be avoided.

Therefore change the function simply to a private function.

Bug: 932818
Change-Id: I790ade09db63bb4c90843722cc3a23ee5525c434
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636288Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Commit-Queue: Siyu An <siyua@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665263}
parent 8101a5e7
...@@ -213,16 +213,6 @@ bool IconLabelBubbleView::IsBubbleShowing() const { ...@@ -213,16 +213,6 @@ bool IconLabelBubbleView::IsBubbleShowing() const {
return false; return false;
} }
void IconLabelBubbleView::UpdateBorder() {
// Bubbles are given the full internal height of the location bar so that all
// child views in the location bar have the same height. The visible height of
// the bubble should be smaller, so use an empty border to shrink down the
// content bounds so the background gets painted correctly.
SetBorder(views::CreateEmptyBorder(
gfx::Insets(GetLayoutConstant(LOCATION_BAR_CHILD_INTERIOR_PADDING),
GetLayoutInsets(LOCATION_BAR_ICON_INTERIOR_PADDING).left())));
}
gfx::Size IconLabelBubbleView::CalculatePreferredSize() const { gfx::Size IconLabelBubbleView::CalculatePreferredSize() const {
// Height will be ignored by the LocationBarView. // Height will be ignored by the LocationBarView.
return GetSizeForLabelWidth(label()->GetPreferredSize().width()); return GetSizeForLabelWidth(label()->GetPreferredSize().width());
...@@ -511,3 +501,13 @@ void IconLabelBubbleView::UpdateHighlightPath() { ...@@ -511,3 +501,13 @@ void IconLabelBubbleView::UpdateHighlightPath() {
focus_ring()->SchedulePaint(); focus_ring()->SchedulePaint();
} }
} }
void IconLabelBubbleView::UpdateBorder() {
// Bubbles are given the full internal height of the location bar so that all
// child views in the location bar have the same height. The visible height of
// the bubble should be smaller, so use an empty border to shrink down the
// content bounds so the background gets painted correctly.
SetBorder(views::CreateEmptyBorder(
gfx::Insets(GetLayoutConstant(LOCATION_BAR_CHILD_INTERIOR_PADDING),
GetLayoutInsets(LOCATION_BAR_ICON_INTERIOR_PADDING).left())));
}
...@@ -122,9 +122,6 @@ class IconLabelBubbleView : public views::InkDropObserver, ...@@ -122,9 +122,6 @@ class IconLabelBubbleView : public views::InkDropObserver,
// prevent the bubble from reshowing on a mouse release. // prevent the bubble from reshowing on a mouse release.
virtual bool IsBubbleShowing() const; virtual bool IsBubbleShowing() const;
// Sets the border padding around this view.
virtual void UpdateBorder();
// views::LabelButton: // views::LabelButton:
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
void Layout() override; void Layout() override;
...@@ -217,6 +214,9 @@ class IconLabelBubbleView : public views::InkDropObserver, ...@@ -217,6 +214,9 @@ class IconLabelBubbleView : public views::InkDropObserver,
// bounds and the separator visibility. // bounds and the separator visibility.
void UpdateHighlightPath(); void UpdateHighlightPath();
// Sets the border padding around this view.
void UpdateBorder();
// The contents of the bubble. // The contents of the bubble.
SeparatorView* separator_view_; SeparatorView* separator_view_;
......
...@@ -50,6 +50,7 @@ PageActionIconView::PageActionIconView(CommandUpdater* command_updater, ...@@ -50,6 +50,7 @@ PageActionIconView::PageActionIconView(CommandUpdater* command_updater,
SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
// Only shows bubble after mouse is released. // Only shows bubble after mouse is released.
set_notify_action(NotifyAction::NOTIFY_ON_RELEASE); set_notify_action(NotifyAction::NOTIFY_ON_RELEASE);
UpdateBorder();
} }
PageActionIconView::~PageActionIconView() {} PageActionIconView::~PageActionIconView() {}
...@@ -178,12 +179,9 @@ void PageActionIconView::OnBoundsChanged(const gfx::Rect& previous_bounds) { ...@@ -178,12 +179,9 @@ void PageActionIconView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
void PageActionIconView::OnTouchUiChanged() { void PageActionIconView::OnTouchUiChanged() {
icon_size_ = GetLayoutConstant(LOCATION_BAR_ICON_SIZE); icon_size_ = GetLayoutConstant(LOCATION_BAR_ICON_SIZE);
UpdateIconImage(); UpdateIconImage();
IconLabelBubbleView::OnTouchUiChanged(); UpdateBorder();
} if (GetVisible())
PreferredSizeChanged();
void PageActionIconView::UpdateBorder() {
SetBorder(views::CreateEmptyBorder(
GetLayoutInsets(LOCATION_BAR_ICON_INTERIOR_PADDING)));
} }
void PageActionIconView::SetIconColor(SkColor icon_color) { void PageActionIconView::SetIconColor(SkColor icon_color) {
...@@ -211,3 +209,8 @@ void PageActionIconView::SetActiveInternal(bool active) { ...@@ -211,3 +209,8 @@ void PageActionIconView::SetActiveInternal(bool active) {
content::WebContents* PageActionIconView::GetWebContents() const { content::WebContents* PageActionIconView::GetWebContents() const {
return delegate_->GetWebContentsForPageActionIconView(); return delegate_->GetWebContentsForPageActionIconView();
} }
void PageActionIconView::UpdateBorder() {
SetBorder(views::CreateEmptyBorder(
GetLayoutInsets(LOCATION_BAR_ICON_INTERIOR_PADDING)));
}
...@@ -125,7 +125,6 @@ class PageActionIconView : public IconLabelBubbleView { ...@@ -125,7 +125,6 @@ class PageActionIconView : public IconLabelBubbleView {
// IconLabelBubbleView: // IconLabelBubbleView:
void OnBoundsChanged(const gfx::Rect& previous_bounds) override; void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
void OnTouchUiChanged() override; void OnTouchUiChanged() override;
void UpdateBorder() override;
// Updates the icon image after some state has changed. // Updates the icon image after some state has changed.
virtual void UpdateIconImage(); virtual void UpdateIconImage();
...@@ -143,6 +142,8 @@ class PageActionIconView : public IconLabelBubbleView { ...@@ -143,6 +142,8 @@ class PageActionIconView : public IconLabelBubbleView {
Delegate* delegate() const { return delegate_; } Delegate* delegate() const { return delegate_; }
private: private:
void UpdateBorder();
// The size of the icon image (excluding the ink drop). // The size of the icon image (excluding the ink drop).
int icon_size_ = GetLayoutConstant(LOCATION_BAR_ICON_SIZE); int icon_size_ = GetLayoutConstant(LOCATION_BAR_ICON_SIZE);
......
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