示例#1
0
void SVGFEDisplacementMapElement::parseMappedAttribute(MappedAttribute* attr)
{
    const String& value = attr->value();
    if (attr->name() == SVGNames::xChannelSelectorAttr)
        setXChannelSelectorBaseValue(stringToChannel(value));
    else if (attr->name() == SVGNames::yChannelSelectorAttr)
        setYChannelSelectorBaseValue(stringToChannel(value));
    else if (attr->name() == SVGNames::inAttr)
        setIn1BaseValue(value);
    else if (attr->name() == SVGNames::in2Attr)
        setIn2BaseValue(value);
    else if (attr->name() == SVGNames::scaleAttr)
        setScaleBaseValue(value.toFloat());
    else
        SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
}
void SVGFEDisplacementMapElement::svgAttributeChanged(const QualifiedName& attrName)
{
    SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);

    if (attrName == SVGNames::xChannelSelectorAttr) {
        ChannelSelectorType selector = static_cast<ChannelSelectorType>(xChannelSelector());
        if (CHANNEL_UNKNOWN > selector || selector > CHANNEL_A)
            setXChannelSelectorBaseValue(CHANNEL_UNKNOWN);
        primitiveAttributeChanged(attrName);
    } else if (attrName == SVGNames::yChannelSelectorAttr) {
        ChannelSelectorType selector = static_cast<ChannelSelectorType>(yChannelSelector());
        if (CHANNEL_UNKNOWN > selector || selector > CHANNEL_A)
            setYChannelSelectorBaseValue(CHANNEL_UNKNOWN);
        primitiveAttributeChanged(attrName);
    } else if (attrName == SVGNames::scaleAttr)
        primitiveAttributeChanged(attrName);
    else if (attrName == SVGNames::inAttr || attrName == SVGNames::in2Attr)
        invalidate();
}
void SVGFEDisplacementMapElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
    if (!isSupportedAttribute(name)) {
        SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value);
        return;
    }

    if (name == SVGNames::xChannelSelectorAttr) {
        ChannelSelectorType propertyValue = SVGPropertyTraits<ChannelSelectorType>::fromString(value);
        if (propertyValue > 0)
            setXChannelSelectorBaseValue(propertyValue);
        return;
    }

    if (name == SVGNames::yChannelSelectorAttr) {
        ChannelSelectorType propertyValue = SVGPropertyTraits<ChannelSelectorType>::fromString(value);
        if (propertyValue > 0)
            setYChannelSelectorBaseValue(propertyValue);
        return;
    }

    if (name == SVGNames::inAttr) {
        setIn1BaseValue(value);
        return;
    }

    if (name == SVGNames::in2Attr) {
        setIn2BaseValue(value);
        return;
    }

    if (name == SVGNames::scaleAttr) {
        setScaleBaseValue(value.toFloat());
        return;
    }

    ASSERT_NOT_REACHED();
}