Changeset 112236 in webkit


Ignore:
Timestamp:
Mar 27, 2012 2:55:18 AM (12 years ago)
Author:
podivilov@chromium.org
Message:

Web Inspector: store UIBreakpoints on UISourceCode.
https://bugs.webkit.org/show_bug.cgi?id=82214

Source/WebCore:

This change will allow us to make breakpoint-added and breakpoint-removed events a part of UISourceCode interface.
See bug 82224 for more details.

Reviewed by Vsevolod Vlasov.

  • inspector/front-end/BreakpointManager.js:

(WebInspector.BreakpointManager.prototype.uiSourceCodeRemoved):
(WebInspector.BreakpointManager.prototype.setBreakpoint):
(WebInspector.BreakpointManager.prototype.removeBreakpoint):
(WebInspector.BreakpointManager.prototype._addBreakpointToUI):
(WebInspector.BreakpointManager.prototype._removeBreakpointFromUI):
(WebInspector.BreakpointManager.prototype.debuggerReset):

  • inspector/front-end/CompilerScriptMapping.js:

(WebInspector.CompilerScriptMapping.prototype.addScript):

  • inspector/front-end/DebuggerPresentationModel.js:

(WebInspector.DebuggerPresentationModel.prototype._updateBreakpointsAfterLiveEdit):
(WebInspector.DebuggerPresentationModel.prototype.breakpointsForUISourceCode):
(WebInspector.DebuggerPresentationModel.prototype.findBreakpoint):
(WebInspector.UISourceCodeImpl):
(WebInspector.UISourceCodeImpl.prototype.breakpoints):
(WebInspector.UISourceCodeImpl.prototype.breakpointAdded):
(WebInspector.UISourceCodeImpl.prototype.breakpointRemoved):

  • inspector/front-end/RawSourceCode.js:

(WebInspector.RawSourceCode.prototype._createUISourceCode):

  • inspector/front-end/SnippetsModel.js:

(WebInspector.SnippetsScriptMapping.prototype._snippetAdded):
(WebInspector.SnippetsScriptMapping.prototype._createUISourceCodeForScript):

  • inspector/front-end/UISourceCode.js:

(WebInspector.UISourceCode.prototype.get domain):
(WebInspector.UISourceCode.prototype.get folderName):
(WebInspector.UISourceCode.prototype.get fileName):
(WebInspector.UISourceCode.prototype.get displayName):
(WebInspector.UISourceCode.prototype._parseURL):
(WebInspector.UISourceCode.prototype._didRequestContent):
(WebInspector.UISourceCode.prototype.breakpoints):

  • inspector/front-end/inspector.html:

LayoutTests:

Reviewed by Vsevolod Vlasov.

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

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r112233 r112236  
     12012-03-26  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: store UIBreakpoints on UISourceCode.
     4        https://bugs.webkit.org/show_bug.cgi?id=82214
     5
     6        Reviewed by Vsevolod Vlasov.
     7
     8        * inspector/debugger/breakpoint-manager.html:
     9
    1102012-03-27  Szilard Ledan  <szledan@inf.u-szeged.hu>
    211
  • trunk/LayoutTests/inspector/debugger/breakpoint-manager.html

    r111595 r112236  
    5959    serializedBreakpoints.push(createBreakpoint("b.js", 3, "", true));
    6060
    61     function createUISourceCode(id, url) { return { id: id, url: url }; }
     61    function createUISourceCode(id, url) { return new WebInspector.UISourceCodeImpl(id, url, null); }
    6262    var uiSourceCodeA = createUISourceCode("a.js", "a.js");
    6363    var uiSourceCodeB = createUISourceCode("b.js", "b.js");
  • trunk/Source/WebCore/ChangeLog

    r112235 r112236  
     12012-03-26  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: store UIBreakpoints on UISourceCode.
     4        https://bugs.webkit.org/show_bug.cgi?id=82214
     5
     6        This change will allow us to make breakpoint-added and breakpoint-removed events a part of UISourceCode interface.
     7        See bug 82224 for more details.
     8
     9        Reviewed by Vsevolod Vlasov.
     10
     11        * inspector/front-end/BreakpointManager.js:
     12        (WebInspector.BreakpointManager.prototype.uiSourceCodeRemoved):
     13        (WebInspector.BreakpointManager.prototype.setBreakpoint):
     14        (WebInspector.BreakpointManager.prototype.removeBreakpoint):
     15        (WebInspector.BreakpointManager.prototype._addBreakpointToUI):
     16        (WebInspector.BreakpointManager.prototype._removeBreakpointFromUI):
     17        (WebInspector.BreakpointManager.prototype.debuggerReset):
     18        * inspector/front-end/CompilerScriptMapping.js:
     19        (WebInspector.CompilerScriptMapping.prototype.addScript):
     20        * inspector/front-end/DebuggerPresentationModel.js:
     21        (WebInspector.DebuggerPresentationModel.prototype._updateBreakpointsAfterLiveEdit):
     22        (WebInspector.DebuggerPresentationModel.prototype.breakpointsForUISourceCode):
     23        (WebInspector.DebuggerPresentationModel.prototype.findBreakpoint):
     24        (WebInspector.UISourceCodeImpl):
     25        (WebInspector.UISourceCodeImpl.prototype.breakpoints):
     26        (WebInspector.UISourceCodeImpl.prototype.breakpointAdded):
     27        (WebInspector.UISourceCodeImpl.prototype.breakpointRemoved):
     28        * inspector/front-end/RawSourceCode.js:
     29        (WebInspector.RawSourceCode.prototype._createUISourceCode):
     30        * inspector/front-end/SnippetsModel.js:
     31        (WebInspector.SnippetsScriptMapping.prototype._snippetAdded):
     32        (WebInspector.SnippetsScriptMapping.prototype._createUISourceCodeForScript):
     33        * inspector/front-end/UISourceCode.js:
     34        (WebInspector.UISourceCode.prototype.get domain):
     35        (WebInspector.UISourceCode.prototype.get folderName):
     36        (WebInspector.UISourceCode.prototype.get fileName):
     37        (WebInspector.UISourceCode.prototype.get displayName):
     38        (WebInspector.UISourceCode.prototype._parseURL):
     39        (WebInspector.UISourceCode.prototype._didRequestContent):
     40        (WebInspector.UISourceCode.prototype.breakpoints):
     41        * inspector/front-end/inspector.html:
     42
    1432012-03-27  Nat Duca  <nduca@chromium.org>
    244
  • trunk/Source/WebCore/inspector/front-end/BreakpointManager.js

    r111595 r112236  
    4242    this._breakpointAddedDelegate = breakpointAddedDelegate;
    4343    this._breakpointRemovedDelegate = breakpointRemovedDelegate;
    44     /**
    45      * @type Map}
    46      */
    47     this._uiBreakpointsByUILocation = new Map();
     44
    4845    /**
    4946     * @type {Object.<string, Object.<string,WebInspector.Breakpoint>>}
     
    8986    uiSourceCodeRemoved: function(uiSourceCode)
    9087    {
    91         var uiBreakpoints = this._uiBreakpoints(uiSourceCode);
     88        var uiBreakpoints = uiSourceCode.breakpoints();
    9289        for (var lineNumber in uiBreakpoints) {
    9390            var uiBreakpoint = uiBreakpoints[lineNumber];
     
    9895    /**
    9996     * @param {WebInspector.UISourceCode} uiSourceCode
    100      * @return {Object.<string,WebInspector.UIBreakpoint>|undefined}
    101      */
    102     breakpointsForUISourceCode: function(uiSourceCode)
    103     {
    104         return this._uiBreakpoints(uiSourceCode);
    105     },
    106 
    107     /**
    108      * @param {WebInspector.UISourceCode} uiSourceCode
    10997     * @param {number} lineNumber
    11098     * @param {string} condition
     
    113101    setBreakpoint: function(uiSourceCode, lineNumber, condition, enabled)
    114102    {
    115         if (this._uiBreakpoint(uiSourceCode, lineNumber))
     103        if (uiSourceCode.breakpoints()[lineNumber])
    116104            return;
    117105        var breakpoint = new WebInspector.Breakpoint(uiSourceCode.id, lineNumber, condition, enabled, !!uiSourceCode.url);
     
    127115    removeBreakpoint: function(uiSourceCode, lineNumber)
    128116    {
    129         var uiBreakpoint = this._uiBreakpoint(uiSourceCode, lineNumber);
     117        var uiBreakpoint = uiSourceCode.breakpoints()[lineNumber];
    130118        if (!uiBreakpoint)
    131119            return;
     
    205193
    206194    /**
    207      * @param {WebInspector.UISourceCode} uiSourceCode
    208      * @return {?Object.<string,WebInspector.UIBreakpoint>}
    209      */
    210     _uiBreakpoints: function(uiSourceCode)
    211     {
    212         if (!this._uiBreakpointsByUILocation.get(uiSourceCode))
    213             this._uiBreakpointsByUILocation.put(uiSourceCode, {});
    214         return this._uiBreakpointsByUILocation.get(uiSourceCode);
    215     },
    216 
    217     /**
    218      * @param {WebInspector.UISourceCode} uiSourceCode
    219      * @param {number} lineNumber
    220      * @return {?WebInspector.UIBreakpoint}
    221      */
    222     _uiBreakpoint: function(uiSourceCode, lineNumber)
    223     {
    224         return this._uiBreakpoints(uiSourceCode)[String(lineNumber)];
    225     },
    226 
    227     /**
    228195     * @param {WebInspector.Breakpoint} breakpoint
    229196     * @param {WebInspector.UISourceCode} uiSourceCode
     
    232199    {
    233200        var uiBreakpoint = breakpoint.createUIBreakpoint(uiSourceCode);
    234         console.assert(!this._uiBreakpoint(uiBreakpoint.uiSourceCode, uiBreakpoint.lineNumber));
    235         this._uiBreakpoints(uiBreakpoint.uiSourceCode)[uiBreakpoint.lineNumber] = uiBreakpoint;
     201        console.assert(!uiSourceCode.breakpoints()[uiBreakpoint.lineNumber]);
     202        uiSourceCode.breakpointAdded(uiBreakpoint.lineNumber, uiBreakpoint);
    236203        this._breakpointAddedDelegate(uiBreakpoint);
    237204    },
     
    242209    _removeBreakpointFromUI: function(uiBreakpoint)
    243210    {
    244         console.assert(this._uiBreakpoint(uiBreakpoint.uiSourceCode, uiBreakpoint.lineNumber) === uiBreakpoint);
    245         delete this._uiBreakpoints(uiBreakpoint.uiSourceCode)[uiBreakpoint.lineNumber];
     211        var uiSourceCode = uiBreakpoint.uiSourceCode;
     212        var lineNumber = uiBreakpoint.lineNumber;
     213        console.assert(uiSourceCode.breakpoints()[lineNumber] === uiBreakpoint);
     214        uiSourceCode.breakpointRemoved(lineNumber);
    246215        uiBreakpoint.breakpoint.removeUIBreakpoint();
    247216        this._breakpointRemovedDelegate(uiBreakpoint);
     
    417386                delete this._breakpointsByUILocation[id];
    418387        }
    419         this._uiBreakpointsByUILocation = new Map();
    420388    }
    421389}
  • trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js

    r112070 r112236  
    118118            else
    119119                contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL);
    120             var uiSourceCode = new WebInspector.UISourceCode(sourceURL, sourceURL, contentProvider);
     120            var uiSourceCode = new WebInspector.UISourceCodeImpl(sourceURL, sourceURL, contentProvider);
    121121            uiSourceCode.isContentScript = script.isContentScript;
    122122            uiSourceCode.isEditable = false;
  • trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js

    r111595 r112236  
    221221    _updateBreakpointsAfterLiveEdit: function(uiSourceCode, oldSource, newSource)
    222222    {
    223         var breakpoints = this._breakpointManager.breakpointsForUISourceCode(uiSourceCode);
     223        var breakpoints = uiSourceCode.breakpoints();
    224224
    225225        // Clear and re-create breakpoints according to text diff.
     
    352352    breakpointsForUISourceCode: function(uiSourceCode)
    353353    {
    354         var breakpointsMap = this._breakpointManager.breakpointsForUISourceCode(uiSourceCode);
     354        var breakpointsMap = uiSourceCode.breakpoints();
    355355        var breakpointsList = [];
    356356        for (var lineNumber in breakpointsMap)
     
    434434    findBreakpoint: function(uiSourceCode, lineNumber)
    435435    {
    436         return this._breakpointManager.breakpointsForUISourceCode(uiSourceCode)[String(lineNumber)];
     436        return uiSourceCode.breakpoints()[lineNumber];
    437437    },
    438438
     
    571571
    572572WebInspector.DebuggerPresentationModel.prototype.__proto__ = WebInspector.Object.prototype;
     573
     574
     575/**
     576 * @constructor
     577 * @extends {WebInspector.UISourceCode}
     578 * @param {string} id
     579 * @param {string} url
     580 * @param {WebInspector.ContentProvider} contentProvider
     581 */
     582WebInspector.UISourceCodeImpl = function(id, url, contentProvider)
     583{
     584    WebInspector.UISourceCode.call(this, id, url, contentProvider);
     585    /**
     586     * @type {Object.<string,WebInspector.UIBreakpoint>}
     587     */
     588    this._breakpoints = {};
     589}
     590
     591WebInspector.UISourceCodeImpl.prototype = {
     592    breakpoints: function()
     593    {
     594        return this._breakpoints;
     595    },
     596
     597    breakpointAdded: function(lineNumber, breakpoint)
     598    {
     599        this._breakpoints[lineNumber] = breakpoint;
     600    },
     601
     602    breakpointRemoved: function(lineNumber)
     603    {
     604        delete this._breakpoints[lineNumber];
     605    }
     606}
     607
     608WebInspector.UISourceCodeImpl.prototype.__proto__ = WebInspector.UISourceCode.prototype;
    573609
    574610/**
  • trunk/Source/WebCore/inspector/front-end/RawSourceCode.js

    r111670 r112236  
    213213    _createUISourceCode: function(id, url, contentProvider)
    214214    {
    215         var uiSourceCode = new WebInspector.UISourceCode(id, url, contentProvider);
     215        var uiSourceCode = new WebInspector.UISourceCodeImpl(id, url, contentProvider);
    216216        uiSourceCode.isContentScript = this.isContentScript;
    217217        uiSourceCode.isEditable = this._scripts.length === 1 && !this._scripts[0].lineOffset && !this._scripts[0].columnOffset && !this._formatted;
  • trunk/Source/WebCore/inspector/front-end/SnippetsModel.js

    r111694 r112236  
    376376        var uiSourceCodeId = ""; // FIXME: to be implemented.
    377377        var uiSourceCodeURL = ""; // FIXME: to be implemented.
    378         var uiSourceCode = new WebInspector.UISourceCode(uiSourceCodeId, uiSourceCodeURL, new WebInspector.SnippetContentProvider(snippet));
     378        var uiSourceCode = new WebInspector.UISourceCodeImpl(uiSourceCodeId, uiSourceCodeURL, new WebInspector.SnippetContentProvider(snippet));
    379379        uiSourceCode.isSnippet = true;
    380380        uiSourceCode.isEditable = true;
     
    399399    _createUISourceCodeForScript: function(script)
    400400    {
    401         var uiSourceCode = new WebInspector.UISourceCode(script.sourceURL, script.sourceURL, new WebInspector.ScriptContentProvider(script));
     401        var uiSourceCode = new WebInspector.UISourceCodeImpl(script.sourceURL, script.sourceURL, new WebInspector.ScriptContentProvider(script));
    402402        uiSourceCode.isSnippetEvaluation = true;
    403403        var oldUISourceCode = this._uiSourceCodeForScriptId[script.scriptId];
  • trunk/Source/WebCore/inspector/front-end/UISourceCode.js

    r109899 r112236  
    113113        if (typeof(this._domain) === "undefined")
    114114            this._parseURL();
    115        
     115
    116116        return this._domain;
    117117    },
    118    
     118
    119119    /**
    120120     * @type {string}
     
    124124        if (typeof(this._folderName) === "undefined")
    125125            this._parseURL();
    126        
     126
    127127        return this._folderName;
    128128    },
    129    
     129
    130130    /**
    131131     * @type {string}
     
    135135        if (typeof(this._fileName) === "undefined")
    136136            this._parseURL();
    137        
     137
    138138        return this._fileName;
    139139    },
    140    
     140
    141141    /**
    142142     * @type {string}
     
    146146        if (typeof(this._displayName) === "undefined")
    147147            this._parseURL();
    148        
     148
    149149        return this._displayName;
    150150    },
    151    
     151
    152152    _parseURL: function()
    153153    {
     
    173173        var lastPathComponent = fileName.substring(0, indexOfQuery);
    174174        var queryParams = fileName.substring(indexOfQuery, fileName.length);
    175        
     175
    176176        const maxDisplayNameLength = 30;
    177177        const minDisplayQueryParamLength = 5;
    178        
     178
    179179        var maxDisplayQueryParamLength = Math.max(minDisplayQueryParamLength, maxDisplayNameLength - lastPathComponent.length);
    180180        var displayQueryParams = queryParams.trimEnd(maxDisplayQueryParamLength);
     
    206206            this._requestContentCallbacks[i](mimeType, content);
    207207        this._requestContentCallbacks = [];
    208     }
     208    },
     209
     210    breakpoints: function() {}
    209211}
    210212
  • trunk/Source/WebCore/inspector/front-end/inspector.html

    r111655 r112236  
    170170    <script type="text/javascript" src="DebuggerModel.js"></script>
    171171    <script type="text/javascript" src="ScriptMapping.js"></script>
     172    <script type="text/javascript" src="UISourceCode.js"></script>
    172173    <script type="text/javascript" src="DebuggerPresentationModel.js"></script>
    173174    <script type="text/javascript" src="BreakpointManager.js"></script>
    174     <script type="text/javascript" src="UISourceCode.js"></script>
    175175    <script type="text/javascript" src="ContentProviders.js"></script>
    176176    <script type="text/javascript" src="RawSourceCode.js"></script>
Note: See TracChangeset for help on using the changeset viewer.