NEW 150741
Web Inspector: Unify management of visibility state for views
https://bugs.webkit.org/show_bug.cgi?id=150741
Summary Web Inspector: Unify management of visibility state for views
Matt Baker
Reported 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?
Attachments
Radar WebKit Bug Importer
Comment 1 2015-10-30 16:47:35 PDT
Note You need to log in before you can comment on or make changes to this bug.