Title: [143797] trunk/Source/WebCore
- Revision
- 143797
- Author
- aba...@webkit.org
- Date
- 2013-02-22 14:17:49 -0800 (Fri, 22 Feb 2013)
Log Message
Threaded HTML parser should pass fast/parser/iframe-sets-parent-to-_javascript_-url.html
https://bugs.webkit.org/show_bug.cgi?id=110637
Reviewed by Eric Seidel.
With the main thread parser, we always parse the first chunk of content
returned as the result of evaluating a _javascript_ URL synchronously. In
particular, if the first chunk has an inline script, we'll execute it
synchronously.
Previous to this patch, the threaded parser would always parse this
content asynchronously. It's conceivable that there could be some
content relying on the synchronous behavior, so this patch introduces
the notion of "pinning" a parser to the main thread and uses that
concept to force the result of _javascript_ URLs to be parsed on the main
thread (which is probably desirable anyway because they're likely to be
quite short).
This patch fixes fast/parser/iframe-sets-parent-to-_javascript_-url.html
and fast/dom/_javascript_-url-crash-function.html with the threaded
parser with --enable-threaded-html-parser.
* dom/DocumentParser.h:
(WebCore::DocumentParser::pinToMainThread):
(DocumentParser):
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::HTMLDocumentParser):
(WebCore):
(WebCore::HTMLDocumentParser::pinToMainThread):
* html/parser/HTMLDocumentParser.h:
(HTMLDocumentParser):
(WebCore::HTMLDocumentParser::shouldUseThreading):
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::replaceDocument):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (143796 => 143797)
--- trunk/Source/WebCore/ChangeLog 2013-02-22 22:16:43 UTC (rev 143796)
+++ trunk/Source/WebCore/ChangeLog 2013-02-22 22:17:49 UTC (rev 143797)
@@ -1,3 +1,40 @@
+2013-02-22 Adam Barth <aba...@webkit.org>
+
+ Threaded HTML parser should pass fast/parser/iframe-sets-parent-to-_javascript_-url.html
+ https://bugs.webkit.org/show_bug.cgi?id=110637
+
+ Reviewed by Eric Seidel.
+
+ With the main thread parser, we always parse the first chunk of content
+ returned as the result of evaluating a _javascript_ URL synchronously. In
+ particular, if the first chunk has an inline script, we'll execute it
+ synchronously.
+
+ Previous to this patch, the threaded parser would always parse this
+ content asynchronously. It's conceivable that there could be some
+ content relying on the synchronous behavior, so this patch introduces
+ the notion of "pinning" a parser to the main thread and uses that
+ concept to force the result of _javascript_ URLs to be parsed on the main
+ thread (which is probably desirable anyway because they're likely to be
+ quite short).
+
+ This patch fixes fast/parser/iframe-sets-parent-to-_javascript_-url.html
+ and fast/dom/_javascript_-url-crash-function.html with the threaded
+ parser with --enable-threaded-html-parser.
+
+ * dom/DocumentParser.h:
+ (WebCore::DocumentParser::pinToMainThread):
+ (DocumentParser):
+ * html/parser/HTMLDocumentParser.cpp:
+ (WebCore::HTMLDocumentParser::HTMLDocumentParser):
+ (WebCore):
+ (WebCore::HTMLDocumentParser::pinToMainThread):
+ * html/parser/HTMLDocumentParser.h:
+ (HTMLDocumentParser):
+ (WebCore::HTMLDocumentParser::shouldUseThreading):
+ * loader/DocumentWriter.cpp:
+ (WebCore::DocumentWriter::replaceDocument):
+
2013-02-22 Joe Mason <jma...@rim.com>
[BlackBerry] Reread cookies when retrying a request with new auth credentials
Modified: trunk/Source/WebCore/dom/DocumentParser.h (143796 => 143797)
--- trunk/Source/WebCore/dom/DocumentParser.h 2013-02-22 22:16:43 UTC (rev 143796)
+++ trunk/Source/WebCore/dom/DocumentParser.h 2013-02-22 22:17:49 UTC (rev 143797)
@@ -49,6 +49,8 @@
virtual void appendBytes(DocumentWriter*, const char* bytes, size_t length) = 0;
virtual void flush(DocumentWriter*) = 0;
+ virtual void pinToMainThread() { }
+
// FIXME: append() should be private, but DocumentWriter::replaceDocument
// uses it for now.
virtual void append(const SegmentedString&) = 0;
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (143796 => 143797)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2013-02-22 22:16:43 UTC (rev 143796)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2013-02-22 22:17:49 UTC (rev 143797)
@@ -89,6 +89,7 @@
, m_weakFactory(this)
#endif
, m_preloader(adoptPtr(new HTMLResourcePreloader(document)))
+ , m_isPinnedToMainThread(false)
, m_endWasDelayed(false)
, m_haveBackgroundParser(false)
, m_pumpSessionNestingLevel(0)
@@ -108,6 +109,7 @@
#if ENABLE(THREADED_HTML_PARSER)
, m_weakFactory(this)
#endif
+ , m_isPinnedToMainThread(true)
, m_endWasDelayed(false)
, m_haveBackgroundParser(false)
, m_pumpSessionNestingLevel(0)
@@ -126,6 +128,19 @@
ASSERT(!m_haveBackgroundParser);
}
+#if ENABLE(THREADED_HTML_PARSER)
+void HTMLDocumentParser::pinToMainThread()
+{
+ ASSERT(!m_haveBackgroundParser);
+ ASSERT(!m_tokenizer);
+ ASSERT(!m_token);
+ ASSERT(!m_isPinnedToMainThread);
+ m_isPinnedToMainThread = true;
+ m_token = adoptPtr(new HTMLToken);
+ m_tokenizer = HTMLTokenizer::create(m_options);
+}
+#endif
+
void HTMLDocumentParser::detach()
{
#if ENABLE(THREADED_HTML_PARSER)
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.h (143796 => 143797)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2013-02-22 22:16:43 UTC (rev 143796)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2013-02-22 22:17:49 UTC (rev 143797)
@@ -96,9 +96,9 @@
#endif
protected:
- virtual void insert(const SegmentedString&);
- virtual void append(const SegmentedString&);
- virtual void finish();
+ virtual void insert(const SegmentedString&) OVERRIDE;
+ virtual void append(const SegmentedString&) OVERRIDE;
+ virtual void finish() OVERRIDE;
HTMLDocumentParser(HTMLDocument*, bool reportErrors);
HTMLDocumentParser(DocumentFragment*, Element* contextElement, FragmentScriptingPermission);
@@ -114,21 +114,24 @@
}
// DocumentParser
- virtual void detach();
- virtual bool hasInsertionPoint();
- virtual bool processingData() const;
- virtual void prepareToStopParsing();
- virtual void stopParsing();
- virtual bool isWaitingForScripts() const;
- virtual bool isExecutingScript() const;
- virtual void executeScriptsWaitingForStylesheets();
+#if ENABLE(THREADED_HTML_PARSER)
+ virtual void pinToMainThread() OVERRIDE;
+#endif
+ virtual void detach() OVERRIDE;
+ virtual bool hasInsertionPoint() OVERRIDE;
+ virtual bool processingData() const OVERRIDE;
+ virtual void prepareToStopParsing() OVERRIDE;
+ virtual void stopParsing() OVERRIDE;
+ virtual bool isWaitingForScripts() const OVERRIDE;
+ virtual bool isExecutingScript() const OVERRIDE;
+ virtual void executeScriptsWaitingForStylesheets() OVERRIDE;
// HTMLScriptRunnerHost
- virtual void watchForLoad(CachedResource*);
- virtual void stopWatchingForLoad(CachedResource*);
+ virtual void watchForLoad(CachedResource*) OVERRIDE;
+ virtual void stopWatchingForLoad(CachedResource*) OVERRIDE;
virtual HTMLInputStream& inputStream() { return m_input; }
virtual bool hasPreloadScanner() const { return m_preloadScanner.get() && !shouldUseThreading(); }
- virtual void appendCurrentInputStreamToPreloadScannerAndScan();
+ virtual void appendCurrentInputStreamToPreloadScannerAndScan() OVERRIDE;
// CachedResourceClient
virtual void notifyFinished(CachedResource*);
@@ -163,7 +166,7 @@
void attemptToRunDeferredScriptsAndEnd();
void end();
- bool shouldUseThreading() const { return m_options.useThreading && !isParsingFragment(); }
+ bool shouldUseThreading() const { return m_options.useThreading && !m_isPinnedToMainThread; }
bool isParsingFragment() const;
bool isScheduledForResume() const;
@@ -195,6 +198,7 @@
#endif
OwnPtr<HTMLResourcePreloader> m_preloader;
+ bool m_isPinnedToMainThread;
bool m_endWasDelayed;
bool m_haveBackgroundParser;
unsigned m_pumpSessionNestingLevel;
Modified: trunk/Source/WebCore/loader/DocumentWriter.cpp (143796 => 143797)
--- trunk/Source/WebCore/loader/DocumentWriter.cpp 2013-02-22 22:16:43 UTC (rev 143796)
+++ trunk/Source/WebCore/loader/DocumentWriter.cpp 2013-02-22 22:17:49 UTC (rev 143797)
@@ -78,8 +78,10 @@
// FIXME: This should call DocumentParser::appendBytes instead of append
// to support RawDataDocumentParsers.
- if (DocumentParser* parser = m_frame->document()->parser())
+ if (DocumentParser* parser = m_frame->document()->parser()) {
+ parser->pinToMainThread();
parser->append(source);
+ }
}
end();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes