Changeset 144801 in webkit
- Timestamp:
- Mar 5, 2013 12:44:37 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r144800 r144801 1 2013-03-05 Tony Gentilcore <tonyg@chromium.org> 2 3 CompactHTMLToken does not need an XSSInfo pointer 4 https://bugs.webkit.org/show_bug.cgi?id=111423 5 6 Reviewed by Eric Seidel. 7 8 The CompactHTMLToken should remain as small as possible because it is copied. This shrinks the size by one pointer 9 by moving a relatively uncommon attribute out to its own Vector. 10 11 No new tests because no new functionality. 12 13 * html/parser/BackgroundHTMLParser.cpp: 14 (WebCore::checkThatXSSInfosAreSafeToSendToAnotherThread): 15 (WebCore): 16 (WebCore::BackgroundHTMLParser::pumpTokenizer): 17 (WebCore::BackgroundHTMLParser::sendTokensToMainThread): 18 * html/parser/BackgroundHTMLParser.h: 19 (BackgroundHTMLParser): 20 * html/parser/CompactHTMLToken.cpp: 21 (SameSizeAsCompactHTMLToken): 22 (WebCore::CompactHTMLToken::isSafeToSendToAnotherThread): 23 * html/parser/CompactHTMLToken.h: 24 (WebCore): 25 (CompactHTMLToken): 26 * html/parser/HTMLDocumentParser.cpp: 27 (WebCore::HTMLDocumentParser::processParsedChunkFromBackgroundParser): 28 * html/parser/HTMLDocumentParser.h: 29 (ParsedChunk): 30 * html/parser/XSSAuditorDelegate.h: 31 (XSSInfo): 32 (WebCore): 33 1 34 2013-03-05 Anders Carlsson <andersca@apple.com> 2 35 -
trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp
r144714 r144801 58 58 for (size_t i = 0; i < preloads.size(); ++i) 59 59 ASSERT(preloads[i]->isSafeToSendToAnotherThread()); 60 } 61 62 static void checkThatXSSInfosAreSafeToSendToAnotherThread(const XSSInfoStream& xssInfos) 63 { 64 for (size_t i = 0; i < xssInfos.size(); ++i) 65 ASSERT(xssInfos[i]->isSafeToSendToAnotherThread()); 60 66 } 61 67 … … 248 254 249 255 { 250 OwnPtr<XSSInfo> xssInfo = m_xssAuditor->filterToken(FilterTokenRequest(*m_token, m_sourceTracker, m_tokenizer->shouldAllowCDATA())); 256 TextPosition position = TextPosition(m_input.current().currentLine(), m_input.current().currentColumn()); 257 258 if (OwnPtr<XSSInfo> xssInfo = m_xssAuditor->filterToken(FilterTokenRequest(*m_token, m_sourceTracker, m_tokenizer->shouldAllowCDATA()))) { 259 xssInfo->m_textPosition = position; 260 m_pendingXSSInfos.append(xssInfo.release()); 261 } 262 251 263 CompactHTMLToken token(m_token.get(), TextPosition(m_input.current().currentLine(), m_input.current().currentColumn())); 252 253 if (xssInfo)254 token.setXSSInfo(xssInfo.release());255 264 256 265 m_preloadScanner->scan(token, m_pendingPreloads); … … 276 285 checkThatTokensAreSafeToSendToAnotherThread(m_pendingTokens.get()); 277 286 checkThatPreloadsAreSafeToSendToAnotherThread(m_pendingPreloads); 287 checkThatXSSInfosAreSafeToSendToAnotherThread(m_pendingXSSInfos); 278 288 #endif 279 289 … … 281 291 chunk->tokens = m_pendingTokens.release(); 282 292 chunk->preloads.swap(m_pendingPreloads); 293 chunk->xssInfos.swap(m_pendingXSSInfos); 283 294 chunk->tokenizerState = m_tokenizer->state(); 284 295 chunk->inputCheckpoint = m_input.createCheckpoint(); -
trunk/Source/WebCore/html/parser/BackgroundHTMLParser.h
r143661 r144801 36 36 #include "HTMLToken.h" 37 37 #include "HTMLTokenizer.h" 38 #include "XSSAuditorDelegate.h" 38 39 #include <wtf/PassOwnPtr.h> 39 40 #include <wtf/RefPtr.h> … … 106 107 OwnPtr<CompactHTMLTokenStream> m_pendingTokens; 107 108 PreloadRequestStream m_pendingPreloads; 109 XSSInfoStream m_pendingXSSInfos; 108 110 109 111 OwnPtr<XSSAuditor> m_xssAuditor; -
trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp
r143415 r144801 42 42 Vector<Attribute> vector; 43 43 TextPosition textPosition; 44 OwnPtr<XSSInfo> xssInfo;45 44 }; 46 45 … … 90 89 } 91 90 92 CompactHTMLToken::CompactHTMLToken(const CompactHTMLToken& other)93 : m_type(other.m_type)94 , m_selfClosing(other.m_selfClosing)95 , m_isAll8BitData(other.m_isAll8BitData)96 , m_doctypeForcesQuirks(other.m_doctypeForcesQuirks)97 , m_data(other.m_data)98 , m_attributes(other.m_attributes)99 , m_textPosition(other.m_textPosition)100 {101 if (other.m_xssInfo)102 m_xssInfo = adoptPtr(new XSSInfo(*other.m_xssInfo));103 }104 105 91 const CompactHTMLToken::Attribute* CompactHTMLToken::getAttributeItem(const QualifiedName& name) const 106 92 { … … 120 106 return false; 121 107 } 122 if (m_xssInfo && !m_xssInfo->isSafeToSendToAnotherThread())123 return false;124 108 return m_data.isSafeToSendToAnotherThread(); 125 }126 127 XSSInfo* CompactHTMLToken::xssInfo() const128 {129 return m_xssInfo.get();130 }131 132 void CompactHTMLToken::setXSSInfo(PassOwnPtr<XSSInfo> xssInfo)133 {134 m_xssInfo = xssInfo;135 109 } 136 110 -
trunk/Source/WebCore/html/parser/CompactHTMLToken.h
r143415 r144801 41 41 42 42 class QualifiedName; 43 class XSSInfo;44 43 45 44 class CompactHTMLToken { … … 57 56 58 57 CompactHTMLToken(const HTMLToken*, const TextPosition&); 59 CompactHTMLToken(const CompactHTMLToken&);60 58 61 59 bool isSafeToSendToAnotherThread() const; … … 74 72 const String& systemIdentifier() const { return m_attributes[0].value; } 75 73 bool doctypeForcesQuirks() const { return m_doctypeForcesQuirks; } 76 XSSInfo* xssInfo() const;77 void setXSSInfo(PassOwnPtr<XSSInfo>);78 74 79 75 private: … … 86 82 Vector<Attribute> m_attributes; 87 83 TextPosition m_textPosition; 88 OwnPtr<XSSInfo> m_xssInfo;89 84 }; 90 85 … … 93 88 } 94 89 95 namespace WTF {96 // This is required for a struct with OwnPtr. We know CompactHTMLToken is simple enough that97 // initializing to 0 and moving with memcpy (and then not destructing the original) will work.98 template<> struct VectorTraits<WebCore::CompactHTMLToken> : SimpleClassVectorTraits { };99 }100 101 90 #endif // ENABLE(THREADED_HTML_PARSER) 102 91 -
trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp
r144756 r144801 394 394 OwnPtr<CompactHTMLTokenStream> tokens = m_currentChunk->tokens.release(); 395 395 396 for (XSSInfoStream::const_iterator it = m_currentChunk->xssInfos.begin(); it != m_currentChunk->xssInfos.end(); ++it) { 397 m_textPosition = (*it)->m_textPosition; 398 m_xssAuditorDelegate.didBlockScript(**it); 399 if (isStopped()) 400 break; 401 } 402 396 403 for (Vector<CompactHTMLToken>::const_iterator it = tokens->begin(); it != tokens->end(); ++it) { 397 404 ASSERT(!isWaitingForScripts()); 398 405 399 406 m_textPosition = it->textPosition(); 400 401 if (XSSInfo* xssInfo = it->xssInfo())402 m_xssAuditorDelegate.didBlockScript(*xssInfo);403 407 404 408 constructTreeFromCompactHTMLToken(*it); -
trunk/Source/WebCore/html/parser/HTMLDocumentParser.h
r144714 r144801 90 90 OwnPtr<CompactHTMLTokenStream> tokens; 91 91 PreloadRequestStream preloads; 92 XSSInfoStream xssInfos; 92 93 HTMLTokenizer::State tokenizerState; 93 94 HTMLInputCheckpoint inputCheckpoint; -
trunk/Source/WebCore/html/parser/XSSAuditorDelegate.h
r142004 r144801 28 28 29 29 #include "KURL.h" 30 #include <wtf/OwnPtr.h> 30 31 #include <wtf/PassOwnPtr.h> 32 #include <wtf/Vector.h> 33 #include <wtf/text/TextPosition.h> 31 34 #include <wtf/text/WTFString.h> 32 35 … … 48 51 String m_originalHTTPBody; 49 52 bool m_didBlockEntirePage; 53 TextPosition m_textPosition; 50 54 51 55 private: … … 70 74 }; 71 75 76 typedef Vector<OwnPtr<XSSInfo> > XSSInfoStream; 77 72 78 } 73 79
Note: See TracChangeset
for help on using the changeset viewer.