⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 110549 in webkit


Ignore:
Timestamp:
Mar 13, 2012, 2:10:42 AM (15 years ago)
Author:
podivilov@chromium.org
Message:

Web Inspector: move ResourceScriptMapping to a separate file.
​https://bugs.webkit.org/show_bug.cgi?id=80859

Reviewed by Vsevolod Vlasov.

  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • inspector/compile-front-end.sh:
  • inspector/front-end/ResourceScriptMapping.js: Copied from Source/WebCore/inspector/front-end/ScriptMapping.js.

(WebInspector.ResourceScriptMapping):
(WebInspector.ResourceScriptMapping.prototype.rawLocationToUILocation):
(WebInspector.ResourceScriptMapping.prototype.uiSourceCodeList):
(WebInspector.ResourceScriptMapping.prototype._handleUISourceCodeListChanged):
(WebInspector.ResourceScriptMapping.prototype._uiSourceCodeListChanged):
(WebInspector.ResourceScriptMapping.prototype._bindScriptToRawSourceCode):
(WebInspector.ResourceScriptMapping.prototype.setFormatSource):
(WebInspector.ResourceScriptMapping.prototype.forceUpdateSourceMapping):
(WebInspector.ResourceScriptMapping.prototype.reset):

  • inspector/front-end/ScriptMapping.js:
  • inspector/front-end/WebKit.qrc:
  • inspector/front-end/inspector.html:
Location:
trunk/Source/WebCore
Files:
7 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r110547 r110549  
     12012-03-12  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: move ResourceScriptMapping to a separate file.
     4        https://bugs.webkit.org/show_bug.cgi?id=80859
     5
     6        Reviewed by Vsevolod Vlasov.
     7
     8        * WebCore.gypi:
     9        * WebCore.vcproj/WebCore.vcproj:
     10        * inspector/compile-front-end.sh:
     11        * inspector/front-end/ResourceScriptMapping.js: Copied from Source/WebCore/inspector/front-end/ScriptMapping.js.
     12        (WebInspector.ResourceScriptMapping):
     13        (WebInspector.ResourceScriptMapping.prototype.rawLocationToUILocation):
     14        (WebInspector.ResourceScriptMapping.prototype.uiSourceCodeList):
     15        (WebInspector.ResourceScriptMapping.prototype._handleUISourceCodeListChanged):
     16        (WebInspector.ResourceScriptMapping.prototype._uiSourceCodeListChanged):
     17        (WebInspector.ResourceScriptMapping.prototype._bindScriptToRawSourceCode):
     18        (WebInspector.ResourceScriptMapping.prototype.setFormatSource):
     19        (WebInspector.ResourceScriptMapping.prototype.forceUpdateSourceMapping):
     20        (WebInspector.ResourceScriptMapping.prototype.reset):
     21        * inspector/front-end/ScriptMapping.js:
     22        * inspector/front-end/WebKit.qrc:
     23        * inspector/front-end/inspector.html:
     24
    1252012-03-12  Kentaro Hara  <haraken@chromium.org>
    226
  • trunk/Source/WebCore/WebCore.gypi

    r110547 r110549  
    62656265            'inspector/front-end/ResourceHTMLView.js',
    62666266            'inspector/front-end/ResourceResponseView.js',
     6267            'inspector/front-end/ResourceScriptMapping.js',
    62676268            'inspector/front-end/ResourceTimingView.js',
    62686269            'inspector/front-end/ResourceTreeModel.js',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r110547 r110549  
    7376673766                                </File>
    7376773767                                <File
     73768                                        RelativePath="..\inspector\front-end\ResourceScriptMapping.js"
     73769                                        >
     73770                                </File>
     73771                                <File
    7376873772                                        RelativePath="..\inspector\front-end\ResourceTimingView.js"
    7376973773                                        >
  • trunk/Source/WebCore/inspector/compile-front-end.sh

    r109899 r110549  
    4646        --js Source/WebCore/inspector/front-end/HandlerRegistry.js \
    4747        --js Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js \
    48     --module jsmodule_sdk:34:jsmodule_common \
     48    --module jsmodule_sdk:35:jsmodule_common \
    4949        --js Source/WebCore/inspector/front-end/InspectorBackend.js \
    5050        --js Source/WebCore/inspector/front-end/ApplicationCacheModel.js \
    … …  
    7777        --js Source/WebCore/inspector/front-end/Resource.js \
    7878        --js Source/WebCore/inspector/front-end/ResourceCategory.js \
     79        --js Source/WebCore/inspector/front-end/ResourceScriptMapping.js \
    7980        --js Source/WebCore/inspector/front-end/ResourceTreeModel.js \
    8081        --js Source/WebCore/inspector/front-end/ResourceUtils.js \
  • trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js

    r110548 r110549  
    2828 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2929 */
    30 
    31 /**
    32  * @constructor
    33  * @extends {WebInspector.Object}
    34  */
    35 WebInspector.ScriptMapping = function()
    36 {
    37 }
    38 
    39 WebInspector.ScriptMapping.Events = {
    40     UISourceCodeListChanged: "us-source-code-list-changed"
    41 }
    42 
    43 WebInspector.ScriptMapping.prototype = {
    44     /**
    45      * @param {DebuggerAgent.Location} rawLocation
    46      * @return {WebInspector.UILocation}
    47      */
    48     rawLocationToUILocation: function(rawLocation) {},
    49 
    50     /**
    51      * @param {WebInspector.UISourceCode} uiSourceCode
    52      * @param {number} lineNumber
    53      * @param {number} columnNumber
    54      * @return {DebuggerAgent.Location}
    55      */
    56     uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) {},
    57 
    58     /**
    59      * @return {Array.<WebInspector.UISourceCode>}
    60      */
    61     uiSourceCodeList: function() {}
    62 }
    63 
    64 WebInspector.ScriptMapping.prototype.__proto__ = WebInspector.Object.prototype;
    6530
    6631/**
    … …  
    229194
    230195WebInspector.ResourceScriptMapping.prototype.__proto__ = WebInspector.ScriptMapping.prototype;
    231 
    232 /**
    233  * @constructor
    234  * @extends {WebInspector.Object}
    235  */
    236 WebInspector.MainScriptMapping = function()
    237 {
    238     this._mappings = [];
    239     this._resourceMapping = new WebInspector.ResourceScriptMapping();
    240     this._resourceMapping.addEventListener(WebInspector.ScriptMapping.Events.UISourceCodeListChanged, this._handleUISourceCodeListChanged, this);
    241     this._mappings.push(this._resourceMapping);
    242 
    243     this._mappingForScriptId = {};
    244     this._mappingForUISourceCode = new Map();
    245     this._liveLocationsForScriptId = {};
    246 }
    247 
    248 WebInspector.MainScriptMapping.Events = {
    249     UISourceCodeListChanged: "us-source-code-list-changed"
    250 }
    251 
    252 WebInspector.MainScriptMapping.prototype = {
    253     /**
    254      * @param {DebuggerAgent.Location} rawLocation
    255      * @return {WebInspector.UILocation}
    256      */
    257     rawLocationToUILocation: function(rawLocation)
    258     {
    259         return this._mappingForScriptId[rawLocation.scriptId].rawLocationToUILocation(rawLocation);
    260     },
    261 
    262     /**
    263      * @param {WebInspector.UISourceCode} uiSourceCode
    264      * @param {number} lineNumber
    265      * @param {number} columnNumber
    266      * @return {DebuggerAgent.Location}
    267      */
    268     uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
    269     {
    270         return this._mappingForUISourceCode.get(uiSourceCode).uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber);
    271     },
    272 
    273     /**
    274      * @param {DebuggerAgent.Location} rawLocation
    275      * @param {function(WebInspector.UILocation)} updateDelegate
    276      * @return {WebInspector.LiveLocation}
    277      */
    278     createLiveLocation: function(rawLocation, updateDelegate)
    279     {
    280         return new WebInspector.LiveLocation(this, rawLocation, updateDelegate);
    281     },
    282 
    283     _registerLiveLocation: function(scriptId, liveLocation)
    284     {
    285         this._liveLocationsForScriptId[scriptId].push(liveLocation)
    286         liveLocation._update();
    287     },
    288 
    289     _unregisterLiveLocation: function(scriptId, liveLocation)
    290     {
    291         this._liveLocationsForScriptId[scriptId].remove(liveLocation);
    292     },
    293 
    294     _updateLiveLocations: function(scriptIds)
    295     {
    296         for (var i = 0; i < scriptIds.length; ++i) {
    297             var liveLocations = this._liveLocationsForScriptId[scriptIds[i]];
    298             for (var j = 0; j < liveLocations.length; ++j)
    299                 liveLocations[j]._update();
    300         }
    301     },
    302 
    303     /**
    304      * @return {Array.<WebInspector.UISourceCode>}
    305      */
    306     uiSourceCodeList: function()
    307     {
    308         var result = [];
    309         for (var i = 0; i < this._mappings.length; ++i) {
    310             var uiSourceCodeList = this._mappings[i].uiSourceCodeList();
    311             for (var j = 0; j < uiSourceCodeList.length; ++j)
    312                 result.push(uiSourceCodeList[j]);
    313         }
    314         return result;
    315     },
    316 
    317     /**
    318      * @param {WebInspector.Script} script
    319      */
    320     addScript: function(script)
    321     {
    322         this._liveLocationsForScriptId[script.scriptId] = [];
    323 
    324         var mapping = this._resourceMapping;
    325 
    326         this._mappingForScriptId[script.scriptId] = mapping;
    327         mapping.addScript(script);
    328     },
    329 
    330     /**
    331      * @param {WebInspector.Event} event
    332      */
    333     _handleUISourceCodeListChanged: function(event)
    334     {
    335         var scriptMapping = /** @type {WebInspector.ScriptMapping} */ event.target;
    336         var removedItems = /** @type {Array.<WebInspector.UISourceCode>} */ event.data["removedItems"];
    337         var addedItems = /** @type {Array.<WebInspector.UISourceCode>} */ event.data["addedItems"];
    338         var scriptIds = /** @type {Array.<number>} */ event.data["scriptIds"];
    339 
    340         for (var i = 0; i < removedItems.length; ++i)
    341             this._mappingForUISourceCode.remove(removedItems[i]);
    342         for (var i = 0; i < addedItems.length; ++i)
    343             this._mappingForUISourceCode.put(addedItems[i], scriptMapping);
    344         this._updateLiveLocations(scriptIds);
    345         this.dispatchEventToListeners(WebInspector.MainScriptMapping.Events.UISourceCodeListChanged, event.data);
    346     },
    347 
    348     /**
    349      * @param {boolean} formatSource
    350      */
    351     setFormatSource: function(formatSource)
    352     {
    353         this._resourceMapping.setFormatSource(formatSource);
    354     },
    355 
    356     /**
    357      * @param {DebuggerAgent.Location} rawLocation
    358      */
    359     forceUpdateSourceMapping: function(rawLocation)
    360     {
    361         if (this._mappingForScriptId[rawLocation.scriptId] === this._resourceMapping)
    362             this._resourceMapping.forceUpdateSourceMapping(rawLocation);
    363     },
    364 
    365     reset: function()
    366     {
    367         for (var i = 0; i < this._mappings.length; ++i)
    368             this._mappings[i].reset();
    369         this._mappingForScriptId = {};
    370         this._mappingForUISourceCode = new Map();
    371         this._liveLocationsForScriptId = {};
    372     }
    373 }
    374 
    375 WebInspector.MainScriptMapping.prototype.__proto__ = WebInspector.Object.prototype;
    376 
    377 /**
    378  * @constructor
    379  * @param {WebInspector.MainScriptMapping} scriptMapping
    380  * @param {DebuggerAgent.Location} rawLocation
    381  * @param {function(WebInspector.UILocation)} updateDelegate
    382  */
    383 WebInspector.LiveLocation = function(scriptMapping, rawLocation, updateDelegate)
    384 {
    385     this._scriptMapping = scriptMapping;
    386     this._rawLocation = rawLocation;
    387     this._updateDelegate = updateDelegate;
    388 }
    389 
    390 WebInspector.LiveLocation.prototype = {
    391     init: function()
    392     {
    393         this._scriptMapping._registerLiveLocation(this._rawLocation.scriptId, this);
    394     },
    395 
    396     dispose: function()
    397     {
    398         this._scriptMapping._unregisterLiveLocation(this._rawLocation.scriptId, this);
    399     },
    400 
    401     _update: function()
    402     {
    403         var uiLocation = this._scriptMapping.rawLocationToUILocation(this._rawLocation);
    404         if (uiLocation)
    405             this._updateDelegate(uiLocation);
    406     }
    407 }
  • trunk/Source/WebCore/inspector/front-end/ScriptMapping.js

    r110445 r110549  
    6666/**
    6767 * @constructor
    68  * @extends {WebInspector.ScriptMapping}
    69  */
    70 WebInspector.ResourceScriptMapping = function()
    71 {
    72     this._rawSourceCodes = [];
    73     this._rawSourceCodeForScriptId = {};
    74     this._rawSourceCodeForURL = {};
    75     this._rawSourceCodeForDocumentURL = {};
    76     this._rawSourceCodeForUISourceCode = new Map();
    77     this._formatter = new WebInspector.ScriptFormatter();
    78     this._formatSource = false;
    79 }
    80 
    81 WebInspector.ResourceScriptMapping.prototype = {
    82     /**
    83      * @param {DebuggerAgent.Location} rawLocation
    84      * @return {WebInspector.UILocation}
    85      */
    86     rawLocationToUILocation: function(rawLocation)
    87     {
    88         var rawSourceCode = this._rawSourceCodeForScriptId[rawLocation.scriptId];
    89         return rawSourceCode.rawLocationToUILocation(rawLocation);
    90     },
    91 
    92     /**
    93      * @param {WebInspector.UISourceCode} uiSourceCode
    94      * @param {number} lineNumber
    95      * @param {number} columnNumber
    96      * @return {DebuggerAgent.Location}
    97      */
    98     uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
    99     {
    100         var rawSourceCode = this._rawSourceCodeForUISourceCode.get(uiSourceCode);
    101         return rawSourceCode.uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber);
    102     },
    103 
    104     /**
    105      * @return {Array.<WebInspector.UISourceCode>}
    106      */
    107     uiSourceCodeList: function()
    108     {
    109         var result = [];
    110         for (var i = 0; i < this._rawSourceCodes.length; ++i) {
    111             var uiSourceCodeList = this._rawSourceCodes[i].uiSourceCodeList();
    112             for (var j = 0; j < uiSourceCodeList.length; ++j)
    113                 result.push(uiSourceCodeList[j]);
    114         }
    115         return result;
    116     },
    117 
    118     /**
    119      * @param {WebInspector.Script} script
    120      */
    121     addScript: function(script)
    122     {
    123         var resource = null;
    124         var isInlineScript = false;
    125         if (script.isInlineScript()) {
    126             resource = WebInspector.networkManager.inflightResourceForURL(script.sourceURL) || WebInspector.resourceForURL(script.sourceURL);
    127             if (resource && resource.type === WebInspector.Resource.Type.Document) {
    128                 isInlineScript = true;
    129                 var rawSourceCode = this._rawSourceCodeForDocumentURL[script.sourceURL];
    130                 if (rawSourceCode) {
    131                     rawSourceCode.addScript(script);
    132                     this._bindScriptToRawSourceCode(script, rawSourceCode);
    133                     return;
    134                 }
    135             }
    136         }
    137 
    138         var compilerSourceMapping = null;
    139         if (WebInspector.settings.sourceMapsEnabled.get() && script.sourceMapURL)
    140             compilerSourceMapping = new WebInspector.ClosureCompilerSourceMapping(script.sourceMapURL, script.sourceURL);
    141 
    142         var rawSourceCode = new WebInspector.RawSourceCode(script.scriptId, script, resource, this._formatter, this._formatSource, compilerSourceMapping);
    143         this._rawSourceCodes.push(rawSourceCode);
    144         this._bindScriptToRawSourceCode(script, rawSourceCode);
    145 
    146         if (isInlineScript)
    147             this._rawSourceCodeForDocumentURL[script.sourceURL] = rawSourceCode;
    148 
    149         if (rawSourceCode.uiSourceCodeList().length)
    150             this._uiSourceCodeListChanged(rawSourceCode, [], rawSourceCode.uiSourceCodeList());
    151         rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, this._handleUISourceCodeListChanged, this);
    152     },
    153 
    154     /**
    155      * @param {WebInspector.Event} event
    156      */
    157     _handleUISourceCodeListChanged: function(event)
    158     {
    159         var rawSourceCode = /** @type {WebInspector.RawSourceCode} */ event.target;
    160         var oldUISourceCodeList = /** @type {Array.<WebInspector.UISourceCode>} */ event.data["oldUISourceCodeList"];
    161         this._uiSourceCodeListChanged(rawSourceCode, oldUISourceCodeList, rawSourceCode.uiSourceCodeList());
    162     },
    163 
    164     /**
    165      * @param {WebInspector.RawSourceCode} rawSourceCode
    166      * @param {Array.<WebInspector.UISourceCode>} removedItems
    167      * @param {Array.<WebInspector.UISourceCode>} addedItems
    168      */
    169     _uiSourceCodeListChanged: function(rawSourceCode, removedItems, addedItems)
    170     {
    171         for (var i = 0; i < removedItems.length; ++i)
    172             this._rawSourceCodeForUISourceCode.remove(removedItems[i]);
    173         for (var i = 0; i < addedItems.length; ++i)
    174             this._rawSourceCodeForUISourceCode.put(addedItems[i], rawSourceCode);
    175 
    176         var scriptIds = [];
    177         for (var i = 0; i < rawSourceCode._scripts.length; ++i)
    178             scriptIds.push(rawSourceCode._scripts[i].scriptId);
    179         var data = { removedItems: removedItems, addedItems: addedItems, scriptIds: scriptIds };
    180         this.dispatchEventToListeners(WebInspector.ScriptMapping.Events.UISourceCodeListChanged, data);
    181     },
    182 
    183     /**
    184      * @param {WebInspector.Script} script
    185      * @param {WebInspector.RawSourceCode} rawSourceCode
    186      */
    187     _bindScriptToRawSourceCode: function(script, rawSourceCode)
    188     {
    189         this._rawSourceCodeForScriptId[script.scriptId] = rawSourceCode;
    190         this._rawSourceCodeForURL[script.sourceURL] = rawSourceCode;
    191     },
    192 
    193     /**
    194      * @param {boolean} formatSource
    195      */
    196     setFormatSource: function(formatSource)
    197     {
    198         if (this._formatSource === formatSource)
    199             return;
    200 
    201         this._formatSource = formatSource;
    202         for (var i = 0; i < this._rawSourceCodes.length; ++i)
    203             this._rawSourceCodes[i].setFormatted(this._formatSource);
    204     },
    205 
    206     /**
    207      * @param {DebuggerAgent.Location} rawLocation
    208      */
    209     forceUpdateSourceMapping: function(rawLocation)
    210     {
    211         var rawSourceCode = this._rawSourceCodeForScriptId[rawLocation.scriptId];
    212         rawSourceCode.forceUpdateSourceMapping();
    213     },
    214 
    215     reset: function()
    216     {
    217         for (var i = 0; i < this._rawSourceCodes.length; ++i) {
    218             var rawSourceCode = this._rawSourceCodes[i];
    219             this._uiSourceCodeListChanged(rawSourceCode, rawSourceCode.uiSourceCodeList(), []);
    220             rawSourceCode.removeAllListeners();
    221         }
    222         this._rawSourceCodes = [];
    223         this._rawSourceCodeForScriptId = {};
    224         this._rawSourceCodeForURL = {};
    225         this._rawSourceCodeForDocumentURL = {};
    226         this._rawSourceCodeForUISourceCode.clear();
    227     }
    228 }
    229 
    230 WebInspector.ResourceScriptMapping.prototype.__proto__ = WebInspector.ScriptMapping.prototype;
    231 
    232 /**
    233  * @constructor
    23468 * @extends {WebInspector.Object}
    23569 */
  • trunk/Source/WebCore/inspector/front-end/WebKit.qrc

    r109872 r110549  
    110110    <file>ResourcePreviewView.js</file>
    111111    <file>ResourceResponseView.js</file>
     112    <file>ResourceScriptMapping.js</file>
    112113    <file>ResourceTimingView.js</file>
    113114    <file>ResourceTreeModel.js</file>
  • trunk/Source/WebCore/inspector/front-end/inspector.html

    r109872 r110549  
    175175    <script type="text/javascript" src="ContentProviders.js"></script>
    176176    <script type="text/javascript" src="RawSourceCode.js"></script>
     177    <script type="text/javascript" src="ResourceScriptMapping.js"></script>
    177178    <script type="text/javascript" src="CompilerSourceMapping.js"></script>
    178179    <script type="text/javascript" src="ScriptsSearchScope.js"></script>
Note: See TracChangeset for help on using the changeset viewer.