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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 class BackgroundHTMLParser; | 47 class BackgroundHTMLParser; |
48 class CompactHTMLToken; | 48 class CompactHTMLToken; |
49 class Document; | 49 class Document; |
50 class Element; | 50 class Element; |
51 class HTMLParserScheduler; | 51 class HTMLParserScheduler; |
52 class HTMLTreeBuilder; | 52 class HTMLTreeBuilder; |
53 class ScriptSourceCode; | 53 class ScriptSourceCode; |
54 | 54 |
55 class PumpSession; | 55 class PumpSession; |
56 | 56 |
57 class HTMLDocumentParser : public DocumentParser { | 57 class HTMLDocumentParser : public DocumentParser, public HTMLScriptRunnerHost { |
58 WTF_MAKE_FAST_ALLOCATED; | 58 WTF_MAKE_FAST_ALLOCATED; |
59 public: | 59 public: |
60 static PassRefPtr<HTMLDocumentParser> create(Document& document, bool report
Errors) | 60 static PassRefPtr<HTMLDocumentParser> create(Document& document, bool report
Errors) |
61 { | 61 { |
62 return adoptRef(new HTMLDocumentParser(document, reportErrors)); | 62 return adoptRef(new HTMLDocumentParser(document, reportErrors)); |
63 } | 63 } |
64 virtual ~HTMLDocumentParser(); | 64 virtual ~HTMLDocumentParser(); |
65 | 65 |
66 void parse(mojo::ScopedDataPipeConsumerHandle, | 66 void parse(mojo::ScopedDataPipeConsumerHandle, |
67 const base::Closure& completionCallback) override; | 67 const base::Closure& completionCallback) override; |
(...skipping 10 matching lines...) Expand all Loading... |
78 void didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); | 78 void didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); |
79 | 79 |
80 // From DocumentParser: | 80 // From DocumentParser: |
81 void detach() override final; | 81 void detach() override final; |
82 void prepareToStopParsing() override final; | 82 void prepareToStopParsing() override final; |
83 void stopParsing() override final; | 83 void stopParsing() override final; |
84 bool isWaitingForScripts() const override final; | 84 bool isWaitingForScripts() const override final; |
85 bool isExecutingScript() const override final; | 85 bool isExecutingScript() const override final; |
86 void resumeAfterWaitingForImports() override final; | 86 void resumeAfterWaitingForImports() override final; |
87 | 87 |
| 88 // From HTMLScriptRunnerHost: |
| 89 void scriptExecutionCompleted(); |
| 90 |
88 private: | 91 private: |
89 HTMLDocumentParser(Document&, bool reportErrors); | 92 HTMLDocumentParser(Document&, bool reportErrors); |
90 | 93 |
91 HTMLTreeBuilder* treeBuilder() const { return m_treeBuilder.get(); } | 94 HTMLTreeBuilder* treeBuilder() const { return m_treeBuilder.get(); } |
92 | 95 |
93 bool hasInsertionPoint(); | 96 bool hasInsertionPoint(); |
94 | 97 |
95 void stopBackgroundParser(); | 98 void stopBackgroundParser(); |
96 void processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); | 99 void processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); |
97 void pumpPendingChunks(); | 100 void pumpPendingChunks(); |
(...skipping 11 matching lines...) Expand all Loading... |
109 | 112 |
110 bool isParsingFragment() const; | 113 bool isParsingFragment() const; |
111 bool isScheduledForResume() const; | 114 bool isScheduledForResume() const; |
112 bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; } | 115 bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; } |
113 bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts(
) || isScheduledForResume() || isExecutingScript(); } | 116 bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts(
) || isScheduledForResume() || isExecutingScript(); } |
114 | 117 |
115 OwnPtr<HTMLTreeBuilder> m_treeBuilder; | 118 OwnPtr<HTMLTreeBuilder> m_treeBuilder; |
116 OwnPtr<HTMLParserScheduler> m_parserScheduler; | 119 OwnPtr<HTMLParserScheduler> m_parserScheduler; |
117 TextPosition m_textPosition; | 120 TextPosition m_textPosition; |
118 | 121 |
119 HTMLScriptRunner m_scriptRunner; | 122 OwnPtr<HTMLScriptRunner> m_scriptRunner; |
120 | 123 |
121 OwnPtr<ParsedChunk> m_lastChunkBeforeScript; | 124 OwnPtr<ParsedChunk> m_lastChunkBeforeScript; |
122 Deque<OwnPtr<ParsedChunk> > m_pendingChunks; | 125 Deque<OwnPtr<ParsedChunk> > m_pendingChunks; |
123 base::WeakPtrFactory<HTMLDocumentParser> m_weakFactory; | 126 base::WeakPtrFactory<HTMLDocumentParser> m_weakFactory; |
124 base::WeakPtr<BackgroundHTMLParser> m_backgroundParser; | 127 base::WeakPtr<BackgroundHTMLParser> m_backgroundParser; |
125 | 128 |
126 base::Closure m_completionCallback; | 129 base::Closure m_completionCallback; |
127 | 130 |
128 bool m_isFragment; | 131 bool m_isFragment; |
129 bool m_endWasDelayed; | 132 bool m_endWasDelayed; |
130 bool m_haveBackgroundParser; | 133 bool m_haveBackgroundParser; |
131 unsigned m_pumpSessionNestingLevel; | 134 unsigned m_pumpSessionNestingLevel; |
132 }; | 135 }; |
133 | 136 |
134 } | 137 } |
135 | 138 |
136 #endif // SKY_ENGINE_CORE_HTML_PARSER_HTMLDOCUMENTPARSER_H_ | 139 #endif // SKY_ENGINE_CORE_HTML_PARSER_HTMLDOCUMENTPARSER_H_ |
OLD | NEW |