Changeset 53795 in webkit
- Timestamp:
- Jan 25, 2010 2:58:01 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r53794 r53795 1 2010-01-24 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Timothy Hatcher. 4 5 Web Inspector: Add support for addMessage/clearMessages to SourceFrame2. 6 7 https://bugs.webkit.org/show_bug.cgi?id=33904 8 9 * WebCore.gypi: 10 * WebCore.vcproj/WebCore.vcproj: 11 * inspector/front-end/SourceFrame2.js: 12 (WebInspector.SourceFrame2): 13 (WebInspector.SourceFrame2.prototype.addMessage): 14 (WebInspector.SourceFrame2.prototype.clearMessages): 15 (WebInspector.SourceFrame2.prototype._incrementMessageRepeatCount): 16 (WebInspector.SourceFrame2.prototype._addExistingMessagesToSource): 17 (WebInspector.SourceFrame2.prototype._addMessageToSource): 18 (WebInspector.SourceFrame2.prototype.resize): 19 * inspector/front-end/TextEditor.js: 20 (WebInspector.TextEditor): 21 (WebInspector.TextEditor.prototype.setDivDecoration): 22 (WebInspector.TextEditor.prototype._lineHeight): 23 (WebInspector.TextEditor.prototype._highlightChanged): 24 (WebInspector.TextEditor.prototype.packAndRepaintAll): 25 (WebInspector.TextEditor.prototype._updateSize): 26 (WebInspector.TextEditor.prototype._repaintAll): 27 (WebInspector.TextEditor.prototype._paint): 28 (WebInspector.TextEditor.prototype._paintLinesContinuation): 29 (WebInspector.TextEditor.prototype._mouseOut): 30 (WebInspector.TextEditor.prototype._updateDivDecorations): 31 (WebInspector.TextEditor.prototype._positionDivDecoration): 32 (WebInspector.TextEditor.prototype._paintSelection): 33 (WebInspector.TextEditor.prototype._replaceSelectionWith): 34 * inspector/front-end/TextEditorHighlighter.js: 35 (WebInspector.TextEditorHighlighter.prototype.updateHighlight): 36 * inspector/front-end/WebKit.qrc: 37 * inspector/front-end/inspector.css: 38 * inspector/front-end/inspector.html: 39 * inspector/front-end/textEditor.css: Added. 40 1 41 2010-01-24 Pavel Feldman <pfeldman@chromium.org> 2 42 … … 74356 74396 (WebCore::RenderThemeQt::adjustButtonStyle): 74357 74397 74358 === End merge of nitro-extreme branch 2009-07-30 ===74359 74360 74398 2009-05-11 Geoffrey Garen <ggaren@apple.com> 74361 74399 … … 74369 74407 * bindings/scripts/CodeGeneratorJS.pm: 74370 74408 * bridge/c/c_instance.cpp: 74371 74372 === Start merge of nitro-extreme branch 2009-07-30 ===74373 74409 74374 74410 2009-07-30 Dean McNamee <deanm@chromium.org> -
trunk/WebCore/WebCore.gypi
r53690 r53795 3761 3761 'inspector/front-end/inspector.css', 3762 3762 'inspector/front-end/inspectorSyntaxHighlight.css', 3763 'inspector/front-end/textEditor.css', 3763 3764 ], 3764 3765 'webinspector_image_files': [ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r53690 r53795 43077 43077 </File> 43078 43078 <File 43079 RelativePath="..\inspector\front-end\textEditor.css" 43080 > 43081 </File> 43082 <File 43079 43083 RelativePath="..\inspector\front-end\TextPrompt.js" 43080 43084 > -
trunk/WebCore/inspector/front-end/SourceFrame2.js
r53205 r53795 36 36 this._editor.lineDecorator = new WebInspector.ExecutionLineDecorator(this); 37 37 this._editor.readOnly = true; 38 this._messages = []; 39 this._rowMessages = {}; 40 this._messageBubbles = {}; 38 41 this.element = this._editor.element; 39 42 } … … 43 46 { 44 47 this._editor.text = text; 48 }, 49 50 addMessage: function(msg) 51 { 52 // Don't add the message if there is no message or valid line or if the msg isn't an error or warning. 53 if (!msg.message || msg.line <= 0 || !msg.isErrorOrWarning()) 54 return; 55 this._messages.push(msg); 56 this._addMessageToSource(msg); 57 }, 58 59 clearMessages: function() 60 { 61 for (var line in this._messageBubbles) { 62 var bubble = this._messageBubbles[line]; 63 bubble.parentNode.removeChild(bubble); 64 } 65 66 this._messages = []; 67 this._rowMessages = {}; 68 this._messageBubbles = {}; 69 this._editor.packAndRepaintAll(); 70 }, 71 72 _incrementMessageRepeatCount: function(msg, repeatDelta) 73 { 74 if (!msg._resourceMessageLineElement) 75 return; 76 77 if (!msg._resourceMessageRepeatCountElement) { 78 var repeatedElement = document.createElement("span"); 79 msg._resourceMessageLineElement.appendChild(repeatedElement); 80 msg._resourceMessageRepeatCountElement = repeatedElement; 81 } 82 83 msg.repeatCount += repeatDelta; 84 msg._resourceMessageRepeatCountElement.textContent = WebInspector.UIString(" (repeated %d times)", msg.repeatCount); 85 }, 86 87 _addExistingMessagesToSource: function() 88 { 89 var length = this._messages.length; 90 for (var i = 0; i < length; ++i) 91 this._addMessageToSource(this._messages[i]); 92 }, 93 94 _addMessageToSource: function(msg) 95 { 96 if (msg.line >= this._textModel.linesCount) 97 return; 98 99 var messageBubbleElement = this._messageBubbles[msg.line]; 100 if (!messageBubbleElement || messageBubbleElement.nodeType !== Node.ELEMENT_NODE || !messageBubbleElement.hasStyleClass("webkit-html-message-bubble")) { 101 messageBubbleElement = document.createElement("div"); 102 messageBubbleElement.className = "webkit-html-message-bubble"; 103 this._messageBubbles[msg.line] = messageBubbleElement; 104 this._editor.setDivDecoration(msg.line, messageBubbleElement); 105 } 106 107 var rowMessages = this._rowMessages[msg.line]; 108 if (!rowMessages) { 109 rowMessages = []; 110 this._rowMessages[msg.line] = rowMessages; 111 } 112 113 for (var i = 0; i < rowMessages.length; ++i) { 114 if (rowMessages[i].isEqual(msg, true)) { 115 this._incrementMessageRepeatCount(rowMessages[i], msg.repeatDelta); 116 this._editor.packAndRepaintAll(); 117 return; 118 } 119 } 120 121 rowMessages.push(msg); 122 123 var imageURL; 124 switch (msg.level) { 125 case WebInspector.ConsoleMessage.MessageLevel.Error: 126 messageBubbleElement.addStyleClass("webkit-html-error-message"); 127 imageURL = "Images/errorIcon.png"; 128 break; 129 case WebInspector.ConsoleMessage.MessageLevel.Warning: 130 messageBubbleElement.addStyleClass("webkit-html-warning-message"); 131 imageURL = "Images/warningIcon.png"; 132 break; 133 } 134 135 var messageLineElement = document.createElement("div"); 136 messageLineElement.className = "webkit-html-message-line"; 137 messageBubbleElement.appendChild(messageLineElement); 138 139 // Create the image element in the Inspector's document so we can use relative image URLs. 140 var image = document.createElement("img"); 141 image.src = imageURL; 142 image.className = "webkit-html-message-icon"; 143 messageLineElement.appendChild(image); 144 messageLineElement.appendChild(document.createTextNode(msg.message)); 145 146 msg._resourceMessageLineElement = messageLineElement; 147 148 this._editor.packAndRepaintAll(); 45 149 }, 46 150 … … 71 175 resize: function() 72 176 { 73 this._editor. updateCanvasSize();177 this._editor.packAndRepaintAll(); 74 178 } 75 179 } -
trunk/WebCore/inspector/front-end/TextEditor.js
r53242 r53795 59 59 this._cursor = new WebInspector.TextCursor(cursorElement); 60 60 61 this._container.addEventListener("scroll", this._scroll.bind(this) );62 this._sheet.addEventListener("mouseup", this._mouseUp.bind(this) );63 this._sheet.addEventListener("mousedown", this._mouseDown.bind(this) );64 this._sheet.addEventListener("mousemove", this._mouseMove.bind(this) );65 this._sheet.addEventListener("mouseout", this._mouseOut.bind(this) );66 this._sheet.addEventListener("dblclick", this._dblClick.bind(this) );67 this.element.addEventListener("keydown", this._keyDown.bind(this) );68 this.element.addEventListener("textInput", this._textInput.bind(this) );69 this.element.addEventListener("beforecopy", this._beforeCopy.bind(this) );70 this.element.addEventListener("copy", this._copy.bind(this) );71 this.element.addEventListener("beforecut", this._beforeCut.bind(this) );72 this.element.addEventListener("cut", this._cut.bind(this) );73 this.element.addEventListener("beforepaste", this._beforePaste.bind(this) );74 this.element.addEventListener("paste", this._paste.bind(this) );61 this._container.addEventListener("scroll", this._scroll.bind(this), false); 62 this._sheet.addEventListener("mouseup", this._mouseUp.bind(this), false); 63 this._sheet.addEventListener("mousedown", this._mouseDown.bind(this), false); 64 this._sheet.addEventListener("mousemove", this._mouseMove.bind(this), false); 65 this._sheet.addEventListener("mouseout", this._mouseOut.bind(this), false); 66 this._sheet.addEventListener("dblclick", this._dblClick.bind(this), false); 67 this.element.addEventListener("keydown", this._keyDown.bind(this), false); 68 this.element.addEventListener("textInput", this._textInput.bind(this), false); 69 this.element.addEventListener("beforecopy", this._beforeCopy.bind(this), false); 70 this.element.addEventListener("copy", this._copy.bind(this), false); 71 this.element.addEventListener("beforecut", this._beforeCut.bind(this), false); 72 this.element.addEventListener("cut", this._cut.bind(this), false); 73 this.element.addEventListener("beforepaste", this._beforePaste.bind(this), false); 74 this.element.addEventListener("paste", this._paste.bind(this), false); 75 75 76 76 this._desiredCaretColumn = 0; … … 136 136 this._selection.setStart(start.line, start.column); 137 137 this._setSelectionEnd(endLine, endColumn); 138 }, 139 140 setDivDecoration: function(lineNumber, element) 141 { 142 var divDecoration = this._textModel.getAttribute(lineNumber, "div-decoration"); 143 if (divDecoration && divDecoration.element && divDecoration.element.parentNode) 144 divDecoration.element.parentNode.removeChild(divDecoration.element); 145 146 divDecoration = { element: element }; 147 this.element.appendChild(element); 148 149 this._textModel.setAttribute(lineNumber, "div-decoration", divDecoration); 150 this.packAndRepaintAll(); 138 151 }, 139 152 … … 180 193 _lineHeight: function(lineNumber) 181 194 { 182 return this._debugMode ? this._textLineHeight * (1 + lineNumber % 3) : this._textLineHeight; 195 var divDecoration = this._textModel.getAttribute(lineNumber, "div-decoration"); 196 if (divDecoration) 197 return 2 * this._textLineHeight + divDecoration.element.clientHeight; 198 return this._textLineHeight; 183 199 }, 184 200 … … 240 256 _highlightChanged: function(fromLine, toLine) 241 257 { 258 if (this._muteHighlightListener) 259 return; 260 242 261 this._invalidateLines(fromLine, toLine); 243 262 this._paint(); 244 263 }, 245 264 265 packAndRepaintAll: function() 266 { 267 this._setCoalescingUpdate(true); 268 this._lineOffsetsCache = [0]; 269 this._updateSize(0, this._textModel.linesCount); 270 this._repaintAll(); 271 this._setCoalescingUpdate(false); 272 }, 273 246 274 _updateSize: function(startLine, endLine) 247 275 { 276 this._setCoalescingUpdate(true); 248 277 var guardedEndLine = Math.min(this._textModel.linesCount, endLine + 1); 249 278 var newMaximum = false; … … 281 310 this._repaintAll(); 282 311 } 283 312 284 313 // Changes to size can change the client area (scrollers can appear/disappear) 285 314 this.updateCanvasSize(); 315 this._setCoalescingUpdate(false); 286 316 }, 287 317 … … 298 328 { 299 329 this._invalidateLines(0, this._textModel.linesCount); 300 this.paintLineNumbers();301 330 this._paint(); 302 this._updateCursor(this._selection.endLine, this._selection.endColumn);303 331 }, 304 332 … … 325 353 return; 326 354 355 this.paintLineNumbers(); 356 327 357 for (var i = 0; this._damage && i < this._damage.length; ++i) 328 358 this._paintLines(this._damage[i].startLine, this._damage[i].endLine); 329 359 delete this._damage; 360 361 this._updateDivDecorations(); 362 this._updateCursor(this._selection.endLine, this._selection.endColumn); 330 363 }, 331 364 … … 375 408 this._paintSelection(firstLine, lastLine); 376 409 377 if (this._highlightingEnabled) 410 if (this._highlightingEnabled) { 411 this._muteHighlightListener = true; 378 412 this._highlighter.highlight(lastLine); 379 413 delete this._muteHighlightListener; 414 } 380 415 for (var i = firstLine; i < lastLine; ++i) { 381 416 var line = this._textModel.line(i); … … 384 419 if (this._lineDecorator) 385 420 this._lineDecorator.decorate(i, this._ctx, this._lineNumberWidth - 1, lineOffset, this._canvas.width - this._lineNumberWidth + 1, this._lineHeight(i), this._textLineHeight); 421 422 var divDecoration = this._textModel.getAttribute(i, "div-decoration"); 423 if (divDecoration) 424 this._positionDivDecoration(i, divDecoration, true); 386 425 387 426 if (!this._highlightingEnabled) { … … 495 534 _mouseOut: function(e) 496 535 { 497 this._isDragging = false;498 536 }, 499 537 … … 679 717 }, 680 718 719 _updateDivDecorations: function() 720 { 721 var firstLine = this._offsetToLine(this._scrollTop) - 1; 722 var lastLine = this._offsetToLine(this._scrollTop + this._canvas.height) + 1; 723 724 var linesCount = this._textModel.linesCount; 725 for (var i = 0; i < linesCount; ++i) { 726 var divDecoration = this._textModel.getAttribute(i, "div-decoration"); 727 if (divDecoration) 728 this._positionDivDecoration(i, divDecoration, i > firstLine && i < lastLine); 729 } 730 }, 731 732 _positionDivDecoration: function(lineNumber, divDecoration, visible) 733 { 734 divDecoration.element.style.position = "absolute"; 735 divDecoration.element.style.top = this._lineToOffset(lineNumber) - this._scrollTop + this._textLineHeight + "px"; 736 divDecoration.element.style.left = this._lineNumberWidth + "px"; 737 divDecoration.element.style.setProperty("max-width", (this._canvas.width - 200) + "px"); 738 }, 739 681 740 _updateCursor: function(line, column) 682 741 { … … 724 783 to = this._canvas.width; 725 784 726 this._ctx.fillRect(from, this._lineToOffset(i) - this._scrollTop, to - from, this._ textLineHeight);785 this._ctx.fillRect(from, this._lineToOffset(i) - this._scrollTop, to - from, this._lineHeight(i)); 727 786 } 728 787 this._ctx.fillStyle = "rgb(0, 0, 0)"; … … 781 840 { 782 841 var range = overrideRange || this._selection.range(); 783 784 842 this._setCoalescingUpdate(true); 785 843 var newRange = this._textModel.setText(range, newText); -
trunk/WebCore/inspector/front-end/TextEditorHighlighter.js
r53205 r53795 107 107 { 108 108 // Start line was edited, we should highlight everything until endLine synchronously. 109 var state = this._textModel.getAttribute(startLine, "highlighter-state"); 110 if (!state || state.outOfDate) { 111 // Highlighter did not reach this point yet, nothing to update. It will reach it on subsequent timer tick and do the job. 112 return; 109 if (startLine) { 110 var state = this._textModel.getAttribute(startLine - 1, "highlighter-state"); 111 if (!state || state.outOfDate) { 112 // Highlighter did not reach this point yet, nothing to update. It will reach it on subsequent timer tick and do the job. 113 return; 114 } 113 115 } 114 116 -
trunk/WebCore/inspector/front-end/WebKit.qrc
r53328 r53795 90 90 <file>inspector.css</file> 91 91 <file>inspectorSyntaxHighlight.css</file> 92 <file>textEditor.css</file> 92 93 <file>Images/back.png</file> 93 94 <file>Images/checker.png</file> -
trunk/WebCore/inspector/front-end/inspector.css
r53794 r53795 3818 3818 } 3819 3819 3820 .text-editor- sheet, .text-editor-clip {3820 .text-editor-clip { 3821 3821 opacity: 0; 3822 position: absolute; 3823 top:0; 3824 left:0; 3825 pointer-events: none; 3822 3826 } 3823 3827 -
trunk/WebCore/inspector/front-end/inspector.html
r53328 r53795 31 31 <meta http-equiv="content-type" content="text/html; charset=utf-8"> 32 32 <link rel="stylesheet" type="text/css" href="audits.css"> 33 <link rel="stylesheet" type="text/css" href="textEditor.css"> 33 34 <link rel="stylesheet" type="text/css" href="inspector.css"> 34 35 <link rel="stylesheet" type="text/css" href="inspectorSyntaxHighlight.css">
Note: See TracChangeset
for help on using the changeset viewer.