Source/core/html/imports directory contains the implementation of HTML Imports.
The spec can be found here.
HTML Imports form a tree:
HTMLImportTreeRootis owned by
HTMLImportsController, which is owned by the master document as a
HTMLImportChild. They are all owned by
LinkStyleis wired into
HTMLImportChildare derived from
HTMLImportsuperclass that models the tree data structure using
WTF::TreeNodeand provides a set of virtual functions.
HTMLImportsController also owns all loaders in the tree and manages their lifetime through it. One assumption is that the tree is append-only and nodes are never inserted in the middle of the tree nor removed.
Full diagram is here
The HTML Imports spec calls for de-dup mechanism to share already loaded imports. To implement this, the actual loading machinery is split out from
HTMLImportLoader, and each loader shares
HTMLImportLoader with other loader if the URL is same. Check around
HTMLImportTreeRoot::Find() for more detail.
HTMLImportLoader can be shared by multiple imports.
HTMLImportChild (1)-->(*) HTMLImportLoader
<script>until all of its children are loaded. Note that dynamically added import won't block the parser.