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;
}
示例#2
0
void HTMLMenuItemElement::defaultEventHandler(Event* event) {
  if (event->type() == EventTypeNames::click) {
    if (equalIgnoringCase(fastGetAttribute(typeAttr), "checkbox")) {
      if (fastHasAttribute(checkedAttr))
        removeAttribute(checkedAttr);
      else
        setAttribute(checkedAttr, "checked");
    } else if (equalIgnoringCase(fastGetAttribute(typeAttr), "radio")) {
      if (Element* parent = parentElement()) {
        AtomicString group = fastGetAttribute(radiogroupAttr);
        for (HTMLMenuItemElement& menuItem :
             Traversal<HTMLMenuItemElement>::childrenOf(*parent)) {
          if (!menuItem.fastHasAttribute(checkedAttr))
            continue;
          const AtomicString& groupAttr =
              menuItem.fastGetAttribute(radiogroupAttr);
          if (equalIgnoringNullity(groupAttr.impl(), group.impl()))
            menuItem.removeAttribute(checkedAttr);
        }
      }
      setAttribute(checkedAttr, "checked");
    }
    event->setDefaultHandled();
  }
}
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 SVGAnimationElement::startedActiveInterval()
{
    m_animationValid = false;

    if (!isValid())
        return;

    if (!hasValidAttributeType())
        return;

    // These validations are appropriate for all animation modes.
    if (fastHasAttribute(SVGNames::keyPointsAttr) && m_keyPoints.size() != m_keyTimes.size())
        return;

    AnimationMode animationMode = this->animationMode();
    CalcMode calcMode = this->calcMode();
    if (calcMode == CalcModeSpline) {
        unsigned splinesCount = m_keySplines.size();
        if (!splinesCount
            || (fastHasAttribute(SVGNames::keyPointsAttr) && m_keyPoints.size() - 1 != splinesCount)
            || (animationMode == ValuesAnimation && m_values.size() - 1 != splinesCount)
            || (fastHasAttribute(SVGNames::keyTimesAttr) && m_keyTimes.size() - 1 != splinesCount))
            return;
    }

    String from = fromValue();
    String to = toValue();
    String by = byValue();
    if (animationMode == NoAnimation)
        return;
    if ((animationMode == FromToAnimation || animationMode == FromByAnimation || animationMode == ToAnimation || animationMode == ByAnimation)
        && (fastHasAttribute(SVGNames::keyPointsAttr) && fastHasAttribute(SVGNames::keyTimesAttr) && (m_keyTimes.size() < 2 || m_keyTimes.size() != m_keyPoints.size())))
        return;
    if (animationMode == FromToAnimation) {
        m_animationValid = calculateFromAndToValues(from, to);
    } else if (animationMode == ToAnimation) {
        // For to-animations the from value is the current accumulated value from lower priority animations.
        // The value is not static and is determined during the animation.
        m_animationValid = calculateFromAndToValues(emptyString(), to);
    } else if (animationMode == FromByAnimation) {
        m_animationValid = calculateFromAndByValues(from, by);
    } else if (animationMode == ByAnimation) {
        m_animationValid = calculateFromAndByValues(emptyString(), by);
    } else if (animationMode == ValuesAnimation) {
        m_animationValid = m_values.size() >= 1
            && (calcMode == CalcModePaced || !fastHasAttribute(SVGNames::keyTimesAttr) || fastHasAttribute(SVGNames::keyPointsAttr) || (m_values.size() == m_keyTimes.size()))
            && (calcMode == CalcModeDiscrete || !m_keyTimes.size() || m_keyTimes.last() == 1)
            && (calcMode != CalcModeSpline || ((m_keySplines.size() && (m_keySplines.size() == m_values.size() - 1)) || m_keySplines.size() == m_keyPoints.size() - 1))
            && (!fastHasAttribute(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size()));
        if (m_animationValid)
            m_animationValid = calculateToAtEndOfDurationValue(m_values.last());
        if (calcMode == CalcModePaced && m_animationValid)
            calculateKeyTimesForCalcModePaced();
    } else if (animationMode == PathAnimation) {
        m_animationValid = calcMode == CalcModePaced || !fastHasAttribute(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size());
    }
}
示例#5
0
void HTMLDialogElement::close(const String& returnValue, ExceptionState& exceptionState)
{
    if (!fastHasAttribute(openAttr)) {
        exceptionState.throwDOMException(InvalidStateError, "The element does not have an 'open' attribute, and therefore cannot be closed.");
        return;
    }
    closeDialog(returnValue);
}
示例#6
0
void HTMLAnchorElement::sendPings(const URL& destinationURL)
{
    if (!fastHasAttribute(pingAttr) || !document().settings() || !document().settings()->hyperlinkAuditingEnabled())
        return;

    SpaceSplitString pingURLs(fastGetAttribute(pingAttr), false);
    for (unsigned i = 0; i < pingURLs.size(); i++)
        PingLoader::sendPing(*document().frame(), document().completeURL(pingURLs[i]), destinationURL);
}
void HTMLFieldSetElement::disabledAttributeChanged()
{
    if (fastHasAttribute(disabledAttr))
        document().addDisabledFieldsetElement();
    else
        document().removeDisabledFieldsetElement();

    HTMLFormControlElement::disabledAttributeChanged();
}
void HTMLFieldSetElement::didMoveToNewDocument(Document* oldDocument)
{
    HTMLFormControlElement::didMoveToNewDocument(oldDocument);
    if (fastHasAttribute(disabledAttr)) {
        if (oldDocument)
            oldDocument->removeDisabledFieldsetElement();
        document().addDisabledFieldsetElement();
    }
}
void HTMLElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style)
{
    if (name == alignAttr) {
        if (equalIgnoringCase(value, "middle"))
            addPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, CSSValueCenter);
        else
            addPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, value);
    } else if (name == contenteditableAttr) {
        if (value.isEmpty() || equalIgnoringCase(value, "true")) {
            addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserModify, CSSValueReadWrite);
            addPropertyToPresentationAttributeStyle(style, CSSPropertyWordWrap, CSSValueBreakWord);
            addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLineBreak, CSSValueAfterWhiteSpace);
            UseCounter::count(document(), UseCounter::ContentEditableTrue);
            if (hasTagName(htmlTag))
                UseCounter::count(document(), UseCounter::ContentEditableTrueOnHTML);
        } else if (equalIgnoringCase(value, "plaintext-only")) {
            addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserModify, CSSValueReadWritePlaintextOnly);
            addPropertyToPresentationAttributeStyle(style, CSSPropertyWordWrap, CSSValueBreakWord);
            addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLineBreak, CSSValueAfterWhiteSpace);
            UseCounter::count(document(), UseCounter::ContentEditablePlainTextOnly);
        } else if (equalIgnoringCase(value, "false")) {
            addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserModify, CSSValueReadOnly);
        }
    } else if (name == hiddenAttr) {
        addPropertyToPresentationAttributeStyle(style, CSSPropertyDisplay, CSSValueNone);
    } else if (name == draggableAttr) {
        if (equalIgnoringCase(value, "true")) {
            addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserDrag, CSSValueElement);
            addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserSelect, CSSValueNone);
        } else if (equalIgnoringCase(value, "false")) {
            addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserDrag, CSSValueNone);
        }
    } else if (name == dirAttr) {
        if (equalIgnoringCase(value, "auto")) {
            addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBidi, unicodeBidiAttributeForDirAuto(this));
        } else {
            if (isValidDirAttribute(value))
                addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, value);
            else
                addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, "ltr");
            if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(outputTag))
                addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBidi, CSSValueIsolate);
        }
    } else if (name.matches(XMLNames::langAttr)) {
        mapLanguageAttributeToLocale(value, style);
    } else if (name == langAttr) {
        // xml:lang has a higher priority than lang.
        if (!fastHasAttribute(XMLNames::langAttr))
            mapLanguageAttributeToLocale(value, style);
    } else {
        Element::collectStyleForPresentationAttribute(name, value, style);
    }
}
示例#10
0
void HTMLDialogElement::show()
{
    if (fastHasAttribute(openAttr))
        return;
    setBooleanAttribute(openAttr, true);

    // The layout must be updated here because setFocusForDialog calls
    // Element::isFocusable, which requires an up-to-date layout.
    document().updateLayoutIgnorePendingStylesheets();

    setFocusForDialog(this);
}
示例#11
0
void HTMLElement::getItemRefElements(Vector<HTMLElement*>& itemRefElements)
{
    if (!fastHasAttribute(itemscopeAttr))
        return;

    if (!fastHasAttribute(itemrefAttr) || !itemRef()->length()) {
        itemRefElements.append(this);
        return;
    }

    DOMSettableTokenList* itemRefs = itemRef();
    RefPtr<DOMSettableTokenList> processedItemRef = DOMSettableTokenList::create();

    Node* rootNode;
    if (inDocument())
        rootNode = document();
    else {
        rootNode = this;
        while (Node* parent = rootNode->parentNode())
            rootNode = parent;
    }

    for (Node* current = rootNode; current; current = NodeTraversal::next(current, rootNode)) {
        if (!current->isHTMLElement())
            continue;
        HTMLElement* element = toHTMLElement(current);

        if (element == this) {
            itemRefElements.append(element);
            continue;
        }

        const AtomicString& id = element->getIdAttribute();
        if (!processedItemRef->tokens().contains(id) && itemRefs->tokens().contains(id)) {
            processedItemRef->setValue(id);
            if (!element->isDescendantOf(this))
                itemRefElements.append(element);
        }
    }
}
示例#12
0
bool HTMLElement::matchesReadWritePseudoClass() const
{
    if (fastHasAttribute(contenteditableAttr)) {
        const AtomicString& value = fastGetAttribute(contenteditableAttr);

        if (value.isEmpty() || equalIgnoringCase(value, "true") || equalIgnoringCase(value, "plaintext-only"))
            return true;
        if (equalIgnoringCase(value, "false"))
            return false;
        // All other values should be treated as "inherit".
    }

    return parentElement() && parentElement()->hasEditableStyle();
}
void HTMLFieldSetElement::childrenChanged(const ChildChange& change)
{
    HTMLFormControlElement::childrenChanged(change);
    if (!fastHasAttribute(disabledAttr))
        return;

    HTMLLegendElement* legend = Traversal<HTMLLegendElement>::firstChild(*this);
    if (!legend)
        return;

    // We only care about the first legend element (in which form contorls are not disabled by this element) changing here.
    updateFromControlElementsAncestorDisabledStateUnder(*legend, false /* isDisabled */);
    while ((legend = Traversal<HTMLLegendElement>::nextSibling(*legend)))
        updateFromControlElementsAncestorDisabledStateUnder(*legend, true);
}
示例#14
0
void HTMLDialogElement::closeDialog(const String& returnValue)
{
    if (!fastHasAttribute(openAttr))
        return;
    setBooleanAttribute(openAttr, false);

    HTMLDialogElement* activeModalDialog = document().activeModalDialog();
    document().removeFromTopLayer(this);
    if (activeModalDialog == this)
        inertSubtreesChanged(document());

    if (!returnValue.isNull())
        m_returnValue = returnValue;

    dispatchScopedEvent(Event::create(EventTypeNames::close));
}
void HTMLFieldSetElement::disabledStateChanged()
{
    // This element must be updated before the style of nodes in its subtree gets recalculated.
    HTMLFormControlElement::disabledStateChanged();

    if (disabledByAncestorFieldset())
        return;

    bool thisFieldsetIsDisabled = fastHasAttribute(disabledAttr);
    bool hasSeenFirstLegendElement = false;
    for (HTMLElement* control = Traversal<HTMLElement>::firstChild(*this); control; control = Traversal<HTMLElement>::nextSibling(*control)) {
        if (!hasSeenFirstLegendElement && is<HTMLLegendElement>(*control)) {
            hasSeenFirstLegendElement = true;
            updateFromControlElementsAncestorDisabledStateUnder(*control, false /* isDisabled */);
            continue;
        }
        updateFromControlElementsAncestorDisabledStateUnder(*control, thisFieldsetIsDisabled);
    }
}
void SVGAnimateMotionElement::updateAnimationPath()
{
    m_animationPath = Path();
    bool foundMPath = false;

    for (auto& mPath : childrenOfType<SVGMPathElement>(*this)) {
        SVGPathElement* pathElement = mPath.pathElement();
        if (pathElement) {
            updatePathFromGraphicsElement(pathElement, m_animationPath);
            foundMPath = true;
            break;
        }
    }

    if (!foundMPath && fastHasAttribute(SVGNames::pathAttr))
        m_animationPath = m_path;

    updateAnimationMode();
}
示例#17
0
void HTMLDialogElement::showModal(ExceptionState& exceptionState)
{
    if (fastHasAttribute(openAttr)) {
        exceptionState.throwDOMException(InvalidStateError, "The element already has an 'open' attribute, and therefore cannot be opened modally.");
        return;
    }
    if (!inShadowIncludingDocument()) {
        exceptionState.throwDOMException(InvalidStateError, "The element is not in a Document.");
        return;
    }

    document().addToTopLayer(this);
    setBooleanAttribute(openAttr, true);

    // Throw away the AX cache first, so the subsequent steps don't have a chance of queuing up
    // AX events on objects that would be invalidated when the cache is thrown away.
    inertSubtreesChanged(document());

    forceLayoutForCentering();
    setFocusForDialog(this);
}
void HTMLTrackElement::loadTimerFired(Timer<HTMLTrackElement>*)
{
    if (!fastHasAttribute(srcAttr))
        return;

    WTF_LOG(Media, "HTMLTrackElement::loadTimerFired");

    // 6. Set the text track readiness state to loading.
    setReadyState(HTMLTrackElement::LOADING);

    // 7. Let URL be the track URL of the track element.
    KURL url = getNonEmptyURLAttribute(srcAttr);

    // 8. If the track element's parent is a media element then let CORS mode be the state of the parent media
    // element's crossorigin content attribute. Otherwise, let CORS mode be No CORS.
    if (!canLoadUrl(url)) {
        didCompleteLoad(HTMLTrackElement::Failure);
        return;
    }

    ensureTrack()->scheduleLoad(url);
}
示例#19
0
void HTMLMarqueeElement::continueAnimation() {
    if (!shouldContinue())
        return;

    if (m_player && m_player->playState() == "paused") {
        m_player->play();
        return;
    }

    AnimationParameters parameters = getAnimationParameters();
    int scrollDelay = this->scrollDelay();
    int scrollAmount = this->scrollAmount();

    if (scrollDelay < kMinimumScrollDelayMS &&
            !fastHasAttribute(HTMLNames::truespeedAttr))
        scrollDelay = kDefaultScrollDelayMS;
    double duration = 0;
    if (scrollAmount)
        duration = parameters.distance * scrollDelay / scrollAmount;
    if (!duration)
        return;

    StringKeyframeEffectModel* effectModel = createEffectModel(parameters);
    Timing timing;
    timing.fillMode = Timing::FillMode::FORWARDS;
    TimingInput::setIterationDuration(
        timing, UnrestrictedDoubleOrString::fromUnrestrictedDouble(duration),
        ASSERT_NO_EXCEPTION);

    KeyframeEffect* keyframeEffect =
        KeyframeEffect::create(m_mover, effectModel, timing);
    Animation* player = m_mover->document().timeline().play(keyframeEffect);
    player->setId(emptyString());
    player->setOnfinish(new AnimationFinished(this));

    m_player = player;
}
示例#20
0
bool HTMLFormControlElement::formNoValidate() const
{
    return fastHasAttribute(formnovalidateAttr);
}
bool HTMLProgressElement::isDeterminate() const
{
    return fastHasAttribute(valueAttr);
}
void HTMLDialogElement::show()
{
    if (fastHasAttribute(openAttr))
        return;
    setBooleanAttribute(openAttr, true);
}
bool HTMLOptionElement::defaultSelected() const
{
    return fastHasAttribute(selectedAttr);
}
示例#24
0
bool HTMLOptGroupElement::isDisabledFormControl() const
{
    return fastHasAttribute(disabledAttr);
}