This source file includes following definitions.
- frame
- master
- controller
- appendChild
- stateDidChange
- stateWillChange
- recalcTreeState
- isMaster
- show
- showTree
- showThis
#include "config.h"
#include "core/html/imports/HTMLImport.h"
#include "core/dom/Document.h"
#include "core/html/imports/HTMLImportStateResolver.h"
namespace WebCore {
LocalFrame* HTMLImport::frame()
{
return master()->frame();
}
Document* HTMLImport::master()
{
return root()->document();
}
HTMLImportsController* HTMLImport::controller()
{
return root()->toController();
}
void HTMLImport::appendChild(HTMLImport* child)
{
TreeNode<HTMLImport>::appendChild(child);
if (child->isSync())
m_state = HTMLImportState::blockedState();
stateWillChange();
}
void HTMLImport::stateDidChange()
{
if (!state().shouldBlockScriptExecution()) {
if (Document* document = this->document())
document->didLoadAllImports();
}
}
void HTMLImport::stateWillChange()
{
root()->scheduleRecalcState();
}
void HTMLImport::recalcTreeState(HTMLImport* root)
{
ASSERT(root == root->root());
HashMap<HTMLImport*, HTMLImportState> snapshot;
Vector<HTMLImport*> updated;
for (HTMLImport* i = root; i; i = traverseNext(i)) {
snapshot.add(i, i->state());
i->m_state = HTMLImportState::invalidState();
}
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);
ASSERT(!oldState.isReady() || oldState <= newState);
if (newState != oldState)
updated.append(i);
}
for (size_t i = 0; i < updated.size(); ++i)
updated[i]->stateDidChange();
}
bool HTMLImport::isMaster(Document* document)
{
if (!document->import())
return true;
return (document->import()->master() == document);
}
#if !defined(NDEBUG)
void HTMLImport::show()
{
root()->showTree(this, 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);
}
void HTMLImport::showThis()
{
fprintf(stderr, "%p state=%d", this, m_state.peekValueForDebug());
}
#endif
}