Parent Directory
|
Revision Log
|
Patch
| revision 1.11 by wakaba, Sun Apr 27 10:44:36 2008 UTC | revision 1.13 by wakaba, Sun Apr 27 11:27:04 2008 UTC | |
|---|---|---|
| # | Line 2 | Line 2 |
| 2 | <html lang=en> | <html lang=en> |
| 3 | <head> | <head> |
| 4 | <title>Live Scripting HTML Parser</title> | <title>Live Scripting HTML Parser</title> |
| 5 | <link rel=author href="http://suika.fam.cx/~wakaba/who?"> | |
| 6 | <link rel=license href="http://suika.fam.cx/c/gnu/gpl" | |
| 7 | title="GNU GPL2 or later"> | |
| 8 | <style> | <style> |
| 9 | h1, h2 { | h1 { |
| 10 | margin: 0; | |
| 11 | font-size: 150%; | |
| 12 | } | |
| 13 | h2 { | |
| 14 | margin: 0; | margin: 0; |
| 15 | font-size: 100%; | font-size: 100%; |
| 16 | } | } |
| 17 | p, pre { | p { |
| 18 | margin: 0; | margin: 0 1em; |
| 19 | } | } |
| 20 | textarea { | textarea { |
| 21 | width: 100%; | width: 100%; |
| # | Line 79 | Line 86 |
| 86 | this.input = i; | this.input = i; |
| 87 | this.scriptsExecutedAfterParsing = []; | this.scriptsExecutedAfterParsing = []; |
| 88 | this.scriptsExecutedSoon = []; | this.scriptsExecutedSoon = []; |
| 89 | this.scriptsExecutedAsynchronously = []; | |
| 90 | } // Parser | } // Parser |
| 91 | ||
| 92 | Parser.prototype.getNextToken = function () { | Parser.prototype.getNextToken = function () { |
| # | Line 335 | Line 343 |
| 343 | ||
| 344 | // "When a script completes loading" rules start applying. | // "When a script completes loading" rules start applying. |
| 345 | ||
| 346 | // List of scripts that will execute as soon as possible | while (this.scriptsExecutedSoon.length > 0 || |
| 347 | for (var i = 0; i < this.scriptsExecutedSoon.length; i++) { | this.scriptsExecutedAsynchronously.length > 0) { |
| 348 | var e = this.scriptsExecutedSoon[i]; | // Handle "list of scripts that will execute as soon as possible". |
| 349 | while (this.scriptsExecutedSoon.length > 0) { | |
| 350 | // If it has completed loading | var e = this.scriptsExecutedSoon.shift (); |
| 351 | log ('Execute an external script not inserted by parser...'); | |
| 352 | executeScript (this.doc, e); | // If it has completed loading |
| 353 | log ('Execute an external script not inserted by parser...'); | |
| 354 | executeScript (this.doc, e); | |
| 355 | ||
| 356 | // NOTE: It MAY be executed before the end of the parsing, according | |
| 357 | // to the spec. | |
| 358 | this.hasAsyncScript = true; | |
| 359 | } | |
| 360 | ||
| 361 | // Handle "list of scripts that will execute asynchronously". | |
| 362 | while (this.scriptsExecutedAsynchronously.length > 0) { | |
| 363 | var e = this.scriptsExecutedAsynchronously.shift (); | |
| 364 | ||
| 365 | // Step 1. | |
| 366 | // We assume that all scripts have been loaded at this time. | |
| 367 | ||
| 368 | // Step 2. | |
| 369 | log ('Execute an asynchronous script...'); | |
| 370 | executeScript (this.doc, e); | |
| 371 | ||
| 372 | // Step 3. | |
| 373 | // | |
| 374 | ||
| 375 | // Step 4. | |
| 376 | // | |
| 377 | ||
| 378 | // NOTE: It MAY be executed before the end of the parsing, according | this.hasAsyncScript = true; |
| 379 | // to the spec. | } |
| this.hasAsyncScript = true; | ||
| 380 | } | } |
| 381 | ||
| // TODO: Handles | ||
| // "list of scripts that will execute asynchronously" | ||
| 382 | // Handle "list of scripts that will execute when the document has finished | // Handle "list of scripts that will execute when the document has finished |
| 383 | // parsing". | // parsing". |
| 384 | var list = this.scriptsExecutedAfterParsing; | var list = this.scriptsExecutedAfterParsing; |
| # | Line 444 | Line 472 |
| 472 | p.scriptsExecutedAfterParsing.push (e); | p.scriptsExecutedAfterParsing.push (e); |
| 473 | log ('Running a script: aborted (defer)'); | log ('Running a script: aborted (defer)'); |
| 474 | } else if (e.async && e.src != null) { | } else if (e.async && e.src != null) { |
| 475 | // TODO | p.scriptsExecutedAsynchronously.push (e); |
| 476 | } else if (e.async && e.src == null | log ('Running a script: aborted (async src)'); |
| 477 | /* && list of scripts that will execute asynchronously is not empty */) { | } else if (e.async && e.src == null && |
| 478 | // TODO | p.scriptsExecutedAsynchronously.length > 0) { |
| 479 | p.scriptsExecutedAsynchronously.push (e); | |
| 480 | log ('Running a script: aborted (async)'); | |
| 481 | // ISSUE: What is the difference with the case above? | |
| 482 | } else if (e.src != null && e.manakaiParserInserted) { | } else if (e.src != null && e.manakaiParserInserted) { |
| 483 | if (p.scriptExecutedWhenParserResumes) { | if (p.scriptExecutedWhenParserResumes) { |
| 484 | log ('Error: There is a script that will execute as soon as the parser resumes.'); | log ('Error: There is a script that will execute as soon as the parser resumes.'); |
| # | Line 792 the <abbr title="Uniform Resource Id |