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

Side by Side Diff: Source/core/html/HTMLImports.h

Issue 15856002: First step of HTMLImports (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 #ifndef HTMLImports_h
32 #define HTMLImports_h
33
34 #include "core/html/LinkResource.h"
35 #include "core/loader/cache/CachedDocument.h"
36 #include "wtf/FastAllocBase.h"
37 #include "wtf/PassOwnPtr.h"
38 #include "wtf/Vector.h"
39
40 namespace WebCore {
41
42 class DocumentFragment;
43 class HTMLImports;
44 class HTMLImportsHost;
45
46 //
47 // A LinkResource subclasss used for @rel=import.
48 //
49 class LinkImport : public LinkResource, CachedDocumentClient {
50 public:
51 enum State {
52 StatePreparing,
53 StateStarted,
54 StateDone
55 };
56
57 static PassRefPtr<LinkImport> create(HTMLLinkElement* owner);
58
59 explicit LinkImport(HTMLLinkElement* owner);
60 virtual ~LinkImport();
61
62 // LinkResource
63 virtual void process() OVERRIDE;
64 virtual Type type() const OVERRIDE { return Import; }
65 virtual void ownerRemoved() OVERRIDE;
66
67 DocumentFragment* importedFragment() const;
68 const KURL& url() const { return m_url; }
69 void importDestroyed();
70 bool isDone() const { return m_state == StateDone; }
71
72 private:
73 State startRequest();
74 State finish();
75 void setState(State);
76
77 // CachedResourceClient
78 virtual void notifyFinished(CachedResource*) OVERRIDE;
79
80 HTMLImports* m_imports;
81 LinkImport* m_ofSameLocation;
82 KURL m_url;
83 State m_state;
84 CachedResourceHandle<CachedDocument> m_cachedDocument;
85 RefPtr<DocumentFragment> m_importedFragment;
86 };
87
88
89 class HTMLImports {
dglazkov 2013/05/23 18:32:00 I was sort of expecting to find the imported fragm
Hajime Morrita 2013/05/24 02:28:27 That is HTMLImport::m_owner Document, which is cre
90 WTF_MAKE_FAST_ALLOCATED;
91 public:
92 static PassOwnPtr<HTMLImports> create(HTMLImportsHost*);
93
94 explicit HTMLImports(HTMLImportsHost*);
95 virtual ~HTMLImports();
96
97 void addLink(PassRefPtr<LinkImport>);
98 PassRefPtr<DocumentFragment> createFragmentFrom(Document* source) const;
99 PassRefPtr<LinkImport> findLinkFor(const KURL&) const;
100 SecurityOrigin* securityOrigin() const;
101 bool haveLoaded() const;
102 void didLoad();
103
104 private:
105 typedef Vector<RefPtr<LinkImport> > LinkList;
106
107 HTMLImportsHost* m_host;
108 RefPtr<Document> m_owner;
109 LinkList m_links;
dglazkov 2013/05/23 18:32:00 Is this the loaded import list? I am not sure...
Hajime Morrita 2013/05/24 02:28:27 This is a list of LinkImports which are loaded or
110 };
111
112 } // namespace WebCore
113
114 #endif // HTMLImports_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698