Architecture Drawing - https://www.dropbox.com/s/xo8ra6gd1n687v7/IMG_0126.JPG?dl=0
WIP Branch - https://github.com/mozilla/firefox-ios/tree/sleroux/Bug1212021-InvertTabTray
Present Day BVC
- Acts as a singleton
- Never is deallocated
- Contains all opened web views in hierarchy
- Relies on TabManager's selectedTab property to determine what to show and how to configure itself
- This is why we have so many conditionals everywhere and check state so much
- https://github.com/mozilla/firefox-ios/blob/master/Client/Frontend/Browser/BrowserViewController.swift#L627
- https://github.com/mozilla/firefox-ios/blob/master/Client/Frontend/Browser/BrowserViewController.swift#L685
- https://github.com/mozilla/firefox-ios/blob/master/Client/Frontend/Browser/BrowserViewController.swift#L759
- Seriously, it's almost in every method
(Potentially) Future BVC
- Contains only one web view for the selected tab
- Removes need for 'selectedTab' state
- BVC can implicitly configure itself
- We would pass in the Tab (currently named Browser) to the BVC when we instiatiate it
- Is instantiated when tapping a tab from the Tab Tray and is deallocated when going back to the tray
- WebViews are kept alive in the TabManager
- One tab per BVC -> One HomeViewController per BVC
- Would simplify/solve the state problem we have with Bookmarks
Questions:
- What are the performance impliciations of moving from a singleton BVC model to per tab model?
- Best way to manage getting this into mainline for 2.0 potentially?
- Other ramifications?
- I know theres already refactoring needed for handling the crash detection, queued tabs, openURLInTab since they rely on the BVC...
Is there a reason not to keep one
BVC
alive per tab?Is there a reason not to allow multiple
HomeViewControllers
, one for each time the home page appears in the navigation stack? I'm thinking of a future where we navigate into and out of web content, not just between web pages.That is,
TabManager
owns(Tab, BVC)
s.BVC
s own a web view, a URL stack, and potentially that URL stack is actually URLs + home panels. Think about how we're going to implement navigating through a bookmark hierarchy, and hit Back in the final page and end up in the same folder, same scroll position…