Web Inspector: refactor revision history to not include resource itself.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 May 2012 17:27:37 +0000 (17:27 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 May 2012 17:27:37 +0000 (17:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=87026

Reviewed by Vsevolod Vlasov.

Source/WebCore:

This change makes resource contain pure revisions, it stops updating Resources upon free flow editing.

* inspector/front-end/JavaScriptSource.js:
(WebInspector.JavaScriptSource.prototype.setFormatted.didGetContent.didFormatContent):
(WebInspector.JavaScriptSource.prototype.setFormatted.didGetContent):
(WebInspector.JavaScriptSource.prototype.setFormatted):
* inspector/front-end/JavaScriptSourceFrame.js:
(WebInspector.JavaScriptSourceFrame.prototype.commitEditing):
(WebInspector.JavaScriptSourceFrame.prototype._onContentChanged):
(WebInspector.JavaScriptSourceFrame.prototype._didEditContent):
* inspector/front-end/Resource.js:
(WebInspector.Resource.prototype.addRevision):
(WebInspector.Resource.prototype._innerRequestContent.callback):
(WebInspector.Resource.prototype._innerRequestContent):
(WebInspector.Resource.prototype.revertToOriginal):
(WebInspector.ResourceRevision.prototype.revertToThis):
(WebInspector.ResourceRevision.prototype.requestContent):
(WebInspector.ResourceRevision.prototype.searchInContent):
(WebInspector.ResourceRevision.prototype._persistRevision):
* inspector/front-end/RevisionHistoryView.js:
(WebInspector.RevisionHistoryView):
(WebInspector.RevisionHistoryView.prototype._revisionAdded):
(WebInspector.RevisionHistoryTreeElement):
* inspector/front-end/ScriptSnippetModel.js:
(WebInspector.ScriptSnippetModel.prototype.setScriptSnippetContent):
* inspector/front-end/StylesPanel.js:
(WebInspector.StyleSourceFrame.prototype.commitEditing):
(WebInspector.StyleSourceFrame.prototype._didEditContent):
(WebInspector.StyleSourceFrame.prototype._onContentChanged):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode.prototype._revisionAdded):
(WebInspector.UISourceCode.prototype.contentChanged):
(WebInspector.UISourceCode.prototype.commitWorkingCopy):
* inspector/front-end/inspector.js:
(WebInspector._doLoadedDoneWithCapabilities.get if):

LayoutTests:

* http/tests/inspector/network/network-request-revision-content.html:
* inspector/styles/styles-history-expected.txt:
* inspector/styles/styles-history.html:

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/network/network-request-revision-content.html
LayoutTests/inspector/styles/styles-history-expected.txt
LayoutTests/inspector/styles/styles-history.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/JavaScriptSource.js
Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js
Source/WebCore/inspector/front-end/Resource.js
Source/WebCore/inspector/front-end/RevisionHistoryView.js
Source/WebCore/inspector/front-end/ScriptSnippetModel.js
Source/WebCore/inspector/front-end/StylesPanel.js
Source/WebCore/inspector/front-end/UISourceCode.js
Source/WebCore/inspector/front-end/inspector.js

index b8c93f9..f546225 100644 (file)
@@ -1,3 +1,14 @@
+2012-05-21  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: refactor revision history to not include resource itself.
+        https://bugs.webkit.org/show_bug.cgi?id=87026
+
+        Reviewed by Vsevolod Vlasov.
+
+        * http/tests/inspector/network/network-request-revision-content.html:
+        * inspector/styles/styles-history-expected.txt:
+        * inspector/styles/styles-history.html:
+
 2012-05-21  Stephen Chenney  <schenney@chromium.org>
 
         SVGAnimatedPropertyTearOff does not clear a self pointer on deletion
index e69951e..f584ead 100644 (file)
@@ -23,10 +23,10 @@ function test()
         resource.history[0].requestContent(step3);
     }
 
-    function step3()
+    function step3(content)
     {
         InspectorTest.addResult(resource.url);
-        InspectorTest.addResult(resource.content);
+        InspectorTest.addResult(content);
         InspectorTest.completeTest();
     }
 }
index 688e4b2..5db7f58 100644 (file)
@@ -5,23 +5,11 @@ Running: testSetUp
 
 Running: testSetResourceContentMinor
 History length: 0
-Item <tip>:
-body {
-  margin: 10px;
-  padding: 10px;
-}
-
 
 Running: testSetResourceContentMajor
 History length: 1
 Item 0:
 body {
-  margin: 10px;
-  padding: 10px;
-}
-
-Item <tip>:
-body {
   margin: 20px;
   padding: 10px;
 }
@@ -30,12 +18,6 @@ Running: testSetContentViaModelMinor
 History length: 1
 Item 0:
 body {
-  margin: 10px;
-  padding: 10px;
-}
-
-Item <tip>:
-body {
   margin: 20px;
   padding: 10px;
 }
@@ -44,16 +26,10 @@ Running: testSetContentViaModelMajor
 History length: 2
 Item 0:
 body {
-  margin: 10px;
-  padding: 10px;
-}
-
-Item 1:
-body {
   margin: 20px;
   padding: 10px;
 }
-Item <tip>:
+Item 1:
 body {
   margin:30px;
   padding: 10px;
index cbe7626..59dc5e3 100644 (file)
@@ -96,20 +96,14 @@ function test()
         function result()
         {
             InspectorTest.addResult("History length: " + styleResource.history.length);
-            for (var i = 0; i < styleResource.history.length; ++i)
-                styleResource.history[i].requestContent(dumpRevision.bind(this, i, null));
-            styleResource.requestContent(dumpRevision.bind(this, "<tip>", next));
+            for (var i = 0; i < styleResource.history.length; ++i) {
+                InspectorTest.addResult("Item " + i + ":");
+                InspectorTest.addResult(styleResource.history[i].content);
+            }
+            next();
         }
         return result;
     }
-
-    function dumpRevision(index, next, content)
-    {
-        InspectorTest.addResult("Item " + index + ":");
-        InspectorTest.addResult(content);
-        if (next)
-            next();
-    }
 }
 
 </script>
index 2f2bb74..fdeaa10 100644 (file)
@@ -1,3 +1,46 @@
+2012-05-21  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: refactor revision history to not include resource itself.
+        https://bugs.webkit.org/show_bug.cgi?id=87026
+
+        Reviewed by Vsevolod Vlasov.
+
+        This change makes resource contain pure revisions, it stops updating Resources upon free flow editing.
+
+        * inspector/front-end/JavaScriptSource.js:
+        (WebInspector.JavaScriptSource.prototype.setFormatted.didGetContent.didFormatContent):
+        (WebInspector.JavaScriptSource.prototype.setFormatted.didGetContent):
+        (WebInspector.JavaScriptSource.prototype.setFormatted):
+        * inspector/front-end/JavaScriptSourceFrame.js:
+        (WebInspector.JavaScriptSourceFrame.prototype.commitEditing):
+        (WebInspector.JavaScriptSourceFrame.prototype._onContentChanged):
+        (WebInspector.JavaScriptSourceFrame.prototype._didEditContent):
+        * inspector/front-end/Resource.js:
+        (WebInspector.Resource.prototype.addRevision):
+        (WebInspector.Resource.prototype._innerRequestContent.callback):
+        (WebInspector.Resource.prototype._innerRequestContent):
+        (WebInspector.Resource.prototype.revertToOriginal):
+        (WebInspector.ResourceRevision.prototype.revertToThis):
+        (WebInspector.ResourceRevision.prototype.requestContent):
+        (WebInspector.ResourceRevision.prototype.searchInContent):
+        (WebInspector.ResourceRevision.prototype._persistRevision):
+        * inspector/front-end/RevisionHistoryView.js:
+        (WebInspector.RevisionHistoryView):
+        (WebInspector.RevisionHistoryView.prototype._revisionAdded):
+        (WebInspector.RevisionHistoryTreeElement):
+        * inspector/front-end/ScriptSnippetModel.js:
+        (WebInspector.ScriptSnippetModel.prototype.setScriptSnippetContent):
+        * inspector/front-end/StylesPanel.js:
+        (WebInspector.StyleSourceFrame.prototype.commitEditing):
+        (WebInspector.StyleSourceFrame.prototype._didEditContent):
+        (WebInspector.StyleSourceFrame.prototype._onContentChanged):
+        * inspector/front-end/UISourceCode.js:
+        (WebInspector.UISourceCode.prototype._revisionAdded):
+        (WebInspector.UISourceCode.prototype.contentChanged):
+        (WebInspector.UISourceCode.prototype.commitWorkingCopy):
+        * inspector/front-end/inspector.js:
+        (WebInspector._doLoadedDoneWithCapabilities.get if):
+
 2012-05-21  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
 
         GCC 4.7 and C++11
index 0e3c76a..f2943ab 100644 (file)
@@ -102,7 +102,7 @@ WebInspector.JavaScriptSource.prototype = {
         {
             if (!formatted) {
                 this._togglingFormatter = true;
-                this.contentChanged(content || "");
+                this.contentChanged(content || "", mimeType);
                 delete this._togglingFormatter;
                 this._formatterMapping = new WebInspector.IdentityFormatterSourceMapping();
                 this.updateLiveLocations();
@@ -121,7 +121,7 @@ WebInspector.JavaScriptSource.prototype = {
             function didFormatContent(formattedContent, formatterMapping)
             {
                 this._togglingFormatter = true;
-                this.contentChanged(formattedContent);
+                this.contentChanged(formattedContent, mimeType);
                 delete this._togglingFormatter;
                 this._formatterMapping = formatterMapping;
                 this.updateLiveLocations();
index d60c75e..ff2b2a0 100644 (file)
@@ -92,7 +92,7 @@ WebInspector.JavaScriptSourceFrame.prototype = {
      */
     commitEditing: function(text)
     {
-        this._editingContent = true;
+        this._isCommittingEditing = true;
         this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this));
     },
 
@@ -101,9 +101,8 @@ WebInspector.JavaScriptSourceFrame.prototype = {
      */
     _onContentChanged: function(event)
     {
-        if (this._editingContent)
+        if (this._isCommittingEditing)
             return;
-        var oldContent = /** @type {string} */ event.data.oldContent;
         var content = /** @type {string} */ event.data.content;
 
         if (this._uiSourceCode.togglingFormatter())
@@ -176,7 +175,7 @@ WebInspector.JavaScriptSourceFrame.prototype = {
 
     _didEditContent: function(error)
     {
-        delete this._editingContent;
+        delete this._isCommittingEditing;
 
         if (error) {
             WebInspector.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true);
index f95455e..8e1040f 100644 (file)
@@ -114,18 +114,19 @@ WebInspector.Resource.restoreRevisions = function()
 }
 
 /**
- * @param {WebInspector.Resource} resource
+ * @param {WebInspector.ResourceRevision} revision
  */
-WebInspector.Resource.persistRevision = function(resource)
+WebInspector.Resource.persistRevision = function(revision)
 {
     if (!window.localStorage)
         return;
 
+    var resource = revision.resource;
     var url = resource.url;
     var loaderId = resource.loaderId;
-    var timestamp = resource._contentTimestamp.getTime();
+    var timestamp = revision.timestamp.getTime();
     var key = "resource-history|" + url + "|" + loaderId + "|" + timestamp;
-    var content = resource._content;
+    var content = revision._content;
 
     var registry = WebInspector.Resource._resourceRevisionRegistry();
 
@@ -301,14 +302,6 @@ WebInspector.Resource.prototype = {
     },
 
     /**
-     * @return {Date}
-     */
-    get contentTimestamp()
-    {
-        return this._contentTimestamp;
-    },
-
-    /**
      * @return {boolean}
      */
     isEditable: function()
@@ -336,27 +329,24 @@ WebInspector.Resource.prototype = {
     },
 
     /**
-     * @param {string} newContent
+     * @param {string} content
      * @param {Date=} timestamp
      * @param {boolean=} restoringHistory
      */
-    addRevision: function(newContent, timestamp, restoringHistory)
+    addRevision: function(content, timestamp, restoringHistory)
     {
-        var revision = new WebInspector.ResourceRevision(this, this._content, this._contentTimestamp);
+        if (this.history.length) {
+            var lastRevision = this.history[this.history.length - 1];
+            if (lastRevision._content === content)
+                return;
+        }
+        var revision = new WebInspector.ResourceRevision(this, content, timestamp || new Date());
         this.history.push(revision);
 
-        this._content = newContent;
-        this._contentTimestamp = timestamp || new Date();
-
         this.dispatchEventToListeners(WebInspector.Resource.Events.RevisionAdded, revision);
         if (!restoringHistory)
-            this._persistRevision();
-        WebInspector.resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceContentCommitted, { resource: this, content: newContent });
-    },
-
-    _persistRevision: function()
-    {
-        WebInspector.Resource.persistRevision(this);
+            revision._persistRevision();
+        WebInspector.resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceContentCommitted, { resource: this, content: content });
     },
 
     /**
@@ -458,7 +448,6 @@ WebInspector.Resource.prototype = {
         {
             this._content = error ? null : content;
             this._contentEncoded = contentEncoded;
-            this._originalContent = content;
             var callbacks = this._pendingContentCallbacks.slice();
             for (var i = 0; i < callbacks.length; ++i)
                 callbacks[i](this._content, this._contentEncoded, this.canonicalMimeType());
@@ -466,6 +455,15 @@ WebInspector.Resource.prototype = {
             delete this._contentRequested;
         }
         PageAgent.getResourceContent(this.frameId, this.url, callback.bind(this));
+    },
+
+    revertToOriginal: function()
+    {
+        function revert(content)
+        {
+            this.setContent(content, true, function() {});
+        }
+        this.requestContent(revert.bind(this));
     }
 }
 
@@ -476,7 +474,7 @@ WebInspector.Resource.prototype.__proto__ = WebInspector.Object.prototype;
  * @implements {WebInspector.ContentProvider}
  * @param {WebInspector.Resource} resource
  * @param {?string|undefined} content
- * @param {number} timestamp
+ * @param {Date} timestamp
  */
 WebInspector.ResourceRevision = function(resource, content, timestamp)
 {
@@ -495,7 +493,7 @@ WebInspector.ResourceRevision.prototype = {
     },
 
     /**
-     * @return {number}
+     * @return {Date}
      */
     get timestamp()
     {
@@ -515,7 +513,7 @@ WebInspector.ResourceRevision.prototype = {
         function revert(content)
         {
             if (this._resource._content !== content)
-                this._resource.setContent(content, true);
+                this._resource.setContent(content, true, function() {});
         }
         this.requestContent(revert.bind(this));
     },
@@ -541,29 +539,7 @@ WebInspector.ResourceRevision.prototype = {
      */
     requestContent: function(callback)
     {
-        if (typeof this._content === "string") {
-            callback(this._content, false, this.resource.mimeType);
-            return;
-        }
-
-        // If we are here, this is initial revision. First, look up content fetched over the wire.
-        if (typeof this.resource._originalContent === "string") {
-            this._content = this._resource._originalContent;
-            callback(this._content, false, this.resource.mimeType);
-            return;
-        }
-
-        /**
-         * @param {?Protocol.Error} error
-         * @param {string} content
-         * @param {boolean} contentEncoded
-         */
-        function callbackWrapper(error, content, contentEncoded)
-        {
-            callback(error ? null : content, contentEncoded, this.resource.mimeType);
-        }
-
-        PageAgent.getResourceContent(this._resource.frameId, this._resource.url, callbackWrapper.bind(this));
+        callback(this._content || "", false, this.resource.mimeType);
     },
 
     /**
@@ -575,6 +551,11 @@ WebInspector.ResourceRevision.prototype = {
     searchInContent: function(query, caseSensitive, isRegex, callback)
     {
         callback([]);
+    },
+
+    _persistRevision: function()
+    {
+        WebInspector.Resource.persistRevision(this);
     }
 }
 
index cfab782..fb5c64b 100644 (file)
@@ -50,19 +50,22 @@ WebInspector.RevisionHistoryView = function(uiSourceCode)
         label.textContent = WebInspector.UIString("No revisions");
     } else {
         var olElement = this.element.createChild("ol");
-        var treeOutline = new TreeOutline(olElement);
+        this._treeOutline = new TreeOutline(olElement);
         revisionCount = this._resource.history.length;
 
-        var historyItem = new WebInspector.RevisionHistoryTreeElement(this._resource);
-        historyItem.selectable = false;
-        treeOutline.appendChild(historyItem);
-
         for (var i = revisionCount - 1; i >= 0; --i) {
             var revision = this._resource.history[i];
-            historyItem = new WebInspector.RevisionHistoryTreeElement(this._resource, i);
-            historyItem.selectable = false;
-            treeOutline.appendChild(historyItem);
+            var historyItem = new WebInspector.RevisionHistoryTreeElement(revision, this._resource.history[i - 1]);
+            this._treeOutline.appendChild(historyItem);
         }
+
+        var baseItem = new TreeElement("", null, false);
+        baseItem.selectable = false;
+        this._treeOutline.appendChild(baseItem);
+
+        var revertToOriginal = baseItem.listItemElement.createChild("span", "revision-history-link");
+        revertToOriginal.textContent = WebInspector.UIString("revert to original");
+        revertToOriginal.addEventListener("click", this._resource.revertToOriginal.bind(this._resource));
     }
 
     this._statusElement = document.createElement("span");
@@ -97,9 +100,15 @@ WebInspector.RevisionHistoryView.uiSourceCodeSelected = function(uiSourceCode)
 }
 
 WebInspector.RevisionHistoryView.prototype = {
-    _revisionAdded: function()
+    _revisionAdded: function(event)
     {
-        WebInspector.RevisionHistoryView.showHistory(this._uiSourceCode);
+        if (this._resource.history.length === 1) {
+            WebInspector.RevisionHistoryView.showHistory(this._uiSourceCode);
+            return;
+        }
+        var historyLength = this._resource.history.length;
+        var historyItem = new WebInspector.RevisionHistoryTreeElement(this._resource.history[historyLength - 1], this._resource.history[historyLength - 2]);
+        this._treeOutline.insertChild(historyItem, 0);
     },
 
     _onclose: function()
@@ -115,34 +124,23 @@ WebInspector.RevisionHistoryView.prototype.__proto__ = WebInspector.View.prototy
 /**
  * @constructor
  * @extends {TreeElement}
- * @param {WebInspector.Resource} resource
- * @param {number=} revisionOrdinal
+ * @param {WebInspector.ResourceRevision} revision
+ * @param {WebInspector.ResourceRevision=} baseRevision
  */
-WebInspector.RevisionHistoryTreeElement = function(resource, revisionOrdinal)
+WebInspector.RevisionHistoryTreeElement = function(revision, baseRevision)
 {
-    this._resource = resource;
-
     var titleElement = document.createElement("span");
-    if (isNaN(revisionOrdinal)) {
-        this._revision = resource;
-        this._baseRevision = resource.history[resource.history.length - 1];
+    titleElement.textContent = revision.timestamp.toLocaleTimeString();
 
-        titleElement.textContent = resource.contentTimestamp.toLocaleTimeString();
-    } else {
-        this._revision = resource.history[revisionOrdinal];
-        this._baseRevision = resource.history[revisionOrdinal - 1];
+    TreeElement.call(this, titleElement, null, true);
+    this.selectable = false;
 
-        titleElement.textContent = revisionOrdinal ? resource.history[revisionOrdinal].timestamp.toLocaleTimeString() : WebInspector.UIString("(original)");
-        function revert()
-        {
-            this._revision.revertToThis();
-        }
+    this._revision = revision;
+    this._baseRevision = baseRevision;
 
-        var revertElement = titleElement.createChild("span", "revision-history-link");
-        revertElement.textContent = WebInspector.UIString("revert to this");
-        revertElement.addEventListener("click", revert.bind(this), false);
-    }
-    TreeElement.call(this, titleElement, null, revisionOrdinal !== 0);
+    var revertElement = titleElement.createChild("span", "revision-history-link");
+    revertElement.textContent = WebInspector.UIString("revert to this");
+    revertElement.addEventListener("click", this._revision.revertToThis.bind(this._revision), false);
 }
 
 WebInspector.RevisionHistoryTreeElement.prototype = {
@@ -153,7 +151,10 @@ WebInspector.RevisionHistoryTreeElement.prototype = {
         this._wasExpandedOnce = true;
 
         this.childrenListElement.addStyleClass("source-code");
-        this._baseRevision.requestContent(step1.bind(this));
+        if (this._baseRevision)
+            this._baseRevision.requestContent(step1.bind(this));
+        else
+            this._revision.resource.requestContent(step1.bind(this));
 
         function step1(baseContent)
         {
index cc8b093..003ef94 100644 (file)
@@ -113,7 +113,7 @@ WebInspector.ScriptSnippetModel.prototype = {
     {
         var snippet = this._snippetStorage.snippetForId(snippetJavaScriptSource.snippetId);
         snippet.content = newContent;
-        snippetJavaScriptSource.contentChanged(newContent);
+        snippetJavaScriptSource.contentChanged(newContent, "text/javascript");
     },
 
     /**
index 1311ba9..9a5b5be 100644 (file)
@@ -145,6 +145,7 @@ WebInspector.StyleSourceFrame.prototype = {
      */
     commitEditing: function(text)
     {
+        this._isCommittingEditing = true;
         this._styleSource.commitWorkingCopy(this._didEditContent.bind(this));
     },
 
@@ -159,6 +160,7 @@ WebInspector.StyleSourceFrame.prototype = {
             WebInspector.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true);
             return;
         }
+        delete this._isCommittingEditing;
     },
 
     _clearIncrementalUpdateTimer: function()
@@ -173,7 +175,8 @@ WebInspector.StyleSourceFrame.prototype = {
      */
     _onContentChanged: function(event)
     {
-        this.setContent(this._styleSource.resource().content, false, "text/stylesheet");
+        if (!this._isCommittingEditing)
+            this.setContent(this._styleSource.content() || "", false, "text/css");
     },
 
     populateTextAreaContextMenu: function(contextMenu, lineNumber)
index 6fdcf37..e972490 100644 (file)
@@ -136,21 +136,24 @@ WebInspector.UISourceCode.prototype = {
 
     _revisionAdded: function(event)
     {
-        this.contentChanged(this.resource().content || "");
+        var revision = /** @type {WebInspector.ResourceRevision} */ event.data;
+        this.contentChanged(revision.content || "", this._resource.canonicalMimeType());
     },
 
     /**
      * @param {string} newContent
+     * @param {string} mimeType
      */
-    contentChanged: function(newContent)
+    contentChanged: function(newContent, mimeType)
     {
         if (this._committingWorkingCopy)
             return;
 
-        var oldContent = this._contentLoaded ? this._content : undefined;
         this._content = newContent;
+        this._mimeType = mimeType;
+        this._contentLoaded = true;
         delete this._workingCopy;
-        this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ContentChanged, {oldContent: oldContent, content: newContent});
+        this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ContentChanged, {content: newContent});
     },
 
     /**
@@ -204,7 +207,7 @@ WebInspector.UISourceCode.prototype = {
         {
             delete this._committingWorkingCopy;
             if (!error)
-                this.contentChanged(newContent);
+                this.contentChanged(newContent, this._mimeType);
             callback(error);
         }
 
index 1f57122..4e6a500 100644 (file)
@@ -416,6 +416,8 @@ WebInspector._doLoadedDoneWithCapabilities = function()
     this.scriptSnippetModel = new WebInspector.ScriptSnippetModel();
     this.breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, this.debuggerModel);
 
+    WebInspector.CSSCompletions.requestCSSNameCompletions();
+
     this.drawer = new WebInspector.Drawer();
     this.consoleView = new WebInspector.ConsoleView(WebInspector.WorkerManager.isWorkerFrontend());
 
@@ -444,7 +446,6 @@ WebInspector._doLoadedDoneWithCapabilities = function()
     if (this._zoomLevel)
         this._requestZoom();
 
-    WebInspector.CSSCompletions.requestCSSNameCompletions();
     this._createPanels();
     this._createGlobalStatusBarItems();