diff options
Diffstat (limited to 'WebCore/html/HTMLTokenizer.cpp')
-rw-r--r-- | WebCore/html/HTMLTokenizer.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/WebCore/html/HTMLTokenizer.cpp b/WebCore/html/HTMLTokenizer.cpp index 7c01f6a..c38a9be 100644 --- a/WebCore/html/HTMLTokenizer.cpp +++ b/WebCore/html/HTMLTokenizer.cpp @@ -43,6 +43,7 @@ #include "HTMLParser.h" #include "HTMLScriptElement.h" #include "HTMLViewSourceDocument.h" +#include "ImageLoader.h" #include "InspectorTimelineAgent.h" #include "MappedAttribute.h" #include "Page.h" @@ -419,13 +420,13 @@ HTMLTokenizer::State HTMLTokenizer::parseNonHTMLText(SegmentedString& src, State return state; } - + HTMLTokenizer::State HTMLTokenizer::scriptHandler(State state) { // We are inside a <script> bool doScriptExec = false; int startLine = m_currentScriptTagStartLineNumber + 1; // Script line numbers are 1 based, HTMLTokenzier line numbers are 0 based - + // Reset m_currentScriptTagStartLineNumber to indicate that we've finished parsing the current script element m_currentScriptTagStartLineNumber = 0; @@ -562,7 +563,13 @@ HTMLTokenizer::State HTMLTokenizer::scriptExecution(const ScriptSourceCode& sour if (m_fragment || !m_doc->frame()) return state; m_executingScript++; - + +#if ENABLE(INSPECTOR) + InspectorTimelineAgent* timelineAgent = m_doc->inspectorTimelineAgent(); + if (timelineAgent) + timelineAgent->willEvaluateScriptTag(sourceCode.url().isNull() ? String() : sourceCode.url().string(), sourceCode.startLine()); +#endif + SegmentedString* savedPrependingSrc = m_currentPrependingSrc; SegmentedString prependingSrc; m_currentPrependingSrc = &prependingSrc; @@ -573,7 +580,7 @@ HTMLTokenizer::State HTMLTokenizer::scriptExecution(const ScriptSourceCode& sour #endif m_state = state; - m_doc->frame()->loader()->executeScript(sourceCode); + m_doc->frame()->script()->executeScript(sourceCode); state = m_state; state.setAllowYield(true); @@ -619,7 +626,12 @@ HTMLTokenizer::State HTMLTokenizer::scriptExecution(const ScriptSourceCode& sour } m_currentPrependingSrc = savedPrependingSrc; - + +#if ENABLE(INSPECTOR) + if (timelineAgent) + timelineAgent->didEvaluateScriptTag(); +#endif + return state; } @@ -1624,7 +1636,7 @@ inline bool HTMLTokenizer::continueProcessing(int& processedCount, double startT processedCount++; return true; } - + void HTMLTokenizer::write(const SegmentedString& str, bool appendData) { if (!m_buffer) @@ -1821,6 +1833,9 @@ void HTMLTokenizer::write(const SegmentedString& str, bool appendData) if (m_noMoreData && !m_inWrite && !state.loadingExtScript() && !m_executingScript && !m_timer.isActive()) end(); // this actually causes us to be deleted + + // After parsing, go ahead and dispatch image beforeload/load events. + ImageLoader::dispatchPendingEvents(); } void HTMLTokenizer::stopParsing() @@ -2005,6 +2020,14 @@ void HTMLTokenizer::enlargeScriptBuffer(int len) CRASH(); int newSize = m_scriptCodeCapacity + delta; + // If we allow fastRealloc(ptr, 0), it will call CRASH(). We run into this + // case if the HTML being parsed begins with "<!--" and there's more data + // coming. + if (!newSize) { + ASSERT(!m_scriptCode); + return; + } + m_scriptCode = static_cast<UChar*>(fastRealloc(m_scriptCode, newSize * sizeof(UChar))); m_scriptCodeCapacity = newSize; } |