Commit dd50e17d authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Account for separators when clipping the favicon.

The clip is inset by the separator opacities, which means the favicon bounds
animate as the separator fades.  It's possible crossfading would look better,
but it's not clear (and that's harder to implement).

This also makes a few other minor changes:
* Use kSeparatorThickness in tab_strip.cc for consistency
* Try to improve comments
* Use a lambda when computing separator colors to avoid repetition
* Ignore subsequent tab hover value for leading separator.  This is technically
  more correct; in practice it would only be visible if the bounds animation
  were slow enough that you could have a preceding tab still animating back into
  position (thus not covering the leading separator) while hovering a subsequent
  tab.  Since that's not really possible, this is mostly just to make the code
  easier to reason about.

Bug: none
Change-Id: I37eceae6c3b12a3730a0706853fc8cc1526c16c4
Reviewed-on: https://chromium-review.googlesource.com/1121785
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572067}
parent b3c30047
This diff is collapsed.
...@@ -54,6 +54,10 @@ class Tab : public gfx::AnimationDelegate, ...@@ -54,6 +54,10 @@ class Tab : public gfx::AnimationDelegate,
// The Tab's class name. // The Tab's class name.
static const char kViewClassName[]; static const char kViewClassName[];
// Under refresh, thickness in DIPs of the separator painted on the left and
// right edges of the tab.
static constexpr int kSeparatorThickness = 1;
Tab(TabController* controller, gfx::AnimationContainer* container); Tab(TabController* controller, gfx::AnimationContainer* container);
~Tab() override; ~Tab() override;
...@@ -218,6 +222,13 @@ class Tab : public gfx::AnimationDelegate, ...@@ -218,6 +222,13 @@ class Tab : public gfx::AnimationDelegate,
FRIEND_TEST_ALL_PREFIXES(TabStripTest, FRIEND_TEST_ALL_PREFIXES(TabStripTest,
TabCloseButtonVisibilityWhenNotStacked); TabCloseButtonVisibilityWhenNotStacked);
// Contains values 0..1 representing the opacity of the corresponding
// separators. These are physical and not logical, so "left" is the left
// separator in both LTR and RTL.
struct SeparatorOpacities {
float left = 0, right = 0;
};
// Invoked from Layout to adjust the position of the favicon or alert // Invoked from Layout to adjust the position of the favicon or alert
// indicator for pinned tabs. The visual_width parameter is how wide the // indicator for pinned tabs. The visual_width parameter is how wide the
// icon looks (rather than how wide the bounds are). // icon looks (rather than how wide the bounds are).
...@@ -266,6 +277,11 @@ class Tab : public gfx::AnimationDelegate, ...@@ -266,6 +277,11 @@ class Tab : public gfx::AnimationDelegate,
// pinned tab. // pinned tab.
bool ShouldRenderAsNormalTab() const; bool ShouldRenderAsNormalTab() const;
// Returns the opacities of the separators. If |for_layout| is true, returns
// the "layout" opacities, which ignore the effects of surrounding tabs' hover
// effects and consider only the current tab's state.
SeparatorOpacities GetSeparatorOpacities(bool for_layout) const;
// Gets the throb value for the tab. When a tab is not selected the active // Gets the throb value for the tab. When a tab is not selected the active
// background is drawn at GetThrobValue() * 100%. This is used for hover, mini // background is drawn at GetThrobValue() * 100%. This is used for hover, mini
// tab title change and pulsing. // tab title change and pulsing.
......
...@@ -1352,7 +1352,8 @@ void TabStrip::OnPaint(gfx::Canvas* canvas) { ...@@ -1352,7 +1352,8 @@ void TabStrip::OnPaint(gfx::Canvas* canvas) {
float separator_height = Tab::GetTabSeparatorHeight(); float separator_height = Tab::GetTabSeparatorHeight();
gfx::RectF separator_bounds( gfx::RectF separator_bounds(
new_tab_button_bounds_.x() - Tab::GetCornerRadius(), new_tab_button_bounds_.x() - Tab::GetCornerRadius(),
(height() - separator_height) / 2, 1, separator_height); (height() - separator_height) / 2, Tab::kSeparatorThickness,
separator_height);
cc::PaintFlags flags; cc::PaintFlags flags;
flags.setAntiAlias(true); flags.setAntiAlias(true);
flags.setColor(GetTabSeparatorColor()); flags.setColor(GetTabSeparatorColor());
......
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