<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Web Inspector: Unify management of visibility state for views"
   href="https://bugs.webkit.org/show_bug.cgi?id=150741">150741</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Web Inspector: Unify management of visibility state for views
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>WebKit Nightly Build
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Web Inspector
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mattbaker&#64;apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>bburg&#64;apple.com, graouts&#64;webkit.org, joepeck&#64;webkit.org, mattbaker&#64;apple.com, nvasilyev&#64;apple.com, timothy&#64;apple.com, webkit-bug-importer&#64;group.apple.com
          </td>
        </tr>

        <tr>
          <th>Depends on</th>
          <td>149186
          </td>
        </tr></table>
      <p>
        <div>
        <pre>* 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) =&gt; {
      console.assert(view.visible !== flag, &quot;Unexpected subview visible state.&quot;);
      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?</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>