Bug 110517 - Make BackgroundHTMLParser rewind the preload scanner instead of clear it
Summary: Make BackgroundHTMLParser rewind the preload scanner instead of clear it
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tony Gentilcore
URL:
Keywords:
Depends on:
Blocks: 106127
  Show dependency treegraph
 
Reported: 2013-02-21 15:02 PST by Tony Gentilcore
Modified: 2013-02-21 16:23 PST (History)
5 users (show)

See Also:


Attachments
Patch (8.94 KB, patch)
2013-02-21 15:04 PST, Tony Gentilcore
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tony Gentilcore 2013-02-21 15:02:09 PST
Make BackgroundHTMLParser rewind the preload scanner instead of clear it
Comment 1 Tony Gentilcore 2013-02-21 15:04:48 PST
Created attachment 189607 [details]
Patch
Comment 2 Tony Gentilcore 2013-02-21 15:06:25 PST
Comment on attachment 189607 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=189607&action=review

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:285
> +    m_cssScanner.reset();

It looks like it is safe to just reset the CSSPreloadScanner instead of restoring any of its members, but I'm not 100% sure about this part.
Comment 3 Adam Barth 2013-02-21 15:08:58 PST
Comment on attachment 189607 [details]
Patch

Great!  Does this have any effect on the top25 benchmark?  (Just curious---not a requirement for landing.)
Comment 4 Adam Barth 2013-02-21 15:09:57 PST
Yes.  There's no way to document.write in the middle of a <style> element.
Comment 5 Eric Seidel (no email) 2013-02-21 15:10:04 PST
Comment on attachment 189607 [details]
Patch

Should this just be a state struct?  And we have one single checkpoint object?   Which has one of each state struct?  The preload scanner just has an m_state member for all its state?
Comment 6 Tony Gentilcore 2013-02-21 15:13:20 PST
(In reply to comment #5)
> (From update of attachment 189607 [details])
> Should this just be a state struct?  And we have one single checkpoint object?   Which has one of each state struct?  The preload scanner just has an m_state member for all its state?

I don't quite see where you are going. Can you please explain a bit more?
Comment 7 Tony Gentilcore 2013-02-21 15:14:30 PST
(In reply to comment #3)
> (From update of attachment 189607 [details])
> Great!  Does this have any effect on the top25 benchmark?  (Just curious---not a requirement for landing.)

I didn't run it, but it sure seems like we would have missed some preload scanning opportunities before.
Comment 8 Eric Seidel (no email) 2013-02-21 15:24:24 PST
class PreloadScanner {
    struct State {
        bool inStyle;
        int templateCount;
         ...
    }

private:
   PreloadScannerState m_state;
}

class CheckPoint {
    TokenizerState tokenizerState;
    PreloadScannerState preloadScannerState;
}
Comment 9 Tony Gentilcore 2013-02-21 15:28:10 PST
(In reply to comment #8)
> class PreloadScanner {
>     struct State {
>         bool inStyle;
>         int templateCount;
>          ...
>     }
> 
> private:
>    PreloadScannerState m_state;
> }
> 
> class CheckPoint {
>     TokenizerState tokenizerState;
>     PreloadScannerState preloadScannerState;
> }

Sure, I'll rework this
Comment 10 Eric Seidel (no email) 2013-02-21 15:31:54 PST
My review comment was more a question than anything. :)  You should use your discretion of course and do whatever you think reads best.
Comment 11 Tony Gentilcore 2013-02-21 15:32:15 PST
(In reply to comment #9)
> (In reply to comment #8)
> > class PreloadScanner {
> >     struct State {
> >         bool inStyle;
> >         int templateCount;
> >          ...
> >     }
> > 
> > private:
> >    PreloadScannerState m_state;
> > }
> > 
> > class CheckPoint {
> >     TokenizerState tokenizerState;
> >     PreloadScannerState preloadScannerState;
> > }
> 
> Sure, I'll rework this

On second thought, BackgroundHTMLInputStream's rewindTo() is a bit more involved than just copying a single state object. I'm not sure it lends itself well to this approach. I also think it is a bit awkward for the preload scanner code to have to do m_state.inStyle everywhere instead of just m_inStyle. WDYT?
Comment 12 Adam Barth 2013-02-21 15:50:49 PST
I don't think it's a big deal either way.
Comment 13 Eric Seidel (no email) 2013-02-21 15:51:13 PST
I'm not sure it matters much either way.  Just felt a bit odd at first sight to have 2 separate Checkpoint objects.
Comment 14 WebKit Review Bot 2013-02-21 16:23:17 PST
Comment on attachment 189607 [details]
Patch

Clearing flags on attachment: 189607

Committed r143661: <http://trac.webkit.org/changeset/143661>
Comment 15 WebKit Review Bot 2013-02-21 16:23:21 PST
All reviewed patches have been landed.  Closing bug.