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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 class HTMLImportsController; | 44 class HTMLImportsController; |
45 class KURL; | 45 class KURL; |
46 | 46 |
47 // | 47 // |
48 // # Basic Data Structure and Algorithms of HTML Imports implemenation. | 48 // # Basic Data Structure and Algorithms of HTML Imports implemenation. |
49 // | 49 // |
50 // ## The Import Tree | 50 // ## The Import Tree |
51 // | 51 // |
52 // HTML Imports form a tree: | 52 // HTML Imports form a tree: |
53 // | 53 // |
54 // * The root of the tree is HTMLImportsController, which is owned by the master | 54 // * The root of the tree is HTMLImportTreeRoot. |
| 55 // |
| 56 // * The HTMLImportTreeRoot is owned HTMLImportsController, which is owned by th
e master |
55 // document as a DocumentSupplement. | 57 // document as a DocumentSupplement. |
56 // | 58 // |
57 // * The non-root nodes are HTMLImportChild, which is owned by LinkStyle, that i
s owned by HTMLLinkElement. | 59 // * The non-root nodes are HTMLImportChild. They are also owned by HTMLImportsC
ontroller. |
58 // LinkStyle is wired into HTMLImportChild by implementing HTMLImportChildClie
nt interface | 60 // LinkStyle is wired into HTMLImportChild by implementing HTMLImportChildClie
nt interface |
59 // | 61 // |
60 // * Both HTMLImportsController and HTMLImportChild are derived from HTMLImport
superclass | 62 // * Both HTMLImportTreeRoot and HTMLImportChild are derived from HTMLImport sup
erclass |
61 // that models the tree data structure using WTF::TreeNode and provides a set
of | 63 // that models the tree data structure using WTF::TreeNode and provides a set
of |
62 // virtual functions. | 64 // virtual functions. |
63 // | 65 // |
64 // HTMLImportsController also owns all loaders in the tree and manages their lif
etime through it. | 66 // HTMLImportsController also owns all loaders in the tree and manages their lif
etime through it. |
65 // One assumption is that the tree is append-only and nodes are never inserted i
n the middle of the tree nor removed. | 67 // One assumption is that the tree is append-only and nodes are never inserted i
n the middle of the tree nor removed. |
66 // | 68 // |
67 // | 69 // |
68 // HTMLImport <|- HTMLImportsController <- Document | |
69 // * | |
70 // | | |
71 // <|- HTMLImportChild <- LinkStyle <- HTMLLinkElement | |
72 // | |
73 // | |
74 // # Import Sharing and HTMLImportLoader | 70 // # Import Sharing and HTMLImportLoader |
75 // | 71 // |
76 // The HTML Imports spec calls for de-dup mechanism to share already loaded impo
rts. | 72 // The HTML Imports spec calls for de-dup mechanism to share already loaded impo
rts. |
77 // To implement this, the actual loading machinery is split out from HTMLImportC
hild to | 73 // To implement this, the actual loading machinery is split out from HTMLImportC
hild to |
78 // HTMLImportLoader, and each loader shares HTMLImportLoader with other loader i
f the URL is same. | 74 // HTMLImportLoader, and each loader shares HTMLImportLoader with other loader i
f the URL is same. |
79 // Check around HTMLImportsController::findLink() for more detail. | 75 // Check around HTMLImportsController::findLink() for more detail. |
80 // | 76 // |
81 // HTMLImportLoader can be shared by multiple imports. | 77 // HTMLImportLoader can be shared by multiple imports. |
82 // | 78 // |
83 // HTMLImportChild (1)-->(*) HTMLImportLoader | 79 // HTMLImportChild (1)-->(*) HTMLImportLoader |
84 // | 80 // |
85 // | 81 // |
86 // # Script Blocking | 82 // # Script Blocking |
87 // | 83 // |
88 // - An import blocks the HTML parser of its own imported document from running
<script> | 84 // - An import blocks the HTML parser of its own imported document from running
<script> |
89 // until all of its children are loaded. | 85 // until all of its children are loaded. |
90 // Note that dynamically added import won't block the parser. | 86 // Note that dynamically added import won't block the parser. |
91 // | 87 // |
92 // - An import under loading also blocks imported documents that follow from bei
ng created. | 88 // - An import under loading also blocks imported documents that follow from bei
ng created. |
93 // This is because an import can include another import that has same URLs of
following ones. | 89 // This is because an import can include another import that has same URLs of
following ones. |
94 // In such case, the preceding import should be loaded and following ones shou
ld be de-duped. | 90 // In such case, the preceding import should be loaded and following ones shou
ld be de-duped. |
95 // | 91 // |
96 | 92 |
97 // The superclass of HTMLImportsController and HTMLImportChild | 93 // The superclass of HTMLImportTreeRoot and HTMLImportChild |
98 // This represents the import tree data structure. | 94 // This represents the import tree data structure. |
99 class HTMLImport : public TreeNode<HTMLImport> { | 95 class HTMLImport : public TreeNode<HTMLImport> { |
100 public: | 96 public: |
101 enum SyncMode { | 97 enum SyncMode { |
102 Sync = 0, | 98 Sync = 0, |
103 Async = 1 | 99 Async = 1 |
104 }; | 100 }; |
105 | 101 |
106 virtual ~HTMLImport() { } | 102 virtual ~HTMLImport() { } |
107 | 103 |
| 104 // FIXME: Consider returning HTMLImportTreeRoot. |
108 HTMLImport* root(); | 105 HTMLImport* root(); |
109 bool precedes(HTMLImport*); | 106 bool precedes(HTMLImport*); |
110 bool isRoot() const { return !isChild(); } | 107 bool isRoot() const { return !isChild(); } |
111 bool isSync() const { return SyncMode(m_sync) == Sync; } | 108 bool isSync() const { return SyncMode(m_sync) == Sync; } |
112 bool formsCycle() const; | 109 bool formsCycle() const; |
113 const HTMLImportState& state() const { return m_state; } | 110 const HTMLImportState& state() const { return m_state; } |
114 | 111 |
115 void appendImport(HTMLImport*); | 112 void appendImport(HTMLImport*); |
116 | 113 |
117 virtual bool isChild() const { return false; } | 114 virtual bool isChild() const { return false; } |
(...skipping 19 matching lines...) Expand all Loading... |
137 #endif | 134 #endif |
138 | 135 |
139 private: | 136 private: |
140 HTMLImportState m_state; | 137 HTMLImportState m_state; |
141 unsigned m_sync : 1; | 138 unsigned m_sync : 1; |
142 }; | 139 }; |
143 | 140 |
144 } // namespace WebCore | 141 } // namespace WebCore |
145 | 142 |
146 #endif // HTMLImport_h | 143 #endif // HTMLImport_h |
OLD | NEW |