Index: Source/devtools/front_end/DOMSyntaxHighlighter.js |
diff --git a/Source/devtools/front_end/DOMSyntaxHighlighter.js b/Source/devtools/front_end/DOMSyntaxHighlighter.js |
index 4ae97ebadcb8801c0f427929a1ad674301d0d2d2..ed5af04ef5bba91e85f54fc7cbd4a7ed1d73f00a 100644 |
--- a/Source/devtools/front_end/DOMSyntaxHighlighter.js |
+++ b/Source/devtools/front_end/DOMSyntaxHighlighter.js |
@@ -33,7 +33,8 @@ |
*/ |
WebInspector.DOMSyntaxHighlighter = function(mimeType, stripExtraWhitespace) |
{ |
- this._tokenizer = WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer(mimeType); |
+ loadScript("CodeMirrorTextEditor.js"); |
+ this._mimeType = mimeType; |
this._stripExtraWhitespace = stripExtraWhitespace; |
} |
@@ -41,7 +42,7 @@ WebInspector.DOMSyntaxHighlighter.prototype = { |
createSpan: function(content, className) |
{ |
var span = document.createElement("span"); |
- span.className = "webkit-" + className; |
+ span.className = "cm-" + className; |
if (this._stripExtraWhitespace && className !== "whitespace") |
content = content.replace(/^[\n\r]*/, "").replace(/\s*$/, ""); |
span.appendChild(document.createTextNode(content)); |
@@ -50,36 +51,31 @@ WebInspector.DOMSyntaxHighlighter.prototype = { |
syntaxHighlightNode: function(node) |
{ |
- this._tokenizer.condition = this._tokenizer.createInitialCondition(); |
var lines = node.textContent.split("\n"); |
node.removeChildren(); |
+ var tokenize = WebInspector.CodeMirrorUtils.createTokenizer(this._mimeType); |
for (var i = lines[0].length ? 0 : 1; i < lines.length; ++i) { |
var line = lines[i]; |
var plainTextStart = 0; |
- this._tokenizer.line = line; |
- var column = 0; |
- do { |
- var newColumn = this._tokenizer.nextToken(column); |
- var tokenType = this._tokenizer.tokenType; |
+ function processToken(token, tokenType, column, newColumn) |
+ { |
if (tokenType) { |
if (column > plainTextStart) { |
var plainText = line.substring(plainTextStart, column); |
node.appendChild(document.createTextNode(plainText)); |
} |
- var token = line.substring(column, newColumn); |
node.appendChild(this.createSpan(token, tokenType)); |
plainTextStart = newColumn; |
} |
- column = newColumn; |
- } while (column < line.length) |
- |
- if (plainTextStart < line.length) { |
- var plainText = line.substring(plainTextStart, line.length); |
- node.appendChild(document.createTextNode(plainText)); |
- } |
- if (i < lines.length - 1) |
- node.appendChild(document.createElement("br")); |
+ } |
+ tokenize(line, processToken.bind(this)); |
+ if (plainTextStart < line.length) { |
+ var plainText = line.substring(plainTextStart, line.length); |
+ node.appendChild(document.createTextNode(plainText)); |
+ } |
+ if (i < lines.length - 1) |
+ node.appendChild(document.createElement("br")); |
} |
} |
} |