Bug 150741 - Web Inspector: Unify management of visibility state for views
Summary: Web Inspector: Unify management of visibility state for views
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on: 149186
Blocks:
  Show dependency treegraph
 
Reported: 2015-10-30 16:46 PDT by Matt Baker
Modified: 2016-12-13 15:37 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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>