void SVGUseElement::parseMappedAttribute(Attribute* attr) { if (attr->name() == SVGNames::xAttr) setXBaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::yAttr) setYBaseValue(SVGLength(LengthModeHeight, attr->value())); else if (attr->name() == SVGNames::widthAttr) { setWidthBaseValue(SVGLength(LengthModeWidth, attr->value())); if (widthBaseValue().value(this) < 0.0) document()->accessSVGExtensions()->reportError("A negative value for use attribute <width> is not allowed"); } else if (attr->name() == SVGNames::heightAttr) { setHeightBaseValue(SVGLength(LengthModeHeight, attr->value())); if (heightBaseValue().value(this) < 0.0) document()->accessSVGExtensions()->reportError("A negative value for use attribute <height> is not allowed"); } else { if (SVGTests::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; if (SVGURIReference::parseMappedAttribute(attr)) return; SVGStyledTransformableElement::parseMappedAttribute(attr); } }
void SVGMaskElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == SVGNames::maskUnitsAttr) { if (attr->value() == "userSpaceOnUse") setMaskUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE); else if (attr->value() == "objectBoundingBox") setMaskUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); } else if (attr->name() == SVGNames::maskContentUnitsAttr) { if (attr->value() == "userSpaceOnUse") setMaskContentUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE); else if (attr->value() == "objectBoundingBox") setMaskContentUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); } else if (attr->name() == SVGNames::xAttr) setXBaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::yAttr) setYBaseValue(SVGLength(LengthModeHeight, attr->value())); else if (attr->name() == SVGNames::widthAttr) setWidthBaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::heightAttr) setHeightBaseValue(SVGLength(LengthModeHeight, attr->value())); else { if (SVGURIReference::parseMappedAttribute(attr)) return; if (SVGTests::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; SVGStyledElement::parseMappedAttribute(attr); } }
void SVGImageElement::parseMappedAttribute(MappedAttribute *attr) { if (attr->name() == SVGNames::xAttr) setXBaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::yAttr) setYBaseValue(SVGLength(LengthModeHeight, attr->value())); else if (attr->name() == SVGNames::preserveAspectRatioAttr) { const UChar* c = attr->value().characters(); const UChar* end = c + attr->value().length(); preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end); } else if (attr->name() == SVGNames::widthAttr) { setWidthBaseValue(SVGLength(LengthModeWidth, attr->value())); addCSSProperty(attr, CSSPropertyWidth, attr->value()); if (widthBaseValue().value(this) < 0.0) document()->accessSVGExtensions()->reportError("A negative value for image attribute <width> is not allowed"); } else if (attr->name() == SVGNames::heightAttr) { setHeightBaseValue(SVGLength(LengthModeHeight, attr->value())); addCSSProperty(attr, CSSPropertyHeight, attr->value()); if (heightBaseValue().value(this) < 0.0) document()->accessSVGExtensions()->reportError("A negative value for image attribute <height> is not allowed"); } else { if (SVGTests::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; if (SVGURIReference::parseMappedAttribute(attr)) return; SVGStyledTransformableElement::parseMappedAttribute(attr); } }
SVGLength DOMSVGLength::ToSVGLength() { if (HasOwner()) { return SVGLength(InternalItem().GetValueInCurrentUnits(), InternalItem().GetUnit()); } return SVGLength(mValue, mUnit); }
void SVGSVGElement::parseMappedAttribute(Attribute* attr) { if (!nearestViewportElement()) { bool setListener = true; // Only handle events if we're the outermost <svg> element if (attr->name() == onunloadAttr) document()->setWindowAttributeEventListener(eventNames().unloadEvent, createAttributeEventListener(document()->frame(), attr)); else if (attr->name() == onresizeAttr) document()->setWindowAttributeEventListener(eventNames().resizeEvent, createAttributeEventListener(document()->frame(), attr)); else if (attr->name() == onscrollAttr) document()->setWindowAttributeEventListener(eventNames().scrollEvent, createAttributeEventListener(document()->frame(), attr)); else if (attr->name() == SVGNames::onzoomAttr) document()->setWindowAttributeEventListener(eventNames().zoomEvent, createAttributeEventListener(document()->frame(), attr)); else setListener = false; if (setListener) return; } if (attr->name() == onabortAttr) document()->setWindowAttributeEventListener(eventNames().abortEvent, createAttributeEventListener(document()->frame(), attr)); else if (attr->name() == onerrorAttr) document()->setWindowAttributeEventListener(eventNames().errorEvent, createAttributeEventListener(document()->frame(), attr)); else if (attr->name() == SVGNames::xAttr) setXBaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::yAttr) setYBaseValue(SVGLength(LengthModeHeight, attr->value())); else if (attr->name() == SVGNames::widthAttr) { setWidthBaseValue(SVGLength(LengthModeWidth, attr->value())); addCSSProperty(attr, CSSPropertyWidth, attr->value()); if (widthBaseValue().value(this) < 0.0) document()->accessSVGExtensions()->reportError("A negative value for svg attribute <width> is not allowed"); } else if (attr->name() == SVGNames::heightAttr) { setHeightBaseValue(SVGLength(LengthModeHeight, attr->value())); addCSSProperty(attr, CSSPropertyHeight, attr->value()); if (heightBaseValue().value(this) < 0.0) document()->accessSVGExtensions()->reportError("A negative value for svg attribute <height> is not allowed"); } else { if (SVGTests::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; if (SVGFitToViewBox::parseMappedAttribute(document(), attr)) return; if (SVGZoomAndPan::parseMappedAttribute(attr)) return; SVGStyledLocatableElement::parseMappedAttribute(attr); } }
SVGLength SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue* value) { ASSERT(value); SVGLengthType svgType; switch (value->primitiveType()) { case CSSPrimitiveValue::CSS_NUMBER: svgType = LengthTypeNumber; break; case CSSPrimitiveValue::CSS_PERCENTAGE: svgType = LengthTypePercentage; break; case CSSPrimitiveValue::CSS_EMS: svgType = LengthTypeEMS; break; case CSSPrimitiveValue::CSS_EXS: svgType = LengthTypeEXS; break; case CSSPrimitiveValue::CSS_PX: svgType = LengthTypePX; break; case CSSPrimitiveValue::CSS_CM: svgType = LengthTypeCM; break; case CSSPrimitiveValue::CSS_MM: svgType = LengthTypeMM; break; case CSSPrimitiveValue::CSS_IN: svgType = LengthTypeIN; break; case CSSPrimitiveValue::CSS_PT: svgType = LengthTypePT; break; case CSSPrimitiveValue::CSS_PC: svgType = LengthTypePC; break; case CSSPrimitiveValue::CSS_UNKNOWN: default: svgType = LengthTypeUnknown; break; }; if (svgType == LengthTypeUnknown) return SVGLength(); TrackExceptionState exceptionState; SVGLength length; length.newValueSpecifiedUnits(svgType, value->getFloatValue(), exceptionState); if (exceptionState.hadException()) return SVGLength(); return length; }
void SVGLinearGradientElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == SVGNames::x1Attr) setX1BaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::y1Attr) setY1BaseValue(SVGLength(LengthModeHeight, attr->value())); else if (attr->name() == SVGNames::x2Attr) setX2BaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::y2Attr) setY2BaseValue(SVGLength(LengthModeHeight, attr->value())); else SVGGradientElement::parseMappedAttribute(attr); }
SVGLength SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue& value) { SVGLengthType svgType; switch (value.primitiveType()) { case CSSPrimitiveValue::CSS_NUMBER: svgType = LengthTypeNumber; break; case CSSPrimitiveValue::CSS_PERCENTAGE: svgType = LengthTypePercentage; break; case CSSPrimitiveValue::CSS_EMS: svgType = LengthTypeEMS; break; case CSSPrimitiveValue::CSS_EXS: svgType = LengthTypeEXS; break; case CSSPrimitiveValue::CSS_PX: svgType = LengthTypePX; break; case CSSPrimitiveValue::CSS_CM: svgType = LengthTypeCM; break; case CSSPrimitiveValue::CSS_MM: svgType = LengthTypeMM; break; case CSSPrimitiveValue::CSS_IN: svgType = LengthTypeIN; break; case CSSPrimitiveValue::CSS_PT: svgType = LengthTypePT; break; case CSSPrimitiveValue::CSS_PC: svgType = LengthTypePC; break; case CSSPrimitiveValue::CSS_UNKNOWN: default: svgType = LengthTypeUnknown; break; }; if (svgType == LengthTypeUnknown) return SVGLength(); ExceptionCode ec = 0; SVGLength length; length.newValueSpecifiedUnits(svgType, value.getFloatValue(), ec); if (ec) return SVGLength(); return length; }
void SVGSVGElement::parseMappedAttribute(MappedAttribute* attr) { if (!nearestViewportElement()) { // Only handle events if we're the outermost <svg> element if (attr->name() == onunloadAttr) addSVGWindowEventListener(unloadEvent, attr); else if (attr->name() == onabortAttr) addSVGWindowEventListener(abortEvent, attr); else if (attr->name() == onerrorAttr) addSVGWindowEventListener(errorEvent, attr); else if (attr->name() == onresizeAttr) addSVGWindowEventListener(resizeEvent, attr); else if (attr->name() == onscrollAttr) addSVGWindowEventListener(scrollEvent, attr); else if (attr->name() == SVGNames::onzoomAttr) addSVGWindowEventListener(zoomEvent, attr); } if (attr->name() == SVGNames::xAttr) setXBaseValue(SVGLength(this, LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::yAttr) setYBaseValue(SVGLength(this, LengthModeHeight, attr->value())); else if (attr->name() == SVGNames::widthAttr) { setWidthBaseValue(SVGLength(this, LengthModeWidth, attr->value())); addCSSProperty(attr, CSS_PROP_WIDTH, attr->value()); if (width().value() < 0.0) document()->accessSVGExtensions()->reportError("A negative value for svg attribute <width> is not allowed"); } else if (attr->name() == SVGNames::heightAttr) { setHeightBaseValue(SVGLength(this, LengthModeHeight, attr->value())); addCSSProperty(attr, CSS_PROP_HEIGHT, attr->value()); if (height().value() < 0.0) document()->accessSVGExtensions()->reportError("A negative value for svg attribute <height> is not allowed"); } else { if (SVGTests::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; if (SVGFitToViewBox::parseMappedAttribute(attr) && renderer()) { static_cast<RenderSVGContainer*>(renderer())->setViewBox(viewBox()); return; } if (SVGZoomAndPan::parseMappedAttribute(attr)) return; SVGStyledLocatableElement::parseMappedAttribute(attr); } }
void SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(Attribute* attr) { const AtomicString& value = attr->value(); if (attr->name() == SVGNames::xAttr) setXBaseValue(SVGLength(LengthModeWidth, value)); else if (attr->name() == SVGNames::yAttr) setYBaseValue(SVGLength(LengthModeHeight, value)); else if (attr->name() == SVGNames::widthAttr) setWidthBaseValue(SVGLength(LengthModeWidth, value)); else if (attr->name() == SVGNames::heightAttr) setHeightBaseValue(SVGLength(LengthModeHeight, value)); else if (attr->name() == SVGNames::resultAttr) setResultBaseValue(value); else return SVGStyledElement::parseMappedAttribute(attr); }
void SVGTextContentElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == SVGNames::lengthAdjustAttr) { if (attr->value() == "spacing") setLengthAdjustBaseValue(LENGTHADJUST_SPACING); else if (attr->value() == "spacingAndGlyphs") setLengthAdjustBaseValue(LENGTHADJUST_SPACINGANDGLYPHS); } else if (attr->name() == SVGNames::textLengthAttr) { setTextLengthBaseValue(SVGLength(this, LengthModeOther, attr->value())); if (textLength().value() < 0.0) document()->accessSVGExtensions()->reportError("A negative value for text attribute <textLength> is not allowed"); } else { if (SVGTests::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) { if (attr->name().matches(XMLNames::spaceAttr)) { static const AtomicString preserveString("preserve"); if (attr->value() == preserveString) addCSSProperty(attr, CSSPropertyWhiteSpace, CSSValuePre); else addCSSProperty(attr, CSSPropertyWhiteSpace, CSSValueNowrap); } return; } if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; SVGStyledElement::parseMappedAttribute(attr); } }
void SVGRadialGradientElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == SVGNames::cxAttr) setCxBaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::cyAttr) setCyBaseValue(SVGLength(LengthModeHeight, attr->value())); else if (attr->name() == SVGNames::rAttr) { setRBaseValue(SVGLength(LengthModeOther, attr->value())); if (rBaseValue().value(this) < 0.0) document()->accessSVGExtensions()->reportError("A negative value for radial gradient radius <r> is not allowed"); } else if (attr->name() == SVGNames::fxAttr) setFxBaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::fyAttr) setFyBaseValue(SVGLength(LengthModeHeight, attr->value())); else SVGGradientElement::parseMappedAttribute(attr); }
void SVGCursorElement::parseMappedAttribute(Attribute* attr) { if (attr->name() == SVGNames::xAttr) setXBaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::yAttr) setYBaseValue(SVGLength(LengthModeHeight, attr->value())); else { if (SVGTests::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; if (SVGURIReference::parseMappedAttribute(attr)) return; SVGElement::parseMappedAttribute(attr); } }
void SVGPatternElement::parseMappedAttribute(Attribute* attr) { if (attr->name() == SVGNames::patternUnitsAttr) { if (attr->value() == "userSpaceOnUse") setPatternUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE); else if (attr->value() == "objectBoundingBox") setPatternUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); } else if (attr->name() == SVGNames::patternContentUnitsAttr) { if (attr->value() == "userSpaceOnUse") setPatternContentUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE); else if (attr->value() == "objectBoundingBox") setPatternContentUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); } else if (attr->name() == SVGNames::patternTransformAttr) { SVGTransformList newList; if (!SVGTransformable::parseTransformAttribute(newList, attr->value())) newList.clear(); detachAnimatedPatternTransformListWrappers(newList.size()); setPatternTransformBaseValue(newList); } else if (attr->name() == SVGNames::xAttr) setXBaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::yAttr) setYBaseValue(SVGLength(LengthModeHeight, attr->value())); else if (attr->name() == SVGNames::widthAttr) { setWidthBaseValue(SVGLength(LengthModeWidth, attr->value())); if (widthBaseValue().value(this) < 0.0) document()->accessSVGExtensions()->reportError("A negative value for pattern attribute <width> is not allowed"); } else if (attr->name() == SVGNames::heightAttr) { setHeightBaseValue(SVGLength(LengthModeHeight, attr->value())); if (heightBaseValue().value(this) < 0.0) document()->accessSVGExtensions()->reportError("A negative value for pattern attribute <height> is not allowed"); } else { if (SVGURIReference::parseMappedAttribute(attr)) return; if (SVGTests::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; if (SVGFitToViewBox::parseMappedAttribute(document(), attr)) return; SVGStyledElement::parseMappedAttribute(attr); } }
void SVGAnimatedLengthListAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, OwnPtr<SVGAnimatedType>& animated) { ASSERT(m_animationElement); ASSERT(m_contextElement); SVGAnimateElement* animationElement = static_cast<SVGAnimateElement*>(m_animationElement); AnimationMode animationMode = animationElement->animationMode(); // To animation uses contributions from the lower priority animations as the base value. SVGLengthList& fromLengthList = from->lengthList(); SVGLengthList& animatedLengthList = animated->lengthList(); if (animationMode == ToAnimation) fromLengthList = animatedLengthList; // Replace 'inherit' by their computed property values. SVGLengthList& toLengthList = to->lengthList(); if (animationElement->fromPropertyValueType() == InheritValue) { String fromLengthString; animationElement->adjustForInheritance(m_contextElement, animationElement->attributeName(), fromLengthString); fromLengthList.parse(fromLengthString, m_lengthMode); } if (animationElement->toPropertyValueType() == InheritValue) { String toLengthString; animationElement->adjustForInheritance(m_contextElement, animationElement->attributeName(), toLengthString); toLengthList.parse(toLengthString, m_lengthMode); } unsigned itemsCount = fromLengthList.size(); if (itemsCount != toLengthList.size()) { if (percentage < 0.5) { if (animationMode != ToAnimation) animatedLengthList = fromLengthList; } else animatedLengthList = toLengthList; return; } bool animatedListSizeEqual = itemsCount == animatedLengthList.size(); if (!animatedListSizeEqual) animatedLengthList.clear(); SVGLengthContext lengthContext(m_contextElement); ExceptionCode ec = 0; for (unsigned i = 0; i < itemsCount; ++i) { float result = animatedListSizeEqual ? animatedLengthList[i].value(lengthContext) : 0; SVGLengthType unitType = percentage < 0.5 ? fromLengthList[i].unitType() : toLengthList[i].unitType(); SVGAnimatedNumberAnimator::calculateAnimatedNumber(animationElement, percentage, repeatCount, result, fromLengthList[i].value(lengthContext), toLengthList[i].value(lengthContext)); if (!animatedListSizeEqual) animatedLengthList.append(SVGLength(lengthContext, result, m_lengthMode, unitType)); else { animatedLengthList[i].setValue(lengthContext, result, m_lengthMode, unitType, ec); ASSERT(!ec); } } }
void SVGLineElement::parseMappedAttribute(Attribute* attr) { if (attr->name() == SVGNames::x1Attr) setX1BaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::y1Attr) setY1BaseValue(SVGLength(LengthModeHeight, attr->value())); else if (attr->name() == SVGNames::x2Attr) setX2BaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::y2Attr) setY2BaseValue(SVGLength(LengthModeHeight, attr->value())); else { if (SVGTests::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; SVGStyledTransformableElement::parseMappedAttribute(attr); } }
void SVGCircleElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == SVGNames::cxAttr) setCxBaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::cyAttr) setCyBaseValue(SVGLength(LengthModeHeight, attr->value())); else if (attr->name() == SVGNames::rAttr) { setRBaseValue(SVGLength(LengthModeOther, attr->value())); if (rBaseValue().value(this) < 0.0) document()->accessSVGExtensions()->reportError("A negative value for circle <r> is not allowed"); } else { if (SVGTests::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; SVGStyledTransformableElement::parseMappedAttribute(attr); } }
void SVGForeignObjectElement::parseMappedAttribute(Attribute* attr) { const AtomicString& value = attr->value(); if (attr->name() == SVGNames::xAttr) setXBaseValue(SVGLength(LengthModeWidth, value)); else if (attr->name() == SVGNames::yAttr) setYBaseValue(SVGLength(LengthModeHeight, value)); else if (attr->name() == SVGNames::widthAttr) setWidthBaseValue(SVGLength(LengthModeWidth, value)); else if (attr->name() == SVGNames::heightAttr) setHeightBaseValue(SVGLength(LengthModeHeight, value)); else { if (SVGTests::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; SVGStyledTransformableElement::parseMappedAttribute(attr); } }
void SVGMarkerElement::parseMappedAttribute(Attribute* attr) { if (attr->name() == SVGNames::markerUnitsAttr) { if (attr->value() == "userSpaceOnUse") setMarkerUnitsBaseValue(SVG_MARKERUNITS_USERSPACEONUSE); else if (attr->value() == "strokeWidth") setMarkerUnitsBaseValue(SVG_MARKERUNITS_STROKEWIDTH); } else if (attr->name() == SVGNames::refXAttr) setRefXBaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::refYAttr) setRefYBaseValue(SVGLength(LengthModeHeight, attr->value())); else if (attr->name() == SVGNames::markerWidthAttr) setMarkerWidthBaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::markerHeightAttr) setMarkerHeightBaseValue(SVGLength(LengthModeHeight, attr->value())); else if (attr->name() == SVGNames::orientAttr) { SVGAngle angle; if (attr->value() == "auto") setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO); else { ExceptionCode ec = 0; angle.setValueAsString(attr->value(), ec); setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE); } setOrientAngleBaseValue(angle); } else { if (SVGLangSpace::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; if (SVGFitToViewBox::parseMappedAttribute(document(), attr)) return; SVGStyledElement::parseMappedAttribute(attr); } }
void SVGFilterElement::parseMappedAttribute(MappedAttribute* attr) { const String& value = attr->value(); if (attr->name() == SVGNames::filterUnitsAttr) { if (value == "userSpaceOnUse") setFilterUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE); else if (value == "objectBoundingBox") setFilterUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); } else if (attr->name() == SVGNames::primitiveUnitsAttr) { if (value == "userSpaceOnUse") setPrimitiveUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE); else if (value == "objectBoundingBox") setPrimitiveUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); } else if (attr->name() == SVGNames::xAttr) setXBaseValue(SVGLength(LengthModeWidth, value)); else if (attr->name() == SVGNames::yAttr) setYBaseValue(SVGLength(LengthModeHeight, value)); else if (attr->name() == SVGNames::widthAttr) setWidthBaseValue(SVGLength(LengthModeWidth, value)); else if (attr->name() == SVGNames::heightAttr) setHeightBaseValue(SVGLength(LengthModeHeight, value)); else if (attr->name() == SVGNames::filterResAttr) { float x, y; if (parseNumberOptionalNumber(value, x, y)) { setFilterResXBaseValue(x); setFilterResYBaseValue(y); } } else { if (SVGURIReference::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; SVGStyledElement::parseMappedAttribute(attr); } }
void SVGLengthList::parse(const String& value, const SVGStyledElement* context, SVGLengthMode mode) { ExceptionCode ec = 0; clear(ec); const UChar* ptr = value.characters(); const UChar* end = ptr + value.length(); while (ptr < end) { const UChar* start = ptr; while (ptr < end && *ptr != ',' && !isWhitespace(*ptr)) ptr++; if (ptr == start) break; appendItem(SVGLength(context, mode, String(start, ptr - start)), ec); skipOptionalSpacesOrDelimiter(ptr, end); } }
float SVGLength::GetValueInSpecifiedUnit(PRUint8 aUnit, const nsSVGElement *aElement, PRUint8 aAxis) const { if (aUnit == mUnit) { return mValue; } if ((aUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER && mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_PX) || (aUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_PX && mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER)) { return mValue; } if (IsAbsoluteUnit(aUnit) && IsAbsoluteUnit(mUnit)) { return mValue * GetAbsUnitsPerAbsUnit(aUnit, mUnit); } // Otherwise we do a two step convertion via user units. This can only // succeed if aElement is non-null (although that's not sufficent to // guarantee success). float userUnitsPerCurrentUnit = GetUserUnitsPerUnit(aElement, aAxis); float userUnitsPerNewUnit = SVGLength(0.0f, aUnit).GetUserUnitsPerUnit(aElement, aAxis); NS_ASSERTION(userUnitsPerCurrentUnit >= 0 || !NS_finite(userUnitsPerCurrentUnit), "bad userUnitsPerCurrentUnit"); NS_ASSERTION(userUnitsPerNewUnit >= 0 || !NS_finite(userUnitsPerNewUnit), "bad userUnitsPerNewUnit"); float value = mValue * userUnitsPerCurrentUnit / userUnitsPerNewUnit; // userUnitsPerCurrentUnit could be infinity, or userUnitsPerNewUnit could // be zero. if (NS_finite(value)) { return value; } return std::numeric_limits<float>::quiet_NaN(); }
void DOMSVGLength::GetValueAsString(nsAString& aValue) { if (mVal) { if (mIsAnimValItem) { mSVGElement->FlushAnimations(); mVal->GetAnimValueString(aValue); } else { mVal->GetBaseValueString(aValue); } return; } if (mIsAnimValItem && HasOwner()) { Element()->FlushAnimations(); // May make HasOwner() == false } if (HasOwner()) { InternalItem().GetValueAsString(aValue); return; } SVGLength(mValue, mUnit).GetValueAsString(aValue); }
void SVGTextPathElement::parseMappedAttribute(MappedAttribute* attr) { const String& value = attr->value(); if (attr->name() == SVGNames::startOffsetAttr) setStartOffsetBaseValue(SVGLength(LengthModeOther, value)); else if (attr->name() == SVGNames::methodAttr) { if (value == "align") setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_ALIGN); else if(value == "stretch") setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_STRETCH); } else if (attr->name() == SVGNames::spacingAttr) { if (value == "auto") setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_AUTO); else if (value == "exact") setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_EXACT); } else { if (SVGURIReference::parseMappedAttribute(attr)) return; SVGTextContentElement::parseMappedAttribute(attr); } }
SVGLength SVGSVGElement::createSVGLength() { return SVGLength(); }
void SVGSVGElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { if (!nearestViewportElement()) { // Since we only handle events if we're the outermost <svg> element, set listeners only // if we are. Set the listeners directly on the window attribute. // FIXME: This strategy is wrong. It won't work if we an existing <svg> element becomes // the outermost or if an existing <svg> element later becomes no longer outmost. if (name == HTMLNames::onunloadAttr) { document().setWindowAttributeEventListener(eventNames().unloadEvent, name, value); return; } if (name == HTMLNames::onresizeAttr) { document().setWindowAttributeEventListener(eventNames().resizeEvent, name, value); return; } if (name == HTMLNames::onscrollAttr) { document().setWindowAttributeEventListener(eventNames().scrollEvent, name, value); return; } if (name == SVGNames::onzoomAttr) { document().setWindowAttributeEventListener(eventNames().zoomEvent, name, value); return; } } SVGParsingError parseError = NoError; if (name == HTMLNames::onabortAttr) document().setWindowAttributeEventListener(eventNames().abortEvent, name, value); else if (name == HTMLNames::onerrorAttr) document().setWindowAttributeEventListener(eventNames().errorEvent, name, value); else if (name == SVGNames::xAttr) setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); else if (name == SVGNames::yAttr) setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)); else if (name == SVGNames::widthAttr) { SVGLength length = SVGLength::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths); if (parseError != NoError || value.isEmpty()) { // FIXME: This is definitely the correct behavior for a missing/removed attribute. // Not sure it's correct for the empty string or for something that can't be parsed. length = SVGLength(LengthModeWidth, ASCIILiteral("100%")); } setWidthBaseValue(length); } else if (name == SVGNames::heightAttr) { SVGLength length = SVGLength::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths); if (parseError != NoError || value.isEmpty()) { // FIXME: This is definitely the correct behavior for a removed attribute. // Not sure it's correct for the empty string or for something that can't be parsed. length = SVGLength(LengthModeHeight, ASCIILiteral("100%")); } setHeightBaseValue(length); } reportAttributeParsingError(parseError, name, value); SVGLangSpace::parseAttribute(name, value); SVGExternalResourcesRequired::parseAttribute(name, value); SVGFitToViewBox::parseAttribute(this, name, value); SVGZoomAndPan::parseAttribute(*this, name, value); SVGGraphicsElement::parseAttribute(name, value); }
SVGLength toSVGLength(KJS::JSValue* val) { return val->isObject(&JSSVGLength::info) ? (SVGLength) *static_cast<JSSVGLength*>(val)->impl() : SVGLength(); }
void SVGSVGElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { if (!nearestViewportElement()) { // For these events, the outermost <svg> element works like a <body> element does, // setting certain event handlers directly on the window object. if (name == HTMLNames::onunloadAttr) { document().setWindowAttributeEventListener(eventNames().unloadEvent, name, value); return; } if (name == HTMLNames::onresizeAttr) { document().setWindowAttributeEventListener(eventNames().resizeEvent, name, value); return; } if (name == HTMLNames::onscrollAttr) { document().setWindowAttributeEventListener(eventNames().scrollEvent, name, value); return; } if (name == SVGNames::onzoomAttr) { document().setWindowAttributeEventListener(eventNames().zoomEvent, name, value); return; } } // For these events, any <svg> element works like a <body> element does, // setting certain event handlers directly on the window object. // FIXME: Why different from the events above that work only on the outermost <svg> element? if (name == HTMLNames::onabortAttr) { document().setWindowAttributeEventListener(eventNames().abortEvent, name, value); return; } if (name == HTMLNames::onerrorAttr) { document().setWindowAttributeEventListener(eventNames().errorEvent, name, value); return; } SVGParsingError parseError = NoError; if (name == SVGNames::xAttr) setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); else if (name == SVGNames::yAttr) setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)); else if (name == SVGNames::widthAttr) { SVGLength length = SVGLength::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths); if (parseError != NoError || value.isEmpty()) { // FIXME: This is definitely the correct behavior for a missing/removed attribute. // Not sure it's correct for the empty string or for something that can't be parsed. length = SVGLength(LengthModeWidth, ASCIILiteral("100%")); } setWidthBaseValue(length); } else if (name == SVGNames::heightAttr) { SVGLength length = SVGLength::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths); if (parseError != NoError || value.isEmpty()) { // FIXME: This is definitely the correct behavior for a removed attribute. // Not sure it's correct for the empty string or for something that can't be parsed. length = SVGLength(LengthModeHeight, ASCIILiteral("100%")); } setHeightBaseValue(length); } reportAttributeParsingError(parseError, name, value); SVGExternalResourcesRequired::parseAttribute(name, value); SVGFitToViewBox::parseAttribute(this, name, value); SVGZoomAndPan::parseAttribute(*this, name, value); SVGGraphicsElement::parseAttribute(name, value); }