Web Inspector: Convert remaining ContentViews to View base class
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Nov 2015 00:03:59 +0000 (00:03 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Nov 2015 00:03:59 +0000 (00:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150729

Reviewed by Brian Burg.

Refactor content views to reuse View features: remove updateLayout and
element getters, and use View.prototype.addSubview and removeSubview
where appropriate.

* UserInterface/Views/ApplicationCacheFrameContentView.js:
(WebInspector.ApplicationCacheFrameContentView.prototype._createDataGrid):
* UserInterface/Views/ClusterContentView.js:
(WebInspector.ClusterContentView):
(WebInspector.ClusterContentView.prototype.updateLayout): Deleted.
* UserInterface/Views/CookieStorageContentView.js:
(WebInspector.CookieStorageContentView.prototype._rebuildTable):
(WebInspector.CookieStorageContentView.prototype.updateLayout): Deleted.
* UserInterface/Views/DOMStorageContentView.js:
(WebInspector.DOMStorageContentView):
(WebInspector.DOMStorageContentView.prototype.updateLayout): Deleted.
* UserInterface/Views/DOMTreeContentView.js:
(WebInspector.DOMTreeContentView.prototype.layout):
(WebInspector.DOMTreeContentView.prototype.updateLayout): Deleted.
* UserInterface/Views/DatabaseTableContentView.js:
(WebInspector.DatabaseTableContentView):
(WebInspector.DatabaseTableContentView.prototype._queryFinished):
(WebInspector.DatabaseTableContentView.prototype._queryError):
* UserInterface/Views/FontResourceContentView.js:
(WebInspector.FontResourceContentView.prototype.layout):
(WebInspector.FontResourceContentView):
(WebInspector.FontResourceContentView.prototype.updateLayout): Deleted.
* UserInterface/Views/IndexedDatabaseObjectStoreContentView.js:
(WebInspector.IndexedDatabaseObjectStoreContentView):
(WebInspector.IndexedDatabaseObjectStoreContentView.prototype.updateLayout): Deleted.
* UserInterface/Views/LogContentView.js:
(WebInspector.LogContentView.prototype.layout):
(WebInspector.LogContentView.prototype.updateLayout): Deleted.
* UserInterface/Views/NetworkGridContentView.js:
(WebInspector.NetworkGridContentView):
(WebInspector.NetworkGridContentView.prototype.needsLayout):
(WebInspector.NetworkGridContentView.prototype.layout):
(WebInspector.NetworkGridContentView.prototype.updateLayout): Deleted.
* UserInterface/Views/OverviewTimelineView.js:
(WebInspector.OverviewTimelineView):
(WebInspector.OverviewTimelineView.prototype.layout): Deleted.
* UserInterface/Views/ScriptContentView.js:
(WebInspector.ScriptContentView.prototype._contentWillPopulate):
(WebInspector.ScriptContentView.prototype.updateLayout): Deleted.
* UserInterface/Views/TextContentView.js:
(WebInspector.TextContentView):
(WebInspector.TextContentView.prototype.updateLayout): Deleted.
* UserInterface/Views/TextEditor.js:
(WebInspector.TextEditor):
(WebInspector.TextEditor.prototype.layout):
(WebInspector.TextEditor.prototype.get element): Deleted.
(WebInspector.TextEditor.prototype.updateLayout): Deleted.
* UserInterface/Views/TimelineRecordingContentView.js:
(WebInspector.TimelineRecordingContentView):
(WebInspector.TimelineRecordingContentView.prototype.layout):
(WebInspector.TimelineRecordingContentView.prototype._currentContentViewDidChange):
(WebInspector.TimelineRecordingContentView.prototype.updateLayout): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192086 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/ApplicationCacheFrameContentView.js
Source/WebInspectorUI/UserInterface/Views/ClusterContentView.js
Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js
Source/WebInspectorUI/UserInterface/Views/DOMStorageContentView.js
Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js
Source/WebInspectorUI/UserInterface/Views/DatabaseTableContentView.js
Source/WebInspectorUI/UserInterface/Views/FontResourceContentView.js
Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseObjectStoreContentView.js
Source/WebInspectorUI/UserInterface/Views/LogContentView.js
Source/WebInspectorUI/UserInterface/Views/NetworkGridContentView.js
Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js
Source/WebInspectorUI/UserInterface/Views/ScriptContentView.js
Source/WebInspectorUI/UserInterface/Views/TextContentView.js
Source/WebInspectorUI/UserInterface/Views/TextEditor.js
Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js

index 188bf7f..4256080 100644 (file)
@@ -1,3 +1,67 @@
+2015-11-05  Matt Baker  <mattbaker@apple.com>
+
+        Web Inspector: Convert remaining ContentViews to View base class
+        https://bugs.webkit.org/show_bug.cgi?id=150729
+
+        Reviewed by Brian Burg.
+
+        Refactor content views to reuse View features: remove updateLayout and
+        element getters, and use View.prototype.addSubview and removeSubview
+        where appropriate.
+
+        * UserInterface/Views/ApplicationCacheFrameContentView.js:
+        (WebInspector.ApplicationCacheFrameContentView.prototype._createDataGrid):
+        * UserInterface/Views/ClusterContentView.js:
+        (WebInspector.ClusterContentView):
+        (WebInspector.ClusterContentView.prototype.updateLayout): Deleted.
+        * UserInterface/Views/CookieStorageContentView.js:
+        (WebInspector.CookieStorageContentView.prototype._rebuildTable):
+        (WebInspector.CookieStorageContentView.prototype.updateLayout): Deleted.
+        * UserInterface/Views/DOMStorageContentView.js:
+        (WebInspector.DOMStorageContentView):
+        (WebInspector.DOMStorageContentView.prototype.updateLayout): Deleted.
+        * UserInterface/Views/DOMTreeContentView.js:
+        (WebInspector.DOMTreeContentView.prototype.layout):
+        (WebInspector.DOMTreeContentView.prototype.updateLayout): Deleted.
+        * UserInterface/Views/DatabaseTableContentView.js:
+        (WebInspector.DatabaseTableContentView):
+        (WebInspector.DatabaseTableContentView.prototype._queryFinished):
+        (WebInspector.DatabaseTableContentView.prototype._queryError):
+        * UserInterface/Views/FontResourceContentView.js:
+        (WebInspector.FontResourceContentView.prototype.layout):
+        (WebInspector.FontResourceContentView):
+        (WebInspector.FontResourceContentView.prototype.updateLayout): Deleted.
+        * UserInterface/Views/IndexedDatabaseObjectStoreContentView.js:
+        (WebInspector.IndexedDatabaseObjectStoreContentView):
+        (WebInspector.IndexedDatabaseObjectStoreContentView.prototype.updateLayout): Deleted.
+        * UserInterface/Views/LogContentView.js:
+        (WebInspector.LogContentView.prototype.layout):
+        (WebInspector.LogContentView.prototype.updateLayout): Deleted.
+        * UserInterface/Views/NetworkGridContentView.js:
+        (WebInspector.NetworkGridContentView):
+        (WebInspector.NetworkGridContentView.prototype.needsLayout):
+        (WebInspector.NetworkGridContentView.prototype.layout):
+        (WebInspector.NetworkGridContentView.prototype.updateLayout): Deleted.
+        * UserInterface/Views/OverviewTimelineView.js:
+        (WebInspector.OverviewTimelineView):
+        (WebInspector.OverviewTimelineView.prototype.layout): Deleted.
+        * UserInterface/Views/ScriptContentView.js:
+        (WebInspector.ScriptContentView.prototype._contentWillPopulate):
+        (WebInspector.ScriptContentView.prototype.updateLayout): Deleted.
+        * UserInterface/Views/TextContentView.js:
+        (WebInspector.TextContentView):
+        (WebInspector.TextContentView.prototype.updateLayout): Deleted.
+        * UserInterface/Views/TextEditor.js:
+        (WebInspector.TextEditor):
+        (WebInspector.TextEditor.prototype.layout):
+        (WebInspector.TextEditor.prototype.get element): Deleted.
+        (WebInspector.TextEditor.prototype.updateLayout): Deleted.
+        * UserInterface/Views/TimelineRecordingContentView.js:
+        (WebInspector.TimelineRecordingContentView):
+        (WebInspector.TimelineRecordingContentView.prototype.layout):
+        (WebInspector.TimelineRecordingContentView.prototype._currentContentViewDidChange):
+        (WebInspector.TimelineRecordingContentView.prototype.updateLayout): Deleted.
+
 2015-11-05  Nikita Vasilyev  <nvasilyev@apple.com>
 
         Web Inspector: Pretty print falsely triggers on some JS that wasn't minified
index 0186dc3..5a82d5f 100644 (file)
@@ -171,7 +171,7 @@ WebInspector.ApplicationCacheFrameContentView = class ApplicationCacheFrameConte
         this._dataGrid.sortColumnIdentifier = "url";
         this._dataGrid.sortOrder = WebInspector.DataGrid.SortOrder.Ascending;
 
-        this.element.appendChild(this._dataGrid.element);
+        this.addSubview(this._dataGrid);
         this._dataGrid.updateLayout();
     }
 
index 0413591..34b8bfb 100644 (file)
@@ -33,7 +33,7 @@ WebInspector.ClusterContentView = class ClusterContentView extends WebInspector.
 
         this._contentViewContainer = new WebInspector.ContentViewContainer;
         this._contentViewContainer.addEventListener(WebInspector.ContentViewContainer.Event.CurrentContentViewDidChange, this._currentContentViewDidChange, this);
-        this.element.appendChild(this._contentViewContainer.element);
+        this.addSubview(this._contentViewContainer);
 
         WebInspector.ContentView.addEventListener(WebInspector.ContentView.Event.SelectionPathComponentsDidChange, this._contentViewSelectionPathComponentDidChange, this);
         WebInspector.ContentView.addEventListener(WebInspector.ContentView.Event.SupplementalRepresentedObjectsDidChange, this._contentViewSupplementalRepresentedObjectsDidChange, this);
@@ -60,11 +60,6 @@ WebInspector.ClusterContentView = class ClusterContentView extends WebInspector.
         return true;
     }
 
-    updateLayout()
-    {
-        this._contentViewContainer.updateLayout();
-    }
-
     shown()
     {
         this._contentViewContainer.shown();
index d1de268..0dbb5bb 100644 (file)
@@ -78,12 +78,6 @@ WebInspector.CookieStorageContentView = class CookieStorageContentView extends W
         PageAgent.getCookies(callback.bind(this));
     }
 
-    updateLayout()
-    {
-        if (this._dataGrid)
-            this._dataGrid.updateLayout();
-    }
-
     saveToCookie(cookie)
     {
         cookie.type = WebInspector.ContentViewCookieType.CookieStorage;
@@ -144,7 +138,7 @@ WebInspector.CookieStorageContentView = class CookieStorageContentView extends W
             this._dataGrid = new WebInspector.DataGrid(columns, null, this._deleteCallback.bind(this));
             this._dataGrid.addEventListener(WebInspector.DataGrid.Event.SortChanged, this._sortDataGrid, this);
 
-            this.element.appendChild(this._dataGrid.element);
+            this.addSubview(this._dataGrid);
             this._dataGrid.updateLayout();
         }
 
index d2dc98b..92f3d71 100644 (file)
@@ -46,7 +46,7 @@ WebInspector.DOMStorageContentView = class DOMStorageContentView extends WebInsp
         this._dataGrid.sortColumnIdentifier = "key";
         this._dataGrid.addEventListener(WebInspector.DataGrid.Event.SortChanged, this._sortDataGrid, this);
 
-        this.element.appendChild(this._dataGrid.element);
+        this.addSubview(this._dataGrid);
 
         this._populate();
     }
@@ -112,12 +112,6 @@ WebInspector.DOMStorageContentView = class DOMStorageContentView extends WebInsp
         this._sortDataGrid();
     }
 
-    updateLayout()
-    {
-        if (this._dataGrid)
-            this._dataGrid.updateLayout();
-    }
-
     get scrollableElements()
     {
         if (!this._dataGrid)
index 1432efa..add37b2 100644 (file)
@@ -81,11 +81,6 @@ WebInspector.DOMTreeContentView = class DOMTreeContentView extends WebInspector.
         return [this.element];
     }
 
-    updateLayout()
-    {
-        this._domTreeOutline.updateSelection();
-    }
-
     shown()
     {
         this._domTreeOutline.setVisible(true, WebInspector.isConsoleFocused());
@@ -284,6 +279,13 @@ WebInspector.DOMTreeContentView = class DOMTreeContentView extends WebInspector.
         this._revealSearchResult(this._currentSearchResultIndex, changeFocus);
     }
 
+    // Protected
+
+    layout()
+    {
+        this._domTreeOutline.updateSelection();
+    }
+
     // Private
 
     _revealSearchResult(index, changeFocus)
index c5e9467..9626292 100644 (file)
@@ -33,6 +33,7 @@ WebInspector.DatabaseTableContentView = class DatabaseTableContentView extends W
 
         this._refreshButtonNavigationItem = new WebInspector.ButtonNavigationItem("database-table-refresh", WebInspector.UIString("Refresh"), "Images/ReloadFull.svg", 13, 13);
         this._refreshButtonNavigationItem.addEventListener(WebInspector.ButtonNavigationItem.Event.Clicked, this._refreshButtonClicked, this);
+        this._messageTextViewElement = null;
 
         this.update();
     }
@@ -82,27 +83,40 @@ WebInspector.DatabaseTableContentView = class DatabaseTableContentView extends W
         // It would be nice to do better than creating a new data grid each time the table is updated, but the table updating
         // doesn't happen very frequently. Additionally, using DataGrid's createSortableDataGrid makes our code much cleaner and it knows
         // how to sort arbitrary columns.
-        this.element.removeChildren();
+        if (this._dataGrid) {
+            this.removeSubview(this._dataGrid);
+            this._dataGrid = null;
+        }
+
+        if (this._messageTextViewElement)
+            this._messageTextViewElement.remove();
 
-        this._dataGrid = WebInspector.DataGrid.createSortableDataGrid(columnNames, values);
-        if (!this._dataGrid || !this._dataGrid.element) {
-            this._dataGrid = undefined;
+        if (columnNames.length) {
+            this._dataGrid = WebInspector.DataGrid.createSortableDataGrid(columnNames, values);
 
-            // If the DataGrid is empty, then we were returned a table with no columns. This can happen when a table has
-            // no data, the SELECT query only returns column names when there is data.
-            this.element.removeChildren();
-            this.element.appendChild(WebInspector.createMessageTextView(WebInspector.UIString("The “%s”\ntable is empty.").format(this.representedObject.name), false));
+            this.addSubview(this._dataGrid);
+            this.updateLayout();
             return;
         }
 
-        this.element.appendChild(this._dataGrid.element);
-        this._dataGrid.updateLayout();
+        // We were returned a table with no columns. This can happen when a table has
+        // no data, the SELECT query only returns column names when there is data.
+        this._messageTextViewElement = WebInspector.createMessageTextView(WebInspector.UIString("The “%s”\ntable is empty.").format(this.representedObject.name), false);
+        this.element.appendChild(this._messageTextViewElement);
     }
 
     _queryError(error)
     {
-        this.element.removeChildren();
-        this.element.appendChild(WebInspector.createMessageTextView(WebInspector.UIString("An error occured trying to\nread the “%s” table.").format(this.representedObject.name), true));
+        if (this._dataGrid) {
+            this.removeSubview(this._dataGrid);
+            this._dataGrid = null;
+        }
+
+        if (this._messageTextViewElement)
+            this._messageTextViewElement.remove();
+
+        this._messageTextViewElement = WebInspector.createMessageTextView(WebInspector.UIString("An error occured trying to\nread the “%s” table.").format(this.representedObject.name), true);
+        this.element.appendChild(this._messageTextViewElement);
     }
 
     _refreshButtonClicked()
index 95ccb7f..2e56a09 100644 (file)
@@ -112,11 +112,6 @@ WebInspector.FontResourceContentView = class FontResourceContentView extends Web
         this.sizeToFit();
     }
 
-    updateLayout()
-    {
-        this.sizeToFit();
-    }
-
     shown()
     {
         // Add the style element since it is removed when hidden.
@@ -140,6 +135,13 @@ WebInspector.FontResourceContentView = class FontResourceContentView extends Web
         if (this._fontObjectURL)
             URL.revokeObjectURL(this._fontObjectURL);
     }
+
+    // Protected
+
+    layout()
+    {
+        this.sizeToFit();
+    }
 }
 
 WebInspector.FontResourceContentView._uniqueFontIdentifier = 0;
index 0ea9a0b..ac86054 100644 (file)
@@ -69,7 +69,7 @@ WebInspector.IndexedDatabaseObjectStoreContentView = class IndexedDatabaseObject
 
         this._dataGrid = new WebInspector.DataGrid(columnInfo);
         this._dataGrid.scrollContainer.addEventListener("scroll", this._dataGridScrolled.bind(this));
-        this.element.appendChild(this._dataGrid.element);
+        this.addSubview(this._dataGrid);
 
         this._entries = [];
 
@@ -100,11 +100,6 @@ WebInspector.IndexedDatabaseObjectStoreContentView = class IndexedDatabaseObject
         cookie.objectStoreIndexName = this._objectStoreIndex && this._objectStoreIndex.name;
     }
 
-    updateLayout()
-    {
-        this._dataGrid.updateLayout();
-    }
-
     // Private
 
     _reset()
index 39577b5..dd85d2f 100644 (file)
@@ -107,13 +107,6 @@ WebInspector.LogContentView = class LogContentView extends WebInspector.ContentV
         return this._logViewController;
     }
 
-    updateLayout()
-    {
-        super.updateLayout();
-
-        this._scrollElementHeight = this.messagesElement.getBoundingClientRect().height;
-    }
-
     get scrollableElements()
     {
         return [this.element];
@@ -253,6 +246,13 @@ WebInspector.LogContentView = class LogContentView extends WebInspector.ContentV
             this.prompt.focus();
     }
 
+    // Protected
+
+    layout()
+    {
+        this._scrollElementHeight = this.messagesElement.getBoundingClientRect().height;
+    }
+
     // Private
 
     _formatMessagesAsData(onlySelected)
index f3d672f..a34ed35 100644 (file)
@@ -86,7 +86,7 @@ WebInspector.NetworkGridContentView = class NetworkGridContentView extends WebIn
         this._dataGrid.sortOrder = WebInspector.DataGrid.SortOrder.Ascending;
 
         this.element.classList.add("network-grid");
-        this.element.appendChild(this._dataGrid.element);
+        this.addSubview(this._dataGrid);
 
         var networkTimeline = WebInspector.timelineManager.persistentNetworkTimeline;
         networkTimeline.addEventListener(WebInspector.Timeline.Event.RecordAdded, this._networkTimelineRecordAdded, this);
@@ -136,27 +136,12 @@ WebInspector.NetworkGridContentView = class NetworkGridContentView extends WebIn
         this._dataGrid.closed();
     }
 
-    updateLayout()
-    {
-        if (this._scheduledLayoutUpdateIdentifier) {
-            cancelAnimationFrame(this._scheduledLayoutUpdateIdentifier);
-            delete this._scheduledLayoutUpdateIdentifier;
-        }
-
-        this._dataGrid.updateLayout();
-
-        this._processPendingRecords();
-    }
-
     needsLayout()
     {
         if (!this._networkSidebarPanel.visible)
             return;
 
-        if (this._scheduledLayoutUpdateIdentifier)
-            return;
-
-        this._scheduledLayoutUpdateIdentifier = requestAnimationFrame(this.updateLayout.bind(this));
+        super.needsLayout();
     }
 
     reset()
@@ -165,6 +150,13 @@ WebInspector.NetworkGridContentView = class NetworkGridContentView extends WebIn
         this._dataGrid.reset();
     }
 
+    // Protected
+
+    layout()
+    {
+        this._processPendingRecords();
+    }
+
     // Private
 
     _processPendingRecords()
index edfd44b..a6e6ec3 100644 (file)
@@ -41,8 +41,7 @@ WebInspector.OverviewTimelineView = class OverviewTimelineView extends WebInspec
 
         this._timelineRuler = new WebInspector.TimelineRuler;
         this._timelineRuler.allowsClippedLabels = true;
-        // FIXME: change to `this.addSubview(this._timelineRuler)` once <https://webkit.org/b/150703> is fixed.
-        this.element.appendChild(this._timelineRuler.element);
+        this.addSubview(this._timelineRuler);
 
         this._currentTimeMarker = new WebInspector.TimelineMarker(0, WebInspector.TimelineMarker.Type.CurrentTime);
         this._timelineRuler.addMarker(this._currentTimeMarker);
@@ -182,9 +181,6 @@ WebInspector.OverviewTimelineView = class OverviewTimelineView extends WebInspec
             }
         }
 
-        // FIXME: remove once <https://webkit.org/b/150703> is fixed.
-        this._timelineRuler.updateLayout();
-
         this._processPendingRepresentedObjects();
     }
 
index 408ec5c..1f7b1ff 100644 (file)
@@ -184,11 +184,6 @@ WebInspector.ScriptContentView = class ScriptContentView extends WebInspector.Co
         this._textEditor.revealNextSearchResult(changeFocus);
     }
 
-    updateLayout()
-    {
-        this._textEditor.updateLayout();
-    }
-
     // Private
 
     _contentWillPopulate(event)
@@ -201,7 +196,7 @@ WebInspector.ScriptContentView = class ScriptContentView extends WebInspector.Co
             this._textEditor.readOnly = false;
 
         this.element.removeChildren();
-        this.element.appendChild(this._textEditor.element);
+        this.addSubview(this._textEditor);
     }
 
     _contentDidPopulate(event)
index 41c9992..d3a5e59 100644 (file)
@@ -35,7 +35,7 @@ WebInspector.TextContentView = class TextContentView extends WebInspector.Conten
         this._textEditor.addEventListener(WebInspector.TextEditor.Event.NumberOfSearchResultsDidChange, this._numberOfSearchResultsDidChange, this);
         this._textEditor.addEventListener(WebInspector.TextEditor.Event.FormattingDidChange, this._textEditorFormattingDidChange, this);
 
-        this.element.appendChild(this._textEditor.element);
+        this.addSubview(this._textEditor);
 
         this._textEditor.readOnly = true;
         this._textEditor.mimeType = mimeType;
@@ -147,11 +147,6 @@ WebInspector.TextContentView = class TextContentView extends WebInspector.Conten
         this._textEditor.revealNextSearchResult(changeFocus);
     }
 
-    updateLayout()
-    {
-        this._textEditor.updateLayout();
-    }
-
     // Private
 
     _togglePrettyPrint(event)
index eab01b3..4c718f5 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-WebInspector.TextEditor = class TextEditor extends WebInspector.Object
+WebInspector.TextEditor = class TextEditor extends WebInspector.View
 {
     constructor(element, mimeType, delegate)
     {
-        super();
+        super(element);
 
-        this._element = element || document.createElement("div");
-        this._element.classList.add("text-editor", WebInspector.SyntaxHighlightedStyleClassName);
+        this.element.classList.add("text-editor", WebInspector.SyntaxHighlightedStyleClassName);
 
         // FIXME: <https://webkit.org/b/149120> Web Inspector: Preferences for Text Editor behavior
         this._codeMirror = CodeMirror(this.element, {
@@ -72,11 +71,6 @@ WebInspector.TextEditor = class TextEditor extends WebInspector.Object
 
     // Public
 
-    get element()
-    {
-        return this._element;
-    }
-
     get visible()
     {
         return this._visible;
@@ -505,15 +499,6 @@ WebInspector.TextEditor = class TextEditor extends WebInspector.Object
         this._codeMirror.operation(revealAndHighlightLine.bind(this));
     }
 
-    updateLayout(force)
-    {
-        // FIXME: <https://webkit.org/b/146256> Web Inspector: Nested ContentBrowsers / ContentViewContainers cause too many ContentView updates
-        // Ideally we would not get an updateLayout call if we are not visible. We should restructure ContentView
-        // show/hide restoration to reduce duplicated work and solve this in the process.
-        if (this._visible)
-            this._codeMirror.refresh();
-    }
-
     shown()
     {
         this._visible = true;
@@ -724,6 +709,17 @@ WebInspector.TextEditor = class TextEditor extends WebInspector.Object
 
     // Protected
 
+    layout()
+    {
+        // FIXME: <https://webkit.org/b/146256> Web Inspector: Nested ContentBrowsers / ContentViewContainers cause too many ContentView updates
+        // Ideally we would not get an updateLayout call if we are not visible. We should restructure ContentView
+        // show/hide restoration to reduce duplicated work and solve this in the process.
+
+        // FIXME: visible check can be removed once <https://webkit.org/b/150741> is fixed.
+        if (this._visible)
+            this._codeMirror.refresh();
+    }
+
     prettyPrint(pretty)
     {
         function prettyPrintAndUpdateEditor()
@@ -937,7 +933,7 @@ WebInspector.TextEditor = class TextEditor extends WebInspector.Object
         var coordinates = this._codeMirror.cursorCoords(true, "page");
 
         // Adjust the coordinates to be based in the text editor's space.
-        var textEditorRect = this._element.getBoundingClientRect();
+        let textEditorRect = this.element.getBoundingClientRect();
         coordinates.top -= textEditorRect.top;
         coordinates.left -= textEditorRect.left;
 
@@ -945,7 +941,7 @@ WebInspector.TextEditor = class TextEditor extends WebInspector.Object
         this._bouncyHighlightElement.textContent = textContent;
         this._bouncyHighlightElement.style.top = coordinates.top + "px";
         this._bouncyHighlightElement.style.left = coordinates.left + "px";
-        this._element.appendChild(this._bouncyHighlightElement);
+        this.element.appendChild(this._bouncyHighlightElement);
 
         function animationEnded()
         {
index 7597bc8..f385110 100644 (file)
@@ -46,11 +46,13 @@ WebInspector.TimelineRecordingContentView = class TimelineRecordingContentView e
         this._renderingFrameTimelineOverview.addEventListener(WebInspector.TimelineOverview.Event.RecordSelected, this._recordSelected, this);
 
         this._currentTimelineOverview = this._linearTimelineOverview;
+
+        // FIXME: use View.prototype.addSubview once <https://webkit.org/b/149190> is fixed.
         this.element.appendChild(this._currentTimelineOverview.element);
 
         this._contentViewContainer = new WebInspector.ContentViewContainer;
         this._contentViewContainer.addEventListener(WebInspector.ContentViewContainer.Event.CurrentContentViewDidChange, this._currentContentViewDidChange, this);
-        this.element.appendChild(this._contentViewContainer.element);
+        this.addSubview(this._contentViewContainer);
 
         this._clearTimelineNavigationItem = new WebInspector.ButtonNavigationItem("clear-timeline", WebInspector.UIString("Clear Timeline"), "Images/NavigationItemTrash.svg", 15, 15);
         this._clearTimelineNavigationItem.addEventListener(WebInspector.ButtonNavigationItem.Event.Clicked, this._clearTimeline, this);
@@ -210,12 +212,6 @@ WebInspector.TimelineRecordingContentView = class TimelineRecordingContentView e
         this._contentViewContainer.goForward();
     }
 
-    updateLayout()
-    {
-        this._currentTimelineOverview.updateLayoutForResize();
-        this._contentViewContainer.updateLayout();
-    }
-
     saveToCookie(cookie)
     {
         cookie.type = WebInspector.ContentViewCookieType.Timelines;
@@ -324,6 +320,13 @@ WebInspector.TimelineRecordingContentView = class TimelineRecordingContentView e
         return true;
     }
 
+    // Protected
+
+    layout()
+    {
+        this._currentTimelineOverview.updateLayoutForResize();
+    }
+
     // Private
 
     _currentContentViewDidChange(event)
@@ -338,6 +341,7 @@ WebInspector.TimelineRecordingContentView = class TimelineRecordingContentView e
         if (newTimelineOverview !== this._currentTimelineOverview) {
             this._currentTimelineOverview.hidden();
 
+            // FIXME: use View.prototype.replaceSubview once <https://webkit.org/b/149190> is fixed.
             this.element.insertBefore(newTimelineOverview.element, this._currentTimelineOverview.element);
             this.element.removeChild(this._currentTimelineOverview.element);