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 HTMLImportsController_h | 31 #ifndef HTMLImportsController_h |
32 #define HTMLImportsController_h | 32 #define HTMLImportsController_h |
33 | 33 |
| 34 #include "core/html/HTMLImport.h" |
34 #include "core/html/LinkResource.h" | 35 #include "core/html/LinkResource.h" |
35 #include "core/loader/cache/CachedRawResource.h" | 36 #include "core/loader/cache/CachedRawResource.h" |
36 #include "core/loader/cache/CachedResourceHandle.h" | 37 #include "core/loader/cache/CachedResourceHandle.h" |
| 38 #include "core/platform/Supplementable.h" |
37 #include "wtf/FastAllocBase.h" | 39 #include "wtf/FastAllocBase.h" |
38 #include "wtf/PassOwnPtr.h" | 40 #include "wtf/PassOwnPtr.h" |
39 #include "wtf/Vector.h" | 41 #include "wtf/Vector.h" |
40 | 42 |
41 namespace WebCore { | 43 namespace WebCore { |
42 | 44 |
| 45 class ScriptExecutionContext; |
43 class CachedResourceLoader; | 46 class CachedResourceLoader; |
44 class HTMLImportLoader; | 47 class HTMLImportLoader; |
45 class HTMLImportsController; | 48 class HTMLImportsController; |
46 class DocumentWriter; | 49 class DocumentWriter; |
47 | 50 |
48 // | 51 // |
49 // A LinkResource subclasss used for @rel=import. | 52 // A LinkResource subclasss used for @rel=import. |
50 // | 53 // |
51 class LinkImport : public LinkResource { | 54 class LinkImport : public LinkResource { |
52 WTF_MAKE_FAST_ALLOCATED; | 55 WTF_MAKE_FAST_ALLOCATED; |
53 public: | 56 public: |
54 | 57 |
55 static PassRefPtr<LinkImport> create(HTMLLinkElement* owner); | 58 static PassRefPtr<LinkImport> create(HTMLLinkElement* owner); |
56 | 59 |
57 explicit LinkImport(HTMLLinkElement* owner); | 60 explicit LinkImport(HTMLLinkElement* owner); |
58 virtual ~LinkImport(); | 61 virtual ~LinkImport(); |
59 | 62 |
60 // LinkResource | 63 // LinkResource |
61 virtual void process() OVERRIDE; | 64 virtual void process() OVERRIDE; |
62 virtual Type type() const OVERRIDE { return Import; } | 65 virtual Type type() const OVERRIDE { return Import; } |
63 virtual void ownerRemoved() OVERRIDE; | 66 virtual void ownerRemoved() OVERRIDE; |
64 | 67 |
65 Document* importedDocument() const; | 68 Document* importedDocument() const; |
66 | 69 |
67 private: | 70 private: |
68 RefPtr<HTMLImportLoader> m_loader; | 71 RefPtr<HTMLImportLoader> m_loader; |
69 }; | 72 }; |
70 | 73 |
71 | 74 class HTMLImportLoader : public RefCounted<HTMLImportLoader>, public HTMLImport,
public CachedRawResourceClient { |
72 class HTMLImportLoader : public RefCounted<HTMLImportLoader>, public CachedRawRe
sourceClient { | |
73 public: | 75 public: |
74 enum State { | 76 enum State { |
75 StateLoading, | 77 StateLoading, |
76 StateError, | 78 StateError, |
77 StateReady | 79 StateReady |
78 }; | 80 }; |
79 | 81 |
80 static PassRefPtr<HTMLImportLoader> create(HTMLImportsController*, const KUR
L&, const CachedResourceHandle<CachedScript>&); | 82 static PassRefPtr<HTMLImportLoader> create(HTMLImport* parent, const KURL&,
const CachedResourceHandle<CachedScript>&); |
81 virtual ~HTMLImportLoader(); | 83 virtual ~HTMLImportLoader(); |
82 | 84 |
83 Document* importedDocument() const; | 85 Document* importedDocument() const; |
84 const KURL& url() const { return m_url; } | 86 const KURL& url() const { return m_url; } |
85 | 87 |
86 void importDestroyed(); | 88 void importDestroyed(); |
87 bool isDone() const { return m_state == StateReady || m_state == StateError;
} | 89 bool isDone() const { return m_state == StateReady || m_state == StateError;
} |
88 | 90 |
| 91 // HTMLImport |
| 92 virtual HTMLImportsController* controller() OVERRIDE; |
| 93 virtual HTMLImport* parent() OVERRIDE; |
| 94 virtual Document* document() OVERRIDE; |
| 95 virtual void wasDetachedFromDocument() OVERRIDE; |
| 96 |
89 private: | 97 private: |
90 HTMLImportLoader(HTMLImportsController*, const KURL&, const CachedResourceHa
ndle<CachedScript>&); | 98 HTMLImportLoader(HTMLImport*, const KURL&, const CachedResourceHandle<Cached
Script>&); |
91 | 99 |
92 // CachedRawResourceClient | 100 // CachedRawResourceClient |
93 virtual void responseReceived(CachedResource*, const ResourceResponse&) OVER
RIDE; | 101 virtual void responseReceived(CachedResource*, const ResourceResponse&) OVER
RIDE; |
94 virtual void dataReceived(CachedResource*, const char* data, int length) OVE
RRIDE; | 102 virtual void dataReceived(CachedResource*, const char* data, int length) OVE
RRIDE; |
95 virtual void notifyFinished(CachedResource*) OVERRIDE; | 103 virtual void notifyFinished(CachedResource*) OVERRIDE; |
96 | 104 |
97 State startParsing(const ResourceResponse&); | 105 State startParsing(const ResourceResponse&); |
98 State finish(); | 106 State finish(); |
99 void setState(State); | 107 void setState(State); |
100 void dispose(); | 108 void dispose(); |
101 | 109 |
102 HTMLImportsController* m_controller; | 110 HTMLImport* m_parent; |
103 State m_state; | 111 State m_state; |
104 KURL m_url; | 112 KURL m_url; |
105 CachedResourceHandle<CachedRawResource> m_resource; | 113 CachedResourceHandle<CachedRawResource> m_resource; |
106 RefPtr<Document> m_importedDocument; | 114 RefPtr<Document> m_importedDocument; |
107 RefPtr<DocumentWriter> m_writer; | 115 RefPtr<DocumentWriter> m_writer; |
108 }; | 116 }; |
109 | 117 |
110 | 118 class HTMLImportsController : public HTMLImport, public Supplement<ScriptExecuti
onContext> { |
111 class HTMLImportsController : public RefCounted<HTMLImportsController> { | |
112 WTF_MAKE_FAST_ALLOCATED; | 119 WTF_MAKE_FAST_ALLOCATED; |
113 public: | 120 public: |
114 static PassRefPtr<HTMLImportsController> create(Document*); | 121 static void provideTo(Document*); |
115 | 122 |
116 explicit HTMLImportsController(Document*); | 123 explicit HTMLImportsController(Document*); |
117 virtual ~HTMLImportsController(); | 124 virtual ~HTMLImportsController(); |
118 | 125 |
| 126 // HTMLImport |
| 127 virtual HTMLImportsController* controller() OVERRIDE; |
| 128 virtual HTMLImport* parent() OVERRIDE; |
| 129 virtual Document* document() OVERRIDE; |
| 130 virtual void wasDetachedFromDocument() OVERRIDE; |
| 131 |
119 void addImport(PassRefPtr<HTMLImportLoader>); | 132 void addImport(PassRefPtr<HTMLImportLoader>); |
120 void showSecurityErrorMessage(const String&); | 133 void showSecurityErrorMessage(const String&); |
121 PassRefPtr<HTMLImportLoader> findLinkFor(const KURL&) const; | 134 PassRefPtr<HTMLImportLoader> findLinkFor(const KURL&) const; |
122 SecurityOrigin* securityOrigin() const; | 135 SecurityOrigin* securityOrigin() const; |
123 CachedResourceLoader* cachedResourceLoader() const; | 136 CachedResourceLoader* cachedResourceLoader() const; |
124 bool haveLoaded() const; | 137 bool haveChildrenLoaded(HTMLImport* parent) const; |
125 void didLoad(); | 138 void didLoad(HTMLImportLoader*); |
126 | 139 |
127 private: | 140 private: |
| 141 void clear(); |
| 142 |
128 Document* m_master; | 143 Document* m_master; |
129 | 144 |
130 // List of import which has been loaded or being loaded. | 145 // List of import which has been loaded or being loaded. |
131 typedef Vector<RefPtr<HTMLImportLoader> > ImportList; | 146 typedef Vector<RefPtr<HTMLImportLoader> > ImportList; |
132 ImportList m_imports; | 147 ImportList m_imports; |
133 }; | 148 }; |
134 | 149 |
135 } // namespace WebCore | 150 } // namespace WebCore |
136 | 151 |
137 #endif // HTMLImportsController_h | 152 #endif // HTMLImportsController_h |
OLD | NEW |