[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198
podivilov at chromium.org
podivilov at chromium.org
Sun Feb 20 23:09:17 UTC 2011
The following commit has been merged in the webkit-1.3 branch:
commit 98c4f5a542139f1cd16b51474470c9db1c3f6a66
Author: podivilov at chromium.org <podivilov at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jan 18 10:15:32 2011 +0000
2011-01-11 Pavel Podivilov <podivilov at chromium.org>
Reviewed by Pavel Feldman.
Web Inspector: implement script beautifier prototype.
https://bugs.webkit.org/show_bug.cgi?id=51588
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/front-end/ScriptFormatter.js: Added.
(WebInspector.ScriptFormatter): Implements JavaScript source beautification and conversion between original and
formatted line numbers
(WebInspector.ScriptFormatter.findLineEndings):
(WebInspector.ScriptFormatter.locationToPosition):
(WebInspector.ScriptFormatter.positionToLocation):
(WebInspector.ScriptFormatter.upperBound):
(WebInspector.ScriptFormatter.prototype.format):
(WebInspector.ScriptFormatter.prototype.originalLineNumberToFormattedLineNumber):
(WebInspector.ScriptFormatter.prototype.formattedLineNumberToOriginalLineNumber):
(WebInspector.ScriptFormatter.prototype.originalPositionToFormattedLineNumber):
(WebInspector.ScriptFormatter.prototype.formattedLineNumberToOriginalPosition):
(WebInspector.ScriptFormatter.prototype._convertPosition):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel):
(WebInspector.ScriptsPanel.prototype._clearCurrentExecutionLine):
(WebInspector.ScriptsPanel.prototype._callFrameSelected):
(WebInspector.ScriptsPanel.prototype._formatScript):
* inspector/front-end/SourceFrame.js: Convert original line numbers to UI line numbers and vice versa
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76009 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 4a76f6e..aa9e45a 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,34 @@
+2011-01-11 Pavel Podivilov <podivilov at chromium.org>
+
+ Reviewed by Pavel Feldman.
+
+ Web Inspector: implement script beautifier prototype.
+ https://bugs.webkit.org/show_bug.cgi?id=51588
+
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * inspector/front-end/ScriptFormatter.js: Added.
+ (WebInspector.ScriptFormatter): Implements JavaScript source beautification and conversion between original and
+ formatted line numbers
+ (WebInspector.ScriptFormatter.findLineEndings):
+ (WebInspector.ScriptFormatter.locationToPosition):
+ (WebInspector.ScriptFormatter.positionToLocation):
+ (WebInspector.ScriptFormatter.upperBound):
+ (WebInspector.ScriptFormatter.prototype.format):
+ (WebInspector.ScriptFormatter.prototype.originalLineNumberToFormattedLineNumber):
+ (WebInspector.ScriptFormatter.prototype.formattedLineNumberToOriginalLineNumber):
+ (WebInspector.ScriptFormatter.prototype.originalPositionToFormattedLineNumber):
+ (WebInspector.ScriptFormatter.prototype.formattedLineNumberToOriginalPosition):
+ (WebInspector.ScriptFormatter.prototype._convertPosition):
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel):
+ (WebInspector.ScriptsPanel.prototype._clearCurrentExecutionLine):
+ (WebInspector.ScriptsPanel.prototype._callFrameSelected):
+ (WebInspector.ScriptsPanel.prototype._formatScript):
+ * inspector/front-end/SourceFrame.js: Convert original line numbers to UI line numbers and vice versa
+ * inspector/front-end/WebKit.qrc:
+ * inspector/front-end/inspector.html:
+
2011-01-18 Philippe Normand <pnormand at igalia.com>
Unreviewed, GTK build fix as follow-up of r76004.
diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi
index 84f8837..26240b3 100644
--- a/Source/WebCore/WebCore.gypi
+++ b/Source/WebCore/WebCore.gypi
@@ -4677,6 +4677,7 @@
'inspector/front-end/ResourcesPanel.js',
'inspector/front-end/ScopeChainSidebarPane.js',
'inspector/front-end/Script.js',
+ 'inspector/front-end/ScriptFormatter.js',
'inspector/front-end/ScriptsPanel.js',
'inspector/front-end/ScriptView.js',
'inspector/front-end/ShortcutsHelp.js',
diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
index a54e327..b790472 100755
--- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -65597,6 +65597,10 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\ScriptFormatter.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\ScriptsPanel.js"
>
</File>
diff --git a/Source/WebCore/inspector/front-end/ScriptFormatter.js b/Source/WebCore/inspector/front-end/ScriptFormatter.js
new file mode 100644
index 0000000..bb21ba3
--- /dev/null
+++ b/Source/WebCore/inspector/front-end/ScriptFormatter.js
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2011 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.ScriptFormatter = function(source)
+{
+ this._originalSource = source;
+ this._originalLineEndings = source.findAll("\n");
+ this._originalLineEndings.push(source.length);
+}
+
+WebInspector.ScriptFormatter.locationToPosition = function(lineEndings, location)
+{
+ var position = location.line ? lineEndings[location.line - 1] + 1 : 0;
+ return position + location.column;
+}
+
+WebInspector.ScriptFormatter.positionToLocation = function(lineEndings, position)
+{
+ var location = {};
+ location.line = WebInspector.ScriptFormatter.upperBound(lineEndings, position - 1);
+ if (!location.line)
+ location.column = position;
+ else
+ location.column = position - lineEndings[location.line - 1] - 1;
+ return location;
+}
+
+WebInspector.ScriptFormatter.upperBound = function(array, number)
+{
+ var first = 0;
+ var count = array.length;
+ while (count > 0) {
+ var step = count >> 1;
+ var middle = first + step;
+ if (number >= array[middle]) {
+ first = middle + 1;
+ count -= step + 1;
+ } else
+ count = step;
+ }
+ return first;
+}
+
+WebInspector.ScriptFormatter.prototype = {
+ format: function()
+ {
+ this._formatted = true;
+ this._formattedSource = this._originalSource.replace(/;/g, ";\n");
+ this._formattedLineEndings = this._formattedSource.findAll("\n");
+ this._formattedLineEndings.push(this._formattedSource.length);
+
+ this._originalSymbolPositions = [];
+ this._formattedSymbolPositions = [];
+ var lastCodePosition = 0;
+ var regexp = /[\$\.\w]+|{|}|;/g;
+ while (true) {
+ var match = regexp.exec(this._formattedSource);
+ if (!match)
+ break;
+ var position = this._originalSource.indexOf(match[0], lastCodePosition);
+ if (position === -1)
+ continue;
+ this._originalSymbolPositions.push(position);
+ this._formattedSymbolPositions.push(match.index);
+ lastCodePosition = position + match[0].length;
+ }
+ this._originalSymbolPositions.push(this._originalSource.length);
+ this._formattedSymbolPositions.push(this._formattedSource.length);
+
+ return this._formattedSource;
+ },
+
+ originalLineNumberToFormattedLineNumber: function(originalLineNumber)
+ {
+ if (!this._formatted)
+ return originalLineNumber;
+ var originalPosition = WebInspector.ScriptFormatter.locationToPosition(this._originalLineEndings, { line: originalLineNumber, column: 0 });
+ return this.originalPositionToFormattedLineNumber(originalPosition);
+ },
+
+ formattedLineNumberToOriginalLineNumber: function(formattedLineNumber)
+ {
+ if (!this._formatted)
+ return formattedLineNumber;
+ var originalPosition = this.formattedLineNumberToOriginalPosition(formattedLineNumber);
+ return WebInspector.ScriptFormatter.positionToLocation(this._originalLineEndings, originalPosition).line;
+ },
+
+ originalPositionToFormattedLineNumber: function(originalPosition)
+ {
+ var lineEndings = this._formatted ? this._formattedLineEndings : this._originalLineEndings;
+ if (this._formatted)
+ formattedPosition = this._convertPosition(this._originalSymbolPositions, this._formattedSymbolPositions, originalPosition);
+ return WebInspector.ScriptFormatter.positionToLocation(lineEndings, formattedPosition).line;
+ },
+
+ formattedLineNumberToOriginalPosition: function(formattedLineNumber)
+ {
+ var lineEndings = this._formatted ? this._formattedLineEndings : this._originalLineEndings;
+ var formattedPosition = WebInspector.ScriptFormatter.locationToPosition(lineEndings, { line: formattedLineNumber, column: 0 });
+ if (!this._formatted)
+ return formattedPosition;
+ return this._convertPosition(this._formattedSymbolPositions, this._originalSymbolPositions, formattedPosition);
+ },
+
+ _convertPosition: function(symbolPositions1, symbolPositions2, position)
+ {
+ var index = WebInspector.ScriptFormatter.upperBound(symbolPositions1, position);
+ if (index === symbolPositions2.length - 1)
+ return symbolPositions2[index] - 1;
+ return symbolPositions2[index];
+ }
+}
diff --git a/Source/WebCore/inspector/front-end/ScriptsPanel.js b/Source/WebCore/inspector/front-end/ScriptsPanel.js
index 32212d4..cc8ffc9 100644
--- a/Source/WebCore/inspector/front-end/ScriptsPanel.js
+++ b/Source/WebCore/inspector/front-end/ScriptsPanel.js
@@ -63,6 +63,15 @@ WebInspector.ScriptsPanel = function()
// FIXME: append the functions select element to the top status bar when it is implemented.
// this.topStatusBar.appendChild(this.functionsSelectElement);
+ this.formatButton = document.createElement("button");
+ this.formatButton.className = "status-bar-item";
+ this.formatButton.id = "format-script";
+ this.formatButton.title = WebInspector.UIString("Format script.");
+ this.formatButton.appendChild(document.createElement("img"));
+ this.formatButton.addEventListener("click", this._formatScript.bind(this), false);
+ if (Preferences.debugMode)
+ this.topStatusBar.appendChild(this.formatButton);
+
this.sidebarButtonsElement = document.createElement("div");
this.sidebarButtonsElement.id = "scripts-sidebar-buttons";
this.topStatusBar.appendChild(this.sidebarButtonsElement);
@@ -677,7 +686,7 @@ WebInspector.ScriptsPanel.prototype = {
_clearCurrentExecutionLine: function()
{
if (this._executionSourceFrame)
- this._executionSourceFrame.executionLine = 0;
+ this._executionSourceFrame.clearExecutionLine();
delete this._executionSourceFrame;
},
@@ -699,7 +708,7 @@ WebInspector.ScriptsPanel.prototype = {
this._executionSourceFrame = this._sourceFrameForScriptOrResource(scriptOrResource);
if (this._executionSourceFrame)
- this._executionSourceFrame.executionLine = currentFrame.line;
+ this._executionSourceFrame.setExecutionLine(currentFrame.line);
},
_changeVisibleFile: function(event)
@@ -833,6 +842,12 @@ WebInspector.ScriptsPanel.prototype = {
this._updateBackAndForwardButtons();
},
+ _formatScript: function()
+ {
+ if (this.visibleView && this.visibleView.sourceFrame)
+ this.visibleView.sourceFrame.formatSource();
+ },
+
_enableDebugging: function()
{
if (this._debuggerEnabled)
diff --git a/Source/WebCore/inspector/front-end/SourceFrame.js b/Source/WebCore/inspector/front-end/SourceFrame.js
index af10f1e..da9f4f2 100644
--- a/Source/WebCore/inspector/front-end/SourceFrame.js
+++ b/Source/WebCore/inspector/front-end/SourceFrame.js
@@ -71,23 +71,6 @@ WebInspector.SourceFrame.prototype = {
}
},
- get executionLine()
- {
- return this._executionLine;
- },
-
- set executionLine(x)
- {
- if (this._executionLine === x)
- return;
-
- var previousLine = this._executionLine;
- this._executionLine = x;
-
- if (this._textViewer)
- this._updateExecutionLine(previousLine);
- },
-
markDiff: function(diffData)
{
if (this._diffLines && this._textViewer)
@@ -172,6 +155,7 @@ WebInspector.SourceFrame.prototype = {
{
this._content = content;
this._textModel.setText(null, content);
+ this._formatter = new WebInspector.ScriptFormatter(content);
this._textViewer = new WebInspector.TextViewer(this._textModel, WebInspector.platform, this._url);
var element = this._textViewer.element;
@@ -184,10 +168,7 @@ WebInspector.SourceFrame.prototype = {
this._textViewer.beginUpdates();
this._textViewer.mimeType = mimeType;
- this._addExistingMessagesToSource();
- this._updateExecutionLine();
- this._updateDiffDecorations();
- this._textViewer.resize();
+ this._setTextViewerDecorations();
if (this._lineNumberToReveal) {
this.revealLine(this._lineNumberToReveal);
@@ -210,15 +191,34 @@ WebInspector.SourceFrame.prototype = {
delete this._delayedFindSearchMatches;
}
+ this._textViewer.endUpdates();
+
+ WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointAdded, this._breakpointAdded, this);
+
+ if (this._canEditScripts)
+ this._textViewer.editCallback = this._editLine.bind(this);
+ },
+
+ _setTextViewerDecorations: function()
+ {
+ this._rowMessages = {};
+ this._messageBubbles = {};
+
+ this._textViewer.beginUpdates();
+
+ this._addExistingMessagesToSource();
+ this._updateDiffDecorations();
+
+ if (this._executionLine)
+ this.setExecutionLine(this._executionLine);
+
var breakpoints = this._breakpoints();
for (var i = 0; i < breakpoints.length; ++i)
this._addBreakpoint(breakpoints[i]);
- WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointAdded, this._breakpointAdded, this);
- this._textViewer.endUpdates();
+ this._textViewer.resize();
- if (this._canEditScripts)
- this._textViewer.editCallback = this._editLine.bind(this);
+ this._textViewer.endUpdates();
},
findSearchMatches: function(query, finishedCallback)
@@ -300,18 +300,22 @@ WebInspector.SourceFrame.prototype = {
msg._resourceMessageRepeatCountElement.textContent = WebInspector.UIString(" (repeated %d times)", msg.repeatCount);
},
- _updateExecutionLine: function(previousLine)
+ setExecutionLine: function(lineNumber)
{
- if (previousLine) {
- if (previousLine - 1 < this._textModel.linesCount)
- this._textViewer.removeDecoration(previousLine - 1, "webkit-execution-line");
- }
-
- if (!this._executionLine)
+ this._executionLine = lineNumber;
+ if (!this._textViewer)
return;
+ var textViewerLineNumber = this._formatter.originalLineNumberToFormattedLineNumber(this._executionLine - 1);
+ this._textViewer.addDecoration(textViewerLineNumber, "webkit-execution-line");
+ },
- if (this._executionLine < this._textModel.linesCount)
- this._textViewer.addDecoration(this._executionLine - 1, "webkit-execution-line");
+ clearExecutionLine: function()
+ {
+ if (!this._textViewer)
+ return;
+ var textViewerLineNumber = this._formatter.originalLineNumberToFormattedLineNumber(this._executionLine - 1);
+ this._textViewer.removeDecoration(textViewerLineNumber, "webkit-execution-line");
+ delete this._executionLine;
},
_updateDiffDecorations: function()
@@ -412,14 +416,15 @@ WebInspector.SourceFrame.prototype = {
_addBreakpoint: function(breakpoint)
{
- if (breakpoint.line > this._textModel.linesCount)
+ var textViewerLineNumber = this._formatter.originalLineNumberToFormattedLineNumber(breakpoint.line - 1);
+ if (textViewerLineNumber >= this._textModel.linesCount)
return;
breakpoint.addEventListener("enable-changed", this._breakpointChanged, this);
breakpoint.addEventListener("condition-changed", this._breakpointChanged, this);
breakpoint.addEventListener("removed", this._breakpointRemoved, this);
- this._setBreakpointDecoration(breakpoint.line, breakpoint.enabled, !!breakpoint.condition);
+ this._setBreakpointDecoration(textViewerLineNumber, breakpoint.enabled, !!breakpoint.condition);
},
_breakpointRemoved: function(event)
@@ -430,18 +435,19 @@ WebInspector.SourceFrame.prototype = {
breakpoint.removeEventListener("condition-changed", null, this);
breakpoint.removeEventListener("removed", null, this);
- this._removeBreakpointDecoration(breakpoint.line);
+ var textViewerLineNumber = this._formatter.originalLineNumberToFormattedLineNumber(breakpoint.line - 1);
+ this._removeBreakpointDecoration(textViewerLineNumber);
},
_breakpointChanged: function(event)
{
var breakpoint = event.target;
- this._setBreakpointDecoration(breakpoint.line, breakpoint.enabled, !!breakpoint.condition);
+ var textViewerLineNumber = this._formatter.originalLineNumberToFormattedLineNumber(breakpoint.line - 1);
+ this._setBreakpointDecoration(textViewerLineNumber, breakpoint.enabled, !!breakpoint.condition);
},
_setBreakpointDecoration: function(lineNumber, enabled, hasCondition)
{
- lineNumber -= 1;
this._textViewer.beginUpdates();
this._textViewer.addDecoration(lineNumber, "webkit-breakpoint");
if (enabled)
@@ -457,7 +463,6 @@ WebInspector.SourceFrame.prototype = {
_removeBreakpointDecoration: function(lineNumber)
{
- lineNumber -= 1;
this._textViewer.beginUpdates();
this._textViewer.removeDecoration(lineNumber, "webkit-breakpoint");
this._textViewer.removeDecoration(lineNumber, "webkit-breakpoint-disabled");
@@ -473,27 +478,28 @@ WebInspector.SourceFrame.prototype = {
var target = event.target.enclosingNodeOrSelfWithClass("webkit-line-number");
if (!target)
return;
- var lineNumber = target.parentElement.lineNumber + 1;
+ var textViewerLineNumber = target.parentElement.lineNumber;
+ var originalLineNumber = this._formatter.formattedLineNumberToOriginalLineNumber(textViewerLineNumber);
var contextMenu = new WebInspector.ContextMenu();
- contextMenu.appendItem(WebInspector.UIString("Continue to Here"), this._continueToLine.bind(this, lineNumber));
+ contextMenu.appendItem(WebInspector.UIString("Continue to Here"), this._continueToLine.bind(this, originalLineNumber));
- var breakpoint = this._findBreakpoint(lineNumber);
+ var breakpoint = this._findBreakpoint(originalLineNumber);
if (!breakpoint) {
// This row doesn't have a breakpoint: We want to show Add Breakpoint and Add and Edit Breakpoint.
- contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), this._setBreakpoint.bind(this, lineNumber, "", true));
+ contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), this._setBreakpoint.bind(this, originalLineNumber, "", true));
function addConditionalBreakpoint()
{
- this._setBreakpointDecoration(lineNumber, true, true);
+ this._setBreakpointDecoration(textViewerLineNumber, true, true);
function didEditBreakpointCondition(committed, condition)
{
- this._removeBreakpointDecoration(lineNumber);
+ this._removeBreakpointDecoration(textViewerLineNumber);
if (committed)
- this._setBreakpoint(lineNumber, true, condition);
+ this._setBreakpoint(originalLineNumber, true, condition);
}
- this._editBreakpointCondition(lineNumber, "", didEditBreakpointCondition.bind(this));
+ this._editBreakpointCondition(textViewerLineNumber, "", didEditBreakpointCondition.bind(this));
}
contextMenu.appendItem(WebInspector.UIString("Add Conditional Breakpoint…"), addConditionalBreakpoint.bind(this));
} else {
@@ -505,16 +511,16 @@ WebInspector.SourceFrame.prototype = {
{
if (committed) {
breakpoint.remove();
- this._setBreakpoint(breakpoint.line, breakpoint.enabled, condition);
+ this._setBreakpoint(originalLineNumber, breakpoint.enabled, condition);
}
}
- this._editBreakpointCondition(lineNumber, breakpoint.condition, didEditBreakpointCondition.bind(this));
+ this._editBreakpointCondition(textViewerLineNumber, breakpoint.condition, didEditBreakpointCondition.bind(this));
}
contextMenu.appendItem(WebInspector.UIString("Edit Breakpoint…"), editBreakpointCondition.bind(this));
function setBreakpointEnabled(enabled)
{
breakpoint.remove();
- this._setBreakpoint(breakpoint.line, enabled, breakpoint.condition);
+ this._setBreakpoint(originalLineNumber, enabled, breakpoint.condition);
}
if (breakpoint.enabled)
contextMenu.appendItem(WebInspector.UIString("Disable Breakpoint"), setBreakpointEnabled.bind(this, false));
@@ -538,15 +544,15 @@ WebInspector.SourceFrame.prototype = {
var target = event.target.enclosingNodeOrSelfWithClass("webkit-line-number");
if (!target)
return;
- var lineNumber = target.parentElement.lineNumber + 1;
+ var originalLineNumber = this._formatter.formattedLineNumberToOriginalLineNumber(target.parentElement.lineNumber);
- var breakpoint = this._findBreakpoint(lineNumber);
+ var breakpoint = this._findBreakpoint(originalLineNumber);
if (breakpoint) {
breakpoint.remove();
if (event.shiftKey)
- this._setBreakpoint(breakpoint.line, !breakpoint.enabled, breakpoint.condition);
+ this._setBreakpoint(originalLineNumber, !breakpoint.enabled, breakpoint.condition);
} else
- this._setBreakpoint(lineNumber, true, "");
+ this._setBreakpoint(originalLineNumber, true, "");
event.preventDefault();
},
@@ -710,7 +716,6 @@ WebInspector.SourceFrame.prototype = {
_editBreakpointCondition: function(lineNumber, condition, callback)
{
- lineNumber -= 1;
this._conditionElement = this._createConditionElement(lineNumber);
this._textViewer.addDecoration(lineNumber, this._conditionElement);
@@ -776,22 +781,29 @@ WebInspector.SourceFrame.prototype = {
this._textViewer.resize();
},
+ formatSource: function()
+ {
+ if (!this._formatter)
+ return;
+
+ this._textModel.setText(null, this._formatter.format());
+ this._setTextViewerDecorations();
+ },
+
_continueToLine: function(lineNumber)
{
var sourceID = this._sourceIDForLine(lineNumber);
if (!sourceID)
return;
- WebInspector.debuggerModel.continueToLine(sourceID, lineNumber);
+ WebInspector.debuggerModel.continueToLine(sourceID, lineNumber + 1);
},
_editLine: function(lineNumber, newContent, cancelEditingCallback)
{
- lineNumber += 1;
-
var lines = [];
var oldLines = this._content.split('\n');
for (var i = 0; i < oldLines.length; ++i) {
- if (i === lineNumber - 1)
+ if (i === lineNumber)
lines.push(newContent);
else
lines.push(oldLines[i]);
@@ -800,7 +812,7 @@ WebInspector.SourceFrame.prototype = {
var editData = {};
editData.sourceID = this._sourceIDForLine(lineNumber);
editData.content = lines.join("\n");
- editData.line = lineNumber;
+ editData.line = lineNumber + 1;
editData.linesCountToShift = newContent.split("\n").length - 1;
this._doEditLine(editData, cancelEditingCallback);
},
@@ -826,7 +838,7 @@ WebInspector.SourceFrame.prototype = {
var sourceID = this._sourceIDForLine(lineNumber);
if (!sourceID)
return;
- WebInspector.debuggerModel.setBreakpoint(sourceID, lineNumber, enabled, condition);
+ WebInspector.debuggerModel.setBreakpoint(sourceID, lineNumber + 1, enabled, condition);
if (!WebInspector.panels.scripts.breakpointsActivated)
WebInspector.panels.scripts.toggleBreakpointsClicked();
},
@@ -840,7 +852,7 @@ WebInspector.SourceFrame.prototype = {
_findBreakpoint: function(lineNumber)
{
var sourceID = this._sourceIDForLine(lineNumber);
- return WebInspector.debuggerModel.findBreakpoint(sourceID, lineNumber);
+ return WebInspector.debuggerModel.findBreakpoint(sourceID, lineNumber + 1);
},
_sourceIDForLine: function(lineNumber)
@@ -849,9 +861,9 @@ WebInspector.SourceFrame.prototype = {
var closestStartingLine = 0;
var scripts = this._contentProvider.scripts();
for (var i = 0; i < scripts.length; ++i) {
- var startingLine = scripts[i].startingLine;
- if (startingLine <= lineNumber && startingLine >= closestStartingLine) {
- closestStartingLine = startingLine;
+ var lineOffset = scripts[i].lineOffset;
+ if (lineOffset <= lineNumber && lineOffset >= closestStartingLine) {
+ closestStartingLine = lineOffset;
sourceIDForLine = scripts[i].sourceID;
}
}
diff --git a/Source/WebCore/inspector/front-end/WebKit.qrc b/Source/WebCore/inspector/front-end/WebKit.qrc
index 80a6533..db92ff3 100644
--- a/Source/WebCore/inspector/front-end/WebKit.qrc
+++ b/Source/WebCore/inspector/front-end/WebKit.qrc
@@ -81,6 +81,7 @@
<file>ResourcesPanel.js</file>
<file>ScopeChainSidebarPane.js</file>
<file>Script.js</file>
+ <file>ScriptFormatter.js</file>
<file>ScriptsPanel.js</file>
<file>ScriptView.js</file>
<file>Section.js</file>
diff --git a/Source/WebCore/inspector/front-end/inspector.html b/Source/WebCore/inspector/front-end/inspector.html
index 44f096f..7055092 100644
--- a/Source/WebCore/inspector/front-end/inspector.html
+++ b/Source/WebCore/inspector/front-end/inspector.html
@@ -121,6 +121,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<script type="text/javascript" src="NetworkItemView.js"></script>
<script type="text/javascript" src="ResourceView.js"></script>
<script type="text/javascript" src="SourceFrame.js"></script>
+ <script type="text/javascript" src="ScriptFormatter.js"></script>
<script type="text/javascript" src="DOMSyntaxHighlighter.js"></script>
<script type="text/javascript" src="TextEditorModel.js"></script>
<script type="text/javascript" src="TextEditorHighlighter.js"></script>
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list