Changeset 60450 in webkit


Ignore:
Timestamp:
May 31, 2010 12:46:55 PM (14 years ago)
Author:
pfeldman@chromium.org
Message:

2010-05-31 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: Moved breakpoints add/remove logic to the BreakpointManager.

https://bugs.webkit.org/show_bug.cgi?id=14190

  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • inspector/front-end/Breakpoint.js:
  • inspector/front-end/BreakpointManager.js: Added.
  • inspector/front-end/BreakpointsSidebarPane.js: (WebInspector.BreakpointsSidebarPane): (WebInspector.BreakpointsSidebarPane.prototype.reset): (WebInspector.BreakpointsSidebarPane.prototype._breakpointAdded): (WebInspector.BreakpointsSidebarPane.prototype._breakpointRemoved): (WebInspector.BreakpointsSidebarPane.prototype._breakpointEnableChanged):
  • inspector/front-end/Object.js: (WebInspector.Object.prototype.dispatchEventToListeners):
  • inspector/front-end/ScriptView.js: (WebInspector.ScriptView.prototype._addBreakpoint):
  • inspector/front-end/ScriptsPanel.js: (WebInspector.ScriptsPanel): (WebInspector.ScriptsPanel.prototype._breakpointAdded): (WebInspector.ScriptsPanel.prototype._breakpointRemoved): (WebInspector.ScriptsPanel.prototype.editScriptSource.mycallback): (WebInspector.ScriptsPanel.prototype.editScriptSource): (WebInspector.ScriptsPanel.prototype._showScriptOrResource):
  • inspector/front-end/SourceFrame.js: (WebInspector.SourceFrame.prototype._contextMenu):
  • inspector/front-end/SourceView.js: (WebInspector.SourceView.prototype._addBreakpoint): (WebInspector.SourceView.prototype._removeBreakpoint):
  • inspector/front-end/WebKit.qrc:
  • inspector/front-end/inspector.html:
  • inspector/front-end/inspector.js: (WebInspector.loaded): (WebInspector.restoredBreakpoint): (WebInspector.reset):
Location:
trunk/WebCore
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r60449 r60450  
     12010-05-31  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: Moved breakpoints add/remove logic to the BreakpointManager.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=14190
     8
     9        * WebCore.gypi:
     10        * WebCore.vcproj/WebCore.vcproj:
     11        * inspector/front-end/Breakpoint.js:
     12        * inspector/front-end/BreakpointManager.js: Added.
     13        (WebInspector.BreakpointManager):
     14        (WebInspector.BreakpointManager.prototype.addBreakpoint):
     15        (WebInspector.BreakpointManager.prototype.removeBreakpoint):
     16        (WebInspector.BreakpointManager.prototype.breakpointsForSourceID):
     17        (WebInspector.BreakpointManager.prototype.breakpointsForURL):
     18        (WebInspector.BreakpointManager.prototype.reset):
     19        (WebInspector.BreakpointManager.prototype._saveBreakpointOnBackend):
     20        (WebInspector.BreakpointManager.prototype._removeBreakpointFromBackend):
     21        (WebInspector.Breakpoint):
     22        (WebInspector.Breakpoint.prototype.get enabled):
     23        (WebInspector.Breakpoint.prototype.set enabled):
     24        (WebInspector.Breakpoint.prototype.get sourceText):
     25        (WebInspector.Breakpoint.prototype.set sourceText):
     26        (WebInspector.Breakpoint.prototype.get label):
     27        (WebInspector.Breakpoint.prototype.get id):
     28        (WebInspector.Breakpoint.prototype.get condition):
     29        (WebInspector.Breakpoint.prototype.set condition):
     30        * inspector/front-end/BreakpointsSidebarPane.js:
     31        (WebInspector.BreakpointsSidebarPane):
     32        (WebInspector.BreakpointsSidebarPane.prototype.reset):
     33        (WebInspector.BreakpointsSidebarPane.prototype._breakpointAdded):
     34        (WebInspector.BreakpointsSidebarPane.prototype._breakpointRemoved):
     35        (WebInspector.BreakpointsSidebarPane.prototype._breakpointEnableChanged):
     36        * inspector/front-end/Object.js:
     37        (WebInspector.Object.prototype.dispatchEventToListeners):
     38        * inspector/front-end/ScriptView.js:
     39        (WebInspector.ScriptView.prototype._addBreakpoint):
     40        * inspector/front-end/ScriptsPanel.js:
     41        (WebInspector.ScriptsPanel):
     42        (WebInspector.ScriptsPanel.prototype._breakpointAdded):
     43        (WebInspector.ScriptsPanel.prototype._breakpointRemoved):
     44        (WebInspector.ScriptsPanel.prototype.editScriptSource.mycallback):
     45        (WebInspector.ScriptsPanel.prototype.editScriptSource):
     46        (WebInspector.ScriptsPanel.prototype._showScriptOrResource):
     47        * inspector/front-end/SourceFrame.js:
     48        (WebInspector.SourceFrame.prototype._contextMenu):
     49        * inspector/front-end/SourceView.js:
     50        (WebInspector.SourceView.prototype._addBreakpoint):
     51        (WebInspector.SourceView.prototype._removeBreakpoint):
     52        * inspector/front-end/WebKit.qrc:
     53        * inspector/front-end/inspector.html:
     54        * inspector/front-end/inspector.js:
     55        (WebInspector.loaded):
     56        (WebInspector.restoredBreakpoint):
     57        (WebInspector.reset):
     58
    1592010-05-31  Alexander Pavlov  <apavlov@chromium.org>
    260
  • trunk/WebCore/WebCore.gypi

    r60449 r60450  
    38723872            'inspector/front-end/AuditsPanel.js',
    38733873            'inspector/front-end/BottomUpProfileDataGridTree.js',
    3874             'inspector/front-end/Breakpoint.js',
     3874            'inspector/front-end/BreakpointManager.js',
    38753875            'inspector/front-end/BreakpointsSidebarPane.js',
    38763876            'inspector/front-end/Callback.js',
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r60449 r60450  
    4476944769                                </File>
    4477044770                                <File
    44771                                         RelativePath="..\inspector\front-end\Breakpoint.js"
     44771                                        RelativePath="..\inspector\front-end\BreakpointManager.js"
    4477244772                                        >
    4477344773                                </File>
  • trunk/WebCore/inspector/front-end/Breakpoint.js

    r55071 r60450  
    1 /*
    2  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
    3  *
    4  * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
    7  * 1. Redistributions of source code must retain the above copyright
    8  *    notice, this list of conditions and the following disclaimer.
    9  * 2. Redistributions in binary form must reproduce the above copyright
    10  *    notice, this list of conditions and the following disclaimer in the
    11  *    documentation and/or other materials provided with the distribution.
    12  *
    13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
    14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
    17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    24  */
    25 
    26 WebInspector.Breakpoint = function(url, line, sourceID, condition)
    27 {
    28     this.url = url;
    29     this.line = line;
    30     this.sourceID = sourceID;
    31     this._enabled = true;
    32     this._sourceText = "";
    33     this._condition = condition || "";
    34 }
    35 
    36 WebInspector.Breakpoint.prototype = {
    37     get enabled()
    38     {
    39         return this._enabled;
    40     },
    41 
    42     set enabled(x)
    43     {
    44         if (this._enabled === x)
    45             return;
    46 
    47         this._enabled = x;
    48 
    49         if (this._enabled)
    50             this.dispatchEventToListeners("enabled");
    51         else
    52             this.dispatchEventToListeners("disabled");
    53     },
    54 
    55     get sourceText()
    56     {
    57         return this._sourceText;
    58     },
    59 
    60     set sourceText(text)
    61     {
    62         this._sourceText = text;
    63         this.dispatchEventToListeners("text-changed");
    64     },
    65 
    66     get label()
    67     {
    68         var displayName = (this.url ? WebInspector.displayNameForURL(this.url) : WebInspector.UIString("(program)"));
    69         return displayName + ":" + this.line;
    70     },
    71 
    72     get id()
    73     {
    74         return this.sourceID + ":" + this.line;
    75     },
    76 
    77     get condition()
    78     {
    79         return this._condition;
    80     },
    81 
    82     set condition(c)
    83     {
    84         c = c || "";
    85         if (this._condition === c)
    86             return;
    87 
    88         this._condition = c;
    89         this.dispatchEventToListeners("condition-changed");
    90 
    91         if (this.enabled)
    92             InspectorBackend.setBreakpoint(this.sourceID, this.line, this.enabled, this.condition);
    93     }
    94 }
    95 
    96 WebInspector.Breakpoint.prototype.__proto__ = WebInspector.Object.prototype;
  • trunk/WebCore/inspector/front-end/BreakpointsSidebarPane.js

    r56395 r60450  
    2828    WebInspector.SidebarPane.call(this, WebInspector.UIString("Breakpoints"));
    2929
    30     this.breakpoints = {};
    31 
    3230    this.listElement = document.createElement("ol");
    3331    this.listElement.className = "breakpoint-list";
     
    3836
    3937    this.bodyElement.appendChild(this.emptyElement);
     38
     39    WebInspector.breakpointManager.addEventListener("breakpoint-added", this._breakpointAdded, this);
     40    WebInspector.breakpointManager.addEventListener("breakpoint-removed", this._breakpointRemoved, this);   
    4041}
    4142
     
    4344    reset: function()
    4445    {
    45         this.breakpoints = {};
    4646        this.listElement.removeChildren();
    4747        if (this.listElement.parentElement) {
     
    5151    },
    5252
    53     addBreakpoint: function(breakpoint)
     53    _breakpointAdded: function(event)
    5454    {
    55         if (this.breakpoints[breakpoint.id])
    56             return;
    57 
    58         this.breakpoints[breakpoint.id] = breakpoint;
     55        var breakpoint = event.data;
    5956
    6057        breakpoint.addEventListener("enabled", this._breakpointEnableChanged, this);
     
    6865            this.bodyElement.appendChild(this.listElement);
    6966        }
    70 
    71         InspectorBackend.setBreakpoint(breakpoint.sourceID, breakpoint.line, breakpoint.enabled, breakpoint.condition);
    7267    },
    7368
     
    122117    },
    123118
    124     removeBreakpoint: function(breakpoint)
     119    _breakpointRemoved: function(event)
    125120    {
    126         if (!this.breakpoints[breakpoint.id])
    127             return;
    128         delete this.breakpoints[breakpoint.id];
     121        var breakpoint = event.data;
    129122
    130123        breakpoint.removeEventListener("enabled", null, this);
     
    139132            this.bodyElement.appendChild(this.emptyElement);
    140133        }
    141 
    142         InspectorBackend.removeBreakpoint(breakpoint.sourceID, breakpoint.line);
    143134    },
    144135
     
    149140        var checkbox = breakpoint._breakpointListElement.firstChild;
    150141        checkbox.checked = breakpoint.enabled;
    151         InspectorBackend.setBreakpoint(breakpoint.sourceID, breakpoint.line, breakpoint.enabled, breakpoint.condition);
    152142    },
    153143
  • trunk/WebCore/inspector/front-end/Object.js

    r48970 r60450  
    5151    },
    5252
    53     dispatchEventToListeners: function(eventType) {
     53    dispatchEventToListeners: function(eventType, eventData) {
    5454        if (!("_listeners" in this) || !(eventType in this._listeners))
    5555            return;
     
    6767        }
    6868
    69         var event = {target: this, type: eventType, defaultPrevented: false};
     69        var event = {target: this, type: eventType, data: eventData, defaultPrevented: false};
    7070        event.stopPropagation = stopPropagation;
    7171        event.preventDefault = preventDefault;
  • trunk/WebCore/inspector/front-end/ScriptView.js

    r58477 r60450  
    7474    _addBreakpoint: function(line)
    7575    {
    76         var breakpoint = new WebInspector.Breakpoint(this.script.sourceURL, line, this.script.sourceID);
    77         WebInspector.panels.scripts.addBreakpoint(breakpoint);
     76        WebInspector.breakpointManager.addBreakpoint(this.script.sourceID, this.script.sourceURL, line, true, "");
    7877    },
    7978
  • trunk/WebCore/inspector/front-end/ScriptsPanel.js

    r60265 r60450  
    172172    if (Preferences.debuggerAlwaysEnabled)
    173173        this._attachDebuggerWhenShown = true;
     174
     175    WebInspector.breakpointManager.addEventListener("breakpoint-added", this._breakpointAdded, this);
     176    WebInspector.breakpointManager.addEventListener("breakpoint-removed", this._breakpointRemoved, this);
     177
    174178    this.reset();
    175179}
     
    286290    },
    287291
    288     addBreakpoint: function(breakpoint)
    289     {
     292    _breakpointAdded: function(event)
     293    {
     294        var breakpoint = event.data;
     295
    290296        if (!this.breakpointsActivated)
    291297            this._toggleBreakpointsClicked();
    292 
    293         this.sidebarPanes.breakpoints.addBreakpoint(breakpoint);
    294298
    295299        var sourceFrame;
     
    309313    },
    310314
    311     removeBreakpoint: function(breakpoint)
    312     {
    313         this.sidebarPanes.breakpoints.removeBreakpoint(breakpoint);
     315    _breakpointRemoved: function(event)
     316    {
     317        var breakpoint = event.data;
    314318
    315319        var sourceFrame;
     
    340344
    341345        // Need to clear breakpoints and re-create them later when editing source.
    342         var breakpointsPanel = this.sidebarPanes.breakpoints;
    343         var newBreakpoints = [];
    344         for (var id in breakpointsPanel.breakpoints) {
    345             var breakpoint = breakpointsPanel.breakpoints[id];
    346             breakpointsPanel.removeBreakpoint(breakpoint);
    347             newBreakpoints.push(breakpoint);
    348         }
     346        var breakpoints = WebInspector.breakpointManager.breakpointsForSourceID(sourceID);
     347        for (var i = 0; i < breakpoints.length; ++i)
     348            WebInspector.breakpointManager.removeBreakpoint(breakpoints[i]);
    349349
    350350        function mycallback(newBody)
    351351        {
    352352            callback(newBody);
    353             for (var i = 0; i < newBreakpoints.length; ++i) {
    354                 var breakpoint = newBreakpoints[i];
     353            for (var i = 0; i < breakpoints.length; ++i) {
     354                var breakpoint = breakpoints[i];
    355355                if (breakpoint.line >= line)
    356356                    breakpoint.line += linesCountToShift;
    357                 this.addBreakpoint(breakpoint);
     357                WebInspector.breakpointManager.addBreakpoint(breakpoint);
    358358            }
    359359        };
     
    613613            view = WebInspector.panels.resources.resourceViewForResource(scriptOrResource);
    614614            view.headersVisible = false;
    615             var breakpoints = this.sidebarPanes.breakpoints.breakpoints;
    616             for (var breakpointId in breakpoints) {
    617                 var breakpoint = breakpoints[breakpointId];
    618                 if (breakpoint.url === scriptOrResource.url) {
    619                     var sourceFrame = this._sourceFrameForScriptOrResource(scriptOrResource);
    620                     sourceFrame.addBreakpoint(breakpoint);
    621                 }
    622             }
     615            var sourceFrame = this._sourceFrameForScriptOrResource(scriptOrResource);
     616            var breakpoints = WebInspector.breakpointManager.breakpointsForURL(scriptOrResource.url);
     617            for (var i = 0; i < breakpoints.length; ++i)
     618                sourceFrame.addBreakpoint(breakpoints[i]);
    623619        } else if (scriptOrResource instanceof WebInspector.Script)
    624620            view = this.scriptViewForScript(scriptOrResource);
  • trunk/WebCore/inspector/front-end/SourceFrame.js

    r59688 r60450  
    429429        } else {
    430430            // This row has a breakpoint, we want to show edit and remove breakpoint, and either disable or enable.
    431             contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), WebInspector.panels.scripts.removeBreakpoint.bind(WebInspector.panels.scripts, breakpoint));
     431            contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), this._removeBreakpointDelegate.bind(this, breakpoint));
    432432            contextMenu.appendItem(WebInspector.UIString("Edit Breakpoint…"), this._editBreakpointCondition.bind(this, breakpoint));
    433433            if (breakpoint.enabled)
  • trunk/WebCore/inspector/front-end/SourceView.js

    r60445 r60450  
    119119    {
    120120        var sourceID = this._sourceIDForLine(line);
    121         if (WebInspector.panels.scripts) {
    122             var breakpoint = new WebInspector.Breakpoint(this.resource.url, line, sourceID);
    123             WebInspector.panels.scripts.addBreakpoint(breakpoint);
    124         }
     121        WebInspector.breakpointManager.addBreakpoint(sourceID, this.resource.url, line, true, "");
    125122    },
    126123
    127124    _removeBreakpoint: function(breakpoint)
    128125    {
    129         if (WebInspector.panels.scripts)
    130             WebInspector.panels.scripts.removeBreakpoint(breakpoint);
     126        WebInspector.breakpointManager.removeBreakpoint(breakpoint);
    131127    },
    132128
  • trunk/WebCore/inspector/front-end/WebKit.qrc

    r60449 r60450  
    99    <file>AuditsPanel.js</file>
    1010    <file>BottomUpProfileDataGridTree.js</file>
    11     <file>Breakpoint.js</file>
     11    <file>BreakpointManager.js</file>
    1212    <file>BreakpointsSidebarPane.js</file>
    1313    <file>Callback.js</file>
  • trunk/WebCore/inspector/front-end/inspector.html

    r60445 r60450  
    6565    <script type="text/javascript" src="CookieItemsView.js"></script>
    6666    <script type="text/javascript" src="Script.js"></script>
    67     <script type="text/javascript" src="Breakpoint.js"></script>
     67    <script type="text/javascript" src="BreakpointManager.js"></script>
    6868    <script type="text/javascript" src="SidebarPane.js"></script>
    6969    <script type="text/javascript" src="ElementsTreeOutline.js"></script>
  • trunk/WebCore/inspector/front-end/inspector.js

    r60206 r60450  
    466466    };
    467467
     468    this.breakpointManager = new WebInspector.BreakpointManager();
     469
    468470    this.panels = {};
    469471    this._createPanels();
     
    13241326WebInspector.restoredBreakpoint = function(sourceID, sourceURL, line, enabled, condition)
    13251327{
    1326     var breakpoint = new WebInspector.Breakpoint(sourceURL, line, sourceID, condition);
    1327     breakpoint.enabled = enabled;
    1328     this.panels.scripts.addBreakpoint(breakpoint);
     1328    this.breakpointManager.addBreakpoint(sourceID, sourceURL, line, enabled, condition);
    13291329}
    13301330
     
    13601360            panel.reset();
    13611361    }
     1362
     1363    this.breakpointManager.reset();
    13621364
    13631365    for (var category in this.resourceCategories)
Note: See TracChangeset for help on using the changeset viewer.