| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 virtual ~HTMLDocumentParser(); | 75 virtual ~HTMLDocumentParser(); |
| 76 | 76 |
| 77 // Exposed for HTMLParserScheduler | 77 // Exposed for HTMLParserScheduler |
| 78 void resumeParsingAfterYield(); | 78 void resumeParsingAfterYield(); |
| 79 | 79 |
| 80 static void parseDocumentFragment(const String&, DocumentFragment*, Element*
contextElement, ParserContentPolicy = AllowScriptingContent); | 80 static void parseDocumentFragment(const String&, DocumentFragment*, Element*
contextElement, ParserContentPolicy = AllowScriptingContent); |
| 81 | 81 |
| 82 HTMLTokenizer* tokenizer() const { return m_tokenizer.get(); } | 82 HTMLTokenizer* tokenizer() const { return m_tokenizer.get(); } |
| 83 | 83 |
| 84 virtual TextPosition textPosition() const; | 84 virtual TextPosition textPosition() const OVERRIDE FINAL; |
| 85 virtual OrdinalNumber lineNumber() const; | 85 virtual OrdinalNumber lineNumber() const OVERRIDE FINAL; |
| 86 | 86 |
| 87 virtual void suspendScheduledTasks(); | 87 virtual void suspendScheduledTasks() OVERRIDE FINAL; |
| 88 virtual void resumeScheduledTasks(); | 88 virtual void resumeScheduledTasks() OVERRIDE FINAL; |
| 89 | 89 |
| 90 struct ParsedChunk { | 90 struct ParsedChunk { |
| 91 OwnPtr<CompactHTMLTokenStream> tokens; | 91 OwnPtr<CompactHTMLTokenStream> tokens; |
| 92 PreloadRequestStream preloads; | 92 PreloadRequestStream preloads; |
| 93 XSSInfoStream xssInfos; | 93 XSSInfoStream xssInfos; |
| 94 HTMLTokenizer::State tokenizerState; | 94 HTMLTokenizer::State tokenizerState; |
| 95 HTMLTreeBuilderSimulator::State treeBuilderState; | 95 HTMLTreeBuilderSimulator::State treeBuilderState; |
| 96 HTMLInputCheckpoint inputCheckpoint; | 96 HTMLInputCheckpoint inputCheckpoint; |
| 97 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; | 97 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; |
| 98 }; | 98 }; |
| 99 void didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); | 99 void didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); |
| 100 void didReceiveEncodingDataFromBackgroundParser(const DocumentEncodingData&)
; | 100 void didReceiveEncodingDataFromBackgroundParser(const DocumentEncodingData&)
; |
| 101 | 101 |
| 102 virtual void appendBytes(const char* bytes, size_t length) OVERRIDE; | 102 virtual void appendBytes(const char* bytes, size_t length) OVERRIDE; |
| 103 virtual void flush() OVERRIDE FINAL; | 103 virtual void flush() OVERRIDE FINAL; |
| 104 virtual void setDecoder(PassOwnPtr<TextResourceDecoder>) OVERRIDE FINAL; | 104 virtual void setDecoder(PassOwnPtr<TextResourceDecoder>) OVERRIDE FINAL; |
| 105 | 105 |
| 106 UseCounter* useCounter() { return UseCounter::getFrom(contextForParsingSessi
on()); } | 106 UseCounter* useCounter() { return UseCounter::getFrom(contextForParsingSessi
on()); } |
| 107 | 107 |
| 108 protected: | 108 protected: |
| 109 virtual void insert(const SegmentedString&) OVERRIDE; | 109 virtual void insert(const SegmentedString&) OVERRIDE FINAL; |
| 110 virtual void append(PassRefPtr<StringImpl>) OVERRIDE; | 110 virtual void append(PassRefPtr<StringImpl>) OVERRIDE; |
| 111 virtual void finish() OVERRIDE; | 111 virtual void finish() OVERRIDE FINAL; |
| 112 | 112 |
| 113 HTMLDocumentParser(HTMLDocument*, bool reportErrors); | 113 HTMLDocumentParser(HTMLDocument*, bool reportErrors); |
| 114 HTMLDocumentParser(DocumentFragment*, Element* contextElement, ParserContent
Policy); | 114 HTMLDocumentParser(DocumentFragment*, Element* contextElement, ParserContent
Policy); |
| 115 | 115 |
| 116 HTMLTreeBuilder* treeBuilder() const { return m_treeBuilder.get(); } | 116 HTMLTreeBuilder* treeBuilder() const { return m_treeBuilder.get(); } |
| 117 | 117 |
| 118 void forcePlaintextForTextDocument(); | 118 void forcePlaintextForTextDocument(); |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 static PassRefPtr<HTMLDocumentParser> create(DocumentFragment* fragment, Ele
ment* contextElement, ParserContentPolicy parserContentPolicy) | 121 static PassRefPtr<HTMLDocumentParser> create(DocumentFragment* fragment, Ele
ment* contextElement, ParserContentPolicy parserContentPolicy) |
| 122 { | 122 { |
| 123 return adoptRef(new HTMLDocumentParser(fragment, contextElement, parserC
ontentPolicy)); | 123 return adoptRef(new HTMLDocumentParser(fragment, contextElement, parserC
ontentPolicy)); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // DocumentParser | 126 // DocumentParser |
| 127 virtual void pinToMainThread() OVERRIDE; | 127 virtual void pinToMainThread() OVERRIDE FINAL; |
| 128 virtual void detach() OVERRIDE; | 128 virtual void detach() OVERRIDE FINAL; |
| 129 virtual bool hasInsertionPoint() OVERRIDE; | 129 virtual bool hasInsertionPoint() OVERRIDE FINAL; |
| 130 virtual bool processingData() const OVERRIDE; | 130 virtual bool processingData() const OVERRIDE FINAL; |
| 131 virtual void prepareToStopParsing() OVERRIDE; | 131 virtual void prepareToStopParsing() OVERRIDE FINAL; |
| 132 virtual void stopParsing() OVERRIDE; | 132 virtual void stopParsing() OVERRIDE FINAL; |
| 133 virtual bool isWaitingForScripts() const OVERRIDE; | 133 virtual bool isWaitingForScripts() const OVERRIDE FINAL; |
| 134 virtual bool isExecutingScript() const OVERRIDE; | 134 virtual bool isExecutingScript() const OVERRIDE FINAL; |
| 135 virtual void executeScriptsWaitingForResources() OVERRIDE; | 135 virtual void executeScriptsWaitingForResources() OVERRIDE FINAL; |
| 136 | 136 |
| 137 // HTMLScriptRunnerHost | 137 // HTMLScriptRunnerHost |
| 138 virtual void watchForLoad(Resource*) OVERRIDE; | 138 virtual void watchForLoad(Resource*) OVERRIDE FINAL; |
| 139 virtual void stopWatchingForLoad(Resource*) OVERRIDE; | 139 virtual void stopWatchingForLoad(Resource*) OVERRIDE FINAL; |
| 140 virtual HTMLInputStream& inputStream() { return m_input; } | 140 virtual HTMLInputStream& inputStream() OVERRIDE FINAL { return m_input; } |
| 141 virtual bool hasPreloadScanner() const { return m_preloadScanner.get() && !s
houldUseThreading(); } | 141 virtual bool hasPreloadScanner() const OVERRIDE FINAL { return m_preloadScan
ner.get() && !shouldUseThreading(); } |
| 142 virtual void appendCurrentInputStreamToPreloadScannerAndScan() OVERRIDE; | 142 virtual void appendCurrentInputStreamToPreloadScannerAndScan() OVERRIDE FINA
L; |
| 143 | 143 |
| 144 // ResourceClient | 144 // ResourceClient |
| 145 virtual void notifyFinished(Resource*); | 145 virtual void notifyFinished(Resource*) OVERRIDE FINAL; |
| 146 | 146 |
| 147 void startBackgroundParser(); | 147 void startBackgroundParser(); |
| 148 void stopBackgroundParser(); | 148 void stopBackgroundParser(); |
| 149 void validateSpeculations(PassOwnPtr<ParsedChunk> lastChunk); | 149 void validateSpeculations(PassOwnPtr<ParsedChunk> lastChunk); |
| 150 void discardSpeculationsAndResumeFrom(PassOwnPtr<ParsedChunk> lastChunk, Pas
sOwnPtr<HTMLToken>, PassOwnPtr<HTMLTokenizer>); | 150 void discardSpeculationsAndResumeFrom(PassOwnPtr<ParsedChunk> lastChunk, Pas
sOwnPtr<HTMLToken>, PassOwnPtr<HTMLTokenizer>); |
| 151 void processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); | 151 void processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); |
| 152 void pumpPendingSpeculations(); | 152 void pumpPendingSpeculations(); |
| 153 | 153 |
| 154 Document* contextForParsingSession(); | 154 Document* contextForParsingSession(); |
| 155 | 155 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 205 |
| 206 bool m_isPinnedToMainThread; | 206 bool m_isPinnedToMainThread; |
| 207 bool m_endWasDelayed; | 207 bool m_endWasDelayed; |
| 208 bool m_haveBackgroundParser; | 208 bool m_haveBackgroundParser; |
| 209 unsigned m_pumpSessionNestingLevel; | 209 unsigned m_pumpSessionNestingLevel; |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 } | 212 } |
| 213 | 213 |
| 214 #endif | 214 #endif |
| OLD | NEW |