Files
brave-core/components/tabs
Sangwoo Ko 86eda949d4 [Tree Tabs] Add tree tab collapse/expand UI button (#34469)
* Add tree tab collapse/expand UI and auto-expand on selection

- Add tree toggle button on BraveTab: when a tab has descendants, show
  expand/collapse icon (replacing close button when applicable). When
  the node is collapsed but has descendants, always show the toggle so
  users can expand. Button uses submenu/expand icons per collapsed state.

- Model: BraveTabStripModel::SetTreeTabNodeCollapsed() updates collapse
  state and notifies observers via TreeTabChange::kNodeCollapsedStateChanged.
  TreeTabModel::GetClosestCollapsedAncestor() returns the closest collapsed
  ancestor for a node.

- Controller: BraveBrowserTabStripController exposes
  SetTreeTabNodeCollapsed(), IsInCollapsedTreeTabNode(), and
  GetClosestCollapsedAncestor(). On collapsed-state change, updates the
  tab’s tree toggle icon and invalidates layout.

- Tab strip: Override SetSelection() to post ExpandAllCollapsedAncestors();
  when the user selects a tab (or adds an active new tab) that lives under
  collapsed nodes, all ancestors are expanded so the selection is visible.

- Layout: TabStripLayoutHelper marks slots in collapsed tree nodes as
  TabOpen::kClosed so those tabs are not laid out (hidden).

- Observer: Add TreeTabChange::CollapsedStateChangedChange and
  kNodeCollapsedStateChanged. TabSlotController gains
  SetTreeTabNodeCollapsed() and IsInCollapsedTreeTabNode(); TabSlotView
  gains IsInCollapsedTreeTabNode(). Chromium overrides provide no-ops or
  defaults.

- Tests: TreeTabsBrowserTest for auto-expand on selecting a tab in a
  collapsed tree and on adding an active new tab; BraveTabTestWithTreeTab
  for toggle visibility (replacing close button when has descendants, and
  always visible when collapsed with descendants).

- TreeTabNode: add set_height_for_test() for unit tests.
2026-03-10 20:57:24 +09:00
..