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

Side by Side Diff: sky/engine/core/html/imports/HTMLImportChild.cpp

Issue 1215103007: Remove remaining HTML elements (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
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 #include "sky/engine/core/html/imports/HTMLImportChild.h"
32
33 #include "sky/engine/core/dom/Document.h"
34 #include "sky/engine/core/html/imports/HTMLImportChildClient.h"
35 #include "sky/engine/core/html/imports/HTMLImportLoader.h"
36 #include "sky/engine/core/html/imports/HTMLImportTreeRoot.h"
37 #include "sky/engine/core/html/imports/HTMLImportsController.h"
38
39 namespace blink {
40
41 HTMLImportChild::HTMLImportChild(const KURL& url, HTMLImportLoader* loader, Sync Mode sync)
42 : HTMLImport(sync)
43 , m_url(url)
44 #if !ENABLE(OILPAN)
45 , m_weakFactory(this)
46 #endif
47 , m_loader(loader)
48 , m_client(nullptr)
49 {
50 }
51
52 HTMLImportChild::~HTMLImportChild()
53 {
54 #if !ENABLE(OILPAN)
55 // importDestroyed() should be called before the destruction.
56 ASSERT(!m_loader);
57
58 if (m_client)
59 m_client->importChildWasDestroyed(this);
60 #endif
61 }
62
63 void HTMLImportChild::ownerInserted()
64 {
65 if (!m_loader->isDone())
66 return;
67 root()->document()->styleResolverChanged();
68 }
69
70 void HTMLImportChild::didShareLoader()
71 {
72 stateWillChange();
73 }
74
75 void HTMLImportChild::didStartLoading()
76 {
77 }
78
79 void HTMLImportChild::didFinish()
80 {
81 if (m_client)
82 m_client->didFinish();
83 }
84
85 void HTMLImportChild::didFinishLoading()
86 {
87 stateWillChange();
88 }
89
90 #if !ENABLE(OILPAN)
91 void HTMLImportChild::importDestroyed()
92 {
93 if (parent())
94 parent()->removeChild(this);
95
96 ASSERT(m_loader);
97 m_loader->removeImport(this);
98 m_loader = nullptr;
99 }
100 #endif
101
102 Module* HTMLImportChild::module() const
103 {
104 ASSERT(m_loader);
105 return m_loader->module();
106 }
107
108 Document* HTMLImportChild::document() const
109 {
110 ASSERT(m_loader);
111 return m_loader->document();
112 }
113
114 void HTMLImportChild::stateWillChange()
115 {
116 toHTMLImportTreeRoot(root())->scheduleRecalcState();
117 }
118
119 void HTMLImportChild::stateDidChange()
120 {
121 HTMLImport::stateDidChange();
122
123 if (state().isReady())
124 didFinish();
125 }
126
127 bool HTMLImportChild::isDone() const
128 {
129 ASSERT(m_loader);
130 return m_loader->isDone();
131 }
132
133 HTMLImportLoader* HTMLImportChild::loader() const
134 {
135 // This should never be called after importDestroyed.
136 ASSERT(m_loader);
137 return m_loader;
138 }
139
140 void HTMLImportChild::setClient(HTMLImportChildClient* client)
141 {
142 ASSERT(client);
143 ASSERT(!m_client);
144 m_client = client;
145 }
146
147 #if !ENABLE(OILPAN)
148 void HTMLImportChild::clearClient()
149 {
150 // Doesn't check m_client nullity because we allow
151 // clearClient() to reenter.
152 m_client = nullptr;
153 }
154 #endif
155
156 Element* HTMLImportChild::link() const
157 {
158 if (!m_client)
159 return 0;
160 return m_client->link();
161 }
162
163 // Ensuring following invariants against the import tree:
164 // - HTMLImportChild::firstImport() is the "first import" of the DFS order of th e import tree.
165 // - The "first import" manages all the children that is loaded by the document.
166 void HTMLImportChild::normalize()
167 {
168 if (!loader()->isFirstImport(this) && this->precedes(loader()->firstImport() )) {
169 HTMLImportChild* oldFirst = loader()->firstImport();
170 loader()->moveToFirst(this);
171 takeChildrenFrom(oldFirst);
172 }
173
174 for (HTMLImportChild* child = toHTMLImportChild(firstChild()); child; child = toHTMLImportChild(child->next()))
175 child->normalize();
176 }
177
178 #if !defined(NDEBUG)
179 void HTMLImportChild::showThis()
180 {
181 bool isFirst = loader() ? loader()->isFirstImport(this) : false;
182 HTMLImport::showThis();
183 fprintf(stderr, " loader=%p first=%d, sync=%s url=%s",
184 m_loader.get(),
185 isFirst,
186 isSync() ? "Y" : "N",
187 url().string().utf8().data());
188 }
189 #endif
190
191 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/html/imports/HTMLImportChild.h ('k') | sky/engine/core/html/imports/HTMLImportChildClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698