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

Side by Side Diff: Source/core/html/HTMLImport.cpp

Issue 21182004: [HTML Imports] Make import loading in order. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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
« no previous file with comments | « Source/core/html/HTMLImport.h ('k') | Source/core/html/HTMLImportsController.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
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 #include "config.h" 31 #include "config.h"
32 #include "core/html/HTMLImport.h" 32 #include "core/html/HTMLImport.h"
33 33
34 #include "core/html/HTMLImportsController.h" 34 #include "core/html/HTMLImportsController.h"
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 bool HTMLImport::haveChildrenLoaded()
39 {
40 if (HTMLImportsController* controller = this->controller())
41 return controller->haveChildrenLoaded(this);
42 return true;
43 }
44
45 Frame* HTMLImport::frame() 38 Frame* HTMLImport::frame()
46 { 39 {
47 return master()->frame(); 40 return master()->frame();
48 } 41 }
49 42
50 Document* HTMLImport::master() 43 Document* HTMLImport::master()
51 { 44 {
52 return controller()->document(); 45 return controller()->document();
53 } 46 }
54 47
48 void HTMLImport::appendChild(HTMLImport* child)
49 {
50 ASSERT(child->parent() == this);
51 ASSERT(!child->hasChildren());
52
53 if (isBlocked())
54 child->setBlocked(true);
55 m_children.append(child);
56 blockAfter(child);
57 }
58
59 void HTMLImport::didUnblock()
60 {
61 ASSERT(!isBlocked());
62 if (!isProcessing())
63 return;
64
65 if (Document* document = this->document())
66 document->didLoadAllImports();
67 }
68
69 bool HTMLImport::areChilrenLoaded() const
70 {
71 for (size_t i = 0; i < m_children.size(); ++i) {
72 if (!m_children[i]->isLoaded())
73 return false;
74 }
75
76 return true;
77 }
78
79 bool HTMLImport::arePredecessorsLoaded() const
80 {
81 HTMLImport* parent = this->parent();
82 if (!parent)
83 return true;
84
85 for (size_t i = 0; i < parent->m_children.size(); ++i) {
86 HTMLImport* sibling = parent->m_children[i];
87 if (sibling == this)
88 break;
89 if (!sibling->isLoaded())
90 return false;
91 }
92
93 return true;
94 }
95
96 bool HTMLImport::unblock(HTMLImport* import)
97 {
98 ASSERT(import->arePredecessorsLoaded());
99 ASSERT(import->isBlocked() || import->areChilrenLoaded());
100
101 if (import->isBlocked()) {
102 for (size_t i = 0; i < import->m_children.size(); ++i) {
103 if (!unblock(import->m_children[i]))
104 return false;
105 }
106 }
107
108 import->setBlocked(false);
dglazkov 2013/07/30 22:45:27 Sounds like this gets marked as unblocked even if
Hajime Morrita 2013/07/31 00:49:40 Yes! Unblocked means it can continue parsing. "lo
109 import->didUnblock();
dglazkov 2013/07/30 22:45:27 Will this cause multiple document->didLoadAllImpor
Hajime Morrita 2013/07/31 00:49:40 Yes, I don't think that's a big deal though becaus
110 return import->isLoaded();
111 }
112
113 void HTMLImport::setTreeBlocked(bool blocked)
114 {
115 setBlocked(blocked);
116 for (size_t i = 0; i < m_children.size(); ++i)
117 m_children[i]->setTreeBlocked(blocked);
118 }
119
120 void HTMLImport::blockAfter(HTMLImport* child)
121 {
122 ASSERT(child->parent() == this);
123
124 for (size_t i = 0; i < m_children.size(); ++i) {
125 HTMLImport* sibling = m_children[m_children.size() - i - 1];
126 if (sibling == child)
127 break;
128 sibling->setTreeBlocked(true);
129 }
130
131 setBlocked(true);
132
133 if (HTMLImport* parent = this->parent())
134 parent->blockAfter(this);
135 }
136
137
55 } // namespace WebCore 138 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/HTMLImport.h ('k') | Source/core/html/HTMLImportsController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698