Changeset 195995 in webkit


Ignore:
Timestamp:
Feb 1, 2016 5:27:25 PM (8 years ago)
Author:
Matt Baker
Message:

Web Inspector: add a LayoutReason enum to the View base class
https://bugs.webkit.org/show_bug.cgi?id=153731
<rdar://problem/24430938>

Reviewed by Brian Burg.

Added a LayoutReason enum to the View base class, which can be passed as an optional
argument to needsLayout() and updateLayout(). The value is propagated to the view's
subtree during layout.

  • UserInterface/Base/Main.js:

Update top-level views with Resize layout reason when window is resized.

  • UserInterface/Views/DataGrid.js:

(WebInspector.DataGrid.prototype._positionHeaderViews):
Update header view with Resize layout reason when column is resized.

  • UserInterface/Views/OverviewTimelineView.js:

(WebInspector.OverviewTimelineView.prototype.shown):
Assume the view has been resized when shown, and update layout.
(WebInspector.OverviewTimelineView.prototype.updateLayoutForResize): Deleted.
No longer needed, handled by the View base class.

  • UserInterface/Views/TimelineOverview.js:

(WebInspector.TimelineOverview.prototype.shown):
Assume the view has been resized when shown, and update layout.
(WebInspector.TimelineOverview.prototype.layout):
Invalidate cached scroll container width if resized.
(WebInspector.TimelineOverview.prototype.updateLayoutForResize): Deleted.
No longer needed, handled by the View base class.

  • UserInterface/Views/TimelineRecordingContentView.js:

(WebInspector.TimelineRecordingContentView.prototype.layout): Deleted.
No longer needed, handled by the View base class.

  • UserInterface/Views/TimelineRuler.js:

(WebInspector.TimelineRuler.prototype.needsLayout):
(WebInspector.TimelineRuler.prototype.layout):
Update cached client width if resized.
(WebInspector.TimelineRuler.prototype.resize): Deleted.
Moved resize logic to layout override.

  • UserInterface/Views/View.js:

(WebInspector.View):
(WebInspector.View.prototype.updateLayout):
Set layout reason.
(WebInspector.View.prototype.needsLayout):
Set layout reason even if an animation frame has already been scheduled,
since the layout reason could have changed.
(WebInspector.View.prototype._layoutSubtree):
Propagate layout reason to subtree, and reset the value when done.
(WebInspector.View.prototype._setLayoutReason):
Helper method for updating the layout reason. Ensures that LayoutReason.Resize
has priority over the default (LayoutReason.Dirty).

Location:
trunk/Source/WebInspectorUI
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r195967 r195995  
     12016-02-01  Matt Baker  <mattbaker@apple.com>
     2
     3        Web Inspector: add a LayoutReason enum to the View base class
     4        https://bugs.webkit.org/show_bug.cgi?id=153731
     5        <rdar://problem/24430938>
     6
     7        Reviewed by Brian Burg.
     8
     9        Added a LayoutReason enum to the View base class, which can be passed as an optional
     10        argument to needsLayout() and updateLayout(). The value is propagated to the view's
     11        subtree during layout.
     12
     13        * UserInterface/Base/Main.js:
     14        Update top-level views with Resize layout reason when window is resized.
     15
     16        * UserInterface/Views/DataGrid.js:
     17        (WebInspector.DataGrid.prototype._positionHeaderViews):
     18        Update header view with Resize layout reason when column is resized.
     19
     20        * UserInterface/Views/OverviewTimelineView.js:
     21        (WebInspector.OverviewTimelineView.prototype.shown):
     22        Assume the view has been resized when shown, and update layout.
     23        (WebInspector.OverviewTimelineView.prototype.updateLayoutForResize): Deleted.
     24        No longer needed, handled by the View base class.
     25
     26        * UserInterface/Views/TimelineOverview.js:
     27        (WebInspector.TimelineOverview.prototype.shown):
     28        Assume the view has been resized when shown, and update layout.
     29        (WebInspector.TimelineOverview.prototype.layout):
     30        Invalidate cached scroll container width if resized.
     31        (WebInspector.TimelineOverview.prototype.updateLayoutForResize): Deleted.
     32        No longer needed, handled by the View base class.
     33
     34        * UserInterface/Views/TimelineRecordingContentView.js:
     35        (WebInspector.TimelineRecordingContentView.prototype.layout): Deleted.
     36        No longer needed, handled by the View base class.
     37
     38        * UserInterface/Views/TimelineRuler.js:
     39        (WebInspector.TimelineRuler.prototype.needsLayout):
     40        (WebInspector.TimelineRuler.prototype.layout):
     41        Update cached client width if resized.
     42        (WebInspector.TimelineRuler.prototype.resize): Deleted.
     43        Moved resize logic to layout override.
     44
     45        * UserInterface/Views/View.js:
     46        (WebInspector.View):
     47        (WebInspector.View.prototype.updateLayout):
     48        Set layout reason.
     49        (WebInspector.View.prototype.needsLayout):
     50        Set layout reason even if an animation frame has already been scheduled,
     51        since the layout reason could have changed.
     52        (WebInspector.View.prototype._layoutSubtree):
     53        Propagate layout reason to subtree, and reset the value when done.
     54        (WebInspector.View.prototype._setLayoutReason):
     55        Helper method for updating the layout reason. Ensures that LayoutReason.Resize
     56        has priority over the default (LayoutReason.Dirty).
     57
    1582016-02-01  Matt Baker  <mattbaker@apple.com>
    259
  • trunk/Source/WebInspectorUI/UserInterface/Base/Main.js

    r195835 r195995  
    13421342WebInspector._windowResized = function(event)
    13431343{
    1344     this.toolbar.updateLayout();
    1345     this.tabBar.updateLayout();
     1344    this.toolbar.updateLayout(WebInspector.View.LayoutReason.Resize);
     1345    this.tabBar.updateLayout(WebInspector.View.LayoutReason.Resize);
    13461346    this._tabBrowserSizeDidChange();
    13471347};
     
    14551455WebInspector._tabBrowserSizeDidChange = function()
    14561456{
    1457     this.tabBrowser.updateLayout();
    1458     this.splitContentBrowser.updateLayout();
    1459     this.quickConsole.updateLayout();
     1457    this.tabBrowser.updateLayout(WebInspector.View.LayoutReason.Resize);
     1458    this.splitContentBrowser.updateLayout(WebInspector.View.LayoutReason.Resize);
     1459    this.quickConsole.updateLayout(WebInspector.View.LayoutReason.Resize);
    14601460};
    14611461
    14621462WebInspector._quickConsoleDidResize = function(event)
    14631463{
    1464     this.tabBrowser.updateLayout();
     1464    this.tabBrowser.updateLayout(WebInspector.View.LayoutReason.Resize);
    14651465};
    14661466
  • trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js

    r195966 r195995  
    743743                headerView.element.style.left = left + "px";
    744744                headerView.element.style.width = columnWidth + "px";
    745                 headerView.updateLayout();
     745                headerView.updateLayout(WebInspector.View.LayoutReason.Resize);
    746746            }
    747747
  • trunk/Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js

    r195504 r195995  
    8282
    8383        this._treeOutlineDataGridSynchronizer.synchronize();
    84         this._timelineRuler.resize();
     84        this._timelineRuler.updateLayout(WebInspector.View.LayoutReason.Resize);
    8585    }
    8686
     
    159159
    160160        WebInspector.showOriginalOrFormattedSourceCodeLocation(treeElement.sourceCodeTimeline.sourceCodeLocation);
    161     }
    162 
    163     updateLayoutForResize()
    164     {
    165         this._timelineRuler.resize();
    166161    }
    167162
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js

    r195881 r195995  
    266266        this._visible = true;
    267267
    268         this._timelineRuler.resize()
    269 
    270268        for (var timelineOverviewGraph of this._timelineOverviewGraphsMap.values())
    271269            timelineOverviewGraph.shown();
    272270
    273         this.updateLayout();
     271        this.updateLayout(WebInspector.View.LayoutReason.Resize);
    274272    }
    275273
     
    321319    }
    322320
    323     updateLayoutForResize()
    324     {
    325         this._cachedScrollContainerWidth = NaN;
    326         this._timelineRuler.resize()
    327         this.updateLayout();
    328     }
    329 
    330321    updateLayoutIfNeeded()
    331322    {
     
    354345    }
    355346
    356     layout()
    357     {
     347    layout(layoutReason)
     348    {
     349        if (layoutReason === WebInspector.View.LayoutReason.Resize)
     350            this._cachedScrollContainerWidth = NaN;
     351
    358352        // Calculate the required width based on the duration and seconds per pixel.
    359353        let duration = this._endTime - this._startTime;
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js

    r195967 r195995  
    325325    }
    326326
    327     // Protected
    328 
    329     layout()
    330     {
    331         this._currentTimelineOverview.updateLayoutForResize();
    332 
    333         let currentContentView = this._contentViewContainer.currentContentView;
    334         if (currentContentView && currentContentView.updateLayoutForResize)
    335             currentContentView.updateLayoutForResize();
    336     }
    337 
    338327    // Private
    339328
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js

    r195504 r195995  
    359359    }
    360360
    361     needsLayout()
     361    needsLayout(layoutReason)
    362362    {
    363363        if (this.layoutPending)
     
    374374        }
    375375
    376         super.needsLayout();
     376        super.needsLayout(layoutReason);
    377377    }
    378378
    379379    // Protected
    380380
    381     layout()
    382     {
     381    layout(layoutReason)
     382    {
     383        if (layoutReason === WebInspector.View.LayoutReason.Resize)
     384            this._cachedClientWidth = this.element.clientWidth;
     385
    383386        let visibleWidth = this._recalculate();
    384387        if (visibleWidth <= 0)
     
    536539            this._updateSelection(visibleWidth, this.duration);
    537540        });
    538     }
    539 
    540     resize()
    541     {
    542         this._cachedClientWidth = this.element.clientWidth;
    543         this._recalculate();
    544541    }
    545542
  • trunk/Source/WebInspectorUI/UserInterface/Views/View.js

    r193872 r195995  
    3838        this._needsLayoutWhenAttachedToRoot = false;
    3939        this._isAttachedToRoot = false;
     40        this._layoutReason = null;
    4041    }
    4142
     
    138139    }
    139140
    140     updateLayout()
     141    updateLayout(layoutReason)
    141142    {
    142143        WebInspector.View._cancelScheduledLayoutForView(this);
     144
     145        this._setLayoutReason(layoutReason);
    143146        this._layoutSubtree();
    144147    }
     
    152155    }
    153156
    154     needsLayout()
    155     {
     157    needsLayout(layoutReason)
     158    {
     159        this._setLayoutReason(layoutReason);
     160
    156161        if (this._dirty)
    157162            return;
     
    210215        this._dirtyDescendantsCount = 0;
    211216
    212         this.layout();
    213 
    214         for (let view of this._subviews)
     217        this.layout(this._layoutReason);
     218
     219        for (let view of this._subviews) {
     220            view._setLayoutReason(this._layoutReason);
    215221            view._layoutSubtree();
     222        }
     223
     224        this._layoutReason = null;
     225    }
     226
     227    _setLayoutReason(layoutReason)
     228    {
     229        if (this._layoutReason === WebInspector.View.LayoutReason.Resize)
     230            return;
     231
     232        this._layoutReason = layoutReason || WebInspector.View.LayoutReason.Dirty;
    216233    }
    217234
     
    284301};
    285302
     303WebInspector.View.LayoutReason = {
     304    Dirty: Symbol("layout-reason-dirty"),
     305    Resize: Symbol("layout-reason-resize")
     306};
     307
    286308WebInspector.View._rootView = null;
    287309WebInspector.View._scheduledLayoutUpdateIdentifier = undefined;
Note: See TracChangeset for help on using the changeset viewer.