Bug 150741

Summary: Web Inspector: Unify management of visibility state for views
Product: WebKit Reporter: Matt Baker <mattbaker>
Component: Web InspectorAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: graouts, inspector-bugzilla-changes, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Bug Depends on: 149186    
Bug Blocks:    

Description Matt Baker 2015-10-30 16:46:53 PDT
* SUMMARY
Unify management of visibility state for views. We use methods shown() and hidden(), often coupled with a `visible` flag, throughout the UI to control layouts and perform other tasks. ContentView, DashboardView, and SidebarPanel define shown/hidden as base class methods, and elsewhere the pattern is implemented in an ad-hoc fashion. We should promote this concept to the View base class.

* EXAMPLE
Although implementations differ, the typical pattern is as follows:

shown()
{
   this._visible = true;
   this._childView.shown();
   this.updateLayout();
}

hidden()
{
   this._visible = false;
   this._childView.hidden();
}

needsLayout()
{
   if (!this._visible)
      return;

   ...
}

This could be moved into View as:

get visible()
{
   return this._visible;
}

set visible(flag)
{
   if (flag === this._visible)
      return;

   this._visible = flag;
   if (this._visible)
      this.shown();   // Implemented by subclasses.
   else
      this.hidden();  // Implemented by subclasses.

   this._subviews.forEach((view) => {
      console.assert(view.visible !== flag, "Unexpected subview visible state.");
      view.visible = flag;
   });
}


* NOTES
A few things to consider:

1. Currently when a view is shown, shown() isn't necessarily called for all child views that support it. ConsoleTabContentView.shown() doesn't call ContentBrowser.shown(), but ContentBrowserTabContentView does.
2. Visibility can be derived from other state, rather than being a simple flag (see SidebarPanel.visible).
3. Can all shown()/hidden() call sites simply be replaced with visible = true/false?
4. Layout isn't always updated when a view is shown (maybe limited to ApplicationCacheFrameContentView).
5. Should child views always become visible when the parent does? For example, what if a child view is collapsed?
Comment 1 Radar WebKit Bug Importer 2015-10-30 16:47:35 PDT
<rdar://problem/23341812>