| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * @param {!Element} node | 59 * @param {!Element} node |
| 60 * @return {!Promise.<undefined>} | 60 * @return {!Promise.<undefined>} |
| 61 */ | 61 */ |
| 62 syntaxHighlightNode(node) { | 62 syntaxHighlightNode(node) { |
| 63 var lines = node.textContent.split('\n'); | 63 var lines = node.textContent.split('\n'); |
| 64 var plainTextStart; | 64 var plainTextStart; |
| 65 var line; | 65 var line; |
| 66 | 66 |
| 67 return self.runtime.extension(Common.TokenizerFactory).instance().then(proce
ssTokens.bind(this)); | 67 return self.runtime.extension(TextUtils.TokenizerFactory).instance().then(pr
ocessTokens.bind(this)); |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * @param {!Common.TokenizerFactory} tokenizerFactory | 70 * @param {!TextUtils.TokenizerFactory} tokenizerFactory |
| 71 * @this {UI.SyntaxHighlighter} | 71 * @this {UI.SyntaxHighlighter} |
| 72 */ | 72 */ |
| 73 function processTokens(tokenizerFactory) { | 73 function processTokens(tokenizerFactory) { |
| 74 node.removeChildren(); | 74 node.removeChildren(); |
| 75 var tokenize = tokenizerFactory.createTokenizer(this._mimeType); | 75 var tokenize = tokenizerFactory.createTokenizer(this._mimeType); |
| 76 for (var i = 0; i < lines.length; ++i) { | 76 for (var i = 0; i < lines.length; ++i) { |
| 77 line = lines[i]; | 77 line = lines[i]; |
| 78 plainTextStart = 0; | 78 plainTextStart = 0; |
| 79 tokenize(line, processToken.bind(this)); | 79 tokenize(line, processToken.bind(this)); |
| 80 if (plainTextStart < line.length) { | 80 if (plainTextStart < line.length) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 99 | 99 |
| 100 if (column > plainTextStart) { | 100 if (column > plainTextStart) { |
| 101 var plainText = line.substring(plainTextStart, column); | 101 var plainText = line.substring(plainTextStart, column); |
| 102 node.createTextChild(plainText); | 102 node.createTextChild(plainText); |
| 103 } | 103 } |
| 104 node.appendChild(this.createSpan(token, tokenType)); | 104 node.appendChild(this.createSpan(token, tokenType)); |
| 105 plainTextStart = newColumn; | 105 plainTextStart = newColumn; |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 }; | 108 }; |
| OLD | NEW |