Changeset 145530 in webkit
- Timestamp:
- Mar 12, 2013 5:15:21 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r145524 r145530 1 2013-03-12 Andrey Lushnikov <lushnikov@chromium.org> 2 3 Web Inspector: [CodeMirror] there are bugs in TokenHighlight feature 4 https://bugs.webkit.org/show_bug.cgi?id=112039 5 6 Reviewed by Vsevolod Vlasov. 7 8 Fix token highlight in codeMirror experiment 9 - rewrite token highlight overlay mode to highlight words, not 10 substrings 11 - add workaround to avoid selection of already selected word 12 13 No new tests. 14 15 * inspector/front-end/CodeMirrorTextEditor.js: 16 (WebInspector.CodeMirrorTextEditor.TokenHighlighter.prototype._cursorChange): 17 (WebInspector.CodeMirrorTextEditor.TokenHighlighter.prototype._removeHighlight): 18 (WebInspector.CodeMirrorTextEditor.TokenHighlighter.prototype.nextToken): 19 (WebInspector.CodeMirrorTextEditor.TokenHighlighter.prototype._addHighlight): 20 * inspector/front-end/cm/cmdevtools.css: 21 (.line-with-selection .cm-column-with-selection): 22 1 23 2013-03-12 Sheriff Bot <webkit.review.bot@gmail.com> 2 24 -
trunk/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js
r145520 r145530 442 442 var selectedText = this._codeMirror.getSelection(); 443 443 if (this._isWord(selectedText, selectionStart.line, selectionStart.ch, selectionEnd.ch)) 444 this._codeMirror.operation(this._addHighlight.bind(this, selectedText ));444 this._codeMirror.operation(this._addHighlight.bind(this, selectedText, selectionStart)); 445 445 }, 446 446 … … 455 455 _removeHighlight: function() 456 456 { 457 if (this._overlayMode) { 458 this._codeMirror.removeOverlay(this._overlayMode); 459 delete this._overlayMode; 457 if (this._highlightDescriptor) { 458 this._codeMirror.removeOverlay(this._highlightDescriptor.overlay); 459 this._codeMirror.removeLineClass(this._highlightDescriptor.selectionStart.line, "wrap", "cm-line-with-selection"); 460 delete this._highlightDescriptor; 460 461 } 461 462 }, 462 463 463 _addHighlight: function(token )464 _addHighlight: function(token, selectionStart) 464 465 { 465 466 const tokenFirstChar = token.charAt(0); 466 467 function nextToken(stream) 467 468 { 468 if (stream.match(token)) 469 return "token-highlight"; 470 stream.next(); 471 if (!stream.skipTo(tokenFirstChar)) 472 stream.skipToEnd(); 469 if (stream.match(token) && (stream.eol() || !WebInspector.TextUtils.isWordChar(stream.peek()))) 470 return stream.column() === selectionStart.ch ? "token-highlight column-with-selection" : "token-highlight"; 471 472 var eatenChar; 473 do { 474 eatenChar = stream.next(); 475 } while (eatenChar && (WebInspector.TextUtils.isWordChar(eatenChar) || stream.peek() !== tokenFirstChar)); 473 476 } 474 477 475 this._overlayMode = {478 var overlayMode = { 476 479 token: nextToken 477 480 }; 478 this._codeMirror.addOverlay(this._overlayMode); 481 this._codeMirror.addOverlay(overlayMode); 482 this._codeMirror.addLineClass(selectionStart.line, "wrap", "cm-line-with-selection") 483 this._highlightDescriptor = { 484 overlay: overlayMode, 485 selectionStart: selectionStart 486 }; 479 487 } 480 488 } -
trunk/Source/WebCore/inspector/front-end/cm/cmdevtools.css
r145520 r145530 57 57 } 58 58 59 .cm-line-with-selection .cm-column-with-selection { 60 border: 0px; 61 margin: 0px; 62 } 63 59 64 .cm-s-web-inspector-js span.cm-keyword {color: rgb(170, 13, 145);} 60 65 .cm-s-web-inspector-js span.cm-number {color: rgb(28, 0, 207);}
Note: See TracChangeset
for help on using the changeset viewer.