Parent Directory
|
Revision Log
|
Patch
| revision 1.10 by wakaba, Sun Apr 27 10:34:18 2008 UTC | revision 1.12 by wakaba, Sun Apr 27 11:21:09 2008 UTC | |
|---|---|---|
| # | Line 79 | Line 79 |
| 79 | this.input = i; | this.input = i; |
| 80 | this.scriptsExecutedAfterParsing = []; | this.scriptsExecutedAfterParsing = []; |
| 81 | this.scriptsExecutedSoon = []; | this.scriptsExecutedSoon = []; |
| 82 | this.scriptsExecutedAsynchronously = []; | |
| 83 | } // Parser | } // Parser |
| 84 | ||
| 85 | Parser.prototype.getNextToken = function () { | Parser.prototype.getNextToken = function () { |
| # | Line 335 | Line 336 |
| 336 | ||
| 337 | // "When a script completes loading" rules start applying. | // "When a script completes loading" rules start applying. |
| 338 | ||
| 339 | // List of scripts that will execute as soon as possible | while (this.scriptsExecutedSoon.length > 0 || |
| 340 | for (var i = 0; i < this.scriptsExecutedSoon.length; i++) { | this.scriptsExecutedAsynchronously.length > 0) { |
| 341 | var e = this.scriptsExecutedSoon[i]; | // Handle "list of scripts that will execute as soon as possible". |
| 342 | while (this.scriptsExecutedSoon.length > 0) { | |
| 343 | var e = this.scriptsExecutedSoon.shift (); | |
| 344 | ||
| 345 | // If it has completed loading | |
| 346 | log ('Execute an external script not inserted by parser...'); | |
| 347 | executeScript (this.doc, e); | |
| 348 | ||
| 349 | // NOTE: It MAY be executed before the end of the parsing, according | |
| 350 | // to the spec. | |
| 351 | this.hasAsyncScript = true; | |
| 352 | } | |
| 353 | ||
| 354 | // Handle "list of scripts that will execute asynchronously". | |
| 355 | while (this.scriptsExecutedAsynchronously.length > 0) { | |
| 356 | var e = this.scriptsExecutedAsynchronously.shift (); | |
| 357 | ||
| 358 | // Step 1. | |
| 359 | // We assume that all scripts have been loaded at this time. | |
| 360 | ||
| 361 | // Step 2. | |
| 362 | log ('Execute an asynchronous script...'); | |
| 363 | executeScript (this.doc, e); | |
| 364 | ||
| 365 | // Step 3. | |
| 366 | // | |
| 367 | ||
| 368 | // Step 4. | |
| 369 | // | |
| 370 | ||
| 371 | // If it has completed loading | this.hasAsyncScript = true; |
| 372 | log ('Execute an external script not inserted by parser...'); | } |
| executeScript (this.doc, e); | ||
| // NOTE: It MAY be executed before the end of the parsing, according | ||
| // to the spec. | ||
| this.hasAsyncScript = true; | ||
| 373 | } | } |
| 374 | ||
| // TODO: Handles | ||
| // "list of scripts that will execute asynchronously" | ||
| 375 | // Handle "list of scripts that will execute when the document has finished | // Handle "list of scripts that will execute when the document has finished |
| 376 | // parsing". | // parsing". |
| 377 | var list = this.scriptsExecutedAfterParsing; | var list = this.scriptsExecutedAfterParsing; |
| # | Line 444 | Line 465 |
| 465 | p.scriptsExecutedAfterParsing.push (e); | p.scriptsExecutedAfterParsing.push (e); |
| 466 | log ('Running a script: aborted (defer)'); | log ('Running a script: aborted (defer)'); |
| 467 | } else if (e.async && e.src != null) { | } else if (e.async && e.src != null) { |
| 468 | // TODO | p.scriptsExecutedAsynchronously.push (e); |
| 469 | } else if (e.async && e.src == null | log ('Running a script: aborted (async src)'); |
| 470 | /* && list of scripts that will execute asynchronously is not empty */) { | } else if (e.async && e.src == null && |
| 471 | // TODO | p.scriptsExecutedAsynchronously.length > 0) { |
| 472 | p.scriptsExecutedAsynchronously.push (e); | |
| 473 | log ('Running a script: aborted (async)'); | |
| 474 | // ISSUE: What is the difference with the case above? | |
| 475 | } else if (e.src != null && e.manakaiParserInserted) { | } else if (e.src != null && e.manakaiParserInserted) { |