HTMLImportChild* HTMLImportsController::load(HTMLImport* parent, HTMLImportChildClient* client, FetchRequest request) { ASSERT(!request.url().isEmpty() && request.url().isValid()); ASSERT(parent == root() || toHTMLImportChild(parent)->loader()->isFirstImport(toHTMLImportChild(parent))); if (HTMLImportChild* childToShareWith = root()->find(request.url())) { HTMLImportLoader* loader = childToShareWith->loader(); ASSERT(loader); HTMLImportChild* child = createChild(request.url(), loader, parent, client); child->didShareLoader(); return child; } bool sameOriginRequest = master()->securityOrigin()->canRequest(request.url()); request.setCrossOriginAccessControl( master()->securityOrigin(), sameOriginRequest ? AllowStoredCredentials : DoNotAllowStoredCredentials, ClientDidNotRequestCredentials); ResourcePtr<RawResource> resource = parent->document()->fetcher()->fetchImport(request); if (!resource) return 0; HTMLImportLoader* loader = createLoader(); HTMLImportChild* child = createChild(request.url(), loader, parent, client); // We set resource after the import tree is built since // Resource::addClient() immediately calls back to feed the bytes when the resource is cached. loader->startLoading(resource); child->didStartLoading(); return child; }
// Ensuring following invariants against the import tree: // - HTMLImportChild::firstImport() is the "first import" of the DFS order of the import tree. // - The "first import" manages all the children that is loaded by the document. void HTMLImportChild::normalize() { if (!loader()->isFirstImport(this) && this->precedes(loader()->firstImport())) { HTMLImportChild* oldFirst = loader()->firstImport(); loader()->moveToFirst(this); takeChildrenFrom(oldFirst); } for (HTMLImportChild* child = toHTMLImportChild(firstChild()); child; child = toHTMLImportChild(child->next())) child->normalize(); }
// Ensuring following invariants against the import tree: // - HTMLImportChild::firstImport() is the "first import" of the DFS order of the import tree. // - The "first import" manages all the children that is loaded by the document. void HTMLImportChild::normalize() { if (!loader()->isFirstImport(this) && this->precedes(loader()->firstImport())) { HTMLImportChild* oldFirst = loader()->firstImport(); loader()->moveToFirst(this); takeChildrenFrom(oldFirst); } for (HTMLImportChild* child = toHTMLImportChild(firstChild()); child; child = toHTMLImportChild(child->next())) { if (child->formsCycle()) child->invalidateCustomElementMicrotaskStep(); child->normalize(); } }
inline bool HTMLImportStateResolver::isBlockingFollowers(HTMLImport* import) { if (!import->isSync()) return false; HTMLImportChild* child = toHTMLImportChild(import); if (!child->loader()->isFirstImport(child)) return false; return !import->state().isReady(); }
static bool makesCycle(HTMLImport* parent, const KURL& url) { for (HTMLImport* ancestor = parent; ancestor; ancestor = ancestor->parent()) { if (!ancestor->isRoot() && equalIgnoringFragmentIdentifier(toHTMLImportChild(parent)->url(), url)) return true; } return false; }
HTMLImportChild* HTMLImportsController::load(HTMLImport* parent, HTMLImportChildClient* client, FetchRequest request) { ASSERT(!request.url().isEmpty() && request.url().isValid()); ASSERT(parent == root() || toHTMLImportChild(parent)->loader()->isFirstImport(toHTMLImportChild(parent))); if (HTMLImportChild* childToShareWith = root()->find(request.url())) { HTMLImportLoader* loader = childToShareWith->loader(); ASSERT(loader); HTMLImportChild* child = createChild(request.url(), loader, parent, client); child->didShareLoader(); return child; } HTMLImportLoader* loader = createLoader(); HTMLImportChild* child = createChild(request.url(), loader, parent, client); // We set resource after the import tree is built since // Resource::addClient() immediately calls back to feed the bytes when the resource is cached. loader->startLoading(request.url()); child->didStartLoading(); return child; }