[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.18-1-697-g2f78b87
pfeldman at chromium.org
pfeldman at chromium.org
Wed Jan 20 22:22:41 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit c95613cd3b279de34ac9364e793094a622945ff0
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jan 13 22:12:48 2010 +0000
2010-01-13 Pavel Feldman <pfeldman at chromium.org>
Reviewed by Timothy Hatcher.
Web Inspector: Introduce SourceFrame2 with basic breakpoint / execution line
rendering capabilities.
Contains a drive-by naming fix (lineNumberOffset and lineNumberToOffset were
too close to each other, but were unrelated).
https://bugs.webkit.org/show_bug.cgi?id=33618
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/front-end/SourceFrame2.js: Added.
(WebInspector.SourceFrame2):
(WebInspector.SourceFrame2.prototype.set text):
(WebInspector.SourceFrame2.prototype.get executionLine):
(WebInspector.SourceFrame2.prototype.set executionLine):
(WebInspector.SourceFrame2.prototype.revealLine):
(WebInspector.SourceFrame2.prototype._toggleBreakpoint):
(WebInspector.SourceFrame2.prototype.resize):
(WebInspector.BreakpointLineNumberDecorator):
(WebInspector.BreakpointLineNumberDecorator.prototype.decorate):
(WebInspector.BreakpointLineNumberDecorator.prototype._paintBreakpoint):
(WebInspector.BreakpointLineNumberDecorator.prototype._paintProgramCounter):
(WebInspector.BreakpointLineNumberDecorator.prototype.mouseDown):
(WebInspector.ExecutionLineDecorator):
(WebInspector.ExecutionLineDecorator.prototype.decorate):
* inspector/front-end/TextEditor.js:
(WebInspector.TextEditor):
(WebInspector.TextEditor.prototype.get textModel):
(WebInspector.TextEditor.prototype.set readOnly):
(WebInspector.TextEditor.prototype.set lineNumberDecorator):
(WebInspector.TextEditor.prototype.set lineDecorator):
(WebInspector.TextEditor.prototype.selectionRange):
(WebInspector.TextEditor.prototype._offsetToLine):
(WebInspector.TextEditor.prototype._lineToOffset):
(WebInspector.TextEditor.prototype.reveal):
(WebInspector.TextEditor.prototype._textChanged):
(WebInspector.TextEditor.prototype._updateSize):
(WebInspector.TextEditor.prototype.updateCanvasSize):
(WebInspector.TextEditor.prototype._repaintAll):
(WebInspector.TextEditor.prototype._paintLines):
(WebInspector.TextEditor.prototype._paintLinesContinuation):
(WebInspector.TextEditor.prototype.paintLineNumbers):
(WebInspector.TextEditor.prototype._paintCurrentLine):
(WebInspector.TextEditor.prototype._mouseDown):
(WebInspector.TextEditor.prototype._caretForMouseEvent):
(WebInspector.TextEditor.prototype._keyDown):
(WebInspector.TextEditor.prototype._handleNavigationKey):
(WebInspector.TextEditor.prototype._textInput):
(WebInspector.TextEditor.prototype._updateCursor):
(WebInspector.TextEditor.prototype._paintSelection):
(WebInspector.TextEditor.prototype._initFont):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53205 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 438e655..0c31840 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,59 @@
+2010-01-13 Pavel Feldman <pfeldman at chromium.org>
+
+ Reviewed by Timothy Hatcher.
+
+ Web Inspector: Introduce SourceFrame2 with basic breakpoint / execution line
+ rendering capabilities.
+
+ Contains a drive-by naming fix (lineNumberOffset and lineNumberToOffset were
+ too close to each other, but were unrelated).
+
+ https://bugs.webkit.org/show_bug.cgi?id=33618
+
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * inspector/front-end/SourceFrame2.js: Added.
+ (WebInspector.SourceFrame2):
+ (WebInspector.SourceFrame2.prototype.set text):
+ (WebInspector.SourceFrame2.prototype.get executionLine):
+ (WebInspector.SourceFrame2.prototype.set executionLine):
+ (WebInspector.SourceFrame2.prototype.revealLine):
+ (WebInspector.SourceFrame2.prototype._toggleBreakpoint):
+ (WebInspector.SourceFrame2.prototype.resize):
+ (WebInspector.BreakpointLineNumberDecorator):
+ (WebInspector.BreakpointLineNumberDecorator.prototype.decorate):
+ (WebInspector.BreakpointLineNumberDecorator.prototype._paintBreakpoint):
+ (WebInspector.BreakpointLineNumberDecorator.prototype._paintProgramCounter):
+ (WebInspector.BreakpointLineNumberDecorator.prototype.mouseDown):
+ (WebInspector.ExecutionLineDecorator):
+ (WebInspector.ExecutionLineDecorator.prototype.decorate):
+ * inspector/front-end/TextEditor.js:
+ (WebInspector.TextEditor):
+ (WebInspector.TextEditor.prototype.get textModel):
+ (WebInspector.TextEditor.prototype.set readOnly):
+ (WebInspector.TextEditor.prototype.set lineNumberDecorator):
+ (WebInspector.TextEditor.prototype.set lineDecorator):
+ (WebInspector.TextEditor.prototype.selectionRange):
+ (WebInspector.TextEditor.prototype._offsetToLine):
+ (WebInspector.TextEditor.prototype._lineToOffset):
+ (WebInspector.TextEditor.prototype.reveal):
+ (WebInspector.TextEditor.prototype._textChanged):
+ (WebInspector.TextEditor.prototype._updateSize):
+ (WebInspector.TextEditor.prototype.updateCanvasSize):
+ (WebInspector.TextEditor.prototype._repaintAll):
+ (WebInspector.TextEditor.prototype._paintLines):
+ (WebInspector.TextEditor.prototype._paintLinesContinuation):
+ (WebInspector.TextEditor.prototype.paintLineNumbers):
+ (WebInspector.TextEditor.prototype._paintCurrentLine):
+ (WebInspector.TextEditor.prototype._mouseDown):
+ (WebInspector.TextEditor.prototype._caretForMouseEvent):
+ (WebInspector.TextEditor.prototype._keyDown):
+ (WebInspector.TextEditor.prototype._handleNavigationKey):
+ (WebInspector.TextEditor.prototype._textInput):
+ (WebInspector.TextEditor.prototype._updateCursor):
+ (WebInspector.TextEditor.prototype._paintSelection):
+ (WebInspector.TextEditor.prototype._initFont):
+
2010-01-13 Nate Chapin <japhet at chromium.org>
Reviewed by Dimitri Glazkov.
@@ -21,12 +77,12 @@
Reviewed by Adam Roben.
- REGRESSION (r49268): DHTML drag not allowed unless event.dataTransfer.effectAllowed
+ REGRESSION (r49268): DHTML drag not allowed unless event.dataTransfer.effectAllowed
is set (differs from HTML5).
Fixes <https://bugs.webkit.org/show_bug.cgi?id=33607> and <rdar://7507114>.
If no effectAllowed is set in the dragStart operation, we should default to
- uninitialized instead of none, so the user doesn't have to manually set the
+ uninitialized instead of none, so the user doesn't have to manually set the
effectAllowed to enable drag and drop.
* dom/Clipboard.cpp:
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 912a7e9..6601347 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -3722,6 +3722,7 @@
'inspector/front-end/SidebarPane.js',
'inspector/front-end/SidebarTreeElement.js',
'inspector/front-end/SourceFrame.js',
+ 'inspector/front-end/SourceFrame2.js',
'inspector/front-end/SourceSyntaxHighlighter.js',
'inspector/front-end/SourceView.js',
'inspector/front-end/StatusBarButton.js',
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 43552b8..18aac4c 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -42848,6 +42848,10 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\SourceFrame2.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\SourceSyntaxHighlighter.js"
>
</File>
diff --git a/WebCore/inspector/front-end/SourceFrame2.js b/WebCore/inspector/front-end/SourceFrame2.js
new file mode 100644
index 0000000..93792f8
--- /dev/null
+++ b/WebCore/inspector/front-end/SourceFrame2.js
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2009 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.SourceFrame2 = function()
+{
+ this._editor = new WebInspector.TextEditor(WebInspector.platform);
+ this._textModel = this._editor.textModel;
+ this._editor.lineNumberDecorator = new WebInspector.BreakpointLineNumberDecorator(this);
+ this._editor.lineDecorator = new WebInspector.ExecutionLineDecorator(this);
+ this._editor.readOnly = true;
+ this.element = this._editor.element;
+}
+
+WebInspector.SourceFrame2.prototype = {
+ set text(text)
+ {
+ this._editor.text = text;
+ },
+
+ get executionLine()
+ {
+ return this._executionLine;
+ },
+
+ set executionLine(x)
+ {
+ this._executionLine = x;
+ },
+
+ revealLine: function(lineNumber)
+ {
+ this._editor.reveal(lineNumber, 0);
+ },
+
+ _toggleBreakpoint: function(lineNumber)
+ {
+ if (this._textModel.getAttribute(lineNumber, "breakpoint"))
+ this._textModel.removeAttribute(lineNumber, "breakpoint");
+ else
+ this._textModel.setAttribute(lineNumber, "breakpoint", { disabled: false, conditional: false });
+ this._editor.paintLineNumbers();
+ },
+
+ resize: function()
+ {
+ this._editor.updateCanvasSize();
+ }
+}
+
+WebInspector.SourceFrame2.prototype.__proto__ = WebInspector.Object.prototype;
+
+WebInspector.BreakpointLineNumberDecorator = function(sourceFrame)
+{
+ this._sourceFrame = sourceFrame;
+ this._textModel = sourceFrame._editor.textModel;
+}
+
+WebInspector.BreakpointLineNumberDecorator.prototype = {
+ decorate: function(lineNumber, ctx, x, y, width, height, lineHeight)
+ {
+ var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
+ var isExecutionLine = lineNumber === this._sourceFrame._executionLine;
+ if (breakpoint || isExecutionLine) {
+ ctx.save();
+ ctx.translate(x + 4, y + 2);
+ var breakpointWidth = width - 6;
+ var breakpointHeight = lineHeight - 4;
+
+ if (breakpoint)
+ this._paintBreakpoint(ctx, breakpointWidth, breakpointHeight, breakpoint.conditional, breakpoint.disabled);
+
+ if (isExecutionLine)
+ this._paintProgramCounter(ctx, breakpointWidth, breakpointHeight, false);
+
+ ctx.restore();
+ }
+
+ if (isExecutionLine) {
+ // Override default behavior.
+ return true;
+ }
+
+ ctx.fillStyle = breakpoint ? "rgb(255,255,255)" : "rgb(155,155,155)";
+ return false;
+ },
+
+ _paintBreakpoint: function(ctx, width, height, conditional, disabled)
+ {
+ ctx.beginPath();
+ ctx.moveTo(0, 2);
+ ctx.lineTo(2, 0);
+ ctx.lineTo(width - 5, 0);
+ ctx.lineTo(width, height / 2);
+ ctx.lineTo(width - 5, height);
+ ctx.lineTo(2, height);
+ ctx.lineTo(0, height - 2);
+ ctx.closePath();
+ ctx.fillStyle = conditional ? "rgb(217, 142, 1)" : "rgb(1, 142, 217)";
+ ctx.strokeStyle = conditional ? "rgb(205, 103, 0)" : "rgb(0, 103, 205)";
+ ctx.lineWidth = 3;
+ ctx.fill();
+
+ ctx.save();
+ ctx.clip();
+ ctx.stroke();
+ ctx.restore();
+
+ if (disabled) {
+ ctx.save();
+ ctx.globalCompositeOperation = "destination-out";
+ ctx.fillStyle = "rgba(0, 0, 0, 0.5)";
+ ctx.fillRect(0, 0, breakpointWidth, breakpointHeight);
+ ctx.restore();
+ }
+ },
+
+ _paintProgramCounter: function(ctx, width, height)
+ {
+ ctx.save();
+
+ ctx.beginPath();
+ ctx.moveTo(width - 9, 2);
+ ctx.lineTo(width - 7, 2);
+ ctx.lineTo(width - 7, 0);
+ ctx.lineTo(width - 5, 0);
+ ctx.lineTo(width, height / 2);
+ ctx.lineTo(width - 5, height);
+ ctx.lineTo(width - 7, height);
+ ctx.lineTo(width - 7, height - 2);
+ ctx.lineTo(width - 9, height - 2);
+ ctx.closePath();
+ ctx.fillStyle = "rgb(142, 5, 4)";
+
+ ctx.shadowBlur = 4;
+ ctx.shadowColor = "rgb(255, 255, 255)";
+ ctx.shadowOffsetX = -1;
+ ctx.shadowOffsetY = 0;
+
+ ctx.fill();
+ ctx.fill(); // Fill twice to get a good shadow and darker anti-aliased pixels.
+
+ ctx.restore();
+ },
+
+ mouseDown: function(lineNumber, e)
+ {
+ this._sourceFrame._toggleBreakpoint(lineNumber);
+ return true;
+ }
+}
+
+WebInspector.ExecutionLineDecorator = function(sourceFrame)
+{
+ this._sourceFrame = sourceFrame;
+}
+
+WebInspector.ExecutionLineDecorator.prototype = {
+ decorate: function(lineNumber, ctx, x, y, width, height, lineHeight)
+ {
+ if (this._sourceFrame._executionLine !== lineNumber)
+ return;
+ ctx.save();
+ ctx.fillStyle = "rgb(171, 191, 254)";
+ ctx.fillRect(x, y, width, height);
+
+ ctx.beginPath();
+ ctx.rect(x - 1, y, width + 2, height);
+ ctx.clip();
+ ctx.strokeStyle = "rgb(64, 115, 244)";
+ ctx.stroke();
+
+ ctx.restore();
+ }
+}
diff --git a/WebCore/inspector/front-end/TextEditor.js b/WebCore/inspector/front-end/TextEditor.js
index 38dc3d0..c7b07bf 100644
--- a/WebCore/inspector/front-end/TextEditor.js
+++ b/WebCore/inspector/front-end/TextEditor.js
@@ -94,6 +94,7 @@ WebInspector.TextEditor = function(platform)
this._longestLineNumber = 0;
this._lineOffsetsCache = [0];
+ this._readOnly = false;
}
WebInspector.TextEditor.prototype = {
@@ -105,6 +106,26 @@ WebInspector.TextEditor.prototype = {
this._setCaretLocation(0, 0);
},
+ get textModel()
+ {
+ return this._textModel;
+ },
+
+ set readOnly(readOnly)
+ {
+ this._readOnly = readOnly;
+ },
+
+ set lineNumberDecorator(lineNumberDecorator)
+ {
+ this._lineNumberDecorator = lineNumberDecorator;
+ },
+
+ set lineDecorator(lineDecorator)
+ {
+ this._lineDecorator = lineDecorator;
+ },
+
setSelection: function(startLine, startColumn, endLine, endColumn)
{
var start = this._fit(startLine, startColumn);
@@ -112,12 +133,12 @@ WebInspector.TextEditor.prototype = {
this._setSelectionEnd(endLine, endColumn);
},
- _offsetToLineNumber: function(offset)
+ _offsetToLine: function(offset)
{
if (offset > this._lineOffsetsCache[this._lineOffsetsCache.length - 1]) {
// Seeking outside cached area. Fill the cache.
var lineNumber = this._lineOffsetsCache.length;
- while (this._lineNumberToOffset(lineNumber) < offset)
+ while (this._lineToOffset(lineNumber) < offset)
lineNumber++;
return lineNumber;
}
@@ -135,7 +156,7 @@ WebInspector.TextEditor.prototype = {
return to;
},
- _lineNumberToOffset: function(lineNumber)
+ _lineToOffset: function(lineNumber)
{
var offset = this._lineOffsetsCache[lineNumber];
if (offset)
@@ -158,7 +179,7 @@ WebInspector.TextEditor.prototype = {
},
reveal: function(line, column) {
- var maxScrollTop = this._lineNumberToOffset(line);
+ var maxScrollTop = this._lineToOffset(line);
var minScrollTop = maxScrollTop + this._lineHeight(line) - this._canvas.height;
if (this._scrollTop > maxScrollTop)
this._container.scrollTop = maxScrollTop;
@@ -167,7 +188,7 @@ WebInspector.TextEditor.prototype = {
var firstColumn = this._columnForOffset(line, this._scrollLeft);
var maxScrollLeft = this._columnToOffset(line, column);
- var minScrollLeft = maxScrollLeft - this._container.clientWidth + this._lineNumberOffset;
+ var minScrollLeft = maxScrollLeft - this._container.clientWidth + this._lineNumberWidth;
if (this._scrollLeft < minScrollLeft)
this._container.scrollLeft = minScrollLeft + 100;
if (this._scrollLeft > maxScrollLeft)
@@ -184,7 +205,7 @@ WebInspector.TextEditor.prototype = {
this._invalidateLines(newRange.startLine, this._textModel.linesCount + Math.max(0, oldRange.endLine - newRange.endLine));
if (this._highlightingEnabled) {
- var lastVisibleLine = Math.min(this._textModel.linesCount, this._offsetToLineNumber(this._scrollTop + this._canvas.height) + 1);
+ var lastVisibleLine = Math.min(this._textModel.linesCount, this._offsetToLine(this._scrollTop + this._canvas.height) + 1);
this._highlighter.updateHighlight(newRange.startLine, lastVisibleLine);
}
@@ -193,8 +214,8 @@ WebInspector.TextEditor.prototype = {
// Invalidate offset cache.
this._lineOffsetsCache.length = oldRange.startLine + 1;
// Force linenumber cache to be continuous.
- this._lineNumberToOffset(oldRange.startLine);
- this._paintLineNumbers();
+ this._lineToOffset(oldRange.startLine);
+ this.paintLineNumbers();
}
this._paint();
},
@@ -214,15 +235,12 @@ WebInspector.TextEditor.prototype = {
_highlightChanged: function(fromLine, toLine)
{
- this._invalidateLines(fromLine, toLine + 1);
+ this._invalidateLines(fromLine, toLine);
this._paint();
},
_updateSize: function(startLine, endLine)
{
- var newLineNumberDigits = this._decimalDigits(this._textModel.linesCount);
- this._lineNumberOffset = (newLineNumberDigits + 2) * this._digitWidth;
-
var guardedEndLine = Math.min(this._textModel.linesCount, endLine + 1);
var newMaximum = false;
for (var i = startLine; i < guardedEndLine; ++i) {
@@ -246,13 +264,28 @@ WebInspector.TextEditor.prototype = {
}
}
- this._sheet.style.width = this._textWidth + this._lineNumberOffset + "px";
- this._sheet.style.height = this._lineNumberToOffset(this._textModel.linesCount) + "px";
+ var newLineNumberDigits = this._decimalDigits(this._textModel.linesCount);
+ this._lineNumberWidth = (newLineNumberDigits + 2) * this._digitWidth;
- if (this._canvas.width !== this._container.clientWidth || this._canvas.height !== this._container.clientHeight || newLineNumberDigits !== this._lineNumberDigits) {
+ var newWidth = this._textWidth + this._lineNumberWidth + "px";
+ var newHeight = this._lineToOffset(this._textModel.linesCount) + "px";
+ this._sheet.style.width = newWidth;
+ this._sheet.style.height = newHeight;
+
+ if (newLineNumberDigits !== this._lineNumberDigits) {
+ this._lineNumberDigits = newLineNumberDigits;
+ this._repaintAll();
+ }
+
+ // Changes to size can change the client area (scrollers can appear/disappear)
+ this.updateCanvasSize();
+ },
+
+ updateCanvasSize: function()
+ {
+ if (this._canvas.width !== this._container.clientWidth || this._canvas.height !== this._container.clientHeight) {
this._canvas.width = this._container.clientWidth;
this._canvas.height = this._container.clientHeight;
- this._lineNumberDigits = newLineNumberDigits;
this._repaintAll();
}
},
@@ -260,7 +293,7 @@ WebInspector.TextEditor.prototype = {
_repaintAll: function()
{
this._invalidateLines(0, this._textModel.linesCount);
- this._paintLineNumbers();
+ this.paintLineNumbers();
this._paint();
this._updateCursor(this._selection.endLine, this._selection.endColumn);
},
@@ -296,18 +329,18 @@ WebInspector.TextEditor.prototype = {
{
this._ctx.font = this._font;
this._ctx.textBaseline = "bottom";
-
- firstLine = Math.max(firstLine, this._offsetToLineNumber(this._scrollTop) - 1);
- lastLine = Math.min(lastLine, this._offsetToLineNumber(this._scrollTop + this._canvas.height) + 1);
+
+ firstLine = Math.max(firstLine, this._offsetToLine(this._scrollTop) - 1);
+ lastLine = Math.min(lastLine, this._offsetToLine(this._scrollTop + this._canvas.height) + 1);
if (firstLine > lastLine)
return;
if (this._debugMode) {
WebInspector.log("Repaint %d:%d", firstLine, lastLine);
this._ctx.fillStyle = "rgb(255,255,0)";
- var fromOffset = this._lineNumberToOffset(firstLine);
- var toOffset = this._lineNumberToOffset(lastLine);
- this._ctx.fillRect(this._lineNumberOffset - 1, fromOffset - this._scrollTop, this._canvas.width - this._lineNumberOffset + 1, toOffset - fromOffset);
+ var fromOffset = this._lineToOffset(firstLine);
+ var toOffset = this._lineToOffset(lastLine);
+ this._ctx.fillRect(this._lineNumberWidth - 1, fromOffset - this._scrollTop, this._canvas.width - this._lineNumberWidth + 1, toOffset - fromOffset);
setTimeout(this._paintLinesContinuation.bind(this, firstLine, lastLine), 100);
} else
this._paintLinesContinuation(firstLine, lastLine);
@@ -317,34 +350,39 @@ WebInspector.TextEditor.prototype = {
// Clip editor area.
this._ctx.save();
this._ctx.beginPath();
- this._ctx.rect(this._lineNumberOffset - 1, 0, this._canvas.width - this._lineNumberOffset + 1, this._canvas.height);
+ this._ctx.rect(this._lineNumberWidth - 1, 0, this._canvas.width - this._lineNumberWidth + 1, this._canvas.height);
this._ctx.clip();
// First clear the region, then update last line to fit model (this clears removed lines from the end of the document).
- var fromOffset = this._lineNumberToOffset(firstLine);
- var toOffset = lastLine < this._textModel.linesCount ? this._lineNumberToOffset(lastLine) : this._canvas.height + this._scrollTop;
+ var fromOffset = this._lineToOffset(firstLine);
+ var toOffset = lastLine < this._textModel.linesCount ? this._lineToOffset(lastLine) : this._canvas.height + this._scrollTop;
+
// Do not clear region when paintCurrentLine is likely to do all the necessary work.
- if (firstLine + 1 != lastLine || this._selection.endLine != firstLine) {
+ if (this._readOnly || firstLine + 1 != lastLine || this._selection.endLine != firstLine) {
this._ctx.fillStyle = "rgb(255,255,255)";
this._ctx.fillRect(0, fromOffset - this._scrollTop, this._canvas.width, toOffset - fromOffset);
}
lastLine = Math.min(lastLine, this._textModel.linesCount);
- if (this._highlightingEnabled)
- this._highlighter.highlight(lastLine);
-
- if (this._selection.startLine === this._selection.endLine && firstLine <= this._selection.startLine && this._selection.startLine < lastLine)
+ // Paint current line for editable mode only.
+ if (!this._readOnly && this._selection.startLine === this._selection.endLine && firstLine <= this._selection.startLine && this._selection.startLine < lastLine)
this._paintCurrentLine(this._selection.startLine);
this._paintSelection(firstLine, lastLine);
+ if (this._highlightingEnabled)
+ this._highlighter.highlight(lastLine);
+
for (var i = firstLine; i < lastLine; ++i) {
var line = this._textModel.line(i);
- var lineOffset = this._lineNumberToOffset(i) + this._textLineHeight - this._scrollTop;
+ var lineOffset = this._lineToOffset(i) - this._scrollTop;
+
+ if (this._lineDecorator)
+ this._lineDecorator.decorate(i, this._ctx, this._lineNumberWidth - 1, lineOffset, this._canvas.width - this._lineNumberWidth + 1, this._lineHeight(i), this._textLineHeight);
if (!this._highlightingEnabled) {
this._ctx.fillStyle = "rgb(0,0,0)";
- this._ctx.fillText(line, this._lineNumberOffset - this._scrollLeft, lineOffset);
+ this._ctx.fillText(line, this._lineNumberWidth - this._scrollLeft, lineOffset + this._textLineHeight);
continue;
}
@@ -359,46 +397,49 @@ WebInspector.TextEditor.prototype = {
} else {
if (plainTextStart !== -1) {
this._ctx.fillStyle = "rgb(0,0,0)";
- this._ctx.fillText(line.substring(plainTextStart, j), this._lineNumberOffset - this._scrollLeft + this._columnToOffset(i, plainTextStart), lineOffset);
+ this._ctx.fillText(line.substring(plainTextStart, j), this._lineNumberWidth - this._scrollLeft + this._columnToOffset(i, plainTextStart), lineOffset + this._textLineHeight);
plainTextStart = -1;
}
this._ctx.fillStyle = attribute.style;
- this._ctx.fillText(line.substring(j, j + attribute.length), this._lineNumberOffset - this._scrollLeft + this._columnToOffset(i, j), lineOffset);
+ this._ctx.fillText(line.substring(j, j + attribute.length), this._lineNumberWidth - this._scrollLeft + this._columnToOffset(i, j), lineOffset + this._textLineHeight);
j += attribute.length;
}
}
if (plainTextStart !== -1) {
this._ctx.fillStyle = "rgb(0,0,0)";
- this._ctx.fillText(line.substring(plainTextStart, line.length), this._lineNumberOffset - this._scrollLeft + this._columnToOffset(i, plainTextStart), lineOffset);
+ this._ctx.fillText(line.substring(plainTextStart, line.length), this._lineNumberWidth - this._scrollLeft + this._columnToOffset(i, plainTextStart), lineOffset + this._textLineHeight);
}
}
this._ctx.restore();
},
- _paintLineNumbers: function()
+ paintLineNumbers: function()
{
this._ctx.font = this._font;
this._ctx.textBaseline = "bottom";
this._ctx.fillStyle = "rgb(255,255,255)";
- this._ctx.fillRect(0, 0, this._lineNumberOffset - 2, this._canvas.height);
+ this._ctx.fillRect(0, 0, this._lineNumberWidth - 2, this._canvas.height);
this._ctx.fillStyle = "rgb(235,235,235)";
- this._ctx.fillRect(this._lineNumberOffset - 2, 0, 1, this._canvas.height);
+ this._ctx.fillRect(this._lineNumberWidth - 2, 0, 1, this._canvas.height);
- var firstLine = Math.max(0, this._offsetToLineNumber(this._scrollTop) - 1);
- var lastLine = Math.min(this._textModel.linesCount, this._offsetToLineNumber(this._scrollTop + this._canvas.height) + 1);
+ var firstLine = Math.max(0, this._offsetToLine(this._scrollTop) - 1);
+ var lastLine = Math.min(this._textModel.linesCount, this._offsetToLine(this._scrollTop + this._canvas.height) + 1);
- this._ctx.fillStyle = "rgb(155,155,155)";
- for (var i = firstLine; i < lastLine; ++i)
- this._ctx.fillText(i + 1, (this._lineNumberDigits - this._decimalDigits(i + 1) + 1) * this._digitWidth, this._lineNumberToOffset(i) + this._textLineHeight - this._scrollTop);
+ for (var i = firstLine; i < lastLine; ++i) {
+ var lineOffset = this._lineToOffset(i) - this._scrollTop;
+ this._ctx.fillStyle = "rgb(155,155,155)";
+ if (this._lineNumberDecorator && this._lineNumberDecorator.decorate(i, this._ctx, 0, lineOffset, this._lineNumberWidth, this._lineHeight(i), this._textLineHeight))
+ continue;
+ this._ctx.fillText(i + 1, (this._lineNumberDigits - this._decimalDigits(i + 1) + 1) * this._digitWidth, lineOffset + this._textLineHeight);
+ }
},
_paintCurrentLine: function(line)
{
this._ctx.fillStyle = "rgb(232, 242, 254)";
- this._ctx.fillRect(0, this._lineNumberToOffset(line) - this._scrollTop, this._canvas.width, this._lineHeight(line));
- this._ctx.fillStyle = "rgb(0, 0, 0)";
+ this._ctx.fillRect(0, this._lineToOffset(line) - this._scrollTop, this._canvas.width, this._lineHeight(line));
},
_scroll: function(e)
@@ -425,6 +466,12 @@ WebInspector.TextEditor.prototype = {
_mouseDown: function(e)
{
var location = this._caretForMouseEvent(e);
+
+ if (e.x < this._lineNumberWidth && this._lineNumberDecorator) {
+ if (this._lineNumberDecorator.mouseDown(location.line, e))
+ return;
+ }
+
if (e.shiftKey)
this._setSelectionEnd(location.line, location.column);
else
@@ -455,9 +502,9 @@ WebInspector.TextEditor.prototype = {
_caretForMouseEvent: function(e)
{
- var lineNumber = Math.max(0, this._offsetToLineNumber(e.y + this._scrollTop) - 1);
+ var lineNumber = Math.max(0, this._offsetToLine(e.y + this._scrollTop) - 1);
var line = this._textModel.line(lineNumber);
- var offset = e.x + this._scrollLeft - this._lineNumberOffset - this._digitWidth;
+ var offset = e.x + this._scrollLeft - this._lineNumberWidth - this._digitWidth;
return { line: lineNumber, column: this._columnForOffset(lineNumber, offset) };
},
@@ -494,6 +541,9 @@ WebInspector.TextEditor.prototype = {
return;
}
+ if (this._readOnly)
+ return;
+
var keyCodes = WebInspector.KeyboardShortcut.KeyCodes;
switch (e.keyCode) {
case keyCodes.Backspace:
@@ -534,8 +584,8 @@ WebInspector.TextEditor.prototype = {
if (e.keyCode === keyCodes.Up)
arrowAction.call(this, caretLine - 1, this._desiredCaretColumn, true);
else {
- var offset = Math.max(0, this._lineNumberToOffset(caretLine) - this._canvas.height);
- arrowAction.call(this, this._offsetToLineNumber(offset), this._desiredCaretColumn, true);
+ var offset = Math.max(0, this._lineToOffset(caretLine) - this._canvas.height);
+ arrowAction.call(this, this._offsetToLine(offset), this._desiredCaretColumn, true);
}
}
break;
@@ -549,8 +599,8 @@ WebInspector.TextEditor.prototype = {
if (e.keyCode === keyCodes.Down)
arrowAction.call(this, caretLine + 1, this._desiredCaretColumn, true);
else {
- var offset = this._lineNumberToOffset(caretLine) + this._canvas.height;
- arrowAction.call(this, this._offsetToLineNumber(offset), this._desiredCaretColumn, true);
+ var offset = this._lineToOffset(caretLine) + this._canvas.height;
+ arrowAction.call(this, this._offsetToLine(offset), this._desiredCaretColumn, true);
}
}
break;
@@ -598,6 +648,9 @@ WebInspector.TextEditor.prototype = {
_textInput: function(e)
{
+ if (this._readOnly)
+ return;
+
if (e.data && !e.altKey && !e.ctrlKey && !e.metaKey) {
this._replaceSelectionWith(e.data);
e.preventDefault();
@@ -626,10 +679,10 @@ WebInspector.TextEditor.prototype = {
if (line >= this._textModel.linesCount)
return;
var offset = this._columnToOffset(line, column);
- if (offset >= this._container.scrollLeft)
- this._cursor.setLocation(this._lineNumberOffset + offset - 1, this._lineNumberToOffset(line));
+ if (offset >= this._container.scrollLeft && !this._readOnly)
+ this._cursor.setLocation(this._lineNumberWidth + offset - 1, this._lineToOffset(line));
else
- this._cursor.setLocation(0, 0);
+ this._cursor.hide();
},
_fit: function(line, column)
@@ -656,17 +709,17 @@ WebInspector.TextEditor.prototype = {
if (i === range.startLine) {
var offset = this._columnToOffset(range.startLine, range.startColumn);
- from = offset - this._scrollLeft + this._lineNumberOffset - 1;
+ from = offset - this._scrollLeft + this._lineNumberWidth - 1;
} else
from = 0;
if (i === range.endLine) {
var offset = this._columnToOffset(range.endLine, range.endColumn);
- to = offset - this._scrollLeft + this._lineNumberOffset - 1;
+ to = offset - this._scrollLeft + this._lineNumberWidth - 1;
} else
to = this._canvas.width;
- this._ctx.fillRect(from, this._lineNumberToOffset(i) - this._scrollTop, to - from, this._textLineHeight);
+ this._ctx.fillRect(from, this._lineToOffset(i) - this._scrollTop, to - from, this._textLineHeight);
}
this._ctx.fillStyle = "rgb(0, 0, 0)";
},
@@ -707,6 +760,11 @@ WebInspector.TextEditor.prototype = {
_paste: function(e)
{
+ if (this._readOnly) {
+ e.preventDefault();
+ return;
+ }
+
var text = e.clipboardData.getData("Text");
if (!text)
return;
@@ -765,6 +823,7 @@ WebInspector.TextEditor.prototype = {
this._textLineHeight = Math.floor(this._fontSize * 1.4);
this._cursor.setTextLineHeight(this._textLineHeight);
+ this._lineOffsetsCache = [0];
},
_registerShortcuts: function()
@@ -954,6 +1013,15 @@ WebInspector.TextCursor.prototype = {
this._paint(true);
},
+ hide: function()
+ {
+ if (this._paintInterval) {
+ window.clearInterval(this._paintInterval);
+ delete this._paintInterval;
+ }
+ this._cursorElement.style.display = "none";
+ },
+
setTextLineHeight: function(textLineHeight)
{
this._cursorElement.style.height = textLineHeight + "px";
diff --git a/WebCore/inspector/front-end/TextEditorHighlighter.js b/WebCore/inspector/front-end/TextEditorHighlighter.js
index 2bfde24..064ed0c 100644
--- a/WebCore/inspector/front-end/TextEditorHighlighter.js
+++ b/WebCore/inspector/front-end/TextEditorHighlighter.js
@@ -72,7 +72,7 @@ WebInspector.TextEditorHighlighter.prototype = {
// Do small highlight synchronously. This will provide instant highlight on PageUp / PageDown, gentle scrolling.
var toLine = Math.min(startLine + 200, endLine);
- this._highlightLines(startLine, toLine);
+ this._highlightInChunks(startLine, toLine);
// Schedule tail highlight if necessary.
if (endLine > toLine)
@@ -90,7 +90,7 @@ WebInspector.TextEditorHighlighter.prototype = {
if (this._requestedEndLine !== endLine) {
// User keeps updating the job in between of our timer ticks. Just reschedule self, don't eat CPU (they must be scrolling).
- this._highlightTimer = setTimeout(this._highlightInChunks.bind(this, startLine, this._requestedEndLine), 200);
+ this._highlightTimer = setTimeout(this._highlightInChunks.bind(this, startLine, this._requestedEndLine), 100);
return;
}
@@ -133,11 +133,7 @@ WebInspector.TextEditorHighlighter.prototype = {
else
this._tokenizer.condition = this._tokenizer.initialCondition;
- var damagedFrom = startLine;
- var damagedTo = startLine;
for (var i = startLine; i < endLine; ++i) {
- damagedTo = i;
-
state = {};
state.preCondition = this._tokenizer.condition;
state.attributes = {};
@@ -150,11 +146,11 @@ WebInspector.TextEditorHighlighter.prototype = {
var nextLineState = this._textModel.getAttribute(i + 1, "highlighter-state");
if (nextLineState && nextLineState.preCondition === state.postCondition) {
// Following lines are up to date, no need re-highlight.
- this._damageCallback(damagedFrom, damagedTo);
+ this._damageCallback(startLine, i + 1);
return true;
}
}
- this._damageCallback(damagedFrom, damagedTo);
+ this._damageCallback(startLine, endLine);
return false;
},
diff --git a/WebCore/inspector/front-end/TextEditorModel.js b/WebCore/inspector/front-end/TextEditorModel.js
index 675b0cf..c5f52b7 100644
--- a/WebCore/inspector/front-end/TextEditorModel.js
+++ b/WebCore/inspector/front-end/TextEditorModel.js
@@ -147,7 +147,7 @@ WebInspector.TextEditorModel.prototype = {
_insertLine: function(lineNumber, text)
{
this._lines.splice(lineNumber, 0, text);
- this._attributes.splice(lineNumber, 0, []);
+ this._attributes.splice(lineNumber, 0, {});
},
wordRange: function(lineNumber, column)
@@ -189,7 +189,7 @@ WebInspector.TextEditorModel.prototype = {
{
var attrs = this._attributes[line];
if (!attrs) {
- attrs = [];
+ attrs = {};
this._attributes[line] = attrs;
}
attrs[name] = value;
diff --git a/WebCore/inspector/front-end/WebKit.qrc b/WebCore/inspector/front-end/WebKit.qrc
index 7686f62..5e15cd6 100644
--- a/WebCore/inspector/front-end/WebKit.qrc
+++ b/WebCore/inspector/front-end/WebKit.qrc
@@ -64,6 +64,7 @@
<file>SidebarPane.js</file>
<file>SidebarTreeElement.js</file>
<file>SourceFrame.js</file>
+ <file>SourceFrame2.js</file>
<file>SourceSyntaxHighlighter.js</file>
<file>SourceView.js</file>
<file>StatusBarButton.js</file>
diff --git a/WebCore/inspector/front-end/inspector.html b/WebCore/inspector/front-end/inspector.html
index 6e074ba..9662c02 100644
--- a/WebCore/inspector/front-end/inspector.html
+++ b/WebCore/inspector/front-end/inspector.html
@@ -91,6 +91,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<script type="text/javascript" src="AuditLauncherView.js"></script>
<script type="text/javascript" src="ResourceView.js"></script>
<script type="text/javascript" src="SourceFrame.js"></script>
+ <script type="text/javascript" src="SourceFrame2.js"></script>
<script type="text/javascript" src="SourceSyntaxHighlighter.js"></script>
<script type="text/javascript" src="CSSSourceSyntaxHighlighter.js"></script>
<script type="text/javascript" src="JavaScriptSourceSyntaxHighlighter.js"></script>
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list