Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: Source/devtools/front_end/script_formatter_worker/ScriptFormatterWorker.js

Issue 354833004: DevTools: [CodeMirror] roll CodeMirror to version @e20d175 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 name: tokenValue, 272 name: tokenValue,
273 value: "", 273 value: "",
274 }; 274 };
275 state = FormatterWorker.CSSParserStates.PropertyName; 275 state = FormatterWorker.CSSParserStates.PropertyName;
276 } else if (tokenValue === "}" && tokenType === UndefTokenType) { 276 } else if (tokenValue === "}" && tokenType === UndefTokenType) {
277 rules.push(rule); 277 rules.push(rule);
278 state = FormatterWorker.CSSParserStates.Initial; 278 state = FormatterWorker.CSSParserStates.Initial;
279 } 279 }
280 break; 280 break;
281 case FormatterWorker.CSSParserStates.PropertyName: 281 case FormatterWorker.CSSParserStates.PropertyName:
282 if (tokenValue === ":" && tokenType["operator"]) { 282 if (tokenValue === ":" && tokenType === UndefTokenType) {
283 property.name = property.name.trim(); 283 property.name = property.name.trim();
284 state = FormatterWorker.CSSParserStates.PropertyValue; 284 state = FormatterWorker.CSSParserStates.PropertyValue;
285 } else if (tokenType["property"]) { 285 } else if (tokenType["property"]) {
286 property.name += tokenValue; 286 property.name += tokenValue;
287 } 287 }
288 break; 288 break;
289 case FormatterWorker.CSSParserStates.PropertyValue: 289 case FormatterWorker.CSSParserStates.PropertyValue:
290 if (tokenValue === ";" && tokenType === UndefTokenType) { 290 if (tokenValue === ";" && tokenType === UndefTokenType) {
291 property.value = property.value.trim(); 291 property.value = property.value.trim();
292 rule.properties.push(property); 292 rule.properties.push(property);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 { 382 {
383 this.line = content; 383 this.line = content;
384 this._content = content; 384 this._content = content;
385 this._formattedContent = ""; 385 this._formattedContent = "";
386 this._mapping = { original: [0], formatted: [0] }; 386 this._mapping = { original: [0], formatted: [0] };
387 this._position = 0; 387 this._position = 0;
388 388
389 var scriptOpened = false; 389 var scriptOpened = false;
390 var styleOpened = false; 390 var styleOpened = false;
391 var tokenizer = FormatterWorker.createTokenizer("text/html"); 391 var tokenizer = FormatterWorker.createTokenizer("text/html");
392 var accumulatedTokenValue = "";
393 var accumulatedTokenStart = 0;
392 394
393 /** 395 /**
394 * @this {FormatterWorker.HTMLFormatter} 396 * @this {FormatterWorker.HTMLFormatter}
395 */ 397 */
396 function processToken(tokenValue, tokenType, tokenStart, tokenEnd) { 398 function processToken(tokenValue, tokenType, tokenStart, tokenEnd) {
397 if (tokenType !== "tag") 399 if (!tokenType)
398 return; 400 return;
399 if (tokenValue.toLowerCase() === "<script") { 401 var oldType = tokenType;
402 tokenType = tokenType.split(" ").keySet();
403 if (!tokenType["tag"])
404 return;
405 if (tokenType["bracket"] && (tokenValue === "<" || tokenValue === "< /")) {
406 accumulatedTokenValue = tokenValue;
407 accumulatedTokenStart = tokenStart;
408 return;
409 }
410 accumulatedTokenValue = accumulatedTokenValue + tokenValue.toLowerCa se();
411 if (accumulatedTokenValue === "<script") {
400 scriptOpened = true; 412 scriptOpened = true;
401 } else if (scriptOpened && tokenValue === ">") { 413 } else if (scriptOpened && tokenValue === ">") {
402 scriptOpened = false; 414 scriptOpened = false;
403 this._scriptStarted(tokenEnd); 415 this._scriptStarted(tokenEnd);
404 } else if (tokenValue.toLowerCase() === "</script") { 416 } else if (accumulatedTokenValue === "</script") {
405 this._scriptEnded(tokenStart); 417 this._scriptEnded(accumulatedTokenStart);
406 } else if (tokenValue.toLowerCase() === "<style") { 418 } else if (accumulatedTokenValue === "<style") {
407 styleOpened = true; 419 styleOpened = true;
408 } else if (styleOpened && tokenValue === ">") { 420 } else if (styleOpened && tokenValue === ">") {
409 styleOpened = false; 421 styleOpened = false;
410 this._styleStarted(tokenEnd); 422 this._styleStarted(tokenEnd);
411 } else if (tokenValue.toLowerCase() === "</style") { 423 } else if (accumulatedTokenValue === "</style") {
412 this._styleEnded(tokenStart); 424 this._styleEnded(accumulatedTokenStart);
413 } 425 }
426 accumulatedTokenValue = "";
414 } 427 }
415 tokenizer(content, processToken.bind(this)); 428 tokenizer(content, processToken.bind(this));
416 429
417 this._formattedContent += this._content.substring(this._position); 430 this._formattedContent += this._content.substring(this._position);
418 return { content: this._formattedContent, mapping: this._mapping }; 431 return { content: this._formattedContent, mapping: this._mapping };
419 }, 432 },
420 433
421 /** 434 /**
422 * @param {number} cursor 435 * @param {number} cursor
423 */ 436 */
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 502
490 /** 503 /**
491 * @type {!{tokenizer}} 504 * @type {!{tokenizer}}
492 */ 505 */
493 var exports = { tokenizer: null }; 506 var exports = { tokenizer: null };
494 importScripts("../UglifyJS/parse-js.js"); 507 importScripts("../UglifyJS/parse-js.js");
495 var parse = exports; 508 var parse = exports;
496 509
497 importScripts("JavaScriptFormatter.js"); 510 importScripts("JavaScriptFormatter.js");
498 importScripts("CSSFormatter.js"); 511 importScripts("CSSFormatter.js");
OLDNEW
« no previous file with comments | « Source/devtools/front_end/cm/xml.js ('k') | Source/devtools/front_end/source_frame/CodeMirrorTextEditor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698