Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: sky/engine/core/html/parser/HTMLDocumentParser.h

Issue 664573004: Live the dream (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: DEPS Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 class HTMLDocumentParser : public DecodedDataDocumentParser { 60 class HTMLDocumentParser : public DecodedDataDocumentParser {
61 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; 61 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
62 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLDocumentParser); 62 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLDocumentParser);
63 public: 63 public:
64 static PassRefPtrWillBeRawPtr<HTMLDocumentParser> create(HTMLDocument& docum ent, bool reportErrors) 64 static PassRefPtrWillBeRawPtr<HTMLDocumentParser> create(HTMLDocument& docum ent, bool reportErrors)
65 { 65 {
66 return adoptRefWillBeNoop(new HTMLDocumentParser(document, reportErrors) ); 66 return adoptRefWillBeNoop(new HTMLDocumentParser(document, reportErrors) );
67 } 67 }
68 virtual ~HTMLDocumentParser(); 68 virtual ~HTMLDocumentParser();
69
70 void parse(mojo::ScopedDataPipeConsumerHandle) override;
71
69 virtual void trace(Visitor*) override; 72 virtual void trace(Visitor*) override;
70 73
71 // Exposed for HTMLParserScheduler 74 // Exposed for HTMLParserScheduler
72 void resumeParsingAfterYield(); 75 void resumeParsingAfterYield();
73 76
74 HTMLTokenizer* tokenizer() const { return m_tokenizer.get(); }
75
76 TextPosition textPosition() const; 77 TextPosition textPosition() const;
77 OrdinalNumber lineNumber() const; 78 OrdinalNumber lineNumber() const;
78 79
79 struct ParsedChunk { 80 struct ParsedChunk {
80 OwnPtr<CompactHTMLTokenStream> tokens; 81 OwnPtr<CompactHTMLTokenStream> tokens;
81 }; 82 };
82 void didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); 83 void didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>);
83 84
84 virtual void appendBytes(const char* bytes, size_t length) override;
85 virtual void flush() override final;
86
87 bool isWaitingForScripts() const; 85 bool isWaitingForScripts() const;
88 bool isExecutingScript() const; 86 bool isExecutingScript() const;
89 void executeScriptsWaitingForResources(); 87 void executeScriptsWaitingForResources();
90 88
91 UseCounter* useCounter() { return UseCounter::getFrom(contextForParsingSessi on()); } 89 UseCounter* useCounter() { return UseCounter::getFrom(contextForParsingSessi on()); }
92 90
93 protected: 91 private:
94 virtual void insert(const SegmentedString&) override final;
95 virtual void append(PassRefPtr<StringImpl>) override;
96 virtual void finish() override final;
97
98 HTMLDocumentParser(HTMLDocument&, bool reportErrors); 92 HTMLDocumentParser(HTMLDocument&, bool reportErrors);
99 93
100 HTMLTreeBuilder* treeBuilder() const { return m_treeBuilder.get(); } 94 HTMLTreeBuilder* treeBuilder() const { return m_treeBuilder.get(); }
101 95
102 private:
103 virtual HTMLDocumentParser* asHTMLDocumentParser() override final { return t his; } 96 virtual HTMLDocumentParser* asHTMLDocumentParser() override final { return t his; }
104 97
105 // DocumentParser 98 // DocumentParser
106 virtual void detach() override final; 99 virtual void detach() override final;
107 virtual bool hasInsertionPoint() override final;
108 virtual bool processingData() const override final; 100 virtual bool processingData() const override final;
109 virtual void prepareToStopParsing() override final; 101 virtual void prepareToStopParsing() override final;
110 virtual void stopParsing() override final; 102 virtual void stopParsing() override final;
111 103
104 bool hasInsertionPoint();
105
112 void startBackgroundParser(); 106 void startBackgroundParser();
113 void stopBackgroundParser(); 107 void stopBackgroundParser();
114 void validateSpeculations(PassOwnPtr<ParsedChunk> lastChunk); 108 void validateSpeculations(PassOwnPtr<ParsedChunk> lastChunk);
115 void processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); 109 void processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>);
116 void pumpPendingSpeculations(); 110 void pumpPendingSpeculations();
117 111
118 Document* contextForParsingSession(); 112 Document* contextForParsingSession();
119 113
120 enum SynchronousMode {
121 AllowYield,
122 ForceSynchronous,
123 };
124 bool canTakeNextToken(SynchronousMode, PumpSession&);
125 void pumpTokenizer(SynchronousMode);
126 void pumpTokenizerIfPossible(SynchronousMode);
127 void constructTreeFromHTMLToken(HTMLToken&); 114 void constructTreeFromHTMLToken(HTMLToken&);
128 void constructTreeFromCompactHTMLToken(const CompactHTMLToken&); 115 void constructTreeFromCompactHTMLToken(const CompactHTMLToken&);
129 116
130 void runScriptsForPausedTreeBuilder(); 117 void runScriptsForPausedTreeBuilder();
131 void resumeParsingAfterScriptExecution(); 118 void resumeParsingAfterScriptExecution();
132 119
133 void attemptToEnd(); 120 void attemptToEnd();
134 void endIfDelayed(); 121 void endIfDelayed();
135 void end(); 122 void end();
136 123
137 bool shouldUseThreading() const { return m_options.useThreading; } 124 bool shouldUseThreading() const { return m_options.useThreading; }
138 125
139 bool isParsingFragment() const; 126 bool isParsingFragment() const;
140 bool isScheduledForResume() const; 127 bool isScheduledForResume() const;
141 bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; } 128 bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; }
142 bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts( ) || isScheduledForResume() || isExecutingScript(); } 129 bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts( ) || isScheduledForResume() || isExecutingScript(); }
143 130
144 HTMLToken& token() { return *m_token; } 131 HTMLParserOptions m_options;
145 132
146 HTMLParserOptions m_options;
147 HTMLInputStream m_input;
148
149 OwnPtr<HTMLToken> m_token;
150 OwnPtr<HTMLTokenizer> m_tokenizer;
151 OwnPtrWillBeMember<HTMLTreeBuilder> m_treeBuilder; 133 OwnPtrWillBeMember<HTMLTreeBuilder> m_treeBuilder;
152 OwnPtr<HTMLParserScheduler> m_parserScheduler; 134 OwnPtr<HTMLParserScheduler> m_parserScheduler;
153 TextPosition m_textPosition; 135 TextPosition m_textPosition;
154 136
155 HTMLScriptRunner m_scriptRunner; 137 HTMLScriptRunner m_scriptRunner;
156 138
157 // FIXME: m_lastChunkBeforeScript, m_tokenizer, m_token, and m_input should be combined into a single state object
158 // so they can be set and cleared together and passed between threads togeth er.
159 OwnPtr<ParsedChunk> m_lastChunkBeforeScript; 139 OwnPtr<ParsedChunk> m_lastChunkBeforeScript;
160 Deque<OwnPtr<ParsedChunk> > m_speculations; 140 Deque<OwnPtr<ParsedChunk> > m_speculations;
161 WeakPtrFactory<HTMLDocumentParser> m_weakFactory; 141 WeakPtrFactory<HTMLDocumentParser> m_weakFactory;
162 base::WeakPtr<BackgroundHTMLParser> m_backgroundParser; 142 base::WeakPtr<BackgroundHTMLParser> m_backgroundParser;
163 143
164 bool m_isFragment; 144 bool m_isFragment;
165 bool m_endWasDelayed; 145 bool m_endWasDelayed;
166 bool m_haveBackgroundParser; 146 bool m_haveBackgroundParser;
167 unsigned m_pumpSessionNestingLevel; 147 unsigned m_pumpSessionNestingLevel;
168 }; 148 };
169 149
170 } 150 }
171 151
172 #endif 152 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/html/parser/BackgroundHTMLParser.cpp ('k') | sky/engine/core/html/parser/HTMLDocumentParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698