Firefox/Projects/TabCandy/TabsAndGroups
Note that this page describes an architecture that is not yet in the product, and is currently on hold. See bug 578512.
We have JavaScript modules that keep track of tabs and groups across the entire app:
- /browser/base/content/tabview/module/groups.jsm
- /browser/base/content/tabview/module/tabs.jsm
groups.jsm defines TabViewGroups, which keeps track of all the tab groups in the system and provides events (not literal browser events) to keep track of when new groups are created. You can subscribe to individual groups as well, which send out events for when they're modified or destroyed. tabs.jsm does the same for tabs, with TabViewTabs.
While the intention is to make it look as if all tabs can be available in all windows, at any one time any one tab is attached to only one window. When the user requests to open a tab in one window while the tab resides in a different one, we have to swap the tab from window to window. In fact, we do this for entire groups of tabs, so that the tab bar looks correct. To mirror this, we also associate groups with specific windows, and store them with that window's sessionstore.
In terms of the relationship between these new JavaScript modules and the Tab Candy UI frames (one for each window), we're keeping as much of the UI intelligence as possible in the Tab Candy frame, using TabViewGroups and TabViewTabs simply as repositories for the appropriate data. All of the dragging, squishing, grouping, etc animation is done primarily in the Tab Candy frame (with TabItems and GroupItems), and the results of these operations are then sent to the appropriate TabViewTab and/or TabViewGroup to be propagated to other frames. This keeps the shared data relatively simple/clean, and allows for the UI frames to be directly responsive to user interaction. In MVC terms, TabViewGroups is model, and GroupItem is both view and controller. Note that our model includes such things as display locations.
Speaking of display locations, at the moment all Tab Candy frames show their contents the same size. It is our intention to add a scaling value to each Tab Candy frame, so smaller windows will scale their contents down.