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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return self.runtime.extension(WebInspector.TokenizerFactory).instance().
then(processTokens.bind(this)); | 68 return self.runtime.extension(WebInspector.TokenizerFactory).instance().
then(processTokens.bind(this)); |
69 | 69 |
70 /** | 70 /** |
71 * @param {!WebInspector.TokenizerFactory} tokenizerFactory | 71 * @param {!WebInspector.TokenizerFactory} tokenizerFactory |
72 * @this {WebInspector.DOMSyntaxHighlighter} | 72 * @this {WebInspector.DOMSyntaxHighlighter} |
73 */ | 73 */ |
74 function processTokens(tokenizerFactory) | 74 function processTokens(tokenizerFactory) |
75 { | 75 { |
76 node.removeChildren(); | 76 node.removeChildren(); |
77 var tokenize = tokenizerFactory.createTokenizer(this._mimeType); | 77 var tokenize = tokenizerFactory.createTokenizer(this._mimeType); |
78 for (var i = lines[0].length ? 0 : 1; i < lines.length; ++i) { | 78 for (var i = 0; i < lines.length; ++i) { |
79 line = lines[i]; | 79 line = lines[i]; |
80 plainTextStart = 0; | 80 plainTextStart = 0; |
81 tokenize(line, processToken.bind(this)); | 81 tokenize(line, processToken.bind(this)); |
82 if (plainTextStart < line.length) { | 82 if (plainTextStart < line.length) { |
83 var plainText = line.substring(plainTextStart, line.length); | 83 var plainText = line.substring(plainTextStart, line.length); |
84 node.createTextChild(plainText); | 84 node.createTextChild(plainText); |
85 } | 85 } |
86 if (i < lines.length - 1) | 86 if (i < lines.length - 1) |
87 node.createTextChild("\n"); | 87 node.createTextChild("\n"); |
88 } | 88 } |
(...skipping 13 matching lines...) Expand all Loading... |
102 | 102 |
103 if (column > plainTextStart) { | 103 if (column > plainTextStart) { |
104 var plainText = line.substring(plainTextStart, column); | 104 var plainText = line.substring(plainTextStart, column); |
105 node.createTextChild(plainText); | 105 node.createTextChild(plainText); |
106 } | 106 } |
107 node.appendChild(this.createSpan(token, tokenType)); | 107 node.appendChild(this.createSpan(token, tokenType)); |
108 plainTextStart = newColumn; | 108 plainTextStart = newColumn; |
109 } | 109 } |
110 } | 110 } |
111 } | 111 } |
OLD | NEW |