Changeset 142673 in webkit
- Timestamp:
- Feb 12, 2013 2:44:25 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r142669 r142673 1 2013-02-12 Adam Barth <abarth@webkit.org> 2 3 Threaded HTML parser should pass the remaining fast/tokenizer tests 4 https://bugs.webkit.org/show_bug.cgi?id=109607 5 6 Reviewed by Eric Seidel. 7 8 This patch fixes some edge cases involving document.write. Previously, 9 we would drop input characters on the floor if the tokenizer wasn't 10 able to consume them synchronously. In this patch, we send the unparsed 11 characters to the background thread for consumption after rewinding the 12 input stream. 13 14 * html/parser/BackgroundHTMLInputStream.cpp: 15 (WebCore::BackgroundHTMLInputStream::rewindTo): 16 * html/parser/BackgroundHTMLInputStream.h: 17 (BackgroundHTMLInputStream): 18 * html/parser/BackgroundHTMLParser.cpp: 19 (WebCore::BackgroundHTMLParser::resumeFrom): 20 * html/parser/BackgroundHTMLParser.h: 21 (Checkpoint): 22 * html/parser/HTMLDocumentParser.cpp: 23 (WebCore::HTMLDocumentParser::canTakeNextToken): 24 (WebCore::HTMLDocumentParser::didFailSpeculation): 25 (WebCore::HTMLDocumentParser::pumpTokenizer): 26 (WebCore::HTMLDocumentParser::finish): 27 * html/parser/HTMLInputStream.h: 28 (WebCore::HTMLInputStream::closeWithoutMarkingEndOfFile): 29 (HTMLInputStream): 30 1 31 2013-02-12 Csaba Osztrogonác <ossy@webkit.org> 2 32 -
trunk/Source/WebCore/html/parser/BackgroundHTMLInputStream.cpp
r141363 r142673 54 54 } 55 55 56 void BackgroundHTMLInputStream::rewindTo(HTMLInputCheckpoint checkpointIndex )56 void BackgroundHTMLInputStream::rewindTo(HTMLInputCheckpoint checkpointIndex, const String& unparsedInput) 57 57 { 58 ASSERT(checkpointIndex < m_checkpoints.size()); // If this ASSERT fires, checkpointIndex is invalid. 58 59 const Checkpoint& checkpoint = m_checkpoints[checkpointIndex]; 59 60 … … 61 62 62 63 m_current = checkpoint.input; 64 63 65 for (size_t i = checkpoint.numberOfSegmentsAlreadyAppended; i < m_segments.size(); ++i) 64 66 m_current.append(SegmentedString(m_segments[i])); 65 67 68 if (!unparsedInput.isEmpty()) 69 m_current.prepend(SegmentedString(unparsedInput)); 70 66 71 if (isClosed && !m_current.isClosed()) 67 72 m_current.close(); 73 74 // FIXME: We should be able to actively invalidate all the outstanding checkpoints 75 // by clearing m_segments and m_checkpoints, but that causes 76 // fast/tokenizer/write-before-load.html to hit the ASSERT at the beginning of 77 // this function. 68 78 } 69 79 -
trunk/Source/WebCore/html/parser/BackgroundHTMLInputStream.h
r141363 r142673 47 47 SegmentedString& current() { return m_current; } 48 48 49 // An HTMLInputCheckpoint is valid until the next call to rewindTo, at which 50 // point all outstanding checkpoints are invalidated. 49 51 HTMLInputCheckpoint createCheckpoint(); 50 void rewindTo(HTMLInputCheckpoint );52 void rewindTo(HTMLInputCheckpoint, const String& unparsedInput); 51 53 52 54 private: -
trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp
r142648 r142673 82 82 m_token = checkpoint->token.release(); 83 83 m_tokenizer = checkpoint->tokenizer.release(); 84 m_input.rewindTo(checkpoint->inputCheckpoint );84 m_input.rewindTo(checkpoint->inputCheckpoint, checkpoint->unparsedInput); 85 85 pumpTokenizer(); 86 86 } -
trunk/Source/WebCore/html/parser/BackgroundHTMLParser.h
r142648 r142673 59 59 OwnPtr<HTMLTokenizer> tokenizer; 60 60 HTMLInputCheckpoint inputCheckpoint; 61 String unparsedInput; 61 62 }; 62 63 -
trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp
r142648 r142673 250 250 return false; 251 251 252 ASSERT(! shouldUseThreading()|| mode == ForceSynchronous);252 ASSERT(!m_haveBackgroundParser || mode == ForceSynchronous); 253 253 254 254 if (isWaitingForScripts()) { … … 313 313 checkpoint->tokenizer = tokenizer; 314 314 checkpoint->inputCheckpoint = m_currentChunk->checkpoint; 315 315 checkpoint->unparsedInput = m_input.current().toString().isolatedCopy(); 316 m_input.current().clear(); 317 318 ASSERT(checkpoint->unparsedInput.isSafeToSendToAnotherThread()); 316 319 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::resumeFrom, m_backgroundParser, checkpoint.release())); 317 320 } … … 401 404 ASSERT(m_tokenizer); 402 405 ASSERT(m_token); 403 ASSERT(! shouldUseThreading()|| mode == ForceSynchronous);406 ASSERT(!m_haveBackgroundParser || mode == ForceSynchronous); 404 407 405 408 PumpSession session(m_pumpSessionNestingLevel, contextForParsingSession()); … … 672 675 // However, FrameLoader::stop calls DocumentParser::finish unconditionally. 673 676 674 // We're not going to get any more data off the network, so we tell the675 // input stream we've reached the end of file. finish() can be called more676 // than once, if the first time does not call end().677 if (!m_input.haveSeenEndOfFile())678 m_input.markEndOfFile();679 680 677 #if ENABLE(THREADED_HTML_PARSER) 681 678 // Empty documents never got an append() call, and thus have never started … … 683 680 // and fall through to the non-threading case. 684 681 if (m_haveBackgroundParser) { 682 if (!m_input.haveSeenEndOfFile()) 683 m_input.closeWithoutMarkingEndOfFile(); 685 684 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::finish, m_backgroundParser)); 686 685 return; 687 686 } 687 688 688 if (shouldUseThreading() && !wasCreatedByScript()) { 689 689 ASSERT(!m_tokenizer && !m_token); … … 695 695 } 696 696 #endif 697 698 // We're not going to get any more data off the network, so we tell the 699 // input stream we've reached the end of file. finish() can be called more 700 // than once, if the first time does not call end(). 701 if (!m_input.haveSeenEndOfFile()) 702 m_input.markEndOfFile(); 697 703 698 704 attemptToEnd(); -
trunk/Source/WebCore/html/parser/HTMLInputStream.h
r142497 r142673 78 78 } 79 79 80 void closeWithoutMarkingEndOfFile() 81 { 82 m_last->close(); 83 } 84 80 85 bool haveSeenEndOfFile() const 81 86 {
Note: See TracChangeset
for help on using the changeset viewer.