Changeset 116217 in webkit


Ignore:
Timestamp:
May 5, 2012 3:07:39 AM (12 years ago)
Author:
pfeldman@chromium.org
Message:

Web Inspector: allow overriding the script mapping on the UI level
https://bugs.webkit.org/show_bug.cgi?id=85702

Reviewed by Yury Semikhatsky.

Source/WebCore:

This allows formatting update live locations all over the place automatically.

  • inspector/front-end/Script.js:

(WebInspector.Script.prototype.rawLocationToUILocation):
(WebInspector.Script.Location):
(WebInspector.Script.Location.prototype.update):
(WebInspector.Script.Location.prototype.dispose):

  • inspector/front-end/UISourceCode.js:

(WebInspector.UISourceCode):
(WebInspector.UISourceCode.prototype.addLiveLocation):
(WebInspector.UISourceCode.prototype.removeLiveLocation):
(WebInspector.UISourceCode.prototype.updateLiveLocations):
(WebInspector.UISourceCode.prototype.overrideLocation):

LayoutTests:

  • inspector/debugger/breakpoint-manager.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r116214 r116217  
     12012-05-05  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Web Inspector: allow overriding the script mapping on the UI level
     4        https://bugs.webkit.org/show_bug.cgi?id=85702
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        * inspector/debugger/breakpoint-manager.html:
     9
    1102012-05-05  Zan Dobersek  <zandobersek@gmail.com>
    211
  • trunk/LayoutTests/inspector/debugger/breakpoint-manager.html

    r115961 r116217  
    1010        rawLocationToUILocation: function(rawLocation)
    1111        {
    12             var uiSourceCode = {};
    13             uiSourceCode.id = rawLocation.scriptId;
     12            var uiSourceCode = new WebInspector.UISourceCode(rawLocation.scriptId, rawLocation.scriptId, null);
    1413            return new WebInspector.UILocation(uiSourceCode, rawLocation.lineNumber, 0);
    1514        },
     
    2423        rawLocationToUILocation: function(rawLocation)
    2524        {
    26             var uiSourceCode = {};
    27             uiSourceCode.id = rawLocation.scriptId;
     25            var uiSourceCode = new WebInspector.UISourceCode(rawLocation.scriptId, rawLocation.scriptId, null);
    2826            return new WebInspector.UILocation(uiSourceCode, rawLocation.lineNumber + 10, 0);
    2927        },
  • trunk/Source/WebCore/ChangeLog

    r116216 r116217  
     12012-05-05  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Web Inspector: allow overriding the script mapping on the UI level
     4        https://bugs.webkit.org/show_bug.cgi?id=85702
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        This allows formatting update live locations all over the place automatically.
     9
     10        * inspector/front-end/Script.js:
     11        (WebInspector.Script.prototype.rawLocationToUILocation):
     12        (WebInspector.Script.Location):
     13        (WebInspector.Script.Location.prototype.update):
     14        (WebInspector.Script.Location.prototype.dispose):
     15        * inspector/front-end/UISourceCode.js:
     16        (WebInspector.UISourceCode):
     17        (WebInspector.UISourceCode.prototype.addLiveLocation):
     18        (WebInspector.UISourceCode.prototype.removeLiveLocation):
     19        (WebInspector.UISourceCode.prototype.updateLiveLocations):
     20        (WebInspector.UISourceCode.prototype.overrideLocation):
     21
    1222012-05-05  Pavel Feldman  <pfeldman@chromium.org>
    223
  • trunk/Source/WebCore/inspector/front-end/Script.js

    r115979 r116217  
    157157    {
    158158        console.assert(rawLocation.scriptId === this.scriptId);
    159         return this._sourceMapping.rawLocationToUILocation(rawLocation);
     159        var uiLocation = this._sourceMapping.rawLocationToUILocation(rawLocation);
     160        // FIXME: uiLocation will never be null after the next refactoring step.
     161        return uiLocation ? uiLocation.uiSourceCode.overrideLocation(uiLocation) : null;
    160162    },
    161163
     
    197199    this._rawLocation = rawLocation;
    198200    this._updateDelegate = updateDelegate;
     201    this._uiSourceCodes = [];
    199202}
    200203
    201204WebInspector.Script.Location.prototype = {
    202     dispose: function()
    203     {
    204         this._script._locations.remove(this);
    205     },
    206 
    207205    update: function()
    208206    {
    209         if (!this._script._sourceMapping)
    210             return;
    211         var uiLocation = this._script._sourceMapping.rawLocationToUILocation(this._rawLocation);
     207        var uiLocation = this._script.rawLocationToUILocation(this._rawLocation);
    212208        if (uiLocation) {
     209            var uiSourceCode = uiLocation.uiSourceCode;
     210            if (this._uiSourceCodes.indexOf(uiSourceCode) === -1) {
     211                uiSourceCode.addLiveLocation(this);
     212                this._uiSourceCodes.push(uiSourceCode);
     213            }
    213214            var oneTime = this._updateDelegate(uiLocation);
    214215            if (oneTime)
    215216                this.dispose();
    216217        }
     218    },
     219
     220    dispose: function()
     221    {
     222        for (var i = 0; i < this._uiSourceCodes.length; ++i)
     223            this._uiSourceCodes[i].removeLiveLocation(this);
     224        this._uiSourceCodes = [];
     225        this._script._locations.remove(this);
    217226    }
    218227}
  • trunk/Source/WebCore/inspector/front-end/UISourceCode.js

    r115961 r116217  
    4949     */
    5050    this._requestContentCallbacks = [];
     51    this._liveLocations = [];
    5152}
    5253
     
    136137
    137138    /**
     139     * @param {WebInspector.LiveLocation} liveLocation
     140     */
     141    addLiveLocation: function(liveLocation)
     142    {
     143        this._liveLocations.push(liveLocation);
     144    },
     145
     146    /**
     147     * @param {WebInspector.LiveLocation} liveLocation
     148     */
     149    removeLiveLocation: function(liveLocation)
     150    {
     151        this._liveLocations.remove(liveLocation);
     152    },
     153
     154    updateLiveLocations: function()
     155    {
     156        var locationsCopy = this._liveLocations.slice();
     157        for (var i = 0; i < locationsCopy.length; ++i)
     158            locationsCopy[i].update();
     159    },
     160
     161    /**
     162     * @param {WebInspector.UILocation} uiLocation
     163     * @return {WebInspector.UILocation}
     164     */
     165    overrideLocation: function(uiLocation)
     166    {
     167        return uiLocation;
     168    },
     169
     170    /**
    138171     * @return {Array.<WebInspector.PresentationConsoleMessage>}
    139172     */
Note: See TracChangeset for help on using the changeset viewer.