Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / DOMSyntaxHighlighter.js
index ed5af04..8441dbd 100644 (file)
  */
 WebInspector.DOMSyntaxHighlighter = function(mimeType, stripExtraWhitespace)
 {
-    loadScript("CodeMirrorTextEditor.js");
     this._mimeType = mimeType;
     this._stripExtraWhitespace = stripExtraWhitespace;
 }
 
 WebInspector.DOMSyntaxHighlighter.prototype = {
+    /**
+     * @param {string} content
+     * @param {string} className
+     * @return {!Element}
+     */
     createSpan: function(content, className)
     {
         var span = document.createElement("span");
@@ -54,21 +58,30 @@ WebInspector.DOMSyntaxHighlighter.prototype = {
         var lines = node.textContent.split("\n");
         node.removeChildren();
 
-        var tokenize = WebInspector.CodeMirrorUtils.createTokenizer(this._mimeType);
+        /**
+         * @param {string} token
+         * @param {?string} tokenType
+         * @param {number} column
+         * @param {number} newColumn
+         * @this {WebInspector.DOMSyntaxHighlighter}
+         */
+        function processToken(token, tokenType, column, newColumn)
+        {
+            if (!tokenType)
+                return;
+
+            if (column > plainTextStart) {
+                var plainText = line.substring(plainTextStart, column);
+                node.appendChild(document.createTextNode(plainText));
+            }
+            node.appendChild(this.createSpan(token, tokenType));
+            plainTextStart = newColumn;
+        }
+
+        var tokenize = WebInspector.moduleManager.instance(WebInspector.TokenizerFactory).createTokenizer(this._mimeType);
         for (var i = lines[0].length ? 0 : 1; i < lines.length; ++i) {
             var line = lines[i];
             var plainTextStart = 0;
-            function processToken(token, tokenType, column, newColumn)
-            {
-                if (tokenType) {
-                    if (column > plainTextStart) {
-                        var plainText = line.substring(plainTextStart, column);
-                        node.appendChild(document.createTextNode(plainText));
-                    }
-                    node.appendChild(this.createSpan(token, tokenType));
-                    plainTextStart = newColumn;
-                }
-            }
             tokenize(line, processToken.bind(this));
             if (plainTextStart < line.length) {
                 var plainText = line.substring(plainTextStart, line.length);