Title: [127002] trunk/Source/WebCore
Revision
127002
Author
[email protected]
Date
2012-08-29 08:39:05 -0700 (Wed, 29 Aug 2012)

Log Message

Web Inspector: Extract StylesSourceMapping from StylesUISourceCodeProvider.
https://bugs.webkit.org/show_bug.cgi?id=95345

Reviewed by Alexander Pavlov.

* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/compile-front-end.py:
* inspector/front-end/ResourceScriptMapping.js:
(WebInspector.ResourceScriptMapping): Drive-by: ResourceScriptMapping now uses workspace object passed in parameters, not the global one.
(WebInspector.ResourceScriptMapping.prototype._uiSourceCodeAdded):
(WebInspector.ResourceScriptMapping.prototype._uiSourceCodeReplaced):
* inspector/front-end/StylesSourceMapping.js: Copied from Source/WebCore/inspector/front-end/StylesUISourceCodeProvider.js.
(WebInspector.StylesSourceMapping):
(WebInspector.StylesSourceMapping.prototype.addUISourceCode):
(WebInspector.StylesSourceMapping.prototype.rawLocationToUILocation):
(WebInspector.StylesSourceMapping.prototype.uiLocationToRawLocation):
(WebInspector.StylesSourceMapping.prototype.reset):
* inspector/front-end/StylesUISourceCodeProvider.js:
(WebInspector.StylesUISourceCodeProvider):
(WebInspector.StylesUISourceCodeProvider.prototype._resourceAdded):
(WebInspector.StylesUISourceCodeProvider.prototype._reset): Drive-by: _populate is now called with setTimeout.
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (127001 => 127002)


--- trunk/Source/WebCore/ChangeLog	2012-08-29 15:33:07 UTC (rev 127001)
+++ trunk/Source/WebCore/ChangeLog	2012-08-29 15:39:05 UTC (rev 127002)
@@ -1,3 +1,30 @@
+2012-08-29  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: Extract StylesSourceMapping from StylesUISourceCodeProvider.
+        https://bugs.webkit.org/show_bug.cgi?id=95345
+
+        Reviewed by Alexander Pavlov.
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/compile-front-end.py:
+        * inspector/front-end/ResourceScriptMapping.js:
+        (WebInspector.ResourceScriptMapping): Drive-by: ResourceScriptMapping now uses workspace object passed in parameters, not the global one.
+        (WebInspector.ResourceScriptMapping.prototype._uiSourceCodeAdded):
+        (WebInspector.ResourceScriptMapping.prototype._uiSourceCodeReplaced):
+        * inspector/front-end/StylesSourceMapping.js: Copied from Source/WebCore/inspector/front-end/StylesUISourceCodeProvider.js.
+        (WebInspector.StylesSourceMapping):
+        (WebInspector.StylesSourceMapping.prototype.addUISourceCode):
+        (WebInspector.StylesSourceMapping.prototype.rawLocationToUILocation):
+        (WebInspector.StylesSourceMapping.prototype.uiLocationToRawLocation):
+        (WebInspector.StylesSourceMapping.prototype.reset):
+        * inspector/front-end/StylesUISourceCodeProvider.js:
+        (WebInspector.StylesUISourceCodeProvider):
+        (WebInspector.StylesUISourceCodeProvider.prototype._resourceAdded):
+        (WebInspector.StylesUISourceCodeProvider.prototype._reset): Drive-by: _populate is now called with setTimeout.
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+
 2012-08-29  Alexander Pavlov  <[email protected]>
 
         Web Inspector: Page with @import and :last-child in an edited stylesheet will crash

Modified: trunk/Source/WebCore/WebCore.gypi (127001 => 127002)


--- trunk/Source/WebCore/WebCore.gypi	2012-08-29 15:33:07 UTC (rev 127001)
+++ trunk/Source/WebCore/WebCore.gypi	2012-08-29 15:39:05 UTC (rev 127002)
@@ -6391,6 +6391,7 @@
             'inspector/front-end/SplitView.js',
             'inspector/front-end/StatusBarButton.js',
             'inspector/front-end/StyleSource.js',
+            'inspector/front-end/StylesSourceMapping.js',
             'inspector/front-end/StylesUISourceCodeProvider.js',
             'inspector/front-end/TabbedPane.js',
             'inspector/front-end/TestController.js',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (127001 => 127002)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-08-29 15:33:07 UTC (rev 127001)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-08-29 15:39:05 UTC (rev 127002)
@@ -76598,6 +76598,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\StylesSourceMapping.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\StylesUISourceCodeProvider.js"
 					>
 				</File>

Modified: trunk/Source/WebCore/inspector/compile-front-end.py (127001 => 127002)


--- trunk/Source/WebCore/inspector/compile-front-end.py	2012-08-29 15:33:07 UTC (rev 127001)
+++ trunk/Source/WebCore/inspector/compile-front-end.py	2012-08-29 15:39:05 UTC (rev 127002)
@@ -90,6 +90,7 @@
             "SnippetStorage.js",
             "SourceMapping.js",
             "StyleSource.js",
+            "StylesSourceMapping.js",
             "StylesUISourceCodeProvider.js",
             "TimelineManager.js",
             "RawSourceCode.js",

Modified: trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js (127001 => 127002)


--- trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js	2012-08-29 15:33:07 UTC (rev 127001)
+++ trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js	2012-08-29 15:39:05 UTC (rev 127002)
@@ -33,15 +33,17 @@
  * @extends {WebInspector.Object}
  * @implements {WebInspector.SourceMapping}
  * @implements {WebInspector.UISourceCodeProvider}
+ * @param {WebInspector.Workspace} workspace
  */
-WebInspector.ResourceScriptMapping = function()
+WebInspector.ResourceScriptMapping = function(workspace)
 {
+    this._workspace = workspace;
     this._rawSourceCodes = [];
     this._rawSourceCodeForScriptId = {};
     this._rawSourceCodeForURL = {};
     this._rawSourceCodeForDocumentURL = {};
     this._rawSourceCodeForUISourceCode = new Map();
-    WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
+    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
 }
 
 WebInspector.ResourceScriptMapping.prototype = {
@@ -165,7 +167,7 @@
         if (!uiSourceCode.url)
             return;
         this._rawSourceCodeForUISourceCode.put(uiSourceCode, rawSourceCode);
-        WebInspector.workspace.project().addUISourceCode(uiSourceCode);
+        this._workspace.project().addUISourceCode(uiSourceCode);
     },
 
     /**
@@ -182,7 +184,7 @@
 
         for (var i = 0; i < rawSourceCode._scripts.length; ++i)
             rawSourceCode._scripts[i].setSourceMapping(this);
-        WebInspector.workspace.project().replaceUISourceCode(oldUISourceCode, uiSourceCode);
+        this._workspace.project().replaceUISourceCode(oldUISourceCode, uiSourceCode);
     },
 
     /**

Copied: trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js (from rev 127001, trunk/Source/WebCore/inspector/front-end/StylesUISourceCodeProvider.js) (0 => 127002)


--- trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js	                        (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js	2012-08-29 15:39:05 UTC (rev 127002)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @constructor
+ * @implements {WebInspector.SourceMapping}
+*/
+WebInspector.StylesSourceMapping = function()
+{
+    this._uiSourceCodeForURL = {};
+}
+
+WebInspector.StylesSourceMapping.prototype = {
+    /**
+     * @param {WebInspector.UISourceCode} uiSourceCode
+     */
+    addUISourceCode: function(uiSourceCode)
+    {
+        this._uiSourceCodeForURL[uiSourceCode.url] = uiSourceCode;
+        WebInspector.cssModel.setSourceMapping(uiSourceCode.url, this);
+    },
+
+    /**
+     * @param {WebInspector.RawLocation} rawLocation
+     * @return {WebInspector.UILocation}
+     */
+    rawLocationToUILocation: function(rawLocation)
+    {
+        var location = /** @type WebInspector.CSSLocation */ rawLocation;
+        var uiSourceCode = this._uiSourceCodeForURL[location.url];
+        return new WebInspector.UILocation(uiSourceCode, location.lineNumber, 0);
+    },
+
+    /**
+     * @param {WebInspector.UISourceCode} uiSourceCode
+     * @param {number} lineNumber
+     * @param {number} columnNumber
+     * @return {WebInspector.RawLocation}
+     */
+    uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
+    {
+        return new WebInspector.CSSLocation(uiSourceCode.contentURL() || "", lineNumber);
+    },
+
+    reset: function()
+    {
+        this._uiSourceCodeForURL = {};
+        WebInspector.cssModel.resetSourceMappings();
+    }
+}
+

Modified: trunk/Source/WebCore/inspector/front-end/StylesUISourceCodeProvider.js (127001 => 127002)


--- trunk/Source/WebCore/inspector/front-end/StylesUISourceCodeProvider.js	2012-08-29 15:33:07 UTC (rev 127001)
+++ trunk/Source/WebCore/inspector/front-end/StylesUISourceCodeProvider.js	2012-08-29 15:39:05 UTC (rev 127002)
@@ -30,52 +30,17 @@
 
 /**
  * @constructor
- * @implements {WebInspector.SourceMapping}
  * @param {WebInspector.Workspace} workspace
  */
 WebInspector.StylesUISourceCodeProvider = function(workspace)
 {
     this._workspace = workspace;
-    /**
-     * @type {Array.<WebInspector.UISourceCode>}
-     */
-    this._uiSourceCodes = [];
-    this._uiSourceCodeForURL = {};
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, this._resourceAdded, this);
     this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
+    this._stylesSourceMapping = new WebInspector.StylesSourceMapping();
 }
 
 WebInspector.StylesUISourceCodeProvider.prototype = {
-    /**
-     * @return {Array.<WebInspector.UISourceCode>}
-     */
-    uiSourceCodes: function()
-    {
-        return this._uiSourceCodes;
-    },
-
-    /**
-     * @param {WebInspector.RawLocation} rawLocation
-     * @return {WebInspector.UILocation}
-     */
-    rawLocationToUILocation: function(rawLocation)
-    {
-        var location = /** @type WebInspector.CSSLocation */ rawLocation;
-        var uiSourceCode = this._uiSourceCodeForURL[location.url];
-        return new WebInspector.UILocation(uiSourceCode, location.lineNumber, 0);
-    },
-
-    /**
-     * @param {WebInspector.UISourceCode} uiSourceCode
-     * @param {number} lineNumber
-     * @param {number} columnNumber
-     * @return {WebInspector.RawLocation}
-     */
-    uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
-    {
-        return new WebInspector.CSSLocation(uiSourceCode.contentURL() || "", lineNumber);
-    },
-
     _populate: function()
     {
         function populateFrame(frame)
@@ -100,17 +65,14 @@
         if (resource.type !== WebInspector.resourceTypes.Stylesheet)
             return;
         var uiSourceCode = new WebInspector.StyleSource(resource);
-        this._uiSourceCodes.push(uiSourceCode);
-        this._uiSourceCodeForURL[resource.url] = uiSourceCode;
-        WebInspector.cssModel.setSourceMapping(resource.url, this);
+        this._stylesSourceMapping.addUISourceCode(uiSourceCode);
         this._workspace.project().addUISourceCode(uiSourceCode);
     },
 
     _reset: function()
     {
-        this._uiSourceCodes = [];
-        this._uiSourceCodeForURL = {};
-        WebInspector.cssModel.resetSourceMappings();
-        this._populate();
+        this._stylesSourceMapping.reset();
+        // FIXME: We should not populate until the ProjectWillReset event was handled by all listeners. Introduce ProjectDidReset event for that matter.
+        setTimeout(this._populate.bind(this), 0);
     }
 }

Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (127001 => 127002)


--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2012-08-29 15:33:07 UTC (rev 127001)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2012-08-29 15:39:05 UTC (rev 127002)
@@ -180,6 +180,7 @@
     <file>StatusBarButton.js</file>
     <file>StyleSheetOutlineDialog.js</file>
     <file>StyleSource.js</file>
+    <file>StylesSourceMapping.js</file>
     <file>StylesUISourceCodeProvider.js</file>
     <file>StylesSidebarPane.js</file>
     <file>TabbedEditorContainer.js</file>

Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (127001 => 127002)


--- trunk/Source/WebCore/inspector/front-end/inspector.html	2012-08-29 15:33:07 UTC (rev 127001)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html	2012-08-29 15:39:05 UTC (rev 127002)
@@ -161,6 +161,7 @@
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
+    <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to