| 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 30 matching lines...) Expand all Loading... |
| 41 #include "wtf/Deque.h" | 41 #include "wtf/Deque.h" |
| 42 #include "wtf/OwnPtr.h" | 42 #include "wtf/OwnPtr.h" |
| 43 #include "wtf/WeakPtr.h" | 43 #include "wtf/WeakPtr.h" |
| 44 #include "wtf/text/TextPosition.h" | 44 #include "wtf/text/TextPosition.h" |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 class BackgroundHTMLParser; | 48 class BackgroundHTMLParser; |
| 49 class CompactHTMLToken; | 49 class CompactHTMLToken; |
| 50 class Document; | 50 class Document; |
| 51 class DocumentFragment; | |
| 52 class Element; | 51 class Element; |
| 53 class HTMLDocument; | 52 class HTMLDocument; |
| 54 class HTMLParserScheduler; | 53 class HTMLParserScheduler; |
| 55 class HTMLTreeBuilder; | 54 class HTMLTreeBuilder; |
| 56 class ScriptController; | 55 class ScriptController; |
| 57 class ScriptSourceCode; | 56 class ScriptSourceCode; |
| 58 | 57 |
| 59 class PumpSession; | 58 class PumpSession; |
| 60 | 59 |
| 61 class HTMLDocumentParser : public DecodedDataDocumentParser { | 60 class HTMLDocumentParser : public DecodedDataDocumentParser { |
| 62 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 61 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 63 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLDocumentParser); | 62 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLDocumentParser); |
| 64 public: | 63 public: |
| 65 static PassRefPtrWillBeRawPtr<HTMLDocumentParser> create(HTMLDocument& docum
ent, bool reportErrors) | 64 static PassRefPtrWillBeRawPtr<HTMLDocumentParser> create(HTMLDocument& docum
ent, bool reportErrors) |
| 66 { | 65 { |
| 67 return adoptRefWillBeNoop(new HTMLDocumentParser(document, reportErrors)
); | 66 return adoptRefWillBeNoop(new HTMLDocumentParser(document, reportErrors)
); |
| 68 } | 67 } |
| 69 virtual ~HTMLDocumentParser(); | 68 virtual ~HTMLDocumentParser(); |
| 70 virtual void trace(Visitor*) override; | 69 virtual void trace(Visitor*) override; |
| 71 | 70 |
| 72 // Exposed for HTMLParserScheduler | 71 // Exposed for HTMLParserScheduler |
| 73 void resumeParsingAfterYield(); | 72 void resumeParsingAfterYield(); |
| 74 | 73 |
| 75 static void parseDocumentFragment(const String&, DocumentFragment*, Element*
contextElement); | |
| 76 | |
| 77 HTMLTokenizer* tokenizer() const { return m_tokenizer.get(); } | 74 HTMLTokenizer* tokenizer() const { return m_tokenizer.get(); } |
| 78 | 75 |
| 79 TextPosition textPosition() const; | 76 TextPosition textPosition() const; |
| 80 OrdinalNumber lineNumber() const; | 77 OrdinalNumber lineNumber() const; |
| 81 | 78 |
| 82 struct ParsedChunk { | 79 struct ParsedChunk { |
| 83 OwnPtr<CompactHTMLTokenStream> tokens; | 80 OwnPtr<CompactHTMLTokenStream> tokens; |
| 84 }; | 81 }; |
| 85 void didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); | 82 void didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); |
| 86 | 83 |
| 87 virtual void appendBytes(const char* bytes, size_t length) override; | 84 virtual void appendBytes(const char* bytes, size_t length) override; |
| 88 virtual void flush() override final; | 85 virtual void flush() override final; |
| 89 | 86 |
| 90 bool isWaitingForScripts() const; | 87 bool isWaitingForScripts() const; |
| 91 bool isExecutingScript() const; | 88 bool isExecutingScript() const; |
| 92 void executeScriptsWaitingForResources(); | 89 void executeScriptsWaitingForResources(); |
| 93 | 90 |
| 94 UseCounter* useCounter() { return UseCounter::getFrom(contextForParsingSessi
on()); } | 91 UseCounter* useCounter() { return UseCounter::getFrom(contextForParsingSessi
on()); } |
| 95 | 92 |
| 96 protected: | 93 protected: |
| 97 virtual void insert(const SegmentedString&) override final; | 94 virtual void insert(const SegmentedString&) override final; |
| 98 virtual void append(PassRefPtr<StringImpl>) override; | 95 virtual void append(PassRefPtr<StringImpl>) override; |
| 99 virtual void finish() override final; | 96 virtual void finish() override final; |
| 100 | 97 |
| 101 HTMLDocumentParser(HTMLDocument&, bool reportErrors); | 98 HTMLDocumentParser(HTMLDocument&, bool reportErrors); |
| 102 HTMLDocumentParser(DocumentFragment*, Element* contextElement); | |
| 103 | 99 |
| 104 HTMLTreeBuilder* treeBuilder() const { return m_treeBuilder.get(); } | 100 HTMLTreeBuilder* treeBuilder() const { return m_treeBuilder.get(); } |
| 105 | 101 |
| 106 private: | 102 private: |
| 107 static PassRefPtrWillBeRawPtr<HTMLDocumentParser> create(DocumentFragment* f
ragment, Element* contextElement) | |
| 108 { | |
| 109 return adoptRefWillBeNoop(new HTMLDocumentParser(fragment, contextElemen
t)); | |
| 110 } | |
| 111 | |
| 112 virtual HTMLDocumentParser* asHTMLDocumentParser() override final { return t
his; } | 103 virtual HTMLDocumentParser* asHTMLDocumentParser() override final { return t
his; } |
| 113 | 104 |
| 114 // DocumentParser | 105 // DocumentParser |
| 115 virtual void detach() override final; | 106 virtual void detach() override final; |
| 116 virtual bool hasInsertionPoint() override final; | 107 virtual bool hasInsertionPoint() override final; |
| 117 virtual bool processingData() const override final; | 108 virtual bool processingData() const override final; |
| 118 virtual void prepareToStopParsing() override final; | 109 virtual void prepareToStopParsing() override final; |
| 119 virtual void stopParsing() override final; | 110 virtual void stopParsing() override final; |
| 120 | 111 |
| 121 void startBackgroundParser(); | 112 void startBackgroundParser(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 163 |
| 173 bool m_isFragment; | 164 bool m_isFragment; |
| 174 bool m_endWasDelayed; | 165 bool m_endWasDelayed; |
| 175 bool m_haveBackgroundParser; | 166 bool m_haveBackgroundParser; |
| 176 unsigned m_pumpSessionNestingLevel; | 167 unsigned m_pumpSessionNestingLevel; |
| 177 }; | 168 }; |
| 178 | 169 |
| 179 } | 170 } |
| 180 | 171 |
| 181 #endif | 172 #endif |
| OLD | NEW |