Bug 107602 - HTMLTreeBuilder should not block on <script> tags inside templates
Summary: HTMLTreeBuilder should not block on <script> tags inside templates
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Adam Klein
URL:
Keywords:
Depends on:
Blocks: 154614
  Show dependency treegraph
 
Reported: 2013-01-22 17:23 PST by Adam Klein
Modified: 2022-08-17 04:48 PDT (History)
9 users (show)

See Also:


Attachments
WIP (6.79 KB, patch)
2013-01-23 15:31 PST, Adam Klein
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Klein 2013-01-22 17:23:22 PST
Because the tree builder does block, the parser kicks off a preload scanner. And because the preload scanner starts _inside_ the template, it's not able to make use of its m_templateCount counter to ignore resources it finds inside the scanner. This is what was causing the failure noted in bug 106810.

Since the tree builder knows it's in a template, it could simply avoid queueing an scripts inside the template for processing. But that might be somewhat ugly, since it requires the tree builder to "know" that scripts are inert in templates (currently that knowledge is handled at the ScriptElement level instead, by examining the <script>'s ownerDocument).
Comment 1 Adam Klein 2013-01-22 17:26:15 PST
It's possible this bug should instead be titled "HTMLPreloadScanner should be able to handle starting inside a <template>"; the title depends somewhat on how this should be fixed, which is a question I pose to our resident parser experts, eseidel and abarth.
Comment 2 Adam Barth 2013-01-22 17:27:52 PST
We're in the process of removing the HTMLPreloadScanner.  We shouldn't spend too much effort polishing these issues in the old design.
Comment 3 Adam Barth 2013-01-22 17:29:20 PST
(Maybe that argues for fixing this issue in the tree builder?)
Comment 4 Adam Klein 2013-01-23 15:31:14 PST
Created attachment 184330 [details]
WIP
Comment 5 Adam Klein 2013-01-23 15:32:39 PST
The WIP patch here unfortunately takes the approach of messing with the preload scanner's logic rather than trying to fix things in the tree builder. My first attempt at that (which was simply to avoid setting m_scriptToProcess when in template contents) didn't work, as the script wouldn't run later when attached to the page.