Example #1
0
void LinkImport::process()
{
    if (m_child)
        return;
    if (!m_owner)
        return;
    if (!shouldLoadResource())
        return;

    if (!m_owner->document().import()) {
        ASSERT(m_owner->document().frame()); // The document should be the master.
        HTMLImportsController::provideTo(m_owner->document());
    }

    LinkRequestBuilder builder(m_owner);
    if (!builder.isValid()) {
        didFinish();
        return;
    }

    HTMLImport* parent = m_owner->document().import();
    HTMLImportsController* controller = parent->controller();
    m_child = controller->load(parent, this, builder.build(true));
    if (!m_child) {
        didFinish();
        return;
    }
}
Example #2
0
void HTMLImport::recalcTreeState(HTMLImport* root)
{
    WillBeHeapHashMap<RawPtrWillBeMember<HTMLImport>, HTMLImportState> snapshot;
    WillBeHeapVector<RawPtrWillBeMember<HTMLImport>> updated;

    for (HTMLImport* i = root; i; i = traverseNext(i)) {
        snapshot.add(i, i->state());
        i->m_state = HTMLImportState::invalidState();
    }

    // The post-visit DFS order matters here because
    // HTMLImportStateResolver in recalcState() Depends on
    // |m_state| of its children and precedents of ancestors.
    // Accidental cycle dependency of state computation is prevented
    // by invalidateCachedState() and isStateCacheValid() check.
    for (HTMLImport* i = traverseFirstPostOrder(root); i; i = traverseNextPostOrder(i)) {
        ASSERT(!i->m_state.isValid());
        i->m_state = HTMLImportStateResolver(i).resolve();

        HTMLImportState newState = i->state();
        HTMLImportState oldState = snapshot.get(i);
        // Once the state reaches Ready, it shouldn't go back.
        ASSERT(!oldState.isReady() || oldState <= newState);
        if (newState != oldState)
            updated.append(i);
    }

    for (size_t i = 0; i < updated.size(); ++i)
        updated[i]->stateDidChange();
}
Example #3
0
HTMLImport* HTMLImport::root()
{
    HTMLImport* i = this;
    while (i->parent())
        i = i->parent();
    return i;
}
void LinkImport::process()
{
    if (m_loader)
        return;
    if (!m_owner)
        return;
    if (!m_owner->document()->frame() && !m_owner->document()->import())
        return;

    if (!m_owner->document()->import()) {
        ASSERT(m_owner->document()->frame()); // The document should be the master.
        HTMLImportsController::provideTo(m_owner->document());
    }

    LinkRequestBuilder builder(m_owner);
    if (!builder.isValid()) {
        didFinish();
        return;
    }

    HTMLImport* parent = m_owner->document()->import();
    HTMLImportsController* controller = parent->controller();
    m_loader = controller->createLoader(parent, builder.build(true));
    if (!m_loader) {
        didFinish();
        return;
    }

    m_loader->addClient(this);
}
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;
}
Example #6
0
void HTMLImport::showTree(HTMLImport* highlight, unsigned depth)
{
    for (unsigned i = 0; i < depth*4; ++i)
        fprintf(stderr, " ");

    fprintf(stderr, "%s", this == highlight ? "*" : " ");
    showThis();
    fprintf(stderr, "\n");
    for (HTMLImport* child = firstChild(); child; child = child->next())
        child->showTree(highlight, depth + 1);
}
Example #7
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 (HTMLImport* child = firstChild(); child; child = child->next())
        toHTMLImportChild(child)->normalize();
}
inline bool HTMLImportStateResolver::shouldBlockScriptExecution() const {
  // FIXME: Memoize to make this faster.
  for (HTMLImport* ancestor = m_import; ancestor;
       ancestor = ancestor->parent()) {
    for (HTMLImport* predecessor = ancestor->previous(); predecessor;
         predecessor = predecessor->previous()) {
      if (isBlockingFollowers(predecessor))
        return true;
    }
  }

  for (HTMLImport* child = m_import->firstChild(); child;
       child = child->next()) {
    if (isBlockingFollowers(child))
      return true;
  }

  return false;
}