OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef HTMLImportLoader_h | 31 #ifndef HTMLImportLoader_h |
32 #define HTMLImportLoader_h | 32 #define HTMLImportLoader_h |
33 | 33 |
| 34 #include "core/dom/DocumentParserClient.h" |
34 #include "core/fetch/RawResource.h" | 35 #include "core/fetch/RawResource.h" |
35 #include "core/fetch/ResourceOwner.h" | 36 #include "core/fetch/ResourceOwner.h" |
36 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
37 #include "wtf/OwnPtr.h" | 38 #include "wtf/OwnPtr.h" |
38 #include "wtf/PassOwnPtr.h" | 39 #include "wtf/PassOwnPtr.h" |
39 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
40 | 41 |
41 namespace blink { | 42 namespace blink { |
42 | 43 |
43 class CustomElementSyncMicrotaskQueue; | 44 class CustomElementSyncMicrotaskQueue; |
44 class Document; | 45 class Document; |
45 class DocumentWriter; | 46 class DocumentWriter; |
46 class HTMLImportChild; | 47 class HTMLImportChild; |
47 class HTMLImportsController; | 48 class HTMLImportsController; |
48 | 49 |
49 | 50 |
50 // | 51 // |
51 // Owning imported Document lifetime. It also implements ResourceClient through
ResourceOwner | 52 // Owning imported Document lifetime. It also implements ResourceClient through
ResourceOwner |
52 // to feed fetched bytes to the DocumentWriter of the imported document. | 53 // to feed fetched bytes to the DocumentWriter of the imported document. |
53 // HTMLImportLoader is owned by HTMLImportsController. | 54 // HTMLImportLoader is owned by HTMLImportsController. |
54 // | 55 // |
55 // | 56 // |
56 class HTMLImportLoader FINAL : public NoBaseWillBeGarbageCollectedFinalized<HTML
ImportLoader>, public ResourceOwner<RawResource> { | 57 class HTMLImportLoader FINAL : public NoBaseWillBeGarbageCollectedFinalized<HTML
ImportLoader>, public ResourceOwner<RawResource>, public DocumentParserClient { |
57 public: | 58 public: |
58 enum State { | 59 enum State { |
59 StateLoading, | 60 StateLoading, |
60 StateWritten, | 61 StateWritten, |
61 StateParsed, | 62 StateParsed, |
62 StateLoaded, | 63 StateLoaded, |
63 StateError | 64 StateError |
64 }; | 65 }; |
65 | 66 |
66 static PassOwnPtrWillBeRawPtr<HTMLImportLoader> create(HTMLImportsController
* controller) | 67 static PassOwnPtrWillBeRawPtr<HTMLImportLoader> create(HTMLImportsController
* controller) |
(...skipping 14 matching lines...) Expand all Loading... |
81 | 82 |
82 bool isDone() const { return m_state == StateLoaded || m_state == StateError
; } | 83 bool isDone() const { return m_state == StateLoaded || m_state == StateError
; } |
83 bool hasError() const { return m_state == StateError; } | 84 bool hasError() const { return m_state == StateError; } |
84 bool shouldBlockScriptExecution() const; | 85 bool shouldBlockScriptExecution() const; |
85 | 86 |
86 #if !ENABLE(OILPAN) | 87 #if !ENABLE(OILPAN) |
87 void importDestroyed(); | 88 void importDestroyed(); |
88 #endif | 89 #endif |
89 void startLoading(const ResourcePtr<RawResource>&); | 90 void startLoading(const ResourcePtr<RawResource>&); |
90 | 91 |
91 // Tells the loader that the parser is done with this import. | |
92 // Called by Document::finishedParsing, after DOMContentLoaded was dispatche
d. | |
93 void didFinishParsing(); | |
94 // Tells the loader that all of the import's stylesheets finished | 92 // Tells the loader that all of the import's stylesheets finished |
95 // loading. | 93 // loading. |
96 // Called by Document::didRemoveAllPendingStylesheet. | 94 // Called by Document::didRemoveAllPendingStylesheet. |
97 void didRemoveAllPendingStylesheet(); | 95 void didRemoveAllPendingStylesheet(); |
98 | 96 |
99 PassRefPtrWillBeRawPtr<CustomElementSyncMicrotaskQueue> microtaskQueue() con
st; | 97 PassRefPtrWillBeRawPtr<CustomElementSyncMicrotaskQueue> microtaskQueue() con
st; |
100 | 98 |
101 virtual void trace(Visitor*); | 99 virtual void trace(Visitor*); |
102 | 100 |
103 private: | 101 private: |
104 HTMLImportLoader(HTMLImportsController*); | 102 HTMLImportLoader(HTMLImportsController*); |
105 | 103 |
106 // RawResourceClient | 104 // RawResourceClient |
107 virtual void responseReceived(Resource*, const ResourceResponse&) OVERRIDE; | 105 virtual void responseReceived(Resource*, const ResourceResponse&) OVERRIDE; |
108 virtual void dataReceived(Resource*, const char* data, int length) OVERRIDE; | 106 virtual void dataReceived(Resource*, const char* data, int length) OVERRIDE; |
109 virtual void notifyFinished(Resource*) OVERRIDE; | 107 virtual void notifyFinished(Resource*) OVERRIDE; |
110 | 108 |
| 109 // DocumentParserClient |
| 110 |
| 111 // Called after document parse is complete after DOMContentLoaded was dispat
ched. |
| 112 virtual void notifyParserStopped(); |
| 113 |
111 State startWritingAndParsing(const ResourceResponse&); | 114 State startWritingAndParsing(const ResourceResponse&); |
112 State finishWriting(); | 115 State finishWriting(); |
113 State finishParsing(); | 116 State finishParsing(); |
114 State finishLoading(); | 117 State finishLoading(); |
115 | 118 |
116 void setState(State); | 119 void setState(State); |
117 void didFinishLoading(); | 120 void didFinishLoading(); |
118 bool hasPendingResources() const; | 121 bool hasPendingResources() const; |
119 #if !ENABLE(OILPAN) | 122 #if !ENABLE(OILPAN) |
120 void clear(); | 123 void clear(); |
121 #endif | 124 #endif |
122 | 125 |
123 RawPtrWillBeMember<HTMLImportsController> m_controller; | 126 RawPtrWillBeMember<HTMLImportsController> m_controller; |
124 WillBeHeapVector<RawPtrWillBeMember<HTMLImportChild> > m_imports; | 127 WillBeHeapVector<RawPtrWillBeMember<HTMLImportChild> > m_imports; |
125 State m_state; | 128 State m_state; |
126 RefPtrWillBeMember<Document> m_document; | 129 RefPtrWillBeMember<Document> m_document; |
127 RefPtrWillBeMember<DocumentWriter> m_writer; | 130 RefPtrWillBeMember<DocumentWriter> m_writer; |
128 RefPtrWillBeMember<CustomElementSyncMicrotaskQueue> m_microtaskQueue; | 131 RefPtrWillBeMember<CustomElementSyncMicrotaskQueue> m_microtaskQueue; |
129 }; | 132 }; |
130 | 133 |
131 } // namespace blink | 134 } // namespace blink |
132 | 135 |
133 #endif // HTMLImportLoader_h | 136 #endif // HTMLImportLoader_h |
OLD | NEW |