#include "chrome/browser/ui/views/tabs/compound_tab_container.h"
#include <memory>
#include "base/auto_reset.h"
#include "base/functional/bind.h"
#include "base/trace_event/trace_event.h"
#include "base/types/to_address.h"
#include "chrome/browser/ui/tabs/tab_style.h"
#include "chrome/browser/ui/tabs/tab_types.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/tabs/tab.h"
#include "chrome/browser/ui/views/tabs/tab_container_impl.h"
#include "chrome/browser/ui/views/tabs/tab_hover_card_controller.h"
#include "chrome/browser/ui/views/tabs/tab_scrolling_animation.h"
#include "chrome/browser/ui/views/tabs/tab_slot_animation_delegate.h"
#include "chrome/browser/ui/views/tabs/tab_slot_view.h"
#include "chrome/browser/ui/views/tabs/tab_strip_controller.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/models/list_selection_model.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/views/layout/layout_types.h"
#include "ui/views/rect_based_targeting_utils.h"
#include "ui/views/view.h"
#include "ui/views/view_utils.h"
namespace {
class PinnedTabContainerController final : public TabContainerController { … };
class UnpinnedTabContainerController final : public TabContainerController { … };
class PinUnpinAnimationDelegate : public TabSlotAnimationDelegate { … };
}
CompoundTabContainer::CompoundTabContainer(
TabContainerController& controller,
TabHoverCardController* hover_card_controller,
TabDragContextBase* drag_context,
TabSlotController& tab_slot_controller,
views::View* scroll_contents_view)
: … { … }
CompoundTabContainer::~CompoundTabContainer() { … }
void CompoundTabContainer::SetAvailableWidthCallback(
base::RepeatingCallback<int()> available_width_callback) { … }
Tab* CompoundTabContainer::AddTab(std::unique_ptr<Tab> tab,
int model_index,
TabPinned pinned) { … }
void CompoundTabContainer::MoveTab(int from_model_index, int to_model_index) { … }
void CompoundTabContainer::RemoveTab(int index, bool was_active) { … }
void CompoundTabContainer::SetTabPinned(int model_index, TabPinned pinned) { … }
void CompoundTabContainer::SetActiveTab(
std::optional<size_t> prev_active_index,
std::optional<size_t> new_active_index) { … }
Tab* CompoundTabContainer::RemoveTabFromViewModel(int model_index) { … }
Tab* CompoundTabContainer::AddTabToViewModel(Tab* tab,
int model_index,
TabPinned pinned) { … }
void CompoundTabContainer::ReturnTabSlotView(TabSlotView* view) { … }
void CompoundTabContainer::ScrollTabToVisible(int model_index) { … }
void CompoundTabContainer::ScrollTabContainerByOffset(int offset) { … }
void CompoundTabContainer::OnGroupCreated(const tab_groups::TabGroupId& group) { … }
void CompoundTabContainer::OnGroupEditorOpened(
const tab_groups::TabGroupId& group) { … }
void CompoundTabContainer::OnGroupMoved(const tab_groups::TabGroupId& group) { … }
void CompoundTabContainer::OnGroupContentsChanged(
const tab_groups::TabGroupId& group) { … }
void CompoundTabContainer::OnGroupVisualsChanged(
const tab_groups::TabGroupId& group,
const tab_groups::TabGroupVisualData* old_visuals,
const tab_groups::TabGroupVisualData* new_visuals) { … }
void CompoundTabContainer::ToggleTabGroup(
const tab_groups::TabGroupId& group,
bool is_collapsing,
ToggleTabGroupCollapsedStateOrigin origin) { … }
void CompoundTabContainer::OnGroupClosed(const tab_groups::TabGroupId& group) { … }
void CompoundTabContainer::UpdateTabGroupVisuals(
tab_groups::TabGroupId group_id) { … }
void CompoundTabContainer::NotifyTabGroupEditorBubbleOpened() { … }
void CompoundTabContainer::NotifyTabGroupEditorBubbleClosed() { … }
std::optional<int> CompoundTabContainer::GetModelIndexOf(
const TabSlotView* slot_view) const { … }
Tab* CompoundTabContainer::GetTabAtModelIndex(int index) const { … }
int CompoundTabContainer::GetTabCount() const { … }
std::optional<int> CompoundTabContainer::GetModelIndexOfFirstNonClosingTab(
Tab* tab) const { … }
void CompoundTabContainer::UpdateHoverCard(
Tab* tab,
TabSlotController::HoverCardUpdateType update_type) { … }
void CompoundTabContainer::HandleLongTap(ui::GestureEvent* const event) { … }
bool CompoundTabContainer::IsRectInContentArea(const gfx::Rect& rect) { … }
std::optional<ZOrderableTabContainerElement>
CompoundTabContainer::GetLeadingElementForZOrdering() const { … }
std::optional<ZOrderableTabContainerElement>
CompoundTabContainer::GetTrailingElementForZOrdering() const { … }
void CompoundTabContainer::OnTabSlotAnimationProgressed(TabSlotView* view) { … }
void CompoundTabContainer::OnTabCloseAnimationCompleted(Tab* tab) { … }
void CompoundTabContainer::InvalidateIdealBounds() { … }
void CompoundTabContainer::AnimateToIdealBounds() { … }
bool CompoundTabContainer::IsAnimating() const { … }
void CompoundTabContainer::CancelAnimation() { … }
void CompoundTabContainer::CompleteAnimationAndLayout() { … }
int CompoundTabContainer::GetAvailableWidthForTabContainer() const { … }
void CompoundTabContainer::EnterTabClosingMode(
std::optional<int> override_width,
CloseTabSource source) { … }
void CompoundTabContainer::ExitTabClosingMode() { … }
void CompoundTabContainer::SetTabSlotVisibility() { … }
bool CompoundTabContainer::InTabClose() { … }
TabGroupViews* CompoundTabContainer::GetGroupViews(
tab_groups::TabGroupId group_id) const { … }
const std::map<tab_groups::TabGroupId, std::unique_ptr<TabGroupViews>>&
CompoundTabContainer::get_group_views_for_testing() const { … }
int CompoundTabContainer::GetActiveTabWidth() const { … }
int CompoundTabContainer::GetInactiveTabWidth() const { … }
gfx::Rect CompoundTabContainer::GetIdealBounds(int model_index) const { … }
gfx::Rect CompoundTabContainer::GetIdealBounds(
tab_groups::TabGroupId group) const { … }
gfx::Size CompoundTabContainer::GetMinimumSize() const { … }
views::SizeBounds CompoundTabContainer::GetAvailableSize(
const views::View* child) const { … }
gfx::Size CompoundTabContainer::CalculatePreferredSize(
const views::SizeBounds& available_size) const { … }
views::View* CompoundTabContainer::GetTooltipHandlerForPoint(
const gfx::Point& point) { … }
void CompoundTabContainer::Layout(PassKey) { … }
void CompoundTabContainer::PaintChildren(const views::PaintInfo& paint_info) { … }
void CompoundTabContainer::ChildPreferredSizeChanged(views::View* child) { … }
std::optional<BrowserRootView::DropIndex> CompoundTabContainer::GetDropIndex(
const ui::DropTargetEvent& event) { … }
BrowserRootView::DropTarget* CompoundTabContainer::GetDropTarget(
gfx::Point loc_in_local_coords) { … }
views::View* CompoundTabContainer::GetViewForDrop() { … }
void CompoundTabContainer::HandleDragUpdate(
const std::optional<BrowserRootView::DropIndex>& index) { … }
void CompoundTabContainer::HandleDragExited() { … }
views::View* CompoundTabContainer::TargetForRect(views::View* root,
const gfx::Rect& rect) { … }
void CompoundTabContainer::UpdateAnimationTarget(TabSlotView* tab_slot_view,
gfx::Rect target_bounds,
TabPinned pinned) { … }
int CompoundTabContainer::NumPinnedTabs() const { … }
bool CompoundTabContainer::IsValidViewModelIndex(int index) const { … }
void CompoundTabContainer::TransferTabBetweenContainers(int from_model_index,
int to_model_index) { … }
void CompoundTabContainer::AnimateTabTo(Tab* tab, gfx::Rect ideal_bounds) { … }
gfx::Rect CompoundTabContainer::ConvertUnpinnedContainerIdealBoundsToLocal(
gfx::Rect ideal_bounds) const { … }
TabContainer& CompoundTabContainer::GetTabContainerFor(
TabSlotView* view) const { … }
TabContainer* CompoundTabContainer::GetTabContainerForDrop(
gfx::Point point_in_local_coords) const { … }
TabContainer* CompoundTabContainer::GetTabContainerAt(
gfx::Point point_in_local_coords) const { … }
int CompoundTabContainer::GetUnpinnedContainerIdealLeadingX() const { … }
int CompoundTabContainer::GetAvailableWidthForUnpinnedTabContainer() const { … }
gfx::Size CompoundTabContainer::GetCombinedSizeForTabContainerSizes(
const gfx::Size pinned_size,
const gfx::Size unpinned_size) const { … }
std::optional<gfx::Rect> CompoundTabContainer::GetVisibleContentRect() const { … }
void CompoundTabContainer::AnimateScrollToShowXCoordinate(
const int start_edge,
const int target_edge) { … }
BEGIN_METADATA(…)