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;
}
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();
}
Example #3
0
HTMLImportChild* HTMLImportTreeRoot::find(const KURL& url) const
{
    for (size_t i = 0; i < m_imports.size(); ++i) {
        HTMLImportChild* candidate = m_imports[i].get();
        if (equalIgnoringFragmentIdentifier(candidate->url(), url))
            return candidate;
    }

    return 0;
}
Example #4
0
// 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();
}
Example #5
0
// 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();
    }
}
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;
}