Title: [111743] trunk/Source/WebCore
- Revision
- 111743
- Author
- [email protected]
- Date
- 2012-03-22 12:11:07 -0700 (Thu, 22 Mar 2012)
Log Message
Web Inspector: text gutter decorations should move upon edits.
https://bugs.webkit.org/show_bug.cgi?id=81932
Reviewed by Vsevolod Vlasov.
Decorations set by the line number now shift as editing inserts / removes lines.
* inspector/front-end/TextViewer.js:
(WebInspector.TextViewer.prototype._syncLineHeight):
(WebInspector.TextEditorGutterPanel):
(WebInspector.TextEditorGutterPanel.prototype.textChanged):
(WebInspector.TextEditorGutterPanel.prototype.syncClientHeight):
(WebInspector.TextEditorGutterPanel.prototype.addDecoration):
(WebInspector.TextEditorGutterPanel.prototype.removeDecoration):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (111742 => 111743)
--- trunk/Source/WebCore/ChangeLog 2012-03-22 19:07:32 UTC (rev 111742)
+++ trunk/Source/WebCore/ChangeLog 2012-03-22 19:11:07 UTC (rev 111743)
@@ -1,3 +1,20 @@
+2012-03-22 Pavel Feldman <[email protected]>
+
+ Web Inspector: text gutter decorations should move upon edits.
+ https://bugs.webkit.org/show_bug.cgi?id=81932
+
+ Reviewed by Vsevolod Vlasov.
+
+ Decorations set by the line number now shift as editing inserts / removes lines.
+
+ * inspector/front-end/TextViewer.js:
+ (WebInspector.TextViewer.prototype._syncLineHeight):
+ (WebInspector.TextEditorGutterPanel):
+ (WebInspector.TextEditorGutterPanel.prototype.textChanged):
+ (WebInspector.TextEditorGutterPanel.prototype.syncClientHeight):
+ (WebInspector.TextEditorGutterPanel.prototype.addDecoration):
+ (WebInspector.TextEditorGutterPanel.prototype.removeDecoration):
+
2012-03-21 Robert Hogan <[email protected]>
CSS 2.1 failure: fixed-table-layout-006 fails
Modified: trunk/Source/WebCore/inspector/front-end/TextViewer.js (111742 => 111743)
--- trunk/Source/WebCore/inspector/front-end/TextViewer.js 2012-03-22 19:07:32 UTC (rev 111742)
+++ trunk/Source/WebCore/inspector/front-end/TextViewer.js 2012-03-22 19:11:07 UTC (rev 111743)
@@ -236,7 +236,8 @@
}
},
- _syncLineHeight: function(gutterRow) {
+ _syncLineHeight: function(gutterRow)
+ {
if (this._lineHeightSynced)
return;
if (gutterRow && gutterRow.offsetHeight) {
@@ -639,6 +640,7 @@
this.freeCachedElements();
this._buildChunks();
+ this._decorations = {};
}
WebInspector.TextEditorGutterPanel.prototype = {
@@ -674,11 +676,34 @@
var lastChunk = this._textChunks[this._textChunks.length - 1];
totalLines = lastChunk.startLine + lastChunk.linesCount;
}
+
for (var i = totalLines; i < this._textModel.linesCount; i += this._defaultChunkSize) {
var chunk = this._createNewChunk(i, i + this._defaultChunkSize);
this._textChunks.push(chunk);
this._container.appendChild(chunk.element);
}
+
+ // Shift decorations if necessary
+ for (var lineNumber in this._decorations) {
+ lineNumber = parseInt(lineNumber, 10);
+
+ // Do not move decorations before the start position.
+ if (lineNumber < oldRange.startLine)
+ continue;
+
+ var lineDecorationsCopy = this._decorations[lineNumber].slice();
+ for (var i = 0; i < lineDecorationsCopy.length; ++i) {
+ var decoration = lineDecorationsCopy[i];
+ this.removeDecoration(lineNumber, decoration);
+
+ // Do not restore the decorations before the end position.
+ if (lineNumber < oldRange.endLine)
+ continue;
+
+ this.addDecoration(lineNumber + linesDiff, decoration);
+ }
+ }
+
this._repaintAll();
} else {
// Decorations may have been removed, so we may have to sync those lines.
@@ -700,6 +725,28 @@
this._container.style.setProperty("padding-bottom", (this.element.offsetHeight - clientHeight) + "px");
else
this._container.style.removeProperty("padding-bottom");
+ },
+
+ addDecoration: function(lineNumber, decoration)
+ {
+ WebInspector.TextEditorChunkedPanel.prototype.addDecoration.call(this, lineNumber, decoration);
+ var decorations = this._decorations[lineNumber];
+ if (!decorations) {
+ decorations = [];
+ this._decorations[lineNumber] = decorations;
+ }
+ decorations.push(decoration);
+ },
+
+ removeDecoration: function(lineNumber, decoration)
+ {
+ WebInspector.TextEditorChunkedPanel.prototype.removeDecoration.call(this, lineNumber, decoration);
+ var decorations = this._decorations[lineNumber];
+ if (decorations) {
+ decorations.remove(decoration);
+ if (!decorations.length)
+ delete this._decorations[lineNumber];
+ }
}
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes