Changeset 86430 in webkit
- Timestamp:
- May 13, 2011 7:56:24 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r86428 r86430 1 2011-05-06 Pavel Podivilov <podivilov@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: fix incremental html highlight. 6 https://bugs.webkit.org/show_bug.cgi?id=60163 7 8 SourceTokenizers for html, js, and css are declared to be stateless. However they store some state in 9 various ways (like using _internalJavaScriptTokenizer field in html tokenizer, or modifying "static" 10 initialCondition object via condition link). This all worked because of another bug in tokenizers registry 11 that always returned new tokenizer object. 12 For incremental highlighting, we need to be able to stringify tokenizers state and then restore the 13 state from string. That's why we need tokenizers to be truly stateless. 14 15 * inspector/front-end/DOMSyntaxHighlighter.js: 16 (WebInspector.DOMSyntaxHighlighter.prototype.syntaxHighlightNode): 17 * inspector/front-end/SourceCSSTokenizer.js: 18 (WebInspector.SourceCSSTokenizer): 19 (WebInspector.SourceCSSTokenizer.prototype.createInitialCondition): 20 * inspector/front-end/SourceCSSTokenizer.re2js: 21 * inspector/front-end/SourceHTMLTokenizer.js: 22 (WebInspector.SourceHTMLTokenizer): 23 (WebInspector.SourceHTMLTokenizer.prototype.createInitialCondition): 24 (WebInspector.SourceHTMLTokenizer.prototype.set line): 25 (WebInspector.SourceHTMLTokenizer.prototype.get _internalJavaScriptTokenizer): 26 (WebInspector.SourceHTMLTokenizer.prototype.get _internalCSSTokenizer): 27 (WebInspector.SourceHTMLTokenizer.prototype.scriptStarted): 28 (WebInspector.SourceHTMLTokenizer.prototype.styleSheetStarted): 29 (WebInspector.SourceHTMLTokenizer.prototype.nextToken): 30 * inspector/front-end/SourceHTMLTokenizer.re2js: 31 * inspector/front-end/SourceJavaScriptTokenizer.js: 32 (WebInspector.SourceJavaScriptTokenizer): 33 (WebInspector.SourceJavaScriptTokenizer.prototype.createInitialCondition): 34 * inspector/front-end/SourceJavaScriptTokenizer.re2js: 35 * inspector/front-end/SourceTokenizer.js: 36 (WebInspector.SourceTokenizer.Registry.prototype.getTokenizer): 37 * inspector/front-end/TextEditorHighlighter.js: 38 (WebInspector.TextEditorHighlighter.prototype._highlightLines): 39 1 40 2011-05-13 Adam Roben <aroben@apple.com> 2 41 -
trunk/Source/WebCore/inspector/front-end/DOMSyntaxHighlighter.js
r54053 r86430 45 45 syntaxHighlightNode: function(node) 46 46 { 47 this._tokenizer.condition = this._tokenizer. initialCondition;47 this._tokenizer.condition = this._tokenizer.createInitialCondition(); 48 48 var lines = node.textContent.split("\n"); 49 49 node.removeChildren(); -
trunk/Source/WebCore/inspector/front-end/SourceCSSTokenizer.js
r84483 r86430 1 /* Generated by re2c 0.13.5 on Mon Dec 20 18:44:30 2010*/1 /* Generated by re2c 0.13.5 on Fri May 6 13:46:34 2011 */ 2 2 /* 3 3 * Copyright (C) 2009 Google Inc. All rights reserved. … … 46 46 WebInspector.SourceTokenizer.call(this); 47 47 48 this._propertyKeywords = WebInspector.cssNameCompletions ? WebInspector.cssNameCompletions.keySet() : {};48 this._propertyKeywords = WebInspector.cssNameCompletions.keySet(); 49 49 50 50 this._valueKeywords = [ … … 119 119 this.case_SSTRING = 1004; 120 120 121 this. initialCondition = { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL }121 this.condition = this.createInitialCondition(); 122 122 } 123 123 124 124 WebInspector.SourceCSSTokenizer.prototype = { 125 createInitialCondition: function() 126 { 127 return { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL }; 128 }, 129 125 130 _stringToken: function(cursor, stringEnds) 126 131 { -
trunk/Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js
r74352 r86430 118 118 this.case_SSTRING = 1004; 119 119 120 this. initialCondition = { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL }120 this.condition = this.createInitialCondition(); 121 121 } 122 122 123 123 WebInspector.SourceCSSTokenizer.prototype = { 124 createInitialCondition: function() 125 { 126 return { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL }; 127 }, 128 124 129 _stringToken: function(cursor, stringEnds) 125 130 { -
trunk/Source/WebCore/inspector/front-end/SourceHTMLTokenizer.js
r84625 r86430 1 /* Generated by re2c 0.13.5 on Thu Apr 14 15:53:192011 */1 /* Generated by re2c 0.13.5 on Fri May 6 13:47:06 2011 */ 2 2 /* 3 3 * Copyright (C) 2009 Google Inc. All rights reserved. … … 72 72 }; 73 73 74 this.initialCondition = { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL }; 75 this.condition = this.initialCondition; 74 this.condition = this.createInitialCondition(); 76 75 } 77 76 78 77 WebInspector.SourceHTMLTokenizer.prototype = { 78 createInitialCondition: function() 79 { 80 return { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL }; 81 }, 82 79 83 set line(line) { 80 if (this._ internalJavaScriptTokenizer) {84 if (this._condition.internalJavaScriptTokenizerCondition) { 81 85 var match = /<\/script/i.exec(line); 82 86 if (match) { … … 84 88 } else 85 89 this._internalJavaScriptTokenizer.line = line; 86 } else if (this._ internalCSSTokenizer) {90 } else if (this._condition.internalCSSTokenizerCondition) { 87 91 var match = /<\/style/i.exec(line); 88 92 if (match) { … … 140 144 }, 141 145 146 get _internalJavaScriptTokenizer() 147 { 148 return WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/javascript"); 149 }, 150 151 get _internalCSSTokenizer() 152 { 153 return WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/css"); 154 }, 155 142 156 scriptStarted: function(cursor) 143 157 { 144 if (!this._internalJavaScriptTokenizer) { 145 this._internalJavaScriptTokenizer = WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/javascript"); 146 this._condition.internalJavaScriptTokenizerCondition = this._internalJavaScriptTokenizer.initialCondition; 147 } 158 this._condition.internalJavaScriptTokenizerCondition = this._internalJavaScriptTokenizer.createInitialCondition(); 148 159 }, 149 160 … … 154 165 styleSheetStarted: function(cursor) 155 166 { 156 if (!this._internalCSSTokenizer) { 157 this._internalCSSTokenizer = WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/css"); 158 this._condition.internalCSSTokenizerCondition = this._internalCSSTokenizer.initialCondition; 159 } 167 this._condition.internalCSSTokenizerCondition = this._internalCSSTokenizer.createInitialCondition(); 160 168 }, 161 169 … … 166 174 nextToken: function(cursor) 167 175 { 168 if (this._ internalJavaScriptTokenizer) {176 if (this._condition.internalJavaScriptTokenizerCondition) { 169 177 // Re-set line to force </script> detection first. 170 178 this.line = this._line; … … 177 185 return result; 178 186 } else if (cursor !== this._line.length) 179 delete this._ internalJavaScriptTokenizer;180 } else if (this._ internalCSSTokenizer) {187 delete this._condition.internalJavaScriptTokenizerCondition; 188 } else if (this._condition.internalCSSTokenizerCondition) { 181 189 // Re-set line to force </style> detection first. 182 190 this.line = this._line; … … 189 197 return result; 190 198 } else if (cursor !== this._line.length) 191 delete this._ internalCSSTokenizer;199 delete this._condition.internalCSSTokenizerCondition; 192 200 } 193 201 … … 586 594 this.tokenType = "html-tag"; 587 595 this._condition.parseCondition = this._parseConditions.INITIAL; 596 this.styleSheetEnded(cursor - 7); 588 597 return cursor; 589 598 } -
trunk/Source/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js
r84625 r86430 71 71 }; 72 72 73 this.initialCondition = { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL }; 74 this.condition = this.initialCondition; 73 this.condition = this.createInitialCondition(); 75 74 } 76 75 77 76 WebInspector.SourceHTMLTokenizer.prototype = { 77 createInitialCondition: function() 78 { 79 return { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL }; 80 }, 81 78 82 set line(line) { 79 if (this._ internalJavaScriptTokenizer) {83 if (this._condition.internalJavaScriptTokenizerCondition) { 80 84 var match = /<\/script/i.exec(line); 81 85 if (match) { … … 83 87 } else 84 88 this._internalJavaScriptTokenizer.line = line; 85 } else if (this._ internalCSSTokenizer) {89 } else if (this._condition.internalCSSTokenizerCondition) { 86 90 var match = /<\/style/i.exec(line); 87 91 if (match) { … … 139 143 }, 140 144 145 get _internalJavaScriptTokenizer() 146 { 147 return WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/javascript"); 148 }, 149 150 get _internalCSSTokenizer() 151 { 152 return WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/css"); 153 }, 154 141 155 scriptStarted: function(cursor) 142 156 { 143 if (!this._internalJavaScriptTokenizer) { 144 this._internalJavaScriptTokenizer = WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/javascript"); 145 this._condition.internalJavaScriptTokenizerCondition = this._internalJavaScriptTokenizer.initialCondition; 146 } 157 this._condition.internalJavaScriptTokenizerCondition = this._internalJavaScriptTokenizer.createInitialCondition(); 147 158 }, 148 159 … … 153 164 styleSheetStarted: function(cursor) 154 165 { 155 if (!this._internalCSSTokenizer) { 156 this._internalCSSTokenizer = WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/css"); 157 this._condition.internalCSSTokenizerCondition = this._internalCSSTokenizer.initialCondition; 158 } 166 this._condition.internalCSSTokenizerCondition = this._internalCSSTokenizer.createInitialCondition(); 159 167 }, 160 168 … … 165 173 nextToken: function(cursor) 166 174 { 167 if (this._ internalJavaScriptTokenizer) {175 if (this._condition.internalJavaScriptTokenizerCondition) { 168 176 // Re-set line to force </script> detection first. 169 177 this.line = this._line; … … 176 184 return result; 177 185 } else if (cursor !== this._line.length) 178 delete this._ internalJavaScriptTokenizer;179 } else if (this._ internalCSSTokenizer) {186 delete this._condition.internalJavaScriptTokenizerCondition; 187 } else if (this._condition.internalCSSTokenizerCondition) { 180 188 // Re-set line to force </style> detection first. 181 189 this.line = this._line; … … 188 196 return result; 189 197 } else if (cursor !== this._line.length) 190 delete this._ internalCSSTokenizer;198 delete this._condition.internalCSSTokenizerCondition; 191 199 } 192 200 … … 285 293 this.tokenType = "html-tag"; 286 294 this._condition.parseCondition = this._parseConditions.INITIAL; 287 this.style Ended(cursor - 7);295 this.styleSheetEnded(cursor - 7); 288 296 return cursor; 289 297 } -
trunk/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.js
r55248 r86430 1 /* Generated by re2c 0.13.5 on Thu Feb 25 21:44:55 2010*/1 /* Generated by re2c 0.13.5 on Fri May 6 13:56:13 2011 */ 2 2 /* 3 3 * Copyright (C) 2009 Google Inc. All rights reserved. … … 69 69 this.case_REGEX = 1005; 70 70 71 this.initialCondition = { lexCondition: this._lexConditions.NODIV } 72 this.condition = this.initialCondition; 71 this.condition = this.createInitialCondition(); 73 72 } 74 73 75 74 WebInspector.SourceJavaScriptTokenizer.prototype = { 75 createInitialCondition: function() 76 { 77 return { lexCondition: this._lexConditions.NODIV }; 78 }, 79 76 80 nextToken: function(cursor) 77 81 { -
trunk/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js
r55248 r86430 68 68 this.case_REGEX = 1005; 69 69 70 this.initialCondition = { lexCondition: this._lexConditions.NODIV } 71 this.condition = this.initialCondition; 70 this.condition = this.createInitialCondition(); 72 71 } 73 72 74 73 WebInspector.SourceJavaScriptTokenizer.prototype = { 74 createInitialCondition: function() 75 { 76 return { lexCondition: this._lexConditions.NODIV }; 77 }, 78 75 79 nextToken: function(cursor) 76 80 { -
trunk/Source/WebCore/inspector/front-end/SourceTokenizer.js
r78815 r86430 91 91 if (!tokenizer) { 92 92 tokenizer = new WebInspector[tokenizerClass](); 93 this._tokenizers[ mimeType] = tokenizer;93 this._tokenizers[tokenizerClass] = tokenizer; 94 94 } 95 95 return tokenizer; -
trunk/Source/WebCore/inspector/front-end/TextEditorHighlighter.js
r80704 r86430 142 142 // Restore highlighter context taken from previous line. 143 143 var state = this._textModel.getAttribute(startLine - 1, "highlight"); 144 var postConditionStringified = state ? state.postConditionStringified : JSON.stringify(this._tokenizer. initialCondition);144 var postConditionStringified = state ? state.postConditionStringified : JSON.stringify(this._tokenizer.createInitialCondition()); 145 145 146 146 var tokensCount = 0;
Note: See TracChangeset
for help on using the changeset viewer.