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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 class HTMLDocument; | 58 class HTMLDocument; |
59 class HTMLParserScheduler; | 59 class HTMLParserScheduler; |
60 class HTMLScriptRunner; | 60 class HTMLScriptRunner; |
61 class HTMLTreeBuilder; | 61 class HTMLTreeBuilder; |
62 class HTMLResourcePreloader; | 62 class HTMLResourcePreloader; |
63 class ScriptController; | 63 class ScriptController; |
64 class ScriptSourceCode; | 64 class ScriptSourceCode; |
65 | 65 |
66 class PumpSession; | 66 class PumpSession; |
67 | 67 |
68 class HTMLDocumentParser : public ScriptableDocumentParser, HTMLScriptRunnerHos
t, ResourceClient { | 68 class HTMLDocumentParser : public ScriptableDocumentParser, private HTMLScriptR
unnerHost { |
69 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 69 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 70 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLDocumentParser); |
70 public: | 71 public: |
71 static PassRefPtrWillBeRawPtr<HTMLDocumentParser> create(HTMLDocument& docum
ent, bool reportErrors) | 72 static PassRefPtrWillBeRawPtr<HTMLDocumentParser> create(HTMLDocument& docum
ent, bool reportErrors) |
72 { | 73 { |
73 return adoptRefWillBeNoop(new HTMLDocumentParser(document, reportErrors)
); | 74 return adoptRefWillBeNoop(new HTMLDocumentParser(document, reportErrors)
); |
74 } | 75 } |
75 virtual ~HTMLDocumentParser(); | 76 virtual ~HTMLDocumentParser(); |
76 virtual void trace(Visitor*) OVERRIDE; | 77 virtual void trace(Visitor*) OVERRIDE; |
77 | 78 |
78 // Exposed for HTMLParserScheduler | 79 // Exposed for HTMLParserScheduler |
79 void resumeParsingAfterYield(); | 80 void resumeParsingAfterYield(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 virtual void detach() OVERRIDE FINAL; | 130 virtual void detach() OVERRIDE FINAL; |
130 virtual bool hasInsertionPoint() OVERRIDE FINAL; | 131 virtual bool hasInsertionPoint() OVERRIDE FINAL; |
131 virtual bool processingData() const OVERRIDE FINAL; | 132 virtual bool processingData() const OVERRIDE FINAL; |
132 virtual void prepareToStopParsing() OVERRIDE FINAL; | 133 virtual void prepareToStopParsing() OVERRIDE FINAL; |
133 virtual void stopParsing() OVERRIDE FINAL; | 134 virtual void stopParsing() OVERRIDE FINAL; |
134 virtual bool isWaitingForScripts() const OVERRIDE FINAL; | 135 virtual bool isWaitingForScripts() const OVERRIDE FINAL; |
135 virtual bool isExecutingScript() const OVERRIDE FINAL; | 136 virtual bool isExecutingScript() const OVERRIDE FINAL; |
136 virtual void executeScriptsWaitingForResources() OVERRIDE FINAL; | 137 virtual void executeScriptsWaitingForResources() OVERRIDE FINAL; |
137 | 138 |
138 // HTMLScriptRunnerHost | 139 // HTMLScriptRunnerHost |
139 virtual void watchForLoad(Resource*) OVERRIDE FINAL; | 140 virtual void notifyScriptLoaded(Resource*) OVERRIDE FINAL; |
140 virtual void stopWatchingForLoad(Resource*) OVERRIDE FINAL; | |
141 virtual HTMLInputStream& inputStream() OVERRIDE FINAL { return m_input; } | 141 virtual HTMLInputStream& inputStream() OVERRIDE FINAL { return m_input; } |
142 virtual bool hasPreloadScanner() const OVERRIDE FINAL { return m_preloadScan
ner.get() && !shouldUseThreading(); } | 142 virtual bool hasPreloadScanner() const OVERRIDE FINAL { return m_preloadScan
ner.get() && !shouldUseThreading(); } |
143 virtual void appendCurrentInputStreamToPreloadScannerAndScan() OVERRIDE FINA
L; | 143 virtual void appendCurrentInputStreamToPreloadScannerAndScan() OVERRIDE FINA
L; |
144 | 144 |
145 // ResourceClient | |
146 virtual void notifyFinished(Resource*) OVERRIDE FINAL; | |
147 | |
148 void startBackgroundParser(); | 145 void startBackgroundParser(); |
149 void stopBackgroundParser(); | 146 void stopBackgroundParser(); |
150 void validateSpeculations(PassOwnPtr<ParsedChunk> lastChunk); | 147 void validateSpeculations(PassOwnPtr<ParsedChunk> lastChunk); |
151 void discardSpeculationsAndResumeFrom(PassOwnPtr<ParsedChunk> lastChunk, Pas
sOwnPtr<HTMLToken>, PassOwnPtr<HTMLTokenizer>); | 148 void discardSpeculationsAndResumeFrom(PassOwnPtr<ParsedChunk> lastChunk, Pas
sOwnPtr<HTMLToken>, PassOwnPtr<HTMLTokenizer>); |
152 void processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); | 149 void processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); |
153 void pumpPendingSpeculations(); | 150 void pumpPendingSpeculations(); |
154 | 151 |
155 Document* contextForParsingSession(); | 152 Document* contextForParsingSession(); |
156 | 153 |
157 enum SynchronousMode { | 154 enum SynchronousMode { |
(...skipping 21 matching lines...) Expand all Loading... |
179 bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; } | 176 bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; } |
180 bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts(
) || isScheduledForResume() || isExecutingScript(); } | 177 bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts(
) || isScheduledForResume() || isExecutingScript(); } |
181 | 178 |
182 HTMLToken& token() { return *m_token; } | 179 HTMLToken& token() { return *m_token; } |
183 | 180 |
184 HTMLParserOptions m_options; | 181 HTMLParserOptions m_options; |
185 HTMLInputStream m_input; | 182 HTMLInputStream m_input; |
186 | 183 |
187 OwnPtr<HTMLToken> m_token; | 184 OwnPtr<HTMLToken> m_token; |
188 OwnPtr<HTMLTokenizer> m_tokenizer; | 185 OwnPtr<HTMLTokenizer> m_tokenizer; |
189 OwnPtr<HTMLScriptRunner> m_scriptRunner; | 186 OwnPtrWillBeMember<HTMLScriptRunner> m_scriptRunner; |
190 OwnPtrWillBeMember<HTMLTreeBuilder> m_treeBuilder; | 187 OwnPtrWillBeMember<HTMLTreeBuilder> m_treeBuilder; |
191 OwnPtr<HTMLPreloadScanner> m_preloadScanner; | 188 OwnPtr<HTMLPreloadScanner> m_preloadScanner; |
192 OwnPtr<HTMLPreloadScanner> m_insertionPreloadScanner; | 189 OwnPtr<HTMLPreloadScanner> m_insertionPreloadScanner; |
193 OwnPtr<HTMLParserScheduler> m_parserScheduler; | 190 OwnPtr<HTMLParserScheduler> m_parserScheduler; |
194 HTMLSourceTracker m_sourceTracker; | 191 HTMLSourceTracker m_sourceTracker; |
195 TextPosition m_textPosition; | 192 TextPosition m_textPosition; |
196 XSSAuditor m_xssAuditor; | 193 XSSAuditor m_xssAuditor; |
197 XSSAuditorDelegate m_xssAuditorDelegate; | 194 XSSAuditorDelegate m_xssAuditorDelegate; |
198 | 195 |
199 // FIXME: m_lastChunkBeforeScript, m_tokenizer, m_token, and m_input should
be combined into a single state object | 196 // FIXME: m_lastChunkBeforeScript, m_tokenizer, m_token, and m_input should
be combined into a single state object |
200 // so they can be set and cleared together and passed between threads togeth
er. | 197 // so they can be set and cleared together and passed between threads togeth
er. |
201 OwnPtr<ParsedChunk> m_lastChunkBeforeScript; | 198 OwnPtr<ParsedChunk> m_lastChunkBeforeScript; |
202 Deque<OwnPtr<ParsedChunk> > m_speculations; | 199 Deque<OwnPtr<ParsedChunk> > m_speculations; |
203 WeakPtrFactory<HTMLDocumentParser> m_weakFactory; | 200 WeakPtrFactory<HTMLDocumentParser> m_weakFactory; |
204 WeakPtr<BackgroundHTMLParser> m_backgroundParser; | 201 WeakPtr<BackgroundHTMLParser> m_backgroundParser; |
205 OwnPtr<HTMLResourcePreloader> m_preloader; | 202 OwnPtr<HTMLResourcePreloader> m_preloader; |
206 | 203 |
207 bool m_isPinnedToMainThread; | 204 bool m_isPinnedToMainThread; |
208 bool m_endWasDelayed; | 205 bool m_endWasDelayed; |
209 bool m_haveBackgroundParser; | 206 bool m_haveBackgroundParser; |
210 unsigned m_pumpSessionNestingLevel; | 207 unsigned m_pumpSessionNestingLevel; |
211 }; | 208 }; |
212 | 209 |
213 } | 210 } |
214 | 211 |
215 #endif | 212 #endif |
OLD | NEW |