Node::InsertionNotificationRequest SVGSMILElement::insertedInto(ContainerNode* rootParent)
{
    SVGElement::insertedInto(rootParent);

    if (!rootParent->inDocument())
        return InsertionDone;

    Deprecation::countDeprecation(document(), UseCounter::SVGSMILElementInDocument);

    setAttributeName(constructQualifiedName(this, fastGetAttribute(SVGNames::attributeNameAttr)));
    SVGSVGElement* owner = ownerSVGElement();
    if (!owner)
        return InsertionDone;

    m_timeContainer = owner->timeContainer();
    ASSERT(m_timeContainer);
    m_timeContainer->setDocumentOrderIndexesDirty();

    // "If no attribute is present, the default begin value (an offset-value of 0) must be evaluated."
    if (!fastHasAttribute(SVGNames::beginAttr))
        m_beginTimes.append(SMILTimeWithOrigin());

    if (m_isWaitingForFirstInterval)
        resolveFirstInterval();

    if (m_timeContainer)
        m_timeContainer->notifyIntervalsChanged();

    buildPendingResource();

    return InsertionDone;
}
void SVGSMILElement::svgAttributeChanged(const QualifiedName& attrName)
{
    if (attrName == SVGNames::durAttr) {
        m_cachedDur = invalidCachedTime;
    } else if (attrName == SVGNames::repeatDurAttr) {
        m_cachedRepeatDur = invalidCachedTime;
    } else if (attrName == SVGNames::repeatCountAttr) {
        m_cachedRepeatCount = invalidCachedTime;
    } else if (attrName == SVGNames::minAttr) {
        m_cachedMin = invalidCachedTime;
    } else if (attrName == SVGNames::maxAttr) {
        m_cachedMax = invalidCachedTime;
    } else if (attrName == SVGNames::attributeNameAttr) {
        setAttributeName(constructQualifiedName(this, fastGetAttribute(SVGNames::attributeNameAttr)));
    } else if (attrName.matches(SVGNames::hrefAttr) || attrName.matches(XLinkNames::hrefAttr)) {
        // TODO(fs): Could be smarter here when 'href' is specified and 'xlink:href' is changed.
        SVGElement::InvalidationGuard invalidationGuard(this);
        buildPendingResource();
        if (m_targetElement)
            clearAnimatedType();
    } else if (attrName == SVGNames::beginAttr || attrName == SVGNames::endAttr) {
        if (inDocument()) {
            connectEventBaseConditions();
            if (attrName == SVGNames::beginAttr)
                beginListChanged(elapsed());
            else if (attrName == SVGNames::endAttr)
                endListChanged(elapsed());
        }
    } else {
        SVGElement::svgAttributeChanged(attrName);
        return;
    }

    animationAttributeChanged();
}
Node::InsertionNotificationRequest SVGSMILElement::insertedInto(ContainerNode& rootParent)
{
    SVGElement::insertedInto(rootParent);
    if (!rootParent.inDocument())
        return InsertionDone;

    // Verify we are not in <use> instance tree.
    ASSERT(!isInShadowTree());

    setAttributeName(constructQualifiedName(this, fastGetAttribute(SVGNames::attributeNameAttr)));
    SVGSVGElement* owner = ownerSVGElement();
    if (!owner)
        return InsertionDone;

    m_timeContainer = owner->timeContainer();
    ASSERT(m_timeContainer);
    m_timeContainer->setDocumentOrderIndexesDirty();

    // "If no attribute is present, the default begin value (an offset-value of 0) must be evaluated."
    if (!fastHasAttribute(SVGNames::beginAttr))
        m_beginTimes.append(SMILTimeWithOrigin());

    if (m_isWaitingForFirstInterval)
        resolveFirstInterval();

    if (m_timeContainer)
        m_timeContainer->notifyIntervalsChanged();

    return InsertionShouldCallDidNotifySubtreeInsertions;
}