示例#1
0
void reattachRenderTree(Element* current, const AttachContext& context)
{
    AttachContext reattachContext(context);
    reattachContext.performingReattach = true;

    if (current->attached())
        detachRenderTree(current, reattachContext);

    attachRenderTree(current, reattachContext);
}
示例#2
0
static void attachChildren(ContainerNode& current)
{
    for (Node* child = current.firstChild(); child; child = child->nextSibling()) {
        ASSERT(!child->attached() || childAttachedAllowedWhenAttachingChildren(current));
        if (child->attached())
            continue;
        if (child->isTextNode()) {
            attachTextRenderer(*toText(child));
            continue;
        }
        if (child->isElementNode())
            attachRenderTree(*toElement(child), nullptr);
    }
}
示例#3
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);
    }
}
示例#4
0
static Change resolveLocal(Element& current, Change inheritedChange)
{
    Change localChange = Detach;
    RefPtr<RenderStyle> newStyle;
    RefPtr<RenderStyle> currentStyle = current.renderStyle();

    Document& document = current.document();
    if (currentStyle) {
        newStyle = current.styleForRenderer();
        localChange = determineChange(currentStyle.get(), newStyle.get(), document.settings());
    }
    if (localChange == Detach) {
        if (current.attached())
            detachRenderTree(current, ReattachDetach);
        attachRenderTree(current, newStyle.get());
        return Detach;
    }

    if (RenderObject* renderer = current.renderer()) {
        if (localChange != NoChange || pseudoStyleCacheIsInvalid(renderer, newStyle.get()) || (inheritedChange == Force && renderer->requiresForcedStyleRecalcPropagation()) || current.styleChangeType() == SyntheticStyleChange)
            renderer->setAnimatableStyle(newStyle.get());
        else if (current.needsStyleRecalc()) {
            // Although no change occurred, we use the new style so that the cousin style sharing code won't get
            // fooled into believing this style is the same.
            renderer->setStyleInternal(newStyle.get());
        }
    }

    // If "rem" units are used anywhere in the document, and if the document element's font size changes, then go ahead and force font updating
    // all the way down the tree. This is simpler than having to maintain a cache of objects (and such font size changes should be rare anyway).
    if (document.styleSheetCollection()->usesRemUnits() && document.documentElement() == &current && localChange != NoChange && currentStyle && newStyle && currentStyle->fontSize() != newStyle->fontSize()) {
        // Cached RenderStyles may depend on the re units.
        if (StyleResolver* styleResolver = document.styleResolverIfExists())
            styleResolver->invalidateMatchedPropertiesCache();
        return Force;
    }
    if (inheritedChange == Force)
        return Force;
    if (current.styleChangeType() >= FullStyleChange)
        return Force;

    return localChange;
}
示例#5
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);
}
示例#6
0
void reattachRenderTree(Element& current)
{
    if (current.attached())
        detachRenderTree(current, ReattachDetach);
    attachRenderTree(current, nullptr);
}
示例#7
0
void attachRenderTree(Element& element)
{
    attachRenderTree(element, nullptr);
}