Title: [143828] trunk/Source/WebCore
Revision
143828
Author
to...@chromium.org
Date
2013-02-22 19:14:36 -0800 (Fri, 22 Feb 2013)

Log Message

Correct InspectorInstrumentation for background HTML parser
https://bugs.webkit.org/show_bug.cgi?id=110678

Reviewed by Adam Barth.

resumeParsingAfterScriptExecution potentially calls processParsedChunkFromBackgroundParser multiple times
without yielding. So it is not correct to count each of those as a separate ParseHTML event.

This patch moves the instrumentation outside of the loop.

No new tests because no new functionality.

* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser):
(WebCore::HTMLDocumentParser::processParsedChunkFromBackgroundParser):
(WebCore::HTMLDocumentParser::resumeParsingAfterScriptExecution):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (143827 => 143828)


--- trunk/Source/WebCore/ChangeLog	2013-02-23 02:54:40 UTC (rev 143827)
+++ trunk/Source/WebCore/ChangeLog	2013-02-23 03:14:36 UTC (rev 143828)
@@ -1,3 +1,22 @@
+2013-02-22  Tony Gentilcore  <to...@chromium.org>
+
+        Correct InspectorInstrumentation for background HTML parser
+        https://bugs.webkit.org/show_bug.cgi?id=110678
+
+        Reviewed by Adam Barth.
+
+        resumeParsingAfterScriptExecution potentially calls processParsedChunkFromBackgroundParser multiple times
+        without yielding. So it is not correct to count each of those as a separate ParseHTML event.
+
+        This patch moves the instrumentation outside of the loop.
+
+        No new tests because no new functionality.
+
+        * html/parser/HTMLDocumentParser.cpp:
+        (WebCore::HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser):
+        (WebCore::HTMLDocumentParser::processParsedChunkFromBackgroundParser):
+        (WebCore::HTMLDocumentParser::resumeParsingAfterScriptExecution):
+
 2013-02-22  Aaron Colwell  <acolw...@chromium.org>
 
         Factor MediaSource methods out of MediaPlayer & MediaPlayerPrivate and into a new MediaSourcePrivate interface.

Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (143827 => 143828)


--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp	2013-02-23 02:54:40 UTC (rev 143827)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp	2013-02-23 03:14:36 UTC (rev 143828)
@@ -307,9 +307,19 @@
         m_speculations.append(chunk);
         return;
     }
+
+    // processParsedChunkFromBackgroundParser can cause this parser to be detached from the Document,
+    // but we need to ensure it isn't deleted yet.
+    RefPtr<HTMLDocumentParser> protect(this);
+
+    // FIXME: Pass in current input length.
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteHTML(document(), 0, lineNumber().zeroBasedInt());
+
     ASSERT(m_speculations.isEmpty());
     chunk->preloads.clear(); // We don't need to preload because we're going to parse immediately.
     processParsedChunkFromBackgroundParser(chunk);
+
+    InspectorInstrumentation::didWriteHTML(cookie, lineNumber().zeroBasedInt());
 }
 
 void HTMLDocumentParser::checkForSpeculationFailure()
@@ -347,18 +357,11 @@
 {
     ASSERT(shouldUseThreading());
 
-    // This method can cause this parser to be detached from the Document,
-    // but we need to ensure it isn't deleted yet.
-    RefPtr<HTMLDocumentParser> protect(this);
-
     ActiveParserSession session(contextForParsingSession());
 
     m_currentChunk = chunk;
     OwnPtr<CompactHTMLTokenStream> tokens = m_currentChunk->tokens.release();
 
-    // FIXME: Pass in current input length.
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteHTML(document(), 0, lineNumber().zeroBasedInt());
-
     for (Vector<CompactHTMLToken>::const_iterator it = tokens->begin(); it != tokens->end(); ++it) {
         ASSERT(!isWaitingForScripts());
 
@@ -389,8 +392,6 @@
     }
 
     checkForSpeculationFailure();
-
-    InspectorInstrumentation::didWriteHTML(cookie, lineNumber().zeroBasedInt());
 }
 
 #endif // ENABLE(THREADED_HTML_PARSER)
@@ -791,11 +792,21 @@
     if (m_haveBackgroundParser) {
         checkForSpeculationFailure();
 
+        // processParsedChunkFromBackgroundParser can cause this parser to be detached from the Document,
+        // but we need to ensure it isn't deleted yet.
+        RefPtr<HTMLDocumentParser> protect(this);
+
+        // FIXME: Pass in current input length.
+        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteHTML(document(), 0, lineNumber().zeroBasedInt());
+
         while (!m_speculations.isEmpty()) {
             processParsedChunkFromBackgroundParser(m_speculations.takeFirst());
             if (isWaitingForScripts() || isStopped())
-                return;
+                break;
         }
+
+        InspectorInstrumentation::didWriteHTML(cookie, lineNumber().zeroBasedInt());
+
         return;
     }
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to