[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

podivilov at chromium.org podivilov at chromium.org
Wed Dec 22 18:10:18 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 239a41976f1c41a0b3fbaf90b1f64fbeb795764f
Author: podivilov at chromium.org <podivilov at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Dec 8 11:17:43 2010 +0000

    2010-12-07  Pavel Podivilov  <podivilov at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: introduce DebuggerModel class representing InspectorDebuggerAgent state.
            https://bugs.webkit.org/show_bug.cgi?id=50567
    
            Moved debugging-related code from BreakpointManager to DebuggerModel. Moved Breakpoint class to a separate file.
    
            * English.lproj/localizedStrings.js:
            * WebCore.gypi:
            * WebCore.vcproj/WebCore.vcproj:
            * inspector/front-end/Breakpoint.js: Added.
            (WebInspector.Breakpoint): Moved from BreakpointManager.js.
            * inspector/front-end/BreakpointManager.js:
            (WebInspector.BreakpointManager): Remove debugger-related methods.
            * inspector/front-end/CallStackSidebarPane.js:
            (WebInspector.CallStackSidebarPane):
            (WebInspector.CallStackSidebarPane.prototype._nativeBreakpointHit):
            (WebInspector.CallStackSidebarPane.prototype._scriptBreakpointHit):
            * inspector/front-end/DebuggerModel.js: Added.
            (WebInspector.DebuggerModel): Moved debugger-related methods from BreakpointManager.
            * inspector/front-end/ScriptsPanel.js:
            (WebInspector.ScriptsPanel):
            (WebInspector.ScriptsPanel.prototype.continueToLine):
            (WebInspector.ScriptsPanel.prototype.editScriptSource.mycallback):
            (WebInspector.ScriptsPanel.prototype.editScriptSource):
            (WebInspector.ScriptsPanel.prototype._debuggerPaused):
            (WebInspector.ScriptsPanel.prototype._debuggerResumed):
            (WebInspector.ScriptsPanel.prototype.reset):
            * inspector/front-end/SourceFrame.js:
            (WebInspector.SourceFrame.prototype._createViewerIfNeeded):
            (WebInspector.SourceFrameDelegate.prototype.addBreakpoint):
            (WebInspector.SourceFrameDelegate.prototype.breakpoints):
            (WebInspector.SourceFrameDelegate.prototype.findBreakpoint):
            * inspector/front-end/WebKit.qrc:
            * inspector/front-end/inspector.html:
            * inspector/front-end/inspector.js:
            (WebInspector.createJSBreakpointsSidebarPane):
            (WebInspector.restoredBreakpoint):
            (WebInspector.pausedScript):
            (WebInspector.resumedScript):
            (WebInspector.reset):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73501 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d0247d1..d3a38af 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,47 @@
+2010-12-07  Pavel Podivilov  <podivilov at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: introduce DebuggerModel class representing InspectorDebuggerAgent state.
+        https://bugs.webkit.org/show_bug.cgi?id=50567
+
+        Moved debugging-related code from BreakpointManager to DebuggerModel. Moved Breakpoint class to a separate file.
+
+        * English.lproj/localizedStrings.js:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/front-end/Breakpoint.js: Added.
+        (WebInspector.Breakpoint): Moved from BreakpointManager.js.
+        * inspector/front-end/BreakpointManager.js:
+        (WebInspector.BreakpointManager): Remove debugger-related methods.
+        * inspector/front-end/CallStackSidebarPane.js:
+        (WebInspector.CallStackSidebarPane):
+        (WebInspector.CallStackSidebarPane.prototype._nativeBreakpointHit):
+        (WebInspector.CallStackSidebarPane.prototype._scriptBreakpointHit):
+        * inspector/front-end/DebuggerModel.js: Added.
+        (WebInspector.DebuggerModel): Moved debugger-related methods from BreakpointManager.
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel):
+        (WebInspector.ScriptsPanel.prototype.continueToLine):
+        (WebInspector.ScriptsPanel.prototype.editScriptSource.mycallback):
+        (WebInspector.ScriptsPanel.prototype.editScriptSource):
+        (WebInspector.ScriptsPanel.prototype._debuggerPaused):
+        (WebInspector.ScriptsPanel.prototype._debuggerResumed):
+        (WebInspector.ScriptsPanel.prototype.reset):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame.prototype._createViewerIfNeeded):
+        (WebInspector.SourceFrameDelegate.prototype.addBreakpoint):
+        (WebInspector.SourceFrameDelegate.prototype.breakpoints):
+        (WebInspector.SourceFrameDelegate.prototype.findBreakpoint):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+        * inspector/front-end/inspector.js:
+        (WebInspector.createJSBreakpointsSidebarPane):
+        (WebInspector.restoredBreakpoint):
+        (WebInspector.pausedScript):
+        (WebInspector.resumedScript):
+        (WebInspector.reset):
+
 2010-12-08  Pavel Podivilov  <podivilov at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/English.lproj/localizedStrings.js b/WebCore/English.lproj/localizedStrings.js
index 2f804cd..d96671a 100644
Binary files a/WebCore/English.lproj/localizedStrings.js and b/WebCore/English.lproj/localizedStrings.js differ
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 4ba6155..5884bf2 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -4580,6 +4580,7 @@
             'inspector/front-end/AuditRules.js',
             'inspector/front-end/AuditsPanel.js',
             'inspector/front-end/BottomUpProfileDataGridTree.js',
+            'inspector/front-end/Breakpoint.js',
             'inspector/front-end/BreakpointManager.js',
             'inspector/front-end/BreakpointsSidebarPane.js',
             'inspector/front-end/Callback.js',
@@ -4599,6 +4600,7 @@
             'inspector/front-end/DatabaseQueryView.js',
             'inspector/front-end/DatabaseTableView.js',
             'inspector/front-end/DataGrid.js',
+            'inspector/front-end/DebuggerModel.js',
             'inspector/front-end/DOMAgent.js',
             'inspector/front-end/DOMStorage.js',
             'inspector/front-end/DOMStorageItemsView.js',
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index df77e40..8132bc5 100755
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -65149,6 +65149,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\Breakpoint.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\BreakpointManager.js"
 					>
 				</File>
@@ -65221,6 +65225,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\DebuggerModel.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\DOMAgent.js"
 					>
 				</File>
diff --git a/WebCore/inspector/front-end/Breakpoint.js b/WebCore/inspector/front-end/Breakpoint.js
new file mode 100644
index 0000000..32a6a3d
--- /dev/null
+++ b/WebCore/inspector/front-end/Breakpoint.js
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2010 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.
+ */
+
+WebInspector.Breakpoint = function(debuggerModel, sourceID, url, line, enabled, condition)
+{
+    this.url = url;
+    this.line = line;
+    this.sourceID = sourceID;
+    this._enabled = enabled;
+    this._condition = condition || "";
+    this._sourceText = "";
+    this._hit = false;
+    this._debuggerModel = debuggerModel;
+}
+
+WebInspector.Breakpoint.jsBreakpointId = function(sourceID, line)
+{
+    return sourceID + ":" + line;
+}
+
+WebInspector.Breakpoint.prototype = {
+    get enabled()
+    {
+        return this._enabled;
+    },
+
+    set enabled(x)
+    {
+        if (this._enabled === x)
+            return;
+
+        this._enabled = x;
+        this._debuggerModel._setBreakpointOnBackend(this);
+        this.dispatchEventToListeners("enable-changed");
+    },
+
+    get sourceText()
+    {
+        return this._sourceText;
+    },
+
+    set sourceText(text)
+    {
+        this._sourceText = text;
+        this.dispatchEventToListeners("label-changed");
+    },
+
+    get id()
+    {
+        return WebInspector.Breakpoint.jsBreakpointId(this.sourceID, this.line);
+    },
+
+    get condition()
+    {
+        return this._condition;
+    },
+
+    set condition(c)
+    {
+        c = c || "";
+        if (this._condition === c)
+            return;
+
+        this._condition = c;
+        if (this.enabled)
+            this._debuggerModel._setBreakpointOnBackend(this);
+        this.dispatchEventToListeners("condition-changed");
+    },
+
+    get hit()
+    {
+        return this._hit;
+    },
+
+    set hit(hit)
+    {
+        this._hit = hit;
+        this.dispatchEventToListeners("hit-state-changed");
+    },
+
+    click: function(event)
+    {
+        WebInspector.panels.scripts.showSourceLine(this.url, this.line);
+    },
+
+    compareTo: function(other)
+    {
+        if (this.url != other.url)
+            return this.url < other.url ? -1 : 1;
+        if (this.line != other.line)
+            return this.line < other.line ? -1 : 1;
+        return 0;
+    },
+
+    populateLabelElement: function(element)
+    {
+        var displayName = this.url ? WebInspector.displayNameForURL(this.url) : WebInspector.UIString("(program)");
+        var labelElement = document.createTextNode(displayName + ":" + this.line);
+        element.appendChild(labelElement);
+
+        var sourceTextElement = document.createElement("div");
+        sourceTextElement.textContent = this.sourceText;
+        sourceTextElement.className = "source-text monospace";
+        element.appendChild(sourceTextElement);
+    },
+
+    remove: function()
+    {
+        InspectorBackend.removeBreakpoint(this.sourceID, this.line);
+        this.dispatchEventToListeners("removed");
+        this.removeAllListeners();
+        delete this._debuggerModel;
+    }
+}
+
+WebInspector.Breakpoint.prototype.__proto__ = WebInspector.Object.prototype;
diff --git a/WebCore/inspector/front-end/BreakpointManager.js b/WebCore/inspector/front-end/BreakpointManager.js
index f712367..61b2bc8 100644
--- a/WebCore/inspector/front-end/BreakpointManager.js
+++ b/WebCore/inspector/front-end/BreakpointManager.js
@@ -1,130 +1,43 @@
 /*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
  * Copyright (C) 2010 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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
+ * modification, are permitted provided that the following conditions are
+ * met:
  *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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
+ *     * 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.
  */
 
 WebInspector.BreakpointManager = function()
 {
-    this._breakpoints = {};
     this._nativeBreakpoints = {};
+    this._backendIdToBreakpoint = {};
+
+    WebInspector.debuggerModel.addEventListener("native-breakpoint-hit", this._nativeBreakpointHit, this);
+    WebInspector.debuggerModel.addEventListener("debugger-resumed", this._debuggerResumed, this);
 }
 
 WebInspector.BreakpointManager.prototype = {
-    setOneTimeBreakpoint: function(sourceID, line)
-    {
-        var breakpoint = new WebInspector.Breakpoint(this, sourceID, undefined, line, true, undefined);
-        if (this._breakpoints[breakpoint.id])
-            return;
-        if (this._oneTimeBreakpoint)
-            InspectorBackend.removeBreakpoint(this._oneTimeBreakpoint.sourceID, this._oneTimeBreakpoint.line);
-        this._oneTimeBreakpoint = breakpoint;
-        // FIXME(40669): one time breakpoint will be persisted in inspector settings if not hit.
-        this._setBreakpointOnBackend(breakpoint, true);
-    },
-
-    removeOneTimeBreakpoint: function()
-    {
-        if (this._oneTimeBreakpoint) {
-            InspectorBackend.removeBreakpoint(this._oneTimeBreakpoint.sourceID, this._oneTimeBreakpoint.line);
-            delete this._oneTimeBreakpoint;
-        }
-    },
-
-    setBreakpoint: function(sourceID, url, line, enabled, condition)
-    {
-        var breakpoint = this._setBreakpoint(sourceID, url, line, enabled, condition);
-        if (breakpoint)
-            this._setBreakpointOnBackend(breakpoint);
-    },
-
-    restoredBreakpoint: function(sourceID, url, line, enabled, condition)
-    {
-        this._setBreakpoint(sourceID, url, line, enabled, condition);
-    },
-
-    findBreakpoints: function(filter)
-    {
-        var breakpoints = [];
-        for (var id in this._breakpoints) {
-           var breakpoint = this._breakpoints[id];
-           if (filter(breakpoint))
-               breakpoints.push(breakpoint);
-        }
-        return breakpoints;
-    },
-
-    findBreakpoint: function(sourceID, lineNumber)
-    {
-        var breakpointId = WebInspector.Breakpoint.jsBreakpointId(sourceID, lineNumber);
-        return this._breakpoints[breakpointId];
-    },
-
-    reset: function()
-    {
-        this._breakpoints = {};
-        delete this._oneTimeBreakpoint;
-        this._nativeBreakpoints = {};
-    },
-
-    _setBreakpoint: function(sourceID, url, line, enabled, condition)
-    {
-        var breakpoint = new WebInspector.Breakpoint(this, sourceID, url, line, enabled, condition);
-        if (this._breakpoints[breakpoint.id])
-            return;
-        if (this._oneTimeBreakpoint && (this._oneTimeBreakpoint.id == breakpoint.id))
-            delete this._oneTimeBreakpoint;
-        this._breakpoints[breakpoint.id] = breakpoint;
-        breakpoint.addEventListener("removed", this._breakpointRemoved, this);
-        this.dispatchEventToListeners("breakpoint-added", breakpoint);
-        return breakpoint;
-    },
-
-    _breakpointRemoved: function(event)
-    {
-        delete this._breakpoints[event.target.id];
-    },
-
-    _setBreakpointOnBackend: function(breakpoint, isOneTime)
-    {
-        function didSetBreakpoint(success, line)
-        {
-            if (success && line == breakpoint.line)
-                return;
-            if (isOneTime) {
-                if (success)
-                    this._oneTimeBreakpoint.line = line;
-                else
-                    delete this._oneTimeBreakpoint;
-            } else {
-                breakpoint.remove();
-                if (success)
-                    this._setBreakpoint(breakpoint.sourceID, breakpoint.url, line, breakpoint.enabled, breakpoint.condition);
-            }
-        }
-        InspectorBackend.setBreakpoint(breakpoint.sourceID, breakpoint.line, breakpoint.enabled, breakpoint.condition, didSetBreakpoint.bind(this));
-    },
-
     createDOMBreakpoint: function(nodeId, domEventType, disabled)
     {
         var frontendId = "dom:" + nodeId + ":" + domEventType;
@@ -164,6 +77,11 @@ WebInspector.BreakpointManager.prototype = {
         return breakpoint;
     },
 
+    findBreakpoint: function(backendBreakpointId)
+    {
+        return this._backendIdToBreakpoint[backendBreakpointId];
+    },
+
     _removeNativeBreakpoint: function(breakpoint)
     {
         if (breakpoint._beingSetOnBackend)
@@ -198,7 +116,7 @@ WebInspector.BreakpointManager.prototype = {
             breakpoint._beingSetOnBackend = false;
             if (backendBreakpointId !== "") {
                 breakpoint._backendId = backendBreakpointId;
-                this._breakpoints[backendBreakpointId] = breakpoint;
+                this._backendIdToBreakpoint[backendBreakpointId] = breakpoint;
             }
             breakpoint.dispatchEventToListeners("enable-changed");
             this._updateNativeBreakpointsInSettings();
@@ -208,7 +126,7 @@ WebInspector.BreakpointManager.prototype = {
     _removeNativeBreakpointFromBackend: function(breakpoint)
     {
         InspectorBackend.removeNativeBreakpoint(breakpoint._backendId);
-        delete this._breakpoints[breakpoint._backendId]
+        delete this._backendIdToBreakpoint[breakpoint._backendId]
         delete breakpoint._backendId;
         breakpoint.dispatchEventToListeners("enable-changed");
         this._updateNativeBreakpointsInSettings();
@@ -225,30 +143,20 @@ WebInspector.BreakpointManager.prototype = {
         WebInspector.settings.nativeBreakpoints = persistentBreakpoints;
     },
 
-    debuggerPaused: function(details)
+    _nativeBreakpointHit: function(event)
     {
-        if (details.eventType === WebInspector.DebuggerEventTypes.JavaScriptPause)
-            return;
-
-        if (details.eventData && details.eventData.breakpointId)
-            var breakpointId = details.eventData.breakpointId;
-        else if (details.callFrames && details.callFrames.length)
-            var breakpointId = WebInspector.Breakpoint.jsBreakpointId(details.callFrames[0].sourceID, details.callFrames[0].line);
-        else
-            return;
+        var breakpointId = event.data.breakpointId;
 
-        var breakpoint = this._breakpoints[breakpointId];
+        var breakpoint = this._backendIdToBreakpoint[breakpointId];
         if (!breakpoint)
             return;
 
         breakpoint.hit = true;
         breakpoint.dispatchEventToListeners("hit-state-changed");
         this._lastHitBreakpoint = breakpoint;
-
-        this.dispatchEventToListeners("breakpoint-hit", { breakpoint: breakpoint, eventData: details.eventData });
     },
 
-    debuggerResumed: function()
+    _debuggerResumed: function(event)
     {
         if (!this._lastHitBreakpoint)
             return;
@@ -311,112 +219,16 @@ WebInspector.BreakpointManager.prototype = {
             }
         }
         return result;
-    }
-}
-
-WebInspector.BreakpointManager.prototype.__proto__ = WebInspector.Object.prototype;
-
-WebInspector.Breakpoint = function(breakpointManager, sourceID, url, line, enabled, condition)
-{
-    this.url = url;
-    this.line = line;
-    this.sourceID = sourceID;
-    this._enabled = enabled;
-    this._condition = condition || "";
-    this._sourceText = "";
-    this._breakpointManager = breakpointManager;
-}
-
-WebInspector.Breakpoint.jsBreakpointId = function(sourceID, line)
-{
-    return sourceID + ":" + line;
-}
-
-WebInspector.Breakpoint.prototype = {
-    get enabled()
-    {
-        return this._enabled;
     },
 
-    set enabled(x)
-    {
-        if (this._enabled === x)
-            return;
-
-        this._enabled = x;
-        this._breakpointManager._setBreakpointOnBackend(this);
-        this.dispatchEventToListeners("enable-changed");
-    },
-
-    get sourceText()
-    {
-        return this._sourceText;
-    },
-
-    set sourceText(text)
-    {
-        this._sourceText = text;
-        this.dispatchEventToListeners("label-changed");
-    },
-
-    get id()
-    {
-        return WebInspector.Breakpoint.jsBreakpointId(this.sourceID, this.line);
-    },
-
-    get condition()
-    {
-        return this._condition;
-    },
-
-    set condition(c)
-    {
-        c = c || "";
-        if (this._condition === c)
-            return;
-
-        this._condition = c;
-        if (this.enabled)
-            this._breakpointManager._setBreakpointOnBackend(this);
-        this.dispatchEventToListeners("condition-changed");
-    },
-
-    click: function(event)
-    {
-        WebInspector.panels.scripts.showSourceLine(this.url, this.line);
-    },
-
-    compareTo: function(other)
-    {
-        if (this.url != other.url)
-            return this.url < other.url ? -1 : 1;
-        if (this.line != other.line)
-            return this.line < other.line ? -1 : 1;
-        return 0;
-    },
-
-    populateLabelElement: function(element)
-    {
-        var displayName = this.url ? WebInspector.displayNameForURL(this.url) : WebInspector.UIString("(program)");
-        var labelElement = document.createTextNode(displayName + ":" + this.line);
-        element.appendChild(labelElement);
-
-        var sourceTextElement = document.createElement("div");
-        sourceTextElement.textContent = this.sourceText;
-        sourceTextElement.className = "source-text monospace";
-        element.appendChild(sourceTextElement);
-    },
-
-    remove: function()
+    reset: function()
     {
-        InspectorBackend.removeBreakpoint(this.sourceID, this.line);
-        this.dispatchEventToListeners("removed");
-        this.removeAllListeners();
-        delete this._breakpointManager;
+        this._nativeBreakpoints = {};
+        this._backendIdToBreakpoint = {};
     }
 }
 
-WebInspector.Breakpoint.prototype.__proto__ = WebInspector.Object.prototype;
+WebInspector.BreakpointManager.prototype.__proto__ = WebInspector.Object.prototype;
 
 WebInspector.NativeBreakpoint = function(manager, frontendId, type)
 {
@@ -620,12 +432,6 @@ WebInspector.XHRBreakpoint.prototype = {
 
 WebInspector.XHRBreakpoint.prototype.__proto__ = WebInspector.NativeBreakpoint.prototype;
 
-WebInspector.DebuggerEventTypes = {
-    JavaScriptPause: 0,
-    JavaScriptBreakpoint: 1,
-    NativeBreakpoint: 2
-};
-
 WebInspector.DOMBreakpointTypes = {
     SubtreeModified: 0,
     AttributeModified: 1,
diff --git a/WebCore/inspector/front-end/CallStackSidebarPane.js b/WebCore/inspector/front-end/CallStackSidebarPane.js
index b2e6a5c..16c5fe4 100644
--- a/WebCore/inspector/front-end/CallStackSidebarPane.js
+++ b/WebCore/inspector/front-end/CallStackSidebarPane.js
@@ -26,7 +26,8 @@
 WebInspector.CallStackSidebarPane = function()
 {
     WebInspector.SidebarPane.call(this, WebInspector.UIString("Call Stack"));
-    WebInspector.breakpointManager.addEventListener("breakpoint-hit", this._breakpointHit, this);
+    WebInspector.debuggerModel.addEventListener("native-breakpoint-hit", this._nativeBreakpointHit, this);
+    WebInspector.debuggerModel.addEventListener("script-breakpoint-hit", this._scriptBreakpointHit, this);
 }
 
 WebInspector.CallStackSidebarPane.prototype = {
@@ -170,15 +171,23 @@ WebInspector.CallStackSidebarPane.prototype = {
         section.addRelatedKeys([ nextCallFrame.name, prevCallFrame.name ], WebInspector.UIString("Next/previous call frame"));
     },
 
-    _breakpointHit:  function(event)
+    _nativeBreakpointHit:  function(event)
     {
-        var breakpoint = event.data.breakpoint;
-        if (breakpoint.populateStatusMessageElement) {
-            var statusMessageElement = document.createElement("div");
-            statusMessageElement.className = "info";
-            breakpoint.populateStatusMessageElement(statusMessageElement, event.data.eventData);
-            this.bodyElement.appendChild(statusMessageElement);
-        }
+        var breakpoint = WebInspector.breakpointManager.findBreakpoint(event.data.breakpointId);
+        if (!breakpoint)
+            return;
+        var statusMessageElement = document.createElement("div");
+        statusMessageElement.className = "info";
+        breakpoint.populateStatusMessageElement(statusMessageElement, event.data.eventData);
+        this.bodyElement.appendChild(statusMessageElement);
+    },
+
+    _scriptBreakpointHit:  function(event)
+    {
+        var statusMessageElement = document.createElement("div");
+        statusMessageElement.className = "info";
+        statusMessageElement.appendChild(document.createTextNode(WebInspector.UIString("Paused on a JavaScript breakpoint.")));
+        this.bodyElement.appendChild(statusMessageElement);
     }
 }
 
diff --git a/WebCore/inspector/front-end/DebuggerModel.js b/WebCore/inspector/front-end/DebuggerModel.js
new file mode 100644
index 0000000..37f4dd0
--- /dev/null
+++ b/WebCore/inspector/front-end/DebuggerModel.js
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+WebInspector.DebuggerModel = function()
+{
+    this._breakpoints = {};
+}
+
+WebInspector.DebuggerModel.prototype = {
+    setOneTimeBreakpoint: function(sourceID, line)
+    {
+        var breakpoint = new WebInspector.Breakpoint(this, sourceID, undefined, line, true, undefined);
+        if (this._breakpoints[breakpoint.id])
+            return;
+        if (this._oneTimeBreakpoint)
+            InspectorBackend.removeBreakpoint(this._oneTimeBreakpoint.sourceID, this._oneTimeBreakpoint.line);
+        this._oneTimeBreakpoint = breakpoint;
+        // FIXME(40669): one time breakpoint will be persisted in inspector settings if not hit.
+        this._setBreakpointOnBackend(breakpoint, true);
+    },
+
+    removeOneTimeBreakpoint: function()
+    {
+        if (this._oneTimeBreakpoint) {
+            InspectorBackend.removeBreakpoint(this._oneTimeBreakpoint.sourceID, this._oneTimeBreakpoint.line);
+            delete this._oneTimeBreakpoint;
+        }
+    },
+
+    setBreakpoint: function(sourceID, url, line, enabled, condition)
+    {
+        var breakpoint = this._setBreakpoint(sourceID, url, line, enabled, condition);
+        if (breakpoint)
+            this._setBreakpointOnBackend(breakpoint);
+    },
+
+    breakpointRestored: function(sourceID, url, line, enabled, condition)
+    {
+        this._setBreakpoint(sourceID, url, line, enabled, condition);
+    },
+
+    findBreakpoints: function(filter)
+    {
+        var breakpoints = [];
+        for (var id in this._breakpoints) {
+           var breakpoint = this._breakpoints[id];
+           if (filter(breakpoint))
+               breakpoints.push(breakpoint);
+        }
+        return breakpoints;
+    },
+
+    findBreakpoint: function(sourceID, lineNumber)
+    {
+        var breakpointId = WebInspector.Breakpoint.jsBreakpointId(sourceID, lineNumber);
+        return this._breakpoints[breakpointId];
+    },
+
+    reset: function()
+    {
+        this._breakpoints = {};
+        delete this._oneTimeBreakpoint;
+    },
+
+    _setBreakpoint: function(sourceID, url, line, enabled, condition)
+    {
+        var breakpoint = new WebInspector.Breakpoint(this, sourceID, url, line, enabled, condition);
+        if (this._breakpoints[breakpoint.id])
+            return;
+        if (this._oneTimeBreakpoint && (this._oneTimeBreakpoint.id == breakpoint.id))
+            delete this._oneTimeBreakpoint;
+        this._breakpoints[breakpoint.id] = breakpoint;
+        breakpoint.addEventListener("removed", this._breakpointRemoved, this);
+        this.dispatchEventToListeners("breakpoint-added", breakpoint);
+        return breakpoint;
+    },
+
+    _breakpointRemoved: function(event)
+    {
+        delete this._breakpoints[event.target.id];
+    },
+
+    _setBreakpointOnBackend: function(breakpoint, isOneTime)
+    {
+        function didSetBreakpoint(success, line)
+        {
+            if (success && line == breakpoint.line)
+                return;
+            if (isOneTime) {
+                if (success)
+                    this._oneTimeBreakpoint.line = line;
+                else
+                    delete this._oneTimeBreakpoint;
+            } else {
+                breakpoint.remove();
+                if (success)
+                    this._setBreakpoint(breakpoint.sourceID, breakpoint.url, line, breakpoint.enabled, breakpoint.condition);
+            }
+        }
+        InspectorBackend.setBreakpoint(breakpoint.sourceID, breakpoint.line, breakpoint.enabled, breakpoint.condition, didSetBreakpoint.bind(this));
+    },
+
+    debuggerPaused: function(details)
+    {
+        this.dispatchEventToListeners("debugger-paused", details.callFrames);
+
+        if (details.eventType === WebInspector.DebuggerEventTypes.JavaScriptPause)
+            return;
+        if (details.eventType === WebInspector.DebuggerEventTypes.NativeBreakpoint) {
+            var breakpointId = details.eventData.breakpointId;
+            this.dispatchEventToListeners("native-breakpoint-hit", { breakpointId: breakpointId, eventData: details.eventData });
+            return;
+        }
+
+        var breakpointId = WebInspector.Breakpoint.jsBreakpointId(details.callFrames[0].sourceID, details.callFrames[0].line);
+        var breakpoint = this._breakpoints[breakpointId];
+        if (!breakpoint)
+            return;
+        breakpoint.hit = true;
+        this._lastHitBreakpoint = breakpoint;
+        this.dispatchEventToListeners("script-breakpoint-hit", breakpoint);
+    },
+
+    debuggerResumed: function()
+    {
+        this.dispatchEventToListeners("debugger-resumed");
+
+        if (!this._lastHitBreakpoint)
+            return;
+        this._lastHitBreakpoint.hit = false;
+        delete this._lastHitBreakpoint;
+    }
+}
+
+WebInspector.DebuggerModel.prototype.__proto__ = WebInspector.Object.prototype;
+
+WebInspector.DebuggerEventTypes = {
+    JavaScriptPause: 0,
+    JavaScriptBreakpoint: 1,
+    NativeBreakpoint: 2
+};
diff --git a/WebCore/inspector/front-end/ScriptsPanel.js b/WebCore/inspector/front-end/ScriptsPanel.js
index 9465702..334798c 100644
--- a/WebCore/inspector/front-end/ScriptsPanel.js
+++ b/WebCore/inspector/front-end/ScriptsPanel.js
@@ -176,6 +176,9 @@ WebInspector.ScriptsPanel = function()
     this._debuggerEnabled = Preferences.debuggerAlwaysEnabled;
 
     this.reset();
+
+    WebInspector.debuggerModel.addEventListener("debugger-paused", this._debuggerPaused, this);
+    WebInspector.debuggerModel.addEventListener("debugger-resumed", this._debuggerResumed, this);
 }
 
 // Keep these in sync with WebCore::ScriptDebugServer
@@ -257,7 +260,7 @@ WebInspector.ScriptsPanel.prototype = {
 
     continueToLine: function(sourceID, line)
     {
-        WebInspector.breakpointManager.setOneTimeBreakpoint(sourceID, line);
+        WebInspector.debuggerModel.setOneTimeBreakpoint(sourceID, line);
         if (this.paused)
             this._togglePause();
     },
@@ -290,7 +293,7 @@ WebInspector.ScriptsPanel.prototype = {
             return;
 
         // Need to clear breakpoints and re-create them later when editing source.
-        var breakpoints = WebInspector.breakpointManager.findBreakpoints(function(b) { return b.sourceID === editData.sourceID });
+        var breakpoints = WebInspector.debuggerModel.findBreakpoints(function(b) { return b.sourceID === editData.sourceID });
         for (var i = 0; i < breakpoints.length; ++i)
             breakpoints[i].remove();
 
@@ -299,7 +302,7 @@ WebInspector.ScriptsPanel.prototype = {
             if (success) {
                 commitEditingCallback(newBodyOrErrorMessage);
                 if (callFrames && callFrames.length)
-                    this.debuggerPaused(callFrames);
+                    this._debuggerPaused({ data: callFrames });
             } else {
                 if (cancelEditingCallback)
                     cancelEditingCallback();
@@ -310,7 +313,7 @@ WebInspector.ScriptsPanel.prototype = {
                 var newLine = breakpoint.line;
                 if (success && breakpoint.line >= editData.line)
                     newLine += editData.linesCountToShift;
-                WebInspector.breakpointManager.setBreakpoint(editData.sourceID, breakpoint.url, newLine, breakpoint.enabled, breakpoint.condition);
+                WebInspector.debuggerModel.setBreakpoint(editData.sourceID, breakpoint.url, newLine, breakpoint.enabled, breakpoint.condition);
             }
         };
         InspectorBackend.editScriptSource(editData.sourceID, editData.content, mycallback.bind(this));
@@ -353,9 +356,11 @@ WebInspector.ScriptsPanel.prototype = {
         InjectedScriptAccess.get(callFrame.worldId).evaluateInCallFrame(callFrame.id, code, objectGroup, evalCallback);
     },
 
-    debuggerPaused: function(callFrames)
+    _debuggerPaused: function(event)
     {
-        WebInspector.breakpointManager.removeOneTimeBreakpoint();
+        var callFrames = event.data;
+
+        WebInspector.debuggerModel.removeOneTimeBreakpoint();
         this._paused = true;
         this._waitingToPause = false;
         this._stepping = false;
@@ -368,9 +373,10 @@ WebInspector.ScriptsPanel.prototype = {
         this.sidebarPanes.callstack.selectedCallFrame = callFrames[0];
 
         window.focus();
+        InspectorFrontendHost.bringToFront();
     },
 
-    debuggerResumed: function()
+    _debuggerResumed: function()
     {
         this._paused = false;
         this._waitingToPause = false;
@@ -413,7 +419,7 @@ WebInspector.ScriptsPanel.prototype = {
         delete this.currentQuery;
         this.searchCanceled();
 
-        this.debuggerResumed();
+        this._debuggerResumed();
 
         this._backForwardList = [];
         this._currentBackForwardIndex = -1;
diff --git a/WebCore/inspector/front-end/SourceFrame.js b/WebCore/inspector/front-end/SourceFrame.js
index 29fdc1f..1e0244f 100644
--- a/WebCore/inspector/front-end/SourceFrame.js
+++ b/WebCore/inspector/front-end/SourceFrame.js
@@ -217,7 +217,7 @@ WebInspector.SourceFrame.prototype = {
         var breakpoints = this._breakpoints();
         for (var i = 0; i < breakpoints.length; ++i)
             this._addBreakpoint(breakpoints[i]);
-        WebInspector.breakpointManager.addEventListener("breakpoint-added", this._breakpointAdded, this);
+        WebInspector.debuggerModel.addEventListener("breakpoint-added", this._breakpointAdded, this);
 
         this._textViewer.endUpdates();
 
@@ -804,7 +804,7 @@ WebInspector.SourceFrame.prototype = {
     _setBreakpoint: function(lineNumber)
     {
         var sourceID = this._sourceIDForLine(lineNumber);
-        WebInspector.breakpointManager.setBreakpoint(sourceID, this._url, lineNumber, true, "");
+        WebInspector.debuggerModel.setBreakpoint(sourceID, this._url, lineNumber, true, "");
         if (!WebInspector.panels.scripts.breakpointsActivated)
             WebInspector.panels.scripts.toggleBreakpointsClicked();
     },
@@ -819,13 +819,13 @@ WebInspector.SourceFrame.prototype = {
         {
             return breakpoint.sourceID in sourceIDs;
         }
-        return WebInspector.breakpointManager.findBreakpoints(filter);
+        return WebInspector.debuggerModel.findBreakpoints(filter);
     },
 
     _findBreakpoint: function(lineNumber)
     {
         var sourceID = this._sourceIDForLine(lineNumber);
-        return WebInspector.breakpointManager.findBreakpoint(sourceID, lineNumber);
+        return WebInspector.debuggerModel.findBreakpoint(sourceID, lineNumber);
     },
 
     _shouldDisplayBreakpoint: function(breakpoint)
diff --git a/WebCore/inspector/front-end/WebKit.qrc b/WebCore/inspector/front-end/WebKit.qrc
index 2db0182..2f91adb 100644
--- a/WebCore/inspector/front-end/WebKit.qrc
+++ b/WebCore/inspector/front-end/WebKit.qrc
@@ -9,6 +9,7 @@
     <file>AuditRules.js</file>
     <file>AuditsPanel.js</file>
     <file>BottomUpProfileDataGridTree.js</file>
+    <file>Breakpoint.js</file>
     <file>BreakpointManager.js</file>
     <file>BreakpointsSidebarPane.js</file>
     <file>Callback.js</file>
@@ -28,6 +29,7 @@
     <file>DatabaseQueryView.js</file>
     <file>DatabaseTableView.js</file>
     <file>DataGrid.js</file>
+    <file>DebuggerModel.js</file>
     <file>DOMAgent.js</file>
     <file>DOMStorage.js</file>
     <file>DOMStorageItemsView.js</file>
diff --git a/WebCore/inspector/front-end/inspector.html b/WebCore/inspector/front-end/inspector.html
index 67fd081..40e75ea 100644
--- a/WebCore/inspector/front-end/inspector.html
+++ b/WebCore/inspector/front-end/inspector.html
@@ -73,6 +73,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="ApplicationCacheItemsView.js"></script>
     <script type="text/javascript" src="FileSystemView.js"></script>
     <script type="text/javascript" src="Script.js"></script>
+    <script type="text/javascript" src="Breakpoint.js"></script>
     <script type="text/javascript" src="BreakpointManager.js"></script>
     <script type="text/javascript" src="SidebarPane.js"></script>
     <script type="text/javascript" src="ElementsTreeOutline.js"></script>
@@ -139,6 +140,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="TopDownProfileDataGridTree.js"></script>
     <script type="text/javascript" src="ProfileView.js"></script>
     <script type="text/javascript" src="HeapSnapshotView.js"></script>
+    <script type="text/javascript" src="DebuggerModel.js"></script>
     <script type="text/javascript" src="DOMAgent.js"></script>
     <script type="text/javascript" src="InjectedScript.js"></script>
     <script type="text/javascript" src="InjectedScriptAccess.js"></script>
diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js
index f71b89a..3279d95 100644
--- a/WebCore/inspector/front-end/inspector.js
+++ b/WebCore/inspector/front-end/inspector.js
@@ -192,7 +192,7 @@ var WebInspector = {
         {
             pane.addBreakpointItem(new WebInspector.BreakpointItem(event.data));
         }
-        WebInspector.breakpointManager.addEventListener("breakpoint-added", breakpointAdded);
+        WebInspector.debuggerModel.addEventListener("breakpoint-added", breakpointAdded);
         return pane;
     },
 
@@ -533,8 +533,10 @@ WebInspector.doLoadedDone = function()
         other: new WebInspector.ResourceCategory("other", WebInspector.UIString("Other"), "rgb(186,186,186)")
     };
 
-    this.breakpointManager = new WebInspector.BreakpointManager();
     this.cssModel = new WebInspector.CSSStyleModel();
+    this.debuggerModel = new WebInspector.DebuggerModel();
+
+    this.breakpointManager = new WebInspector.BreakpointManager();
 
     this.panels = {};
     this._createPanels();
@@ -1301,7 +1303,7 @@ WebInspector.parsedScriptSource = function(sourceID, sourceURL, source, starting
 
 WebInspector.restoredBreakpoint = function(sourceID, sourceURL, line, enabled, condition)
 {
-    this.breakpointManager.restoredBreakpoint(sourceID, sourceURL, line, enabled, condition);
+    this.debuggerModel.breakpointRestored(sourceID, sourceURL, line, enabled, condition);
 }
 
 WebInspector.failedToParseScriptSource = function(sourceURL, source, startingLine, errorLine, errorMessage)
@@ -1311,19 +1313,17 @@ WebInspector.failedToParseScriptSource = function(sourceURL, source, startingLin
 
 WebInspector.pausedScript = function(details)
 {
-    this.panels.scripts.debuggerPaused(details.callFrames);
-    this.breakpointManager.debuggerPaused(details);
-    InspectorFrontendHost.bringToFront();
+    this.debuggerModel.debuggerPaused(details);
 }
 
 WebInspector.resumedScript = function()
 {
-    this.breakpointManager.debuggerResumed();
-    this.panels.scripts.debuggerResumed();
+    this.debuggerModel.debuggerResumed();
 }
 
 WebInspector.reset = function()
 {
+    this.debuggerModel.reset();
     this.breakpointManager.reset();
 
     for (var panelName in this.panels) {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list