Title: [195995] trunk/Source/WebInspectorUI
Revision
195995
Author
[email protected]
Date
2016-02-01 17:27:25 -0800 (Mon, 01 Feb 2016)

Log 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).

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (195994 => 195995)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-02-02 01:12:48 UTC (rev 195994)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-02-02 01:27:25 UTC (rev 195995)
@@ -1,5 +1,62 @@
 2016-02-01  Matt Baker  <[email protected]>
 
+        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).
+
+2016-02-01  Matt Baker  <[email protected]>
+
         Web Inspector: Rendering Frames timeline draws all frame bars at minimum height
         https://bugs.webkit.org/show_bug.cgi?id=153736
         <rdar://problem/21946301>

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (195994 => 195995)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2016-02-02 01:12:48 UTC (rev 195994)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2016-02-02 01:27:25 UTC (rev 195995)
@@ -1341,8 +1341,8 @@
 
 WebInspector._windowResized = function(event)
 {
-    this.toolbar.updateLayout();
-    this.tabBar.updateLayout();
+    this.toolbar.updateLayout(WebInspector.View.LayoutReason.Resize);
+    this.tabBar.updateLayout(WebInspector.View.LayoutReason.Resize);
     this._tabBrowserSizeDidChange();
 };
 
@@ -1454,14 +1454,14 @@
 
 WebInspector._tabBrowserSizeDidChange = function()
 {
-    this.tabBrowser.updateLayout();
-    this.splitContentBrowser.updateLayout();
-    this.quickConsole.updateLayout();
+    this.tabBrowser.updateLayout(WebInspector.View.LayoutReason.Resize);
+    this.splitContentBrowser.updateLayout(WebInspector.View.LayoutReason.Resize);
+    this.quickConsole.updateLayout(WebInspector.View.LayoutReason.Resize);
 };
 
 WebInspector._quickConsoleDidResize = function(event)
 {
-    this.tabBrowser.updateLayout();
+    this.tabBrowser.updateLayout(WebInspector.View.LayoutReason.Resize);
 };
 
 WebInspector._sidebarWidthDidChange = function(event)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js (195994 => 195995)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2016-02-02 01:12:48 UTC (rev 195994)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2016-02-02 01:27:25 UTC (rev 195995)
@@ -742,7 +742,7 @@
             if (headerView) {
                 headerView.element.style.left = left + "px";
                 headerView.element.style.width = columnWidth + "px";
-                headerView.updateLayout();
+                headerView.updateLayout(WebInspector.View.LayoutReason.Resize);
             }
 
             left += columnWidth;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js (195994 => 195995)


--- trunk/Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js	2016-02-02 01:12:48 UTC (rev 195994)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js	2016-02-02 01:27:25 UTC (rev 195995)
@@ -81,7 +81,7 @@
         super.shown();
 
         this._treeOutlineDataGridSynchronizer.synchronize();
-        this._timelineRuler.resize();
+        this._timelineRuler.updateLayout(WebInspector.View.LayoutReason.Resize);
     }
 
     closed()
@@ -160,11 +160,6 @@
         WebInspector.showOriginalOrFormattedSourceCodeLocation(treeElement.sourceCodeTimeline.sourceCodeLocation);
     }
 
-    updateLayoutForResize()
-    {
-        this._timelineRuler.resize();
-    }
-
     layout()
     {
         let oldZeroTime = this._timelineRuler.zeroTime;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js (195994 => 195995)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js	2016-02-02 01:12:48 UTC (rev 195994)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js	2016-02-02 01:27:25 UTC (rev 195995)
@@ -265,12 +265,10 @@
     {
         this._visible = true;
 
-        this._timelineRuler.resize()
-
         for (var timelineOverviewGraph of this._timelineOverviewGraphsMap.values())
             timelineOverviewGraph.shown();
 
-        this.updateLayout();
+        this.updateLayout(WebInspector.View.LayoutReason.Resize);
     }
 
     hidden()
@@ -320,13 +318,6 @@
         overviewGraph.selectedRecord = record;
     }
 
-    updateLayoutForResize()
-    {
-        this._cachedScrollContainerWidth = NaN;
-        this._timelineRuler.resize()
-        this.updateLayout();
-    }
-
     updateLayoutIfNeeded()
     {
         if (this.layoutPending) {
@@ -353,8 +344,11 @@
         console.error("Needs to be implemented by a subclass.");
     }
 
-    layout()
+    layout(layoutReason)
     {
+        if (layoutReason === WebInspector.View.LayoutReason.Resize)
+            this._cachedScrollContainerWidth = NaN;
+
         // Calculate the required width based on the duration and seconds per pixel.
         let duration = this._endTime - this._startTime;
         let newWidth = Math.ceil(duration / this._durationPerPixel);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js (195994 => 195995)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2016-02-02 01:12:48 UTC (rev 195994)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2016-02-02 01:27:25 UTC (rev 195995)
@@ -324,17 +324,6 @@
         return true;
     }
 
-    // Protected
-
-    layout()
-    {
-        this._currentTimelineOverview.updateLayoutForResize();
-
-        let currentContentView = this._contentViewContainer.currentContentView;
-        if (currentContentView && currentContentView.updateLayoutForResize)
-            currentContentView.updateLayoutForResize();
-    }
-
     // Private
 
     _currentContentViewDidChange(event)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js (195994 => 195995)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js	2016-02-02 01:12:48 UTC (rev 195994)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js	2016-02-02 01:27:25 UTC (rev 195995)
@@ -358,7 +358,7 @@
             this._updateSelection(visibleWidth, this.duration);
     }
 
-    needsLayout()
+    needsLayout(layoutReason)
     {
         if (this.layoutPending)
             return;
@@ -373,13 +373,16 @@
             this._scheduledSelectionLayoutUpdateIdentifier = undefined;
         }
 
-        super.needsLayout();
+        super.needsLayout(layoutReason);
     }
 
     // Protected
 
-    layout()
+    layout(layoutReason)
     {
+        if (layoutReason === WebInspector.View.LayoutReason.Resize)
+            this._cachedClientWidth = this.element.clientWidth;
+
         let visibleWidth = this._recalculate();
         if (visibleWidth <= 0)
             return;
@@ -537,12 +540,6 @@
         });
     }
 
-    resize()
-    {
-        this._cachedClientWidth = this.element.clientWidth;
-        this._recalculate();
-    }
-
     _recalculate()
     {
         let visibleWidth = this._cachedClientWidth;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/View.js (195994 => 195995)


--- trunk/Source/WebInspectorUI/UserInterface/Views/View.js	2016-02-02 01:12:48 UTC (rev 195994)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/View.js	2016-02-02 01:27:25 UTC (rev 195995)
@@ -37,6 +37,7 @@
         this._dirtyDescendantsCount = 0;
         this._needsLayoutWhenAttachedToRoot = false;
         this._isAttachedToRoot = false;
+        this._layoutReason = null;
     }
 
     // Static
@@ -137,9 +138,11 @@
         this.removeSubview(oldView);
     }
 
-    updateLayout()
+    updateLayout(layoutReason)
     {
         WebInspector.View._cancelScheduledLayoutForView(this);
+
+        this._setLayoutReason(layoutReason);
         this._layoutSubtree();
     }
 
@@ -151,8 +154,10 @@
         this.updateLayout();
     }
 
-    needsLayout()
+    needsLayout(layoutReason)
     {
+        this._setLayoutReason(layoutReason);
+
         if (this._dirty)
             return;
 
@@ -209,12 +214,24 @@
         this._dirty = false;
         this._dirtyDescendantsCount = 0;
 
-        this.layout();
+        this.layout(this._layoutReason);
 
-        for (let view of this._subviews)
+        for (let view of this._subviews) {
+            view._setLayoutReason(this._layoutReason);
             view._layoutSubtree();
+        }
+
+        this._layoutReason = null;
     }
 
+    _setLayoutReason(layoutReason)
+    {
+        if (this._layoutReason === WebInspector.View.LayoutReason.Resize)
+            return;
+
+        this._layoutReason = layoutReason || WebInspector.View.LayoutReason.Dirty;
+    }
+
     // Layout controller logic
 
     static _scheduleLayoutForView(view)
@@ -283,5 +300,10 @@
     }
 };
 
+WebInspector.View.LayoutReason = {
+    Dirty: Symbol("layout-reason-dirty"),
+    Resize: Symbol("layout-reason-resize")
+};
+
 WebInspector.View._rootView = null;
 WebInspector.View._scheduledLayoutUpdateIdentifier = undefined;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to