示例#1
0
void ElementShadow::detach(const Node::AttachContext& context)
{
    Node::AttachContext childrenContext(context);
    childrenContext.resolvedStyle = 0;

    for (ShadowRoot* root = &youngestShadowRoot(); root; root = root->olderShadowRoot())
        root->detach(childrenContext);
}
void ElementShadow::detach(const Node::AttachContext& context)
{
    Node::AttachContext childrenContext(context);
    childrenContext.resolvedStyle = 0;

    if (ShadowRoot* root = shadowRoot()) {
        if (root->attached())
            root->detach(childrenContext);
    }
}
void ElementShadow::attach(const Node::AttachContext& context)
{
    ContentDistributor::ensureDistribution(shadowRoot());

    Node::AttachContext childrenContext(context);
    childrenContext.resolvedStyle = 0;

    if (ShadowRoot* root = shadowRoot()) {
        if (!root->attached())
            root->attach(childrenContext);
    }
}
示例#4
0
文件: If.cpp 项目: stefan0x53/sparrow
void If::doSemanticCheck()
{
    Node* condition = children_[0];
    Node* thenClause = children_[1];
    Node* elseClause = children_[2];
    
    // The resulting type is Void
    type_ = Void::get(context_->evalMode());

    // Semantic check the condition
    condition->semanticCheck();

    // Check that the type of the condition is 'Testable'
    if ( !isTestable(condition) )
        REP_ERROR(condition->location(), "The condition of the if is not Testable");

    // Dereference the condition as much as possible
    while ( condition->type() && condition->type()->noReferences() > 0 )
    {
        condition = mkMemLoad(condition->location(), condition);
        condition->setContext(childrenContext());
        condition->semanticCheck();
    }
    children_[0] = condition;
    // TODO (if): Remove this dereference from here

    if ( nodeEvalMode(this) == modeCt )
    {
        if ( !isCt(condition) )
            REP_ERROR(condition->location(), "The condition of the ct if should be available at compile-time (%1%)") % condition->type();

        // Get the CT value from the condition, and select an active branch
        Node* c = theCompiler().ctEval(condition);
        Node* selectedBranch = getBoolCtValue(c) ? thenClause : elseClause;

        // Expand only the selected branch
        if ( selectedBranch )
            setExplanation(selectedBranch);
        else
            setExplanation(mkNop(location_));
        return;
    }

    // Semantic check the clauses
    if ( thenClause )
        thenClause->semanticCheck();
    if ( elseClause )
        elseClause->semanticCheck();
}
示例#5
0
static void detachChildren(Element* current, const AttachContext& context)
{
    AttachContext childrenContext(context);
    childrenContext.resolvedStyle = 0;

    for (Node* child = current->firstChild(); child; child = child->nextSibling()) {
        if (child->isTextNode()) {
            toText(child)->detachText();
            continue;
        }
        if (child->isElementNode())
            detachRenderTree(toElement(child), childrenContext);
    }
    current->clearChildNeedsStyleRecalc();
}
示例#6
0
static void detachShadowRoot(ShadowRoot* shadowRoot, const AttachContext& context)
{
    if (!shadowRoot->attached())
        return;
    Style::AttachContext childrenContext(context);
    childrenContext.resolvedStyle = 0;
    for (Node* child = shadowRoot->firstChild(); child; child = child->nextSibling()) {
        if (child->isTextNode()) {
            toText(child)->detachText();
            continue;
        }
        if (child->isElementNode())
            detachRenderTree(toElement(child), context);
    }
    shadowRoot->clearChildNeedsStyleRecalc();
    shadowRoot->setAttached(false);
}
示例#7
0
static void attachChildren(Element* current, const AttachContext& context)
{
    AttachContext childrenContext(context);
    childrenContext.resolvedStyle = 0;

    for (Node* child = current->firstChild(); child; child = child->nextSibling()) {
        ASSERT(!child->attached() || childAttachedAllowedWhenAttachingChildren(current));
        if (child->attached())
            continue;
        if (child->isTextNode()) {
            toText(child)->attachText();
            continue;
        }
        if (child->isElementNode())
            attachRenderTree(toElement(child), childrenContext);
    }
}
示例#8
0
static void attachShadowRoot(ShadowRoot* shadowRoot, const AttachContext& context)
{
    if (shadowRoot->attached())
        return;
    StyleResolver& styleResolver = shadowRoot->document()->ensureStyleResolver();
    styleResolver.pushParentShadowRoot(shadowRoot);

    Style::AttachContext childrenContext(context);
    childrenContext.resolvedStyle = 0;
    for (Node* child = shadowRoot->firstChild(); child; child = child->nextSibling()) {
        if (child->isTextNode()) {
            toText(child)->attachText();
            continue;
        }
        if (child->isElementNode())
            attachRenderTree(toElement(child), childrenContext);
    }
    styleResolver.popParentShadowRoot(shadowRoot);

    shadowRoot->clearNeedsStyleRecalc();
    shadowRoot->setAttached(true);
}