Changeset 76943 in webkit
- Timestamp:
- Jan 28, 2011 7:48:00 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r76941 r76943 1 2011-01-28 Alexander Pavlov <apavlov@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: syntax highlight inline JS and CSS in HTML resources 6 https://bugs.webkit.org/show_bug.cgi?id=30831 7 8 * inspector/front-end/SourceHTMLTokenizer.js: 9 (WebInspector.SourceHTMLTokenizer): 10 (WebInspector.SourceHTMLTokenizer.prototype.set line): 11 (WebInspector.SourceHTMLTokenizer.prototype.nextToken): 12 * inspector/front-end/SourceHTMLTokenizer.re2js: 13 1 14 2011-01-28 Alexander Pavlov <apavlov@chromium.org> 2 15 -
trunk/Source/WebCore/inspector/front-end/SourceHTMLTokenizer.js
r55248 r76943 1 /* Generated by re2c 0.13.5 on Thu Feb 25 21:44:55 2010*/1 /* Generated by re2c 0.13.5 on Fri Jan 28 18:32:27 2011 */ 2 2 /* 3 3 * Copyright (C) 2009 Google Inc. All rights reserved. … … 68 68 LINKIFY: 4, 69 69 A_NODE: 8, 70 SCRIPT: 16 70 SCRIPT: 16, 71 STYLE: 32 71 72 }; 72 73 … … 83 84 } else 84 85 this._internalJavaScriptTokenizer.line = line; 86 } else if (this._internalCSSTokenizer) { 87 var match = /<\/style/i.exec(line); 88 if (match) { 89 this._internalCSSTokenizer.line = line.substring(0, match.index); 90 } else 91 this._internalCSSTokenizer.line = line; 85 92 } 86 93 this._line = line; … … 147 154 } else if (cursor !== this._line.length) 148 155 delete this._internalJavaScriptTokenizer; 156 } else if (this._internalCSSTokenizer) { 157 // Re-set line to force </style> detection first. 158 this.line = this._line; 159 if (cursor !== this._internalCSSTokenizer._line.length) { 160 // Tokenizer is stateless, so restore its condition before tokenizing and save it after. 161 this._internalCSSTokenizer.condition = this._condition.internalCSSTokenizerCondition; 162 var result = this._internalCSSTokenizer.nextToken(cursor); 163 this.tokenType = this._internalCSSTokenizer.tokenType; 164 this._condition.internalCSSTokenizerCondition = this._internalCSSTokenizer.condition; 165 return result; 166 } else if (cursor !== this._line.length) 167 delete this._internalCSSTokenizer; 149 168 } 150 169 … … 332 351 this.setLexCondition(this._lexConditions.TAG); 333 352 { 334 if (this._condition.parseCondition & this._parseConditions.SCRIPT) {335 // Do not tokenize script tag contents, keep lexer state although processing "<".353 if (this._condition.parseCondition & (this._parseConditions.SCRIPT | this._parseConditions.STYLE)) { 354 // Do not tokenize script and style tag contents, keep lexer state, even though processing "<". 336 355 this.setLexCondition(this._lexConditions.INITIAL); 337 356 this.tokenType = null; … … 346 365 yyaccept = 0; 347 366 yych = this._charAt(YYMARKER = ++cursor); 348 if (yych == 'S') { gotoCase = 68; continue; };349 if (yych == 's') { gotoCase = 68; continue; };367 if (yych == 'S') { gotoCase = 73; continue; }; 368 if (yych == 's') { gotoCase = 73; continue; }; 350 369 { gotoCase = 40; continue; }; 351 370 case 42: 352 371 yych = this._charAt(++cursor); 353 if (yych == 'C') { gotoCase = 62; continue; }; 354 if (yych == 'c') { gotoCase = 62; continue; }; 372 if (yych <= 'T') { 373 if (yych == 'C') { gotoCase = 62; continue; }; 374 if (yych >= 'T') { gotoCase = 63; continue; }; 375 } else { 376 if (yych <= 'c') { 377 if (yych >= 'c') { gotoCase = 62; continue; }; 378 } else { 379 if (yych == 't') { gotoCase = 63; continue; }; 380 } 381 } 355 382 case 43: 356 383 cursor = YYMARKER; … … 422 449 case 62: 423 450 yych = this._charAt(++cursor); 424 if (yych == 'R') { gotoCase = 63; continue; }; 425 if (yych != 'r') { gotoCase = 43; continue; }; 451 if (yych == 'R') { gotoCase = 68; continue; }; 452 if (yych == 'r') { gotoCase = 68; continue; }; 453 { gotoCase = 43; continue; }; 426 454 case 63: 427 455 yych = this._charAt(++cursor); 428 if (yych == 'I') { gotoCase = 64; continue; }; 456 if (yych == 'Y') { gotoCase = 64; continue; }; 457 if (yych != 'y') { gotoCase = 43; continue; }; 458 case 64: 459 yych = this._charAt(++cursor); 460 if (yych == 'L') { gotoCase = 65; continue; }; 461 if (yych != 'l') { gotoCase = 43; continue; }; 462 case 65: 463 yych = this._charAt(++cursor); 464 if (yych == 'E') { gotoCase = 66; continue; }; 465 if (yych != 'e') { gotoCase = 43; continue; }; 466 case 66: 467 ++cursor; 468 this.setLexCondition(this._lexConditions.TAG); 469 { 470 if (this._condition.parseCondition & this._parseConditions.STYLE) { 471 // Do not tokenize style tag contents, keep lexer state, even though processing "<". 472 this.setLexCondition(this._lexConditions.INITIAL); 473 this.tokenType = null; 474 return cursor; 475 } 476 this.tokenType = "html-tag"; 477 this._condition.parseCondition = this._parseConditions.STYLE; 478 this._setExpectingAttribute(); 479 return cursor; 480 } 481 case 68: 482 yych = this._charAt(++cursor); 483 if (yych == 'I') { gotoCase = 69; continue; }; 429 484 if (yych != 'i') { gotoCase = 43; continue; }; 430 case 6 4:431 yych = this._charAt(++cursor); 432 if (yych == 'P') { gotoCase = 65; continue; };485 case 69: 486 yych = this._charAt(++cursor); 487 if (yych == 'P') { gotoCase = 70; continue; }; 433 488 if (yych != 'p') { gotoCase = 43; continue; }; 434 case 65:435 yych = this._charAt(++cursor); 436 if (yych == 'T') { gotoCase = 66; continue; };489 case 70: 490 yych = this._charAt(++cursor); 491 if (yych == 'T') { gotoCase = 71; continue; }; 437 492 if (yych != 't') { gotoCase = 43; continue; }; 438 case 66:493 case 71: 439 494 ++cursor; 440 495 this.setLexCondition(this._lexConditions.TAG); 441 496 { 442 497 if (this._condition.parseCondition & this._parseConditions.SCRIPT) { 443 // Do not tokenize script tag contents, keep lexer state although processing "<".498 // Do not tokenize script tag contents, keep lexer state, even though processing "<". 444 499 this.setLexCondition(this._lexConditions.INITIAL); 445 500 this.tokenType = null; … … 451 506 return cursor; 452 507 } 453 case 68: 454 yych = this._charAt(++cursor); 455 if (yych == 'C') { gotoCase = 69; continue; }; 456 if (yych != 'c') { gotoCase = 43; continue; }; 457 case 69: 458 yych = this._charAt(++cursor); 459 if (yych == 'R') { gotoCase = 70; continue; }; 508 case 73: 509 yych = this._charAt(++cursor); 510 if (yych <= 'T') { 511 if (yych == 'C') { gotoCase = 75; continue; }; 512 if (yych <= 'S') { gotoCase = 43; continue; }; 513 } else { 514 if (yych <= 'c') { 515 if (yych <= 'b') { gotoCase = 43; continue; }; 516 { gotoCase = 75; continue; }; 517 } else { 518 if (yych != 't') { gotoCase = 43; continue; }; 519 } 520 } 521 yych = this._charAt(++cursor); 522 if (yych == 'Y') { gotoCase = 81; continue; }; 523 if (yych == 'y') { gotoCase = 81; continue; }; 524 { gotoCase = 43; continue; }; 525 case 75: 526 yych = this._charAt(++cursor); 527 if (yych == 'R') { gotoCase = 76; continue; }; 460 528 if (yych != 'r') { gotoCase = 43; continue; }; 461 case 7 0:462 yych = this._charAt(++cursor); 463 if (yych == 'I') { gotoCase = 7 1; continue; };529 case 76: 530 yych = this._charAt(++cursor); 531 if (yych == 'I') { gotoCase = 77; continue; }; 464 532 if (yych != 'i') { gotoCase = 43; continue; }; 465 case 7 1:466 yych = this._charAt(++cursor); 467 if (yych == 'P') { gotoCase = 7 2; continue; };533 case 77: 534 yych = this._charAt(++cursor); 535 if (yych == 'P') { gotoCase = 78; continue; }; 468 536 if (yych != 'p') { gotoCase = 43; continue; }; 469 case 7 2:470 yych = this._charAt(++cursor); 471 if (yych == 'T') { gotoCase = 7 3; continue; };537 case 78: 538 yych = this._charAt(++cursor); 539 if (yych == 'T') { gotoCase = 79; continue; }; 472 540 if (yych != 't') { gotoCase = 43; continue; }; 473 case 7 3:541 case 79: 474 542 ++cursor; 475 543 this.setLexCondition(this._lexConditions.TAG); … … 479 547 return cursor; 480 548 } 549 case 81: 550 yych = this._charAt(++cursor); 551 if (yych == 'L') { gotoCase = 82; continue; }; 552 if (yych != 'l') { gotoCase = 43; continue; }; 553 case 82: 554 yych = this._charAt(++cursor); 555 if (yych == 'E') { gotoCase = 83; continue; }; 556 if (yych != 'e') { gotoCase = 43; continue; }; 557 case 83: 558 ++cursor; 559 this.setLexCondition(this._lexConditions.TAG); 560 { 561 this.tokenType = "html-tag"; 562 this._condition.parseCondition = this._parseConditions.INITIAL; 563 return cursor; 564 } 481 565 /* *********************************** */ 482 566 case this.case_SSTRING: 483 567 yych = this._charAt(cursor); 484 568 if (yych <= '\f') { 485 if (yych == '\n') { gotoCase = 79; continue; };486 { gotoCase = 78; continue; };487 } else { 488 if (yych <= '\r') { gotoCase = 79; continue; };489 if (yych == '\'') { gotoCase = 81; continue; };490 { gotoCase = 78; continue; };491 } 492 case 77:569 if (yych == '\n') { gotoCase = 89; continue; }; 570 { gotoCase = 88; continue; }; 571 } else { 572 if (yych <= '\r') { gotoCase = 89; continue; }; 573 if (yych == '\'') { gotoCase = 91; continue; }; 574 { gotoCase = 88; continue; }; 575 } 576 case 87: 493 577 { return this._stringToken(cursor); } 494 case 78:495 yych = this._charAt(++cursor); 496 { gotoCase = 85; continue; };497 case 79:578 case 88: 579 yych = this._charAt(++cursor); 580 { gotoCase = 95; continue; }; 581 case 89: 498 582 ++cursor; 499 583 { this.tokenType = null; return cursor; } 500 case 81:501 ++cursor; 502 case 82:584 case 91: 585 ++cursor; 586 case 92: 503 587 this.setLexCondition(this._lexConditions.TAG); 504 588 { return this._stringToken(cursor, true); } 505 case 83:506 yych = this._charAt(++cursor); 507 { gotoCase = 82; continue; };508 case 84:509 ++cursor; 510 yych = this._charAt(cursor); 511 case 85:512 if (yych <= '\f') { 513 if (yych == '\n') { gotoCase = 77; continue; };514 { gotoCase = 84; continue; };515 } else { 516 if (yych <= '\r') { gotoCase = 77; continue; };517 if (yych == '\'') { gotoCase = 83; continue; };518 { gotoCase = 84; continue; };589 case 93: 590 yych = this._charAt(++cursor); 591 { gotoCase = 92; continue; }; 592 case 94: 593 ++cursor; 594 yych = this._charAt(cursor); 595 case 95: 596 if (yych <= '\f') { 597 if (yych == '\n') { gotoCase = 87; continue; }; 598 { gotoCase = 94; continue; }; 599 } else { 600 if (yych <= '\r') { gotoCase = 87; continue; }; 601 if (yych == '\'') { gotoCase = 93; continue; }; 602 { gotoCase = 94; continue; }; 519 603 } 520 604 /* *********************************** */ … … 523 607 if (yych <= '&') { 524 608 if (yych <= '\r') { 525 if (yych == '\n') { gotoCase = 90; continue; };526 if (yych >= '\r') { gotoCase = 90; continue; };609 if (yych == '\n') { gotoCase = 100; continue; }; 610 if (yych >= '\r') { gotoCase = 100; continue; }; 527 611 } else { 528 612 if (yych <= ' ') { 529 if (yych >= ' ') { gotoCase = 90; continue; };613 if (yych >= ' ') { gotoCase = 100; continue; }; 530 614 } else { 531 if (yych == '"') { gotoCase = 92; continue; };615 if (yych == '"') { gotoCase = 102; continue; }; 532 616 } 533 617 } … … 535 619 if (yych <= '>') { 536 620 if (yych <= ';') { 537 if (yych <= '\'') { gotoCase = 93; continue; };621 if (yych <= '\'') { gotoCase = 103; continue; }; 538 622 } else { 539 if (yych <= '<') { gotoCase = 90; continue; };540 if (yych <= '=') { gotoCase = 94; continue; };541 { gotoCase = 96; continue; };623 if (yych <= '<') { gotoCase = 100; continue; }; 624 if (yych <= '=') { gotoCase = 104; continue; }; 625 { gotoCase = 106; continue; }; 542 626 } 543 627 } else { 544 628 if (yych <= '[') { 545 if (yych >= '[') { gotoCase = 90; continue; };629 if (yych >= '[') { gotoCase = 100; continue; }; 546 630 } else { 547 if (yych == ']') { gotoCase = 90; continue; };548 } 549 } 550 } 551 ++cursor; 552 yych = this._charAt(cursor); 553 { gotoCase = 1 09; continue; };554 case 89:631 if (yych == ']') { gotoCase = 100; continue; }; 632 } 633 } 634 } 635 ++cursor; 636 yych = this._charAt(cursor); 637 { gotoCase = 119; continue; }; 638 case 99: 555 639 { 556 if (this._condition.parseCondition === this._parseConditions.SCRIPT ) {640 if (this._condition.parseCondition === this._parseConditions.SCRIPT || this._condition.parseCondition === this._parseConditions.STYLE) { 557 641 // Fall through if expecting attributes. 558 642 this.tokenType = null; … … 581 665 return cursor; 582 666 } 583 case 90:667 case 100: 584 668 ++cursor; 585 669 { this.tokenType = null; return cursor; } 586 case 92:670 case 102: 587 671 yyaccept = 0; 588 672 yych = this._charAt(YYMARKER = ++cursor); 589 { gotoCase = 1 05; continue; };590 case 93:673 { gotoCase = 115; continue; }; 674 case 103: 591 675 yyaccept = 0; 592 676 yych = this._charAt(YYMARKER = ++cursor); 593 { gotoCase = 99; continue; };594 case 94:677 { gotoCase = 109; continue; }; 678 case 104: 595 679 ++cursor; 596 680 { … … 600 684 return cursor; 601 685 } 602 case 96:686 case 106: 603 687 ++cursor; 604 688 this.setLexCondition(this._lexConditions.INITIAL); … … 614 698 } 615 699 700 if (this._condition.parseCondition & this._parseConditions.STYLE) { 701 if (!this._internalCSSTokenizer) { 702 this._internalCSSTokenizer = WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/css"); 703 this._condition.internalCSSTokenizerCondition = this._internalCSSTokenizer.initialCondition; 704 } 705 // Do not tokenize style tag contents. 706 return cursor; 707 } 708 616 709 this._condition.parseCondition = this._parseConditions.INITIAL; 617 710 return cursor; 618 711 } 619 case 98:620 ++cursor; 621 yych = this._charAt(cursor); 622 case 99:623 if (yych <= '\f') { 624 if (yych != '\n') { gotoCase = 98; continue; };625 } else { 626 if (yych <= '\r') { gotoCase = 1 00; continue; };627 if (yych == '\'') { gotoCase = 1 02; continue; };628 { gotoCase = 98; continue; };629 } 630 case 1 00:712 case 108: 713 ++cursor; 714 yych = this._charAt(cursor); 715 case 109: 716 if (yych <= '\f') { 717 if (yych != '\n') { gotoCase = 108; continue; }; 718 } else { 719 if (yych <= '\r') { gotoCase = 110; continue; }; 720 if (yych == '\'') { gotoCase = 112; continue; }; 721 { gotoCase = 108; continue; }; 722 } 723 case 110: 631 724 ++cursor; 632 725 this.setLexCondition(this._lexConditions.SSTRING); 633 726 { return this._stringToken(cursor); } 634 case 1 02:727 case 112: 635 728 ++cursor; 636 729 { return this._stringToken(cursor, true); } 637 case 1 04:638 ++cursor; 639 yych = this._charAt(cursor); 640 case 1 05:641 if (yych <= '\f') { 642 if (yych != '\n') { gotoCase = 1 04; continue; };643 } else { 644 if (yych <= '\r') { gotoCase = 1 06; continue; };645 if (yych == '"') { gotoCase = 1 02; continue; };646 { gotoCase = 1 04; continue; };647 } 648 case 1 06:730 case 114: 731 ++cursor; 732 yych = this._charAt(cursor); 733 case 115: 734 if (yych <= '\f') { 735 if (yych != '\n') { gotoCase = 114; continue; }; 736 } else { 737 if (yych <= '\r') { gotoCase = 116; continue; }; 738 if (yych == '"') { gotoCase = 112; continue; }; 739 { gotoCase = 114; continue; }; 740 } 741 case 116: 649 742 ++cursor; 650 743 this.setLexCondition(this._lexConditions.DSTRING); 651 744 { return this._stringToken(cursor); } 652 case 1 08:653 ++cursor; 654 yych = this._charAt(cursor); 655 case 1 09:745 case 118: 746 ++cursor; 747 yych = this._charAt(cursor); 748 case 119: 656 749 if (yych <= '"') { 657 750 if (yych <= '\r') { 658 if (yych == '\n') { gotoCase = 89; continue; };659 if (yych <= '\f') { gotoCase = 1 08; continue; };660 { gotoCase = 89; continue; };661 } else { 662 if (yych == ' ') { gotoCase = 89; continue; };663 if (yych <= '!') { gotoCase = 1 08; continue; };664 { gotoCase = 89; continue; };751 if (yych == '\n') { gotoCase = 99; continue; }; 752 if (yych <= '\f') { gotoCase = 118; continue; }; 753 { gotoCase = 99; continue; }; 754 } else { 755 if (yych == ' ') { gotoCase = 99; continue; }; 756 if (yych <= '!') { gotoCase = 118; continue; }; 757 { gotoCase = 99; continue; }; 665 758 } 666 759 } else { 667 760 if (yych <= '>') { 668 if (yych == '\'') { gotoCase = 89; continue; };669 if (yych <= ';') { gotoCase = 1 08; continue; };670 { gotoCase = 89; continue; };761 if (yych == '\'') { gotoCase = 99; continue; }; 762 if (yych <= ';') { gotoCase = 118; continue; }; 763 { gotoCase = 99; continue; }; 671 764 } else { 672 765 if (yych <= '[') { 673 if (yych <= 'Z') { gotoCase = 1 08; continue; };674 { gotoCase = 89; continue; };766 if (yych <= 'Z') { gotoCase = 118; continue; }; 767 { gotoCase = 99; continue; }; 675 768 } else { 676 if (yych == ']') { gotoCase = 89; continue; };677 { gotoCase = 1 08; continue; };769 if (yych == ']') { gotoCase = 99; continue; }; 770 { gotoCase = 118; continue; }; 678 771 } 679 772 } -
trunk/Source/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js
r55248 r76943 67 67 LINKIFY: 4, 68 68 A_NODE: 8, 69 SCRIPT: 16 69 SCRIPT: 16, 70 STYLE: 32 70 71 }; 71 72 … … 82 83 } else 83 84 this._internalJavaScriptTokenizer.line = line; 85 } else if (this._internalCSSTokenizer) { 86 var match = /<\/style/i.exec(line); 87 if (match) { 88 this._internalCSSTokenizer.line = line.substring(0, match.index); 89 } else 90 this._internalCSSTokenizer.line = line; 84 91 } 85 92 this._line = line; … … 146 153 } else if (cursor !== this._line.length) 147 154 delete this._internalJavaScriptTokenizer; 155 } else if (this._internalCSSTokenizer) { 156 // Re-set line to force </style> detection first. 157 this.line = this._line; 158 if (cursor !== this._internalCSSTokenizer._line.length) { 159 // Tokenizer is stateless, so restore its condition before tokenizing and save it after. 160 this._internalCSSTokenizer.condition = this._condition.internalCSSTokenizerCondition; 161 var result = this._internalCSSTokenizer.nextToken(cursor); 162 this.tokenType = this._internalCSSTokenizer.tokenType; 163 this._condition.internalCSSTokenizerCondition = this._internalCSSTokenizer.condition; 164 return result; 165 } else if (cursor !== this._line.length) 166 delete this._internalCSSTokenizer; 148 167 } 149 168 … … 176 195 ScriptEnd = "</" [Ss] [Cc] [Rr] [Ii] [Pp] [Tt]; 177 196 197 StyleStart = "<" [Ss] [Tt] [Yy] [Ll] [Ee]; 198 StyleEnd = "</" [Ss] [Tt] [Yy] [Ll] [Ee]; 199 178 200 LT = "<" | "</"; 179 201 GT = ">"; … … 202 224 { 203 225 if (this._condition.parseCondition & this._parseConditions.SCRIPT) { 204 // Do not tokenize script tag contents, keep lexer state although processing "<".226 // Do not tokenize script tag contents, keep lexer state, even though processing "<". 205 227 this.setLexCondition(this._lexConditions.INITIAL); 206 228 this.tokenType = null; … … 220 242 } 221 243 244 <INITIAL> StyleStart => TAG 245 { 246 if (this._condition.parseCondition & this._parseConditions.STYLE) { 247 // Do not tokenize style tag contents, keep lexer state, even though processing "<". 248 this.setLexCondition(this._lexConditions.INITIAL); 249 this.tokenType = null; 250 return cursor; 251 } 252 this.tokenType = "html-tag"; 253 this._condition.parseCondition = this._parseConditions.STYLE; 254 this._setExpectingAttribute(); 255 return cursor; 256 } 257 258 <INITIAL> StyleEnd => TAG 259 { 260 this.tokenType = "html-tag"; 261 this._condition.parseCondition = this._parseConditions.INITIAL; 262 return cursor; 263 } 264 222 265 <INITIAL> LT => TAG 223 266 { 224 if (this._condition.parseCondition & this._parseConditions.SCRIPT) {225 // Do not tokenize script tag contents, keep lexer state although processing "<".267 if (this._condition.parseCondition & (this._parseConditions.SCRIPT | this._parseConditions.STYLE)) { 268 // Do not tokenize script and style tag contents, keep lexer state, even though processing "<". 226 269 this.setLexCondition(this._lexConditions.INITIAL); 227 270 this.tokenType = null; … … 243 286 } 244 287 // Do not tokenize script tag contents. 288 return cursor; 289 } 290 291 if (this._condition.parseCondition & this._parseConditions.STYLE) { 292 if (!this._internalCSSTokenizer) { 293 this._internalCSSTokenizer = WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/css"); 294 this._condition.internalCSSTokenizerCondition = this._internalCSSTokenizer.initialCondition; 295 } 296 // Do not tokenize style tag contents. 245 297 return cursor; 246 298 } … … 268 320 <TAG> Identifier 269 321 { 270 if (this._condition.parseCondition === this._parseConditions.SCRIPT ) {322 if (this._condition.parseCondition === this._parseConditions.SCRIPT || this._condition.parseCondition === this._parseConditions.STYLE) { 271 323 // Fall through if expecting attributes. 272 324 this.tokenType = null;
Note: See TracChangeset
for help on using the changeset viewer.