Enable the preload scanner on the background parser thread
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Feb 2013 22:14:31 +0000 (22:14 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Feb 2013 22:14:31 +0000 (22:14 +0000)
commit75708cacb412ab3d1bdc6da4520d03c4ef7609e6
tree5976264b670c07d445196e625f93b16c943e48e9
parente331deb1fa09aabd43e2f94a6e46db44324fa2e1
Enable the preload scanner on the background parser thread
https://bugs.webkit.org/show_bug.cgi?id=108027

Reviewed by Tony Gentilcore.

The patch causes us to pass all the fast/preloader tests with the
threaded parser enabled.

This patch wires up the BackgroundHTMLParser to the
TokenPreloadScanner.  Currently, we bail out of preload scanning if we
encounter a document.write becaues we don't know how to rewind the
preload scanner, but that's something we can tune in the future.

The BackgroundHTMLParser delivers the preloads to the
HTMLDocumentParser together with the token stream. If the
HTMLDocumentParser isn't able to use the token stream immediately, it
kicks off the preloads.

* html/parser/BackgroundHTMLParser.cpp:
(WebCore::checkThatPreloadsAreSafeToSendToAnotherThread):
(WebCore::BackgroundHTMLParser::BackgroundHTMLParser):
(WebCore::BackgroundHTMLParser::resumeFrom):
(WebCore::BackgroundHTMLParser::pumpTokenizer):
(WebCore::BackgroundHTMLParser::sendTokensToMainThread):
* html/parser/BackgroundHTMLParser.h:
(Configuration):
    - We need to add a struct for the create function because the
      number of arguments exceeds the limits of Functional.h.
(BackgroundHTMLParser):
(WebCore::BackgroundHTMLParser::create):
* html/parser/CSSPreloadScanner.cpp:
(WebCore::CSSPreloadScanner::scanCommon):
(WebCore::CSSPreloadScanner::scan):
(WebCore::CSSPreloadScanner::emitRule):
    - We need to use a new string here so that the string is safe to
      send to another thread.
* html/parser/CSSPreloadScanner.h:
(CSSPreloadScanner):
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser):
(WebCore::HTMLDocumentParser::startBackgroundParser):
    - Following the example of the XSSAuditor, we create the
      TokenPreloadScanner on the main thread and then send it to the
      background thread for operation.
* html/parser/HTMLDocumentParser.h:
(WebCore):
(ParsedChunk):
* html/parser/HTMLParserOptions.h:
(HTMLParserOptions):
    - We need to add a default constructor so that the
      HTMLDocumentParser can create an empty
      BackgroundHTMLParser::Configuration struct.
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::TokenPreloadScanner::scan):
(WebCore::TokenPreloadScanner::scanCommon):
(WebCore::HTMLPreloadScanner::scan):
* html/parser/HTMLPreloadScanner.h:
(TokenPreloadScanner):
(WebCore::TokenPreloadScanner::isSafeToSendToAnotherThread):
* html/parser/HTMLResourcePreloader.cpp:
(WebCore::HTMLResourcePreloader::takeAndPreload):
(WebCore):
* html/parser/HTMLResourcePreloader.h:
(WebCore::PreloadRequest::PreloadRequest):
(WebCore):
(HTMLResourcePreloader):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143051 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/html/parser/BackgroundHTMLParser.cpp
Source/WebCore/html/parser/BackgroundHTMLParser.h
Source/WebCore/html/parser/CSSPreloadScanner.cpp
Source/WebCore/html/parser/CSSPreloadScanner.h
Source/WebCore/html/parser/HTMLDocumentParser.cpp
Source/WebCore/html/parser/HTMLDocumentParser.h
Source/WebCore/html/parser/HTMLParserOptions.h
Source/WebCore/html/parser/HTMLPreloadScanner.cpp
Source/WebCore/html/parser/HTMLPreloadScanner.h
Source/WebCore/html/parser/HTMLResourcePreloader.cpp
Source/WebCore/html/parser/HTMLResourcePreloader.h