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*, const KURL&, const C achedResourceHandle<CachedScript>&); |
dominicc (has gone to gerrit)
2013/07/11 03:26:48
I think this parameter needs a name. It is a bit m
| |
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 | |
89 private: | 96 private: |
90 HTMLImportLoader(HTMLImportsController*, const KURL&, const CachedResourceHa ndle<CachedScript>&); | 97 HTMLImportLoader(HTMLImport*, const KURL&, const CachedResourceHandle<Cached Script>&); |
91 | 98 |
92 // CachedRawResourceClient | 99 // CachedRawResourceClient |
93 virtual void responseReceived(CachedResource*, const ResourceResponse&) OVER RIDE; | 100 virtual void responseReceived(CachedResource*, const ResourceResponse&) OVER RIDE; |
94 virtual void dataReceived(CachedResource*, const char* data, int length) OVE RRIDE; | 101 virtual void dataReceived(CachedResource*, const char* data, int length) OVE RRIDE; |
95 virtual void notifyFinished(CachedResource*) OVERRIDE; | 102 virtual void notifyFinished(CachedResource*) OVERRIDE; |
96 | 103 |
97 State startParsing(const ResourceResponse&); | 104 State startParsing(const ResourceResponse&); |
98 State finish(); | 105 State finish(); |
99 void setState(State); | 106 void setState(State); |
100 void dispose(); | 107 void dispose(); |
101 | 108 |
102 HTMLImportsController* m_controller; | 109 HTMLImport* m_parent; |
103 State m_state; | 110 State m_state; |
104 KURL m_url; | 111 KURL m_url; |
105 CachedResourceHandle<CachedRawResource> m_resource; | 112 CachedResourceHandle<CachedRawResource> m_resource; |
106 RefPtr<Document> m_importedDocument; | 113 RefPtr<Document> m_importedDocument; |
107 RefPtr<DocumentWriter> m_writer; | 114 RefPtr<DocumentWriter> m_writer; |
108 }; | 115 }; |
109 | 116 |
110 | 117 class HTMLImportsController : public HTMLImport, public Supplement<ScriptExecuti onContext> { |
111 class HTMLImportsController : public RefCounted<HTMLImportsController> { | |
112 WTF_MAKE_FAST_ALLOCATED; | 118 WTF_MAKE_FAST_ALLOCATED; |
113 public: | 119 public: |
114 static PassRefPtr<HTMLImportsController> create(Document*); | 120 static void provideTo(Document*); |
115 | 121 |
116 explicit HTMLImportsController(Document*); | 122 explicit HTMLImportsController(Document*); |
117 virtual ~HTMLImportsController(); | 123 virtual ~HTMLImportsController(); |
118 | 124 |
125 // HTMLImport | |
126 virtual HTMLImportsController* controller() OVERRIDE; | |
127 virtual HTMLImport* parent() OVERRIDE; | |
128 virtual Document* document() OVERRIDE; | |
129 | |
119 void addImport(PassRefPtr<HTMLImportLoader>); | 130 void addImport(PassRefPtr<HTMLImportLoader>); |
120 void showSecurityErrorMessage(const String&); | 131 void showSecurityErrorMessage(const String&); |
121 PassRefPtr<HTMLImportLoader> findLinkFor(const KURL&) const; | 132 PassRefPtr<HTMLImportLoader> findLinkFor(const KURL&) const; |
122 SecurityOrigin* securityOrigin() const; | 133 SecurityOrigin* securityOrigin() const; |
123 CachedResourceLoader* cachedResourceLoader() const; | 134 CachedResourceLoader* cachedResourceLoader() const; |
124 bool haveLoaded() const; | 135 bool haveChildrenLoaded(HTMLImport* parent) const; |
125 void didLoad(); | 136 void didLoad(HTMLImportLoader*); |
126 | 137 |
127 private: | 138 private: |
128 Document* m_master; | 139 Document* m_master; |
129 | 140 |
130 // List of import which has been loaded or being loaded. | 141 // List of import which has been loaded or being loaded. |
131 typedef Vector<RefPtr<HTMLImportLoader> > ImportList; | 142 typedef Vector<RefPtr<HTMLImportLoader> > ImportList; |
132 ImportList m_imports; | 143 ImportList m_imports; |
133 }; | 144 }; |
134 | 145 |
135 } // namespace WebCore | 146 } // namespace WebCore |
136 | 147 |
137 #endif // HTMLImportsController_h | 148 #endif // HTMLImportsController_h |
OLD | NEW |