Changeset 142363 in webkit
- Timestamp:
- Feb 9, 2013 9:52:19 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r142359 r142363 1 2013-02-09 Eric Seidel <eric@webkit.org> 2 3 Fix TextDocumentParser to play nice with threading 4 https://bugs.webkit.org/show_bug.cgi?id=109240 5 6 Reviewed by Adam Barth. 7 8 Before the HTML5 parser re-write the text document parser 9 was completely custom. With the HTML5 parser, we just made 10 the TextDocumentParser use the HTMLDocumentParser with an 11 artificial script tag. 12 13 However, our solution was slightly over-engineered to avoid 14 lying about the column numbers of the first line of the text document 15 during parsing. :) 16 17 This change makes us use a simpler (and threading-compatible) 18 solution by just inserting a real "<pre>" tag into the 19 input stream instead of hacking one together with the treebuilder 20 and manually setting the Tokenizer state. 21 22 fast/parser/empty-text-resource.html covers this case. 23 24 * html/parser/TextDocumentParser.cpp: 25 (WebCore::TextDocumentParser::TextDocumentParser): 26 (WebCore::TextDocumentParser::insertFakePreElement): 27 1 28 2013-02-09 Kent Tamura <tkent@chromium.org> 2 29 -
trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp
r142305 r142363 97 97 } 98 98 99 void BackgroundHTMLParser::forcePlaintextForTextDocument() 100 { 101 // This is only used by the TextDocumentParser (a subclass of HTMLDocumentParser) 102 // to force us into the PLAINTEXT state w/o using a <plaintext> tag. 103 // The TextDocumentParser uses a <pre> tag for historical/compatibility reasons. 104 m_tokenizer->setState(HTMLTokenizerState::PLAINTEXTState); 105 } 106 99 107 void BackgroundHTMLParser::markEndOfFile() 100 108 { -
trunk/Source/WebCore/html/parser/BackgroundHTMLParser.h
r142305 r142363 59 59 void stop(); 60 60 61 void forcePlaintextForTextDocument(); 62 61 63 private: 62 64 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser> >, const HTMLParserOptions&, const WeakPtr<HTMLDocumentParser>&, PassOwnPtr<XSSAuditor>); -
trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp
r142305 r142363 356 356 #endif // ENABLE(THREADED_HTML_PARSER) 357 357 358 void HTMLDocumentParser::forcePlaintextForTextDocument() 359 { 360 #if ENABLE(THREADED_HTML_PARSER) 361 if (shouldUseThreading()) { 362 // This method is called before any data is appended, so we have to start 363 // the background parser ourselves. 364 if (!m_haveBackgroundParser) 365 startBackgroundParser(); 366 367 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::forcePlaintextForTextDocument, m_backgroundParser)); 368 } else 369 #endif 370 m_tokenizer->setState(HTMLTokenizerState::PLAINTEXTState); 371 } 372 358 373 void HTMLDocumentParser::pumpTokenizer(SynchronousMode mode) 359 374 { -
trunk/Source/WebCore/html/parser/HTMLDocumentParser.h
r142305 r142363 102 102 HTMLTreeBuilder* treeBuilder() const { return m_treeBuilder.get(); } 103 103 104 void forcePlaintextForTextDocument(); 105 104 106 private: 105 107 static PassRefPtr<HTMLDocumentParser> create(DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission permission) -
trunk/Source/WebCore/html/parser/TextDocumentParser.cpp
r141328 r142363 39 39 , m_haveInsertedFakePreElement(false) 40 40 { 41 // FIXME: If we're using threading, we need to tell the BackgroundHTMLParser to use PLAINTEXTState.42 if (tokenizer())43 tokenizer()->setState(HTMLTokenizerState::PLAINTEXTState);44 41 } 45 42 … … 62 59 // sending fake bytes through the front-end of the parser to avoid 63 60 // distrubing the line/column number calculations. 64 65 61 Vector<Attribute> attributes; 66 62 attributes.append(Attribute(styleAttr, "word-wrap: break-word; white-space: pre-wrap;")); 67 63 RefPtr<AtomicHTMLToken> fakePre = AtomicHTMLToken::create(HTMLTokenTypes::StartTag, preTag.localName(), attributes); 64 treeBuilder()->constructTree(fakePre.get()); 68 65 69 treeBuilder()->constructTree(fakePre.get());70 66 // Normally we would skip the first \n after a <pre> element, but we don't 71 67 // want to skip the first \n for text documents! 72 68 treeBuilder()->setShouldSkipLeadingNewline(false); 69 70 // Although Text Documents expose a "pre" element in their DOM, they 71 // act like a <plaintext> tag, so we have to force plaintext mode. 72 forcePlaintextForTextDocument(); 73 73 74 74 m_haveInsertedFakePreElement = true;
Note: See TracChangeset
for help on using the changeset viewer.