Пример #1
0
void SVGSMILElement::parseAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& value)
{
    if (name == SVGNames::beginAttr) {
        if (!m_conditions.isEmpty()) {
            clearConditions();
            parseBeginOrEnd(fastGetAttribute(SVGNames::endAttr), End);
        }
        parseBeginOrEnd(value.getString(), Begin);
        if (inShadowIncludingDocument())
            connectSyncBaseConditions();
    } else if (name == SVGNames::endAttr) {
        if (!m_conditions.isEmpty()) {
            clearConditions();
            parseBeginOrEnd(fastGetAttribute(SVGNames::beginAttr), Begin);
        }
        parseBeginOrEnd(value.getString(), End);
        if (inShadowIncludingDocument())
            connectSyncBaseConditions();
    } else if (name == SVGNames::onbeginAttr) {
        setAttributeEventListener(EventTypeNames::beginEvent, createAttributeEventListener(this, name, value, eventParameterName()));
    } else if (name == SVGNames::onendAttr) {
        setAttributeEventListener(EventTypeNames::endEvent, createAttributeEventListener(this, name, value, eventParameterName()));
    } else if (name == SVGNames::onrepeatAttr) {
        setAttributeEventListener(EventTypeNames::repeatEvent, createAttributeEventListener(this, name, value, eventParameterName()));
    } else {
        SVGElement::parseAttribute(name, oldValue, value);
    }
}
Пример #2
0
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 (inShadowIncludingDocument()) {
            connectEventBaseConditions();
            if (attrName == SVGNames::beginAttr)
                beginListChanged(elapsed());
            else if (attrName == SVGNames::endAttr)
                endListChanged(elapsed());
        }
    } else {
        SVGElement::svgAttributeChanged(attrName);
        return;
    }

    animationAttributeChanged();
}
Пример #3
0
void SVGSMILElement::buildPendingResource()
{
    clearResourceAndEventBaseReferences();

    if (!inShadowIncludingDocument()) {
        // Reset the target element if we are no longer in the document.
        setTargetElement(nullptr);
        return;
    }

    AtomicString id;
    const AtomicString& href = SVGURIReference::legacyHrefString(*this);
    Element* target;
    if (href.isEmpty())
        target = parentNode() && parentNode()->isElementNode() ? toElement(parentNode()) : nullptr;
    else
        target = SVGURIReference::targetElementFromIRIString(href, treeScope(), &id);
    SVGElement* svgTarget = target && target->isSVGElement() ? toSVGElement(target) : nullptr;

    if (svgTarget && !svgTarget->inShadowIncludingDocument())
        svgTarget = nullptr;

    if (svgTarget != targetElement())
        setTargetElement(svgTarget);

    if (!svgTarget) {
        // Do not register as pending if we are already pending this resource.
        if (document().accessSVGExtensions().isElementPendingResource(this, id))
            return;

        if (!id.isEmpty()) {
            document().accessSVGExtensions().addPendingResource(id, this);
            ASSERT(hasPendingResources());
        }
    } else {
        // Register us with the target in the dependencies map. Any change of hrefElement
        // that leads to relayout/repainting now informs us, so we can react to it.
        addReferenceTo(svgTarget);
    }
    connectEventBaseConditions();
}
Пример #4
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);
}
Пример #5
0
void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextFieldSelectionDirection direction, NeedToDispatchSelectEvent eventBehaviour, SelectionOption selectionOption)
{
    if (openShadowRoot() || !isTextFormControl())
        return;
    const int editorValueLength = static_cast<int>(innerEditorValue().length());
    ASSERT(editorValueLength >= 0);
    end = std::max(std::min(end, editorValueLength), 0);
    start = std::min(std::max(start, 0), end);
    cacheSelection(start, end, direction);

    if (selectionOption == NotChangeSelection || (selectionOption == ChangeSelectionIfFocused && document().focusedElement() != this) || !inShadowIncludingDocument()) {
        if (eventBehaviour == DispatchSelectEvent)
            scheduleSelectEvent();
        return;
    }

    LocalFrame* frame = document().frame();
    HTMLElement* innerEditor = innerEditorElement();
    if (!frame || !innerEditor)
        return;

    Position startPosition = positionForIndex(innerEditor, start);
    Position endPosition = start == end ? startPosition : positionForIndex(innerEditor, end);

    ASSERT(start == indexForPosition(innerEditor, startPosition));
    ASSERT(end == indexForPosition(innerEditor, endPosition));

#if ENABLE(ASSERT)
    // startPosition and endPosition can be null position for example when
    // "-webkit-user-select: none" style attribute is specified.
    if (startPosition.isNotNull() && endPosition.isNotNull()) {
        ASSERT(startPosition.anchorNode()->shadowHost() == this
            && endPosition.anchorNode()->shadowHost() == this);
    }
#endif // ENABLE(ASSERT)
    VisibleSelection newSelection;
    if (direction == SelectionHasBackwardDirection)
        newSelection.setWithoutValidation(endPosition, startPosition);
    else
        newSelection.setWithoutValidation(startPosition, endPosition);
    newSelection.setIsDirectional(direction != SelectionHasNoDirection);

    frame->selection().setSelection(newSelection, FrameSelection::DoNotAdjustInFlatTree | FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | (selectionOption == ChangeSelectionAndFocus ? 0 : FrameSelection::DoNotSetFocus));
    if (eventBehaviour == DispatchSelectEvent)
        scheduleSelectEvent();
}