Commit 54ad211b authored by Connie Wan's avatar Connie Wan Committed by Commit Bot

Replace TabAnimationState Active/Open/Pinned enums with universal ones

This also disambiguates the Active, Open, and Pinned states from their -ness suffixed equivalents. The -ness versions are floats that are animation-specific -- TabAnimationState keeps track of the tweened values between 0 and 1. Most implementations only need to care about the binary non-suffixed versions.

For now this is just a find-and-replace and does not change any boolean APIs (e.g. https://cs.chromium.org/chromium/src/chrome/browser/ui/views/tabs/tab_strip.cc?l=982,1004-1005&rcl=1ad5374935374da746af65d05b41104c711fd5cc). There are many examples in tab_strip.cc where ternary operators could be removed if a boolean were converted into enum values. That is next on the list of refactors.

Bug: 966627
Change-Id: Icc2a0aaea0a06186d0bd3fefda645e97252968cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1764419
Commit-Queue: Connie Wan <connily@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Reviewed-by: default avatarTaylor Bergquist <tbergquist@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692182}
parent 0c9d1f5c
......@@ -4,17 +4,17 @@
#include "chrome/browser/ui/views/tabs/tab_animation_state.h"
#include "chrome/browser/ui/tabs/tab_types.h"
#include "chrome/browser/ui/views/tabs/tab_strip_layout_types.h"
#include "ui/gfx/animation/tween.h"
TabAnimationState TabAnimationState::ForIdealTabState(TabOpenness open,
TabPinnedness pinned,
TabActiveness active,
TabAnimationState TabAnimationState::ForIdealTabState(TabOpen open,
TabPinned pinned,
TabActive active,
int tab_index_offset) {
return TabAnimationState(open == TabOpenness::kOpen ? 1 : 0,
pinned == TabPinnedness::kPinned ? 1 : 0,
active == TabActiveness::kActive ? 1 : 0,
tab_index_offset);
return TabAnimationState(
open == TabOpen::kOpen ? 1 : 0, pinned == TabPinned::kPinned ? 1 : 0,
active == TabActive::kActive ? 1 : 0, tab_index_offset);
}
TabAnimationState TabAnimationState::Interpolate(float value,
......@@ -30,21 +30,19 @@ TabAnimationState TabAnimationState::Interpolate(float value,
target.normalized_leading_edge_x_));
}
TabAnimationState TabAnimationState::WithOpenness(TabOpenness open) const {
return TabAnimationState(open == TabOpenness::kOpen ? 1 : 0, pinnedness_,
TabAnimationState TabAnimationState::WithOpen(TabOpen open) const {
return TabAnimationState(open == TabOpen::kOpen ? 1 : 0, pinnedness_,
activeness_, normalized_leading_edge_x_);
}
TabAnimationState TabAnimationState::WithPinnedness(
TabPinnedness pinned) const {
return TabAnimationState(openness_, pinned == TabPinnedness::kPinned ? 1 : 0,
TabAnimationState TabAnimationState::WithPinned(TabPinned pinned) const {
return TabAnimationState(openness_, pinned == TabPinned::kPinned ? 1 : 0,
activeness_, normalized_leading_edge_x_);
}
TabAnimationState TabAnimationState::WithActiveness(
TabActiveness active) const {
TabAnimationState TabAnimationState::WithActive(TabActive active) const {
return TabAnimationState(openness_, pinnedness_,
active == TabActiveness::kActive ? 1 : 0,
active == TabActive::kActive ? 1 : 0,
normalized_leading_edge_x_);
}
......
......@@ -6,27 +6,22 @@
#define CHROME_BROWSER_UI_VIEWS_TABS_TAB_ANIMATION_STATE_H_
#include <vector>
#include "chrome/browser/ui/tabs/tab_types.h"
// Contains the data necessary to determine the bounds of a tab even while
// it's in the middle of animating between states. Immutable (except for
// replacement via assignment).
class TabAnimationState {
public:
enum class TabOpenness { kOpen, kClosed };
enum class TabPinnedness { kPinned, kUnpinned };
enum class TabActiveness { kActive, kInactive };
// Returns the TabAnimationState that expresses the provided
// ideal tab state. These correspond to the endpoints of animations.
// |open| controls whether the returned TabAnimationState is fully open or
// closed. |pinned| and |active| are analogous. |tab_index_offset| is the
// distance, in tab indices, away from its current model position the tab
// should be drawn at. It may be negative.
static TabAnimationState ForIdealTabState(TabOpenness open,
TabPinnedness pinned,
TabActiveness active,
static TabAnimationState ForIdealTabState(TabOpen open,
TabPinned pinned,
TabActive active,
int tab_index_offset);
// Interpolates from |origin| to |target| by |value|.
......@@ -40,9 +35,9 @@ class TabAnimationState {
float pinnedness() const { return pinnedness_; }
float activeness() const { return activeness_; }
TabAnimationState WithOpenness(TabOpenness open) const;
TabAnimationState WithPinnedness(TabPinnedness pinned) const;
TabAnimationState WithActiveness(TabActiveness active) const;
TabAnimationState WithOpen(TabOpen open) const;
TabAnimationState WithPinned(TabPinned pinned) const;
TabAnimationState WithActive(TabActive active) const;
int GetLeadingEdgeOffset(std::vector<int> tab_widths, int my_index) const;
......
......@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "chrome/browser/ui/tabs/tab_types.h"
#include "chrome/browser/ui/views/tabs/tab_animation_state.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -32,9 +33,7 @@ class TabAnimationTest : public testing::Test {
TEST_F(TabAnimationTest, StaticAnimationDoesNotChange) {
TabAnimationState static_state = TabAnimationState::ForIdealTabState(
TabAnimationState::TabOpenness::kOpen,
TabAnimationState::TabPinnedness::kUnpinned,
TabAnimationState::TabActiveness::kInactive, 0);
TabOpen::kOpen, TabPinned::kUnpinned, TabActive::kInactive, 0);
TabAnimation static_animation(static_state, base::BindOnce([]() {}));
EXPECT_EQ(kZeroDuration, static_animation.GetTimeRemaining());
......@@ -48,11 +47,8 @@ TEST_F(TabAnimationTest, StaticAnimationDoesNotChange) {
TEST_F(TabAnimationTest, AnimationAnimates) {
TabAnimationState initial_state = TabAnimationState::ForIdealTabState(
TabAnimationState::TabOpenness::kOpen,
TabAnimationState::TabPinnedness::kUnpinned,
TabAnimationState::TabActiveness::kInactive, 0);
TabAnimationState target_state =
initial_state.WithPinnedness(TabAnimationState::TabPinnedness::kPinned);
TabOpen::kOpen, TabPinned::kUnpinned, TabActive::kInactive, 0);
TabAnimationState target_state = initial_state.WithPinned(TabPinned::kPinned);
TabAnimation animation(initial_state, base::BindOnce([]() {}));
animation.AnimateTo(target_state);
......@@ -72,11 +68,8 @@ TEST_F(TabAnimationTest, AnimationAnimates) {
TEST_F(TabAnimationTest, CompletedAnimationSnapsToTarget) {
TabAnimationState initial_state = TabAnimationState::ForIdealTabState(
TabAnimationState::TabOpenness::kOpen,
TabAnimationState::TabPinnedness::kUnpinned,
TabAnimationState::TabActiveness::kInactive, 0);
TabAnimationState target_state =
initial_state.WithPinnedness(TabAnimationState::TabPinnedness::kPinned);
TabOpen::kOpen, TabPinned::kUnpinned, TabActive::kInactive, 0);
TabAnimationState target_state = initial_state.WithPinned(TabPinned::kPinned);
TabAnimation animation(initial_state, base::BindOnce([]() {}));
animation.AnimateTo(target_state);
......@@ -89,11 +82,8 @@ TEST_F(TabAnimationTest, CompletedAnimationSnapsToTarget) {
TEST_F(TabAnimationTest, ReplacedAnimationRestartsDuration) {
TabAnimationState initial_state = TabAnimationState::ForIdealTabState(
TabAnimationState::TabOpenness::kOpen,
TabAnimationState::TabPinnedness::kUnpinned,
TabAnimationState::TabActiveness::kInactive, 0);
TabAnimationState target_state =
initial_state.WithPinnedness(TabAnimationState::TabPinnedness::kPinned);
TabOpen::kOpen, TabPinned::kUnpinned, TabActive::kInactive, 0);
TabAnimationState target_state = initial_state.WithPinned(TabPinned::kPinned);
TabAnimation animation(initial_state, base::BindOnce([]() {}));
animation.AnimateTo(target_state);
......@@ -108,11 +98,8 @@ TEST_F(TabAnimationTest, ReplacedAnimationRestartsDuration) {
TEST_F(TabAnimationTest, RetargetedAnimationKeepsDuration) {
TabAnimationState initial_state = TabAnimationState::ForIdealTabState(
TabAnimationState::TabOpenness::kOpen,
TabAnimationState::TabPinnedness::kUnpinned,
TabAnimationState::TabActiveness::kInactive, 0);
TabAnimationState target_state =
initial_state.WithPinnedness(TabAnimationState::TabPinnedness::kPinned);
TabOpen::kOpen, TabPinned::kUnpinned, TabActive::kInactive, 0);
TabAnimationState target_state = initial_state.WithPinned(TabPinned::kPinned);
TabAnimation animation(initial_state, base::BindOnce([]() {}));
animation.AnimateTo(target_state);
......@@ -136,9 +123,7 @@ TEST_F(TabAnimationTest, TestNotifyCloseCompleted) {
bool was_closed_ = false;
};
TabAnimationState static_state = TabAnimationState::ForIdealTabState(
TabAnimationState::TabOpenness::kOpen,
TabAnimationState::TabPinnedness::kUnpinned,
TabAnimationState::TabActiveness::kInactive, 0);
TabOpen::kOpen, TabPinned::kUnpinned, TabActive::kInactive, 0);
TabClosedDetector tab_closed_detector;
TabAnimation animation(
static_state, base::BindOnce(&TabClosedDetector::NotifyTabClosed,
......
......@@ -1003,17 +1003,15 @@ void TabStrip::AddTabAt(int model_index, TabRendererData data, bool is_active) {
// Don't animate the first tab, it looks weird, and don't animate anything
// if the containing window isn't visible yet.
TabAnimationState::TabPinnedness pinnedness =
pinned ? TabAnimationState::TabPinnedness::kPinned
: TabAnimationState::TabPinnedness::kUnpinned;
if (tab_count() > 1 && GetWidget() && GetWidget()->IsVisible()) {
StartInsertTabAnimation(model_index, pinnedness);
StartInsertTabAnimation(model_index,
pinned ? TabPinned::kPinned : TabPinned::kUnpinned);
} else {
layout_helper_->InsertTabAtNoAnimation(
model_index, tab,
base::BindOnce(&TabStrip::OnTabCloseAnimationCompleted,
base::Unretained(this), base::Unretained(tab)),
pinnedness);
pinned ? TabPinned::kPinned : TabPinned::kUnpinned);
CompleteAnimationAndLayout();
}
......@@ -1072,10 +1070,8 @@ void TabStrip::MoveTab(int from_model_index,
layout_helper_->MoveTab(moving_tab->group(), from_model_index,
to_model_index);
layout_helper_->SetTabPinnedness(
to_model_index, data.pinned
? TabAnimationState::TabPinnedness::kPinned
: TabAnimationState::TabPinnedness::kUnpinned);
layout_helper_->SetTabPinned(
to_model_index, data.pinned ? TabPinned::kPinned : TabPinned::kUnpinned);
StartMoveTabAnimation();
if (TabDragController::IsAttachedTo(GetDragContext()) &&
(last_tab != GetLastVisibleTab() || last_tab->dragging())) {
......@@ -1132,9 +1128,8 @@ void TabStrip::SetTabData(int model_index, TabRendererData data) {
touch_layout_->SetXAndPinnedCount(start_x, pinned_tab_count);
}
layout_helper_->SetTabPinnedness(
model_index, data.pinned ? TabAnimationState::TabPinnedness::kPinned
: TabAnimationState::TabPinnedness::kUnpinned);
layout_helper_->SetTabPinned(
model_index, data.pinned ? TabPinned::kPinned : TabPinned::kUnpinned);
if (GetWidget() && GetWidget()->IsVisible())
StartPinnedTabAnimation();
else
......@@ -2080,16 +2075,14 @@ std::map<TabGroupId, TabGroupHeader*> TabStrip::GetGroupHeaders() {
return group_headers;
}
void TabStrip::StartInsertTabAnimation(
int model_index,
TabAnimationState::TabPinnedness pinnedness) {
void TabStrip::StartInsertTabAnimation(int model_index, TabPinned pinned) {
if (!bounds_animator_.IsAnimating() && !in_tab_close_) {
layout_helper_->InsertTabAt(
model_index, tab_at(model_index),
base::BindOnce(&TabStrip::OnTabCloseAnimationCompleted,
base::Unretained(this),
base::Unretained(tab_at(model_index))),
pinnedness);
pinned);
} else {
// TODO(958173): Delete this branch once |TabStripLayoutHelper::animator_|
// has taken over all animation responsibilities.
......@@ -2098,7 +2091,7 @@ void TabStrip::StartInsertTabAnimation(
base::BindOnce(&TabStrip::OnTabCloseAnimationCompleted,
base::Unretained(this),
base::Unretained(tab_at(model_index))),
pinnedness);
pinned);
PrepareForAnimation();
......
......@@ -358,8 +358,7 @@ class TabStrip : public views::AccessiblePaneView,
std::map<TabGroupId, TabGroupHeader*> GetGroupHeaders();
// Invoked from |AddTabAt| after the newly created tab has been inserted.
void StartInsertTabAnimation(int model_index,
TabAnimationState::TabPinnedness pinnedness);
void StartInsertTabAnimation(int model_index, TabPinned pinned);
// Animates the removal of the tab at |model_index|. Defers to the old
// animation style when appropriate.
......
......@@ -12,6 +12,7 @@
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/tab_style.h"
#include "chrome/browser/ui/tabs/tab_types.h"
#include "chrome/browser/ui/views/tabs/tab.h"
#include "chrome/browser/ui/views/tabs/tab_animation.h"
#include "chrome/browser/ui/views/tabs/tab_animation_state.h"
......@@ -44,14 +45,14 @@ TabLayoutConstants GetTabLayoutConstants() {
struct TabStripLayoutHelper::TabSlot {
static TabStripLayoutHelper::TabSlot CreateForTab(
Tab* tab,
TabAnimationState::TabOpenness openness,
TabAnimationState::TabPinnedness pinned,
TabOpen open,
TabPinned pinned,
base::OnceClosure removed_callback) {
TabStripLayoutHelper::TabSlot slot;
slot.type = ViewType::kTab;
slot.view = tab;
TabAnimationState initial_state = TabAnimationState::ForIdealTabState(
openness, pinned, TabAnimationState::TabActiveness::kInactive, 0);
open, pinned, TabActive::kInactive, 0);
slot.animation = std::make_unique<TabAnimation>(
initial_state, std::move(removed_callback));
return slot;
......@@ -60,14 +61,13 @@ struct TabStripLayoutHelper::TabSlot {
static TabStripLayoutHelper::TabSlot CreateForGroupHeader(
TabGroupId group,
TabGroupHeader* header,
TabAnimationState::TabPinnedness pinned,
TabPinned pinned,
base::OnceClosure removed_callback) {
TabStripLayoutHelper::TabSlot slot;
slot.type = ViewType::kGroupHeader;
slot.view = header;
TabAnimationState initial_state = TabAnimationState::ForIdealTabState(
TabAnimationState::TabOpenness::kOpen, pinned,
TabAnimationState::TabActiveness::kInactive, 0);
TabOpen::kOpen, pinned, TabActive::kInactive, 0);
slot.animation = std::make_unique<TabAnimation>(
initial_state, std::move(removed_callback));
return slot;
......@@ -122,44 +122,39 @@ void TabStripLayoutHelper::InsertTabAtNoAnimation(
int model_index,
Tab* tab,
base::OnceClosure tab_removed_callback,
TabAnimationState::TabPinnedness pinned) {
TabPinned pinned) {
const int slot_index =
GetSlotIndexForTabModelIndex(model_index, tab->group());
slots_.insert(
slots_.begin() + slot_index,
TabSlot::CreateForTab(tab, TabAnimationState::TabOpenness::kOpen, pinned,
slots_.insert(slots_.begin() + slot_index,
TabSlot::CreateForTab(tab, TabOpen::kOpen, pinned,
std::move(tab_removed_callback)));
}
void TabStripLayoutHelper::InsertTabAt(
int model_index,
void TabStripLayoutHelper::InsertTabAt(int model_index,
Tab* tab,
base::OnceClosure tab_removed_callback,
TabAnimationState::TabPinnedness pinned) {
TabPinned pinned) {
const int slot_index =
GetSlotIndexForTabModelIndex(model_index, tab->group());
slots_.insert(
slots_.begin() + slot_index,
TabSlot::CreateForTab(tab, TabAnimationState::TabOpenness::kClosed,
pinned, std::move(tab_removed_callback)));
AnimateSlot(slot_index,
slots_[slot_index].animation->target_state().WithOpenness(
TabAnimationState::TabOpenness::kOpen));
slots_.insert(slots_.begin() + slot_index,
TabSlot::CreateForTab(tab, TabOpen::kClosed, pinned,
std::move(tab_removed_callback)));
AnimateSlot(slot_index, slots_[slot_index].animation->target_state().WithOpen(
TabOpen::kOpen));
}
void TabStripLayoutHelper::RemoveTabNoAnimation(int model_index, Tab* tab) {
TabAnimation* animation =
slots_[GetSlotIndexForTabModelIndex(model_index, tab->group())]
.animation.get();
animation->AnimateTo(animation->target_state().WithOpenness(
TabAnimationState::TabOpenness::kClosed));
animation->AnimateTo(animation->target_state().WithOpen(TabOpen::kClosed));
animation->CompleteAnimation();
}
void TabStripLayoutHelper::RemoveTab(int model_index, Tab* tab) {
int slot_index = GetSlotIndexForTabModelIndex(model_index, tab->group());
AnimateSlot(slot_index,
slots_[slot_index].animation->target_state().WithOpenness(
TabAnimationState::TabOpenness::kClosed));
AnimateSlot(slot_index, slots_[slot_index].animation->target_state().WithOpen(
TabOpen::kClosed));
}
void TabStripLayoutHelper::EnterTabClosingMode(int available_width) {
......@@ -201,16 +196,14 @@ void TabStripLayoutHelper::MoveTab(base::Optional<TabGroupId> moving_tab_group,
UpdateGroupHeaderIndex(moving_tab_group.value());
}
void TabStripLayoutHelper::SetTabPinnedness(
int model_index,
TabAnimationState::TabPinnedness pinnedness) {
void TabStripLayoutHelper::SetTabPinned(int model_index, TabPinned pinned) {
// TODO(958173): Animate state change.
views::ViewModelT<Tab>* tabs = get_tabs_callback_.Run();
TabAnimation* animation =
slots_[GetSlotIndexForTabModelIndex(model_index,
tabs->view_at(model_index)->group())]
.animation.get();
animation->AnimateTo(animation->target_state().WithPinnedness(pinnedness));
animation->AnimateTo(animation->target_state().WithPinned(pinned));
animation->CompleteAnimation();
}
......@@ -222,9 +215,9 @@ void TabStripLayoutHelper::InsertGroupHeader(
std::vector<int> tabs_in_group = controller_->ListTabsInGroup(group);
const int header_slot_index =
GetSlotIndexForTabModelIndex(tabs_in_group[0], group);
slots_.insert(slots_.begin() + header_slot_index,
TabSlot::CreateForGroupHeader(
group, header, TabAnimationState::TabPinnedness::kUnpinned,
slots_.insert(
slots_.begin() + header_slot_index,
TabSlot::CreateForGroupHeader(group, header, TabPinned::kUnpinned,
std::move(header_removed_callback)));
}
......@@ -249,20 +242,20 @@ void TabStripLayoutHelper::UpdateGroupHeaderIndex(TabGroupId group) {
void TabStripLayoutHelper::SetActiveTab(int prev_active_index,
int new_active_index) {
views::ViewModelT<Tab>* tabs = get_tabs_callback_.Run();
// Set activeness without animating by retargeting the existing animation.
// Set active state without animating by retargeting the existing animation.
if (prev_active_index >= 0) {
const int prev_slot_index = GetSlotIndexForTabModelIndex(
prev_active_index, tabs->view_at(prev_active_index)->group());
TabAnimation* animation = slots_[prev_slot_index].animation.get();
animation->RetargetTo(animation->target_state().WithActiveness(
TabAnimationState::TabActiveness::kInactive));
animation->RetargetTo(
animation->target_state().WithActive(TabActive::kInactive));
}
if (new_active_index >= 0) {
const int new_slot_index = GetSlotIndexForTabModelIndex(
new_active_index, tabs->view_at(new_active_index)->group());
TabAnimation* animation = slots_[new_slot_index].animation.get();
animation->RetargetTo(animation->target_state().WithActiveness(
TabAnimationState::TabActiveness::kActive));
animation->RetargetTo(
animation->target_state().WithActive(TabActive::kActive));
}
}
......@@ -300,15 +293,12 @@ void TabStripLayoutHelper::UpdateIdealBounds(int available_width) {
TabLayoutConstants layout_constants = GetTabLayoutConstants();
std::vector<TabWidthConstraints> tab_widths;
for (int i = 0; i < int{slots_.size()}; i++) {
auto active = i == active_tab_slot_index
? TabAnimationState::TabActiveness::kActive
: TabAnimationState::TabActiveness::kInactive;
auto pinned = i <= last_pinned_tab_slot_index
? TabAnimationState::TabPinnedness::kPinned
: TabAnimationState::TabPinnedness::kUnpinned;
auto open = slots_[i].animation->IsClosing()
? TabAnimationState::TabOpenness::kClosed
: TabAnimationState::TabOpenness::kOpen;
auto active =
i == active_tab_slot_index ? TabActive::kActive : TabActive::kInactive;
auto pinned = i <= last_pinned_tab_slot_index ? TabPinned::kPinned
: TabPinned::kUnpinned;
auto open =
slots_[i].animation->IsClosing() ? TabOpen::kClosed : TabOpen::kOpen;
TabAnimationState ideal_animation_state =
TabAnimationState::ForIdealTabState(open, pinned, active, 0);
TabSizeInfo size_info = slots_[i].view->GetTabSizeInfo();
......@@ -352,9 +342,7 @@ void TabStripLayoutHelper::UpdateIdealBoundsForPinnedTabs() {
for (int tab_index = 0; tab_index < pinned_tab_count; tab_index++) {
TabAnimationState ideal_animation_state =
TabAnimationState::ForIdealTabState(
TabAnimationState::TabOpenness::kOpen,
TabAnimationState::TabPinnedness::kPinned,
TabAnimationState::TabActiveness::kInactive, 0);
TabOpen::kOpen, TabPinned::kPinned, TabActive::kInactive, 0);
TabSizeInfo size_info = tabs->view_at(tab_index)->GetTabSizeInfo();
tab_widths.push_back(TabWidthConstraints(ideal_animation_state,
layout_constants, size_info));
......
......@@ -12,6 +12,7 @@
#include "base/callback_forward.h"
#include "base/optional.h"
#include "base/timer/timer.h"
#include "chrome/browser/ui/tabs/tab_types.h"
#include "chrome/browser/ui/views/tabs/tab_animation_state.h"
#include "chrome/browser/ui/views/tabs/tab_strip_layout.h"
#include "chrome/browser/ui/views/tabs/tab_width_constraints.h"
......@@ -58,14 +59,14 @@ class TabStripLayoutHelper {
void InsertTabAtNoAnimation(int model_index,
Tab* tab,
base::OnceClosure tab_removed_callback,
TabAnimationState::TabPinnedness pinned);
TabPinned pinned);
// Inserts a new tab at |index|, with animation. |tab_removed_callback| will
// be invoked if the tab is removed at the end of a remove animation.
void InsertTabAt(int model_index,
Tab* tab,
base::OnceClosure tab_removed_callback,
TabAnimationState::TabPinnedness pinned);
TabPinned pinned);
// Marks the tab at |model_index| as closed without animating it. Use when
// the tab has been removed from the model but the old animation style owns
......@@ -96,9 +97,8 @@ class TabStripLayoutHelper {
int prev_index,
int new_index);
// Sets the tab at |index|'s pinnedness to |pinnedness|.
void SetTabPinnedness(int model_index,
TabAnimationState::TabPinnedness pinnedness);
// Sets the tab at |index|'s pinned state to |pinned|.
void SetTabPinned(int model_index, TabPinned pinned);
// Inserts a new group header for |group|. |header_removed_callback| will be
// invoked if the group is removed at the end of a remove animation.
......
......@@ -9,6 +9,7 @@
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/ui/tabs/tab_types.h"
#include "chrome/browser/ui/views/tabs/tab_animation_state.h"
#include "chrome/browser/ui/views/tabs/tab_width_constraints.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -69,13 +70,11 @@ std::vector<gfx::Rect> CalculateTabBounds(TestCase test_case) {
for (int tab_index = 0; tab_index < test_case.num_tabs; tab_index++) {
TabAnimationState ideal_animation_state =
TabAnimationState::ForIdealTabState(
TabAnimationState::TabOpenness::kOpen,
tab_index < test_case.num_pinned_tabs
? TabAnimationState::TabPinnedness::kPinned
: TabAnimationState::TabPinnedness::kUnpinned,
tab_index == test_case.active_index
? TabAnimationState::TabActiveness::kActive
: TabAnimationState::TabActiveness::kInactive,
TabOpen::kOpen,
tab_index < test_case.num_pinned_tabs ? TabPinned::kPinned
: TabPinned::kUnpinned,
tab_index == test_case.active_index ? TabActive::kActive
: TabActive::kInactive,
0);
tab_states.push_back(TabWidthConstraints(ideal_animation_state,
layout_constants, size_info));
......
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