summaryrefslogtreecommitdiffstats
path: root/WebCore/svg
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/svg')
-rw-r--r--WebCore/svg/ColorDistance.cpp94
-rw-r--r--WebCore/svg/ColorDistance.h53
-rw-r--r--WebCore/svg/GradientAttributes.h74
-rw-r--r--WebCore/svg/LinearGradientAttributes.h78
-rw-r--r--WebCore/svg/PatternAttributes.h103
-rw-r--r--WebCore/svg/RadialGradientAttributes.h85
-rw-r--r--WebCore/svg/SVGAElement.cpp198
-rw-r--r--WebCore/svg/SVGAElement.h76
-rw-r--r--WebCore/svg/SVGAElement.idl38
-rw-r--r--WebCore/svg/SVGAngle.cpp175
-rw-r--r--WebCore/svg/SVGAngle.h83
-rw-r--r--WebCore/svg/SVGAngle.idl45
-rw-r--r--WebCore/svg/SVGAnimateColorElement.cpp105
-rw-r--r--WebCore/svg/SVGAnimateColorElement.h63
-rw-r--r--WebCore/svg/SVGAnimateColorElement.idl31
-rw-r--r--WebCore/svg/SVGAnimateElement.cpp47
-rw-r--r--WebCore/svg/SVGAnimateElement.h54
-rw-r--r--WebCore/svg/SVGAnimateElement.idl32
-rw-r--r--WebCore/svg/SVGAnimateMotionElement.cpp230
-rw-r--r--WebCore/svg/SVGAnimateMotionElement.h82
-rw-r--r--WebCore/svg/SVGAnimateTransformElement.cpp172
-rw-r--r--WebCore/svg/SVGAnimateTransformElement.h72
-rw-r--r--WebCore/svg/SVGAnimateTransformElement.idl31
-rw-r--r--WebCore/svg/SVGAnimatedAngle.idl33
-rw-r--r--WebCore/svg/SVGAnimatedBoolean.idl34
-rw-r--r--WebCore/svg/SVGAnimatedEnumeration.idl34
-rw-r--r--WebCore/svg/SVGAnimatedInteger.idl34
-rw-r--r--WebCore/svg/SVGAnimatedLength.idl33
-rw-r--r--WebCore/svg/SVGAnimatedLengthList.idl33
-rw-r--r--WebCore/svg/SVGAnimatedNumber.idl35
-rw-r--r--WebCore/svg/SVGAnimatedNumberList.idl33
-rw-r--r--WebCore/svg/SVGAnimatedPathData.cpp42
-rw-r--r--WebCore/svg/SVGAnimatedPathData.h50
-rw-r--r--WebCore/svg/SVGAnimatedPathData.idl35
-rw-r--r--WebCore/svg/SVGAnimatedPoints.cpp42
-rw-r--r--WebCore/svg/SVGAnimatedPoints.h48
-rw-r--r--WebCore/svg/SVGAnimatedPoints.idl33
-rw-r--r--WebCore/svg/SVGAnimatedPreserveAspectRatio.idl33
-rw-r--r--WebCore/svg/SVGAnimatedRect.idl33
-rw-r--r--WebCore/svg/SVGAnimatedString.idl34
-rw-r--r--WebCore/svg/SVGAnimatedTemplate.h177
-rw-r--r--WebCore/svg/SVGAnimatedTransformList.idl33
-rw-r--r--WebCore/svg/SVGAnimationElement.cpp747
-rw-r--r--WebCore/svg/SVGAnimationElement.h193
-rw-r--r--WebCore/svg/SVGAnimationElement.idl39
-rw-r--r--WebCore/svg/SVGCircleElement.cpp102
-rw-r--r--WebCore/svg/SVGCircleElement.h64
-rw-r--r--WebCore/svg/SVGCircleElement.idl40
-rw-r--r--WebCore/svg/SVGClipPathElement.cpp127
-rw-r--r--WebCore/svg/SVGClipPathElement.h67
-rw-r--r--WebCore/svg/SVGClipPathElement.idl39
-rw-r--r--WebCore/svg/SVGColor.cpp123
-rw-r--r--WebCore/svg/SVGColor.h79
-rw-r--r--WebCore/svg/SVGColor.idl48
-rw-r--r--WebCore/svg/SVGComponentTransferFunctionElement.cpp112
-rw-r--r--WebCore/svg/SVGComponentTransferFunctionElement.h61
-rw-r--r--WebCore/svg/SVGComponentTransferFunctionElement.idl46
-rw-r--r--WebCore/svg/SVGCursorElement.cpp97
-rw-r--r--WebCore/svg/SVGCursorElement.h67
-rw-r--r--WebCore/svg/SVGCursorElement.idl36
-rw-r--r--WebCore/svg/SVGDefinitionSrcElement.cpp45
-rw-r--r--WebCore/svg/SVGDefinitionSrcElement.h39
-rw-r--r--WebCore/svg/SVGDefinitionSrcElement.idl31
-rw-r--r--WebCore/svg/SVGDefsElement.cpp56
-rw-r--r--WebCore/svg/SVGDefsElement.h56
-rw-r--r--WebCore/svg/SVGDefsElement.idl36
-rw-r--r--WebCore/svg/SVGDescElement.cpp48
-rw-r--r--WebCore/svg/SVGDescElement.h46
-rw-r--r--WebCore/svg/SVGDescElement.idl33
-rw-r--r--WebCore/svg/SVGDocument.cpp107
-rw-r--r--WebCore/svg/SVGDocument.h62
-rw-r--r--WebCore/svg/SVGDocument.idl34
-rw-r--r--WebCore/svg/SVGDocumentExtensions.cpp178
-rw-r--r--WebCore/svg/SVGDocumentExtensions.h190
-rw-r--r--WebCore/svg/SVGElement.cpp259
-rw-r--r--WebCore/svg/SVGElement.h252
-rw-r--r--WebCore/svg/SVGElement.idl36
-rw-r--r--WebCore/svg/SVGElementInstance.cpp208
-rw-r--r--WebCore/svg/SVGElementInstance.h108
-rw-r--r--WebCore/svg/SVGElementInstance.idl49
-rw-r--r--WebCore/svg/SVGElementInstanceList.cpp66
-rw-r--r--WebCore/svg/SVGElementInstanceList.h48
-rw-r--r--WebCore/svg/SVGElementInstanceList.idl32
-rw-r--r--WebCore/svg/SVGEllipseElement.cpp111
-rw-r--r--WebCore/svg/SVGEllipseElement.h65
-rw-r--r--WebCore/svg/SVGEllipseElement.idl40
-rw-r--r--WebCore/svg/SVGException.h52
-rw-r--r--WebCore/svg/SVGException.idl42
-rw-r--r--WebCore/svg/SVGExternalResourcesRequired.cpp62
-rw-r--r--WebCore/svg/SVGExternalResourcesRequired.h62
-rw-r--r--WebCore/svg/SVGExternalResourcesRequired.idl33
-rw-r--r--WebCore/svg/SVGFEBlendElement.cpp86
-rw-r--r--WebCore/svg/SVGFEBlendElement.h57
-rw-r--r--WebCore/svg/SVGFEBlendElement.idl43
-rw-r--r--WebCore/svg/SVGFEColorMatrixElement.cpp98
-rw-r--r--WebCore/svg/SVGFEColorMatrixElement.h59
-rw-r--r--WebCore/svg/SVGFEColorMatrixElement.idl42
-rw-r--r--WebCore/svg/SVGFEComponentTransferElement.cpp87
-rw-r--r--WebCore/svg/SVGFEComponentTransferElement.h54
-rw-r--r--WebCore/svg/SVGFEComponentTransferElement.idl33
-rw-r--r--WebCore/svg/SVGFECompositeElement.cpp111
-rw-r--r--WebCore/svg/SVGFECompositeElement.h62
-rw-r--r--WebCore/svg/SVGFECompositeElement.idl48
-rw-r--r--WebCore/svg/SVGFEDiffuseLightingElement.cpp126
-rw-r--r--WebCore/svg/SVGFEDiffuseLightingElement.h59
-rw-r--r--WebCore/svg/SVGFEDiffuseLightingElement.idl37
-rw-r--r--WebCore/svg/SVGFEDisplacementMapElement.cpp100
-rw-r--r--WebCore/svg/SVGFEDisplacementMapElement.h55
-rw-r--r--WebCore/svg/SVGFEDisplacementMapElement.idl44
-rw-r--r--WebCore/svg/SVGFEDistantLightElement.cpp44
-rw-r--r--WebCore/svg/SVGFEDistantLightElement.h40
-rw-r--r--WebCore/svg/SVGFEDistantLightElement.idl33
-rw-r--r--WebCore/svg/SVGFEFloodElement.cpp84
-rw-r--r--WebCore/svg/SVGFEFloodElement.h53
-rw-r--r--WebCore/svg/SVGFEFloodElement.idl33
-rw-r--r--WebCore/svg/SVGFEFuncAElement.cpp43
-rw-r--r--WebCore/svg/SVGFEFuncAElement.h41
-rw-r--r--WebCore/svg/SVGFEFuncAElement.idl31
-rw-r--r--WebCore/svg/SVGFEFuncBElement.cpp43
-rw-r--r--WebCore/svg/SVGFEFuncBElement.h41
-rw-r--r--WebCore/svg/SVGFEFuncBElement.idl31
-rw-r--r--WebCore/svg/SVGFEFuncGElement.cpp43
-rw-r--r--WebCore/svg/SVGFEFuncGElement.h41
-rw-r--r--WebCore/svg/SVGFEFuncGElement.idl31
-rw-r--r--WebCore/svg/SVGFEFuncRElement.cpp43
-rw-r--r--WebCore/svg/SVGFEFuncRElement.h41
-rw-r--r--WebCore/svg/SVGFEFuncRElement.idl31
-rw-r--r--WebCore/svg/SVGFEGaussianBlurElement.cpp87
-rw-r--r--WebCore/svg/SVGFEGaussianBlurElement.h60
-rw-r--r--WebCore/svg/SVGFEGaussianBlurElement.idl37
-rw-r--r--WebCore/svg/SVGFEImageElement.cpp110
-rw-r--r--WebCore/svg/SVGFEImageElement.h70
-rw-r--r--WebCore/svg/SVGFEImageElement.idl35
-rw-r--r--WebCore/svg/SVGFELightElement.cpp93
-rw-r--r--WebCore/svg/SVGFELightElement.h58
-rw-r--r--WebCore/svg/SVGFEMergeElement.cpp64
-rw-r--r--WebCore/svg/SVGFEMergeElement.h50
-rw-r--r--WebCore/svg/SVGFEMergeElement.idl32
-rw-r--r--WebCore/svg/SVGFEMergeNodeElement.cpp54
-rw-r--r--WebCore/svg/SVGFEMergeNodeElement.h51
-rw-r--r--WebCore/svg/SVGFEMergeNodeElement.idl32
-rw-r--r--WebCore/svg/SVGFEOffsetElement.cpp80
-rw-r--r--WebCore/svg/SVGFEOffsetElement.h58
-rw-r--r--WebCore/svg/SVGFEOffsetElement.idl35
-rw-r--r--WebCore/svg/SVGFEPointLightElement.cpp47
-rw-r--r--WebCore/svg/SVGFEPointLightElement.h40
-rw-r--r--WebCore/svg/SVGFEPointLightElement.idl34
-rw-r--r--WebCore/svg/SVGFESpecularLightingElement.cpp131
-rw-r--r--WebCore/svg/SVGFESpecularLightingElement.h61
-rw-r--r--WebCore/svg/SVGFESpecularLightingElement.idl36
-rw-r--r--WebCore/svg/SVGFESpotLightElement.cpp54
-rw-r--r--WebCore/svg/SVGFESpotLightElement.h40
-rw-r--r--WebCore/svg/SVGFESpotLightElement.idl39
-rw-r--r--WebCore/svg/SVGFETileElement.cpp71
-rw-r--r--WebCore/svg/SVGFETileElement.h54
-rw-r--r--WebCore/svg/SVGFETileElement.idl33
-rw-r--r--WebCore/svg/SVGFETurbulenceElement.cpp105
-rw-r--r--WebCore/svg/SVGFETurbulenceElement.h66
-rw-r--r--WebCore/svg/SVGFETurbulenceElement.idl48
-rw-r--r--WebCore/svg/SVGFilterElement.cpp164
-rw-r--r--WebCore/svg/SVGFilterElement.h77
-rw-r--r--WebCore/svg/SVGFilterElement.idl47
-rw-r--r--WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp138
-rw-r--r--WebCore/svg/SVGFilterPrimitiveStandardAttributes.h65
-rw-r--r--WebCore/svg/SVGFilterPrimitiveStandardAttributes.idl37
-rw-r--r--WebCore/svg/SVGFitToViewBox.cpp122
-rw-r--r--WebCore/svg/SVGFitToViewBox.h57
-rw-r--r--WebCore/svg/SVGFitToViewBox.idl34
-rw-r--r--WebCore/svg/SVGFont.cpp537
-rw-r--r--WebCore/svg/SVGFontData.cpp45
-rw-r--r--WebCore/svg/SVGFontData.h59
-rw-r--r--WebCore/svg/SVGFontElement.cpp146
-rw-r--r--WebCore/svg/SVGFontElement.h64
-rw-r--r--WebCore/svg/SVGFontElement.idl31
-rw-r--r--WebCore/svg/SVGFontFaceElement.cpp363
-rw-r--r--WebCore/svg/SVGFontFaceElement.h70
-rw-r--r--WebCore/svg/SVGFontFaceElement.idl31
-rw-r--r--WebCore/svg/SVGFontFaceFormatElement.cpp55
-rw-r--r--WebCore/svg/SVGFontFaceFormatElement.h40
-rw-r--r--WebCore/svg/SVGFontFaceFormatElement.idl31
-rw-r--r--WebCore/svg/SVGFontFaceNameElement.cpp43
-rw-r--r--WebCore/svg/SVGFontFaceNameElement.h40
-rw-r--r--WebCore/svg/SVGFontFaceNameElement.idl31
-rw-r--r--WebCore/svg/SVGFontFaceSrcElement.cpp62
-rw-r--r--WebCore/svg/SVGFontFaceSrcElement.h42
-rw-r--r--WebCore/svg/SVGFontFaceSrcElement.idl31
-rw-r--r--WebCore/svg/SVGFontFaceUriElement.cpp61
-rw-r--r--WebCore/svg/SVGFontFaceUriElement.h42
-rw-r--r--WebCore/svg/SVGFontFaceUriElement.idl31
-rw-r--r--WebCore/svg/SVGForeignObjectElement.cpp170
-rw-r--r--WebCore/svg/SVGForeignObjectElement.h67
-rw-r--r--WebCore/svg/SVGForeignObjectElement.idl40
-rw-r--r--WebCore/svg/SVGGElement.cpp85
-rw-r--r--WebCore/svg/SVGGElement.h64
-rw-r--r--WebCore/svg/SVGGElement.idl36
-rw-r--r--WebCore/svg/SVGGlyphElement.cpp166
-rw-r--r--WebCore/svg/SVGGlyphElement.h122
-rw-r--r--WebCore/svg/SVGGlyphElement.idl31
-rw-r--r--WebCore/svg/SVGGradientElement.cpp176
-rw-r--r--WebCore/svg/SVGGradientElement.h82
-rw-r--r--WebCore/svg/SVGGradientElement.idl44
-rw-r--r--WebCore/svg/SVGImageElement.cpp147
-rw-r--r--WebCore/svg/SVGImageElement.h81
-rw-r--r--WebCore/svg/SVGImageElement.idl42
-rw-r--r--WebCore/svg/SVGImageLoader.cpp88
-rw-r--r--WebCore/svg/SVGImageLoader.h46
-rw-r--r--WebCore/svg/SVGLangSpace.cpp87
-rw-r--r--WebCore/svg/SVGLangSpace.h56
-rw-r--r--WebCore/svg/SVGLangSpace.idl36
-rw-r--r--WebCore/svg/SVGLength.cpp325
-rw-r--r--WebCore/svg/SVGLength.h111
-rw-r--r--WebCore/svg/SVGLength.idl51
-rw-r--r--WebCore/svg/SVGLengthList.cpp64
-rw-r--r--WebCore/svg/SVGLengthList.h46
-rw-r--r--WebCore/svg/SVGLengthList.idl48
-rw-r--r--WebCore/svg/SVGLineElement.cpp108
-rw-r--r--WebCore/svg/SVGLineElement.h69
-rw-r--r--WebCore/svg/SVGLineElement.idl40
-rw-r--r--WebCore/svg/SVGLinearGradientElement.cpp164
-rw-r--r--WebCore/svg/SVGLinearGradientElement.h61
-rw-r--r--WebCore/svg/SVGLinearGradientElement.idl35
-rw-r--r--WebCore/svg/SVGList.h256
-rw-r--r--WebCore/svg/SVGListTraits.h53
-rw-r--r--WebCore/svg/SVGLocatable.cpp158
-rw-r--r--WebCore/svg/SVGLocatable.h65
-rw-r--r--WebCore/svg/SVGLocatable.idl40
-rw-r--r--WebCore/svg/SVGMPathElement.cpp56
-rw-r--r--WebCore/svg/SVGMPathElement.h54
-rw-r--r--WebCore/svg/SVGMarkerElement.cpp177
-rw-r--r--WebCore/svg/SVGMarkerElement.h90
-rw-r--r--WebCore/svg/SVGMarkerElement.idl55
-rw-r--r--WebCore/svg/SVGMaskElement.cpp226
-rw-r--r--WebCore/svg/SVGMaskElement.h77
-rw-r--r--WebCore/svg/SVGMaskElement.idl42
-rw-r--r--WebCore/svg/SVGMatrix.idl52
-rw-r--r--WebCore/svg/SVGMetadataElement.cpp38
-rw-r--r--WebCore/svg/SVGMetadataElement.h43
-rw-r--r--WebCore/svg/SVGMetadataElement.idl29
-rw-r--r--WebCore/svg/SVGMissingGlyphElement.cpp34
-rw-r--r--WebCore/svg/SVGMissingGlyphElement.h39
-rw-r--r--WebCore/svg/SVGMissingGlyphElement.idl31
-rw-r--r--WebCore/svg/SVGNumber.idl32
-rw-r--r--WebCore/svg/SVGNumberList.cpp59
-rw-r--r--WebCore/svg/SVGNumberList.h48
-rw-r--r--WebCore/svg/SVGNumberList.idl48
-rw-r--r--WebCore/svg/SVGPaint.cpp120
-rw-r--r--WebCore/svg/SVGPaint.h78
-rw-r--r--WebCore/svg/SVGPaint.idl52
-rw-r--r--WebCore/svg/SVGParserUtilities.cpp873
-rw-r--r--WebCore/svg/SVGParserUtilities.h92
-rw-r--r--WebCore/svg/SVGPathElement.cpp244
-rw-r--r--WebCore/svg/SVGPathElement.h117
-rw-r--r--WebCore/svg/SVGPathElement.idl112
-rw-r--r--WebCore/svg/SVGPathSeg.h76
-rw-r--r--WebCore/svg/SVGPathSeg.idl56
-rw-r--r--WebCore/svg/SVGPathSegArc.cpp210
-rw-r--r--WebCore/svg/SVGPathSegArc.h130
-rw-r--r--WebCore/svg/SVGPathSegArcAbs.idl46
-rw-r--r--WebCore/svg/SVGPathSegArcRel.idl46
-rw-r--r--WebCore/svg/SVGPathSegClosePath.cpp43
-rw-r--r--WebCore/svg/SVGPathSegClosePath.h51
-rw-r--r--WebCore/svg/SVGPathSegClosePath.idl32
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubic.cpp189
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubic.h119
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubicAbs.idl44
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubicRel.idl44
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubicSmooth.cpp143
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubicSmooth.h97
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubicSmoothAbs.idl40
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubicSmoothRel.idl40
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadratic.cpp145
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadratic.h97
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadraticAbs.idl40
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadraticRel.idl40
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.cpp100
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h81
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadraticSmoothAbs.idl36
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadraticSmoothRel.idl36
-rw-r--r--WebCore/svg/SVGPathSegLineto.cpp98
-rw-r--r--WebCore/svg/SVGPathSegLineto.h80
-rw-r--r--WebCore/svg/SVGPathSegLinetoAbs.idl36
-rw-r--r--WebCore/svg/SVGPathSegLinetoHorizontal.cpp78
-rw-r--r--WebCore/svg/SVGPathSegLinetoHorizontal.h72
-rw-r--r--WebCore/svg/SVGPathSegLinetoHorizontalAbs.idl34
-rw-r--r--WebCore/svg/SVGPathSegLinetoHorizontalRel.idl34
-rw-r--r--WebCore/svg/SVGPathSegLinetoRel.idl36
-rw-r--r--WebCore/svg/SVGPathSegLinetoVertical.cpp79
-rw-r--r--WebCore/svg/SVGPathSegLinetoVertical.h73
-rw-r--r--WebCore/svg/SVGPathSegLinetoVerticalAbs.idl34
-rw-r--r--WebCore/svg/SVGPathSegLinetoVerticalRel.idl34
-rw-r--r--WebCore/svg/SVGPathSegList.cpp140
-rw-r--r--WebCore/svg/SVGPathSegList.h49
-rw-r--r--WebCore/svg/SVGPathSegList.idl48
-rw-r--r--WebCore/svg/SVGPathSegMoveto.cpp101
-rw-r--r--WebCore/svg/SVGPathSegMoveto.h80
-rw-r--r--WebCore/svg/SVGPathSegMovetoAbs.idl36
-rw-r--r--WebCore/svg/SVGPathSegMovetoRel.idl36
-rw-r--r--WebCore/svg/SVGPatternElement.cpp330
-rw-r--r--WebCore/svg/SVGPatternElement.h90
-rw-r--r--WebCore/svg/SVGPatternElement.idl45
-rw-r--r--WebCore/svg/SVGPoint.idl36
-rw-r--r--WebCore/svg/SVGPointList.cpp42
-rw-r--r--WebCore/svg/SVGPointList.h46
-rw-r--r--WebCore/svg/SVGPointList.idl47
-rw-r--r--WebCore/svg/SVGPolyElement.cpp131
-rw-r--r--WebCore/svg/SVGPolyElement.h68
-rw-r--r--WebCore/svg/SVGPolygonElement.cpp61
-rw-r--r--WebCore/svg/SVGPolygonElement.h42
-rw-r--r--WebCore/svg/SVGPolygonElement.idl37
-rw-r--r--WebCore/svg/SVGPolylineElement.cpp60
-rw-r--r--WebCore/svg/SVGPolylineElement.h42
-rw-r--r--WebCore/svg/SVGPolylineElement.idl37
-rw-r--r--WebCore/svg/SVGPreserveAspectRatio.cpp207
-rw-r--r--WebCore/svg/SVGPreserveAspectRatio.h91
-rw-r--r--WebCore/svg/SVGPreserveAspectRatio.idl52
-rw-r--r--WebCore/svg/SVGRadialGradientElement.cpp186
-rw-r--r--WebCore/svg/SVGRadialGradientElement.h62
-rw-r--r--WebCore/svg/SVGRadialGradientElement.idl36
-rw-r--r--WebCore/svg/SVGRect.idl38
-rw-r--r--WebCore/svg/SVGRectElement.cpp131
-rw-r--r--WebCore/svg/SVGRectElement.h67
-rw-r--r--WebCore/svg/SVGRectElement.idl43
-rw-r--r--WebCore/svg/SVGRenderingIntent.h51
-rw-r--r--WebCore/svg/SVGRenderingIntent.idl38
-rw-r--r--WebCore/svg/SVGSVGElement.cpp538
-rw-r--r--WebCore/svg/SVGSVGElement.h172
-rw-r--r--WebCore/svg/SVGSVGElement.idl88
-rw-r--r--WebCore/svg/SVGScriptElement.cpp70
-rw-r--r--WebCore/svg/SVGScriptElement.h63
-rw-r--r--WebCore/svg/SVGScriptElement.idl35
-rw-r--r--WebCore/svg/SVGSetElement.cpp57
-rw-r--r--WebCore/svg/SVGSetElement.h52
-rw-r--r--WebCore/svg/SVGSetElement.idl31
-rw-r--r--WebCore/svg/SVGStopElement.cpp68
-rw-r--r--WebCore/svg/SVGStopElement.h49
-rw-r--r--WebCore/svg/SVGStopElement.idl33
-rw-r--r--WebCore/svg/SVGStringList.cpp71
-rw-r--r--WebCore/svg/SVGStringList.h47
-rw-r--r--WebCore/svg/SVGStringList.idl47
-rw-r--r--WebCore/svg/SVGStylable.cpp40
-rw-r--r--WebCore/svg/SVGStylable.h48
-rw-r--r--WebCore/svg/SVGStylable.idl37
-rw-r--r--WebCore/svg/SVGStyleElement.cpp137
-rw-r--r--WebCore/svg/SVGStyleElement.h71
-rw-r--r--WebCore/svg/SVGStyleElement.idl40
-rw-r--r--WebCore/svg/SVGStyledElement.cpp290
-rw-r--r--WebCore/svg/SVGStyledElement.h80
-rw-r--r--WebCore/svg/SVGStyledLocatableElement.cpp72
-rw-r--r--WebCore/svg/SVGStyledLocatableElement.h53
-rw-r--r--WebCore/svg/SVGStyledTransformableElement.cpp111
-rw-r--r--WebCore/svg/SVGStyledTransformableElement.h67
-rw-r--r--WebCore/svg/SVGSwitchElement.cpp66
-rw-r--r--WebCore/svg/SVGSwitchElement.h63
-rw-r--r--WebCore/svg/SVGSwitchElement.idl36
-rw-r--r--WebCore/svg/SVGSymbolElement.cpp60
-rw-r--r--WebCore/svg/SVGSymbolElement.h61
-rw-r--r--WebCore/svg/SVGSymbolElement.idl35
-rw-r--r--WebCore/svg/SVGTRefElement.cpp82
-rw-r--r--WebCore/svg/SVGTRefElement.h57
-rw-r--r--WebCore/svg/SVGTRefElement.idl32
-rw-r--r--WebCore/svg/SVGTSpanElement.cpp61
-rw-r--r--WebCore/svg/SVGTSpanElement.h49
-rw-r--r--WebCore/svg/SVGTSpanElement.idl31
-rw-r--r--WebCore/svg/SVGTests.cpp122
-rw-r--r--WebCore/svg/SVGTests.h61
-rw-r--r--WebCore/svg/SVGTests.idl37
-rw-r--r--WebCore/svg/SVGTextContentElement.cpp496
-rw-r--r--WebCore/svg/SVGTextContentElement.h78
-rw-r--r--WebCore/svg/SVGTextContentElement.idl60
-rw-r--r--WebCore/svg/SVGTextElement.cpp115
-rw-r--r--WebCore/svg/SVGTextElement.h62
-rw-r--r--WebCore/svg/SVGTextElement.idl32
-rw-r--r--WebCore/svg/SVGTextPathElement.cpp108
-rw-r--r--WebCore/svg/SVGTextPathElement.h85
-rw-r--r--WebCore/svg/SVGTextPathElement.idl45
-rw-r--r--WebCore/svg/SVGTextPositioningElement.cpp72
-rw-r--r--WebCore/svg/SVGTextPositioningElement.h52
-rw-r--r--WebCore/svg/SVGTextPositioningElement.idl36
-rw-r--r--WebCore/svg/SVGTimer.cpp172
-rw-r--r--WebCore/svg/SVGTimer.h70
-rw-r--r--WebCore/svg/SVGTitleElement.cpp59
-rw-r--r--WebCore/svg/SVGTitleElement.h50
-rw-r--r--WebCore/svg/SVGTitleElement.idl33
-rw-r--r--WebCore/svg/SVGTransform.cpp156
-rw-r--r--WebCore/svg/SVGTransform.h95
-rw-r--r--WebCore/svg/SVGTransform.idl48
-rw-r--r--WebCore/svg/SVGTransformDistance.cpp278
-rw-r--r--WebCore/svg/SVGTransformDistance.h58
-rw-r--r--WebCore/svg/SVGTransformList.cpp85
-rw-r--r--WebCore/svg/SVGTransformList.h52
-rw-r--r--WebCore/svg/SVGTransformList.idl50
-rw-r--r--WebCore/svg/SVGTransformable.cpp233
-rw-r--r--WebCore/svg/SVGTransformable.h58
-rw-r--r--WebCore/svg/SVGTransformable.idl33
-rw-r--r--WebCore/svg/SVGURIReference.cpp73
-rw-r--r--WebCore/svg/SVGURIReference.h53
-rw-r--r--WebCore/svg/SVGURIReference.idl33
-rw-r--r--WebCore/svg/SVGUnitTypes.h48
-rw-r--r--WebCore/svg/SVGUnitTypes.idl35
-rw-r--r--WebCore/svg/SVGUseElement.cpp817
-rw-r--r--WebCore/svg/SVGUseElement.h116
-rw-r--r--WebCore/svg/SVGUseElement.idl44
-rw-r--r--WebCore/svg/SVGViewElement.cpp73
-rw-r--r--WebCore/svg/SVGViewElement.h63
-rw-r--r--WebCore/svg/SVGViewElement.idl35
-rw-r--r--WebCore/svg/SVGViewSpec.cpp178
-rw-r--r--WebCore/svg/SVGViewSpec.h68
-rw-r--r--WebCore/svg/SVGViewSpec.idl38
-rw-r--r--WebCore/svg/SVGZoomAndPan.cpp87
-rw-r--r--WebCore/svg/SVGZoomAndPan.h60
-rw-r--r--WebCore/svg/SVGZoomAndPan.idl39
-rw-r--r--WebCore/svg/SVGZoomEvent.cpp84
-rw-r--r--WebCore/svg/SVGZoomEvent.h68
-rw-r--r--WebCore/svg/SVGZoomEvent.idl36
-rw-r--r--WebCore/svg/TimeScheduler.cpp152
-rw-r--r--WebCore/svg/TimeScheduler.h77
-rw-r--r--WebCore/svg/graphics/SVGImage.cpp214
-rw-r--r--WebCore/svg/graphics/SVGImage.h75
-rw-r--r--WebCore/svg/graphics/SVGImageEmptyClients.h417
-rw-r--r--WebCore/svg/graphics/SVGPaintServer.cpp169
-rw-r--r--WebCore/svg/graphics/SVGPaintServer.h112
-rw-r--r--WebCore/svg/graphics/SVGPaintServerGradient.cpp143
-rw-r--r--WebCore/svg/graphics/SVGPaintServerGradient.h146
-rw-r--r--WebCore/svg/graphics/SVGPaintServerLinearGradient.cpp74
-rw-r--r--WebCore/svg/graphics/SVGPaintServerLinearGradient.h66
-rw-r--r--WebCore/svg/graphics/SVGPaintServerPattern.cpp101
-rw-r--r--WebCore/svg/graphics/SVGPaintServerPattern.h92
-rw-r--r--WebCore/svg/graphics/SVGPaintServerRadialGradient.cpp87
-rw-r--r--WebCore/svg/graphics/SVGPaintServerRadialGradient.h70
-rw-r--r--WebCore/svg/graphics/SVGPaintServerSolid.cpp61
-rw-r--r--WebCore/svg/graphics/SVGPaintServerSolid.h62
-rw-r--r--WebCore/svg/graphics/SVGResource.cpp182
-rw-r--r--WebCore/svg/graphics/SVGResource.h101
-rw-r--r--WebCore/svg/graphics/SVGResourceClipper.cpp100
-rw-r--r--WebCore/svg/graphics/SVGResourceClipper.h93
-rw-r--r--WebCore/svg/graphics/SVGResourceFilter.cpp123
-rw-r--r--WebCore/svg/graphics/SVGResourceFilter.h99
-rw-r--r--WebCore/svg/graphics/SVGResourceListener.h0
-rw-r--r--WebCore/svg/graphics/SVGResourceMarker.cpp139
-rw-r--r--WebCore/svg/graphics/SVGResourceMarker.h78
-rw-r--r--WebCore/svg/graphics/SVGResourceMasker.cpp71
-rw-r--r--WebCore/svg/graphics/SVGResourceMasker.h73
-rw-r--r--WebCore/svg/graphics/cairo/RenderPathCairo.cpp52
-rw-r--r--WebCore/svg/graphics/cairo/SVGPaintServerCairo.cpp65
-rw-r--r--WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp111
-rw-r--r--WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp36
-rw-r--r--WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp72
-rw-r--r--WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp64
-rw-r--r--WebCore/svg/graphics/cairo/SVGResourceFilterCairo.cpp47
-rw-r--r--WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp44
-rw-r--r--WebCore/svg/graphics/cg/CgSupport.cpp120
-rw-r--r--WebCore/svg/graphics/cg/CgSupport.h54
-rw-r--r--WebCore/svg/graphics/cg/RenderPathCg.cpp79
-rw-r--r--WebCore/svg/graphics/cg/SVGPaintServerCg.cpp89
-rw-r--r--WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp341
-rw-r--r--WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp126
-rw-r--r--WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp78
-rw-r--r--WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp83
-rw-r--r--WebCore/svg/graphics/cg/SVGResourceFilterCg.cpp53
-rw-r--r--WebCore/svg/graphics/cg/SVGResourceFilterCg.mm145
-rw-r--r--WebCore/svg/graphics/cg/SVGResourceMaskerCg.cpp42
-rw-r--r--WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm127
-rw-r--r--WebCore/svg/graphics/filters/SVGDistantLightSource.h52
-rw-r--r--WebCore/svg/graphics/filters/SVGFEBlend.cpp87
-rw-r--r--WebCore/svg/graphics/filters/SVGFEBlend.h64
-rw-r--r--WebCore/svg/graphics/filters/SVGFEColorMatrix.cpp84
-rw-r--r--WebCore/svg/graphics/filters/SVGFEColorMatrix.h64
-rw-r--r--WebCore/svg/graphics/filters/SVGFEComponentTransfer.cpp141
-rw-r--r--WebCore/svg/graphics/filters/SVGFEComponentTransfer.h110
-rw-r--r--WebCore/svg/graphics/filters/SVGFEComposite.cpp111
-rw-r--r--WebCore/svg/graphics/filters/SVGFEComposite.h81
-rw-r--r--WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp155
-rw-r--r--WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h82
-rw-r--r--WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp121
-rw-r--r--WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h75
-rw-r--r--WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp110
-rw-r--r--WebCore/svg/graphics/filters/SVGFEDisplacementMap.h71
-rw-r--r--WebCore/svg/graphics/filters/SVGFEFlood.cpp68
-rw-r--r--WebCore/svg/graphics/filters/SVGFEFlood.h56
-rw-r--r--WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp66
-rw-r--r--WebCore/svg/graphics/filters/SVGFEGaussianBlur.h55
-rw-r--r--WebCore/svg/graphics/filters/SVGFEImage.cpp79
-rw-r--r--WebCore/svg/graphics/filters/SVGFEImage.h59
-rw-r--r--WebCore/svg/graphics/filters/SVGFEMerge.cpp58
-rw-r--r--WebCore/svg/graphics/filters/SVGFEMerge.h51
-rw-r--r--WebCore/svg/graphics/filters/SVGFEMorphology.cpp92
-rw-r--r--WebCore/svg/graphics/filters/SVGFEMorphology.h61
-rw-r--r--WebCore/svg/graphics/filters/SVGFEOffset.cpp65
-rw-r--r--WebCore/svg/graphics/filters/SVGFEOffset.h55
-rw-r--r--WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp131
-rw-r--r--WebCore/svg/graphics/filters/SVGFESpecularLighting.h78
-rw-r--r--WebCore/svg/graphics/filters/SVGFETile.h44
-rw-r--r--WebCore/svg/graphics/filters/SVGFETurbulence.cpp129
-rw-r--r--WebCore/svg/graphics/filters/SVGFETurbulence.h73
-rw-r--r--WebCore/svg/graphics/filters/SVGFilterEffect.cpp133
-rw-r--r--WebCore/svg/graphics/filters/SVGFilterEffect.h99
-rw-r--r--WebCore/svg/graphics/filters/SVGLightSource.cpp65
-rw-r--r--WebCore/svg/graphics/filters/SVGLightSource.h57
-rw-r--r--WebCore/svg/graphics/filters/SVGPointLightSource.h50
-rw-r--r--WebCore/svg/graphics/filters/SVGSpotLightSource.h61
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEBlendCg.mm77
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEColorMatrixCg.mm111
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEComponentTransferCg.mm167
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFECompositeCg.mm85
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEDiffuseLightingCg.mm74
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEDisplacementMapCg.mm58
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEFloodCg.mm54
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEGaussianBlurCg.mm49
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.h88
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm162
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEImageCg.mm80
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEMergeCg.mm57
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEOffsetCg.mm44
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFESpecularLightingCg.mm69
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFETileCg.mm41
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFilterEffectCg.mm37
-rw-r--r--WebCore/svg/graphics/filters/cg/WKArithmeticFilter.cikernel32
-rw-r--r--WebCore/svg/graphics/filters/cg/WKArithmeticFilter.h41
-rw-r--r--WebCore/svg/graphics/filters/cg/WKArithmeticFilter.m94
-rw-r--r--WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.cikernel33
-rw-r--r--WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.h39
-rw-r--r--WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.m70
-rw-r--r--WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.cikernel39
-rw-r--r--WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.h41
-rw-r--r--WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.m97
-rw-r--r--WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.cikernel32
-rw-r--r--WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.h38
-rw-r--r--WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.m73
-rw-r--r--WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.cikernel45
-rw-r--r--WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.h40
-rw-r--r--WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.m81
-rw-r--r--WebCore/svg/graphics/filters/cg/WKDistantLightFilter.cikernel29
-rw-r--r--WebCore/svg/graphics/filters/cg/WKDistantLightFilter.h36
-rw-r--r--WebCore/svg/graphics/filters/cg/WKDistantLightFilter.m73
-rw-r--r--WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.cikernel30
-rw-r--r--WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.h39
-rw-r--r--WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.m85
-rw-r--r--WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.h36
-rw-r--r--WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.m60
-rw-r--r--WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.cikernel30
-rw-r--r--WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.h38
-rw-r--r--WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m80
-rw-r--r--WebCore/svg/graphics/filters/cg/WKNormalMapFilter.cikernel49
-rw-r--r--WebCore/svg/graphics/filters/cg/WKNormalMapFilter.h36
-rw-r--r--WebCore/svg/graphics/filters/cg/WKNormalMapFilter.m109
-rw-r--r--WebCore/svg/graphics/filters/cg/WKPointLightFilter.cikernel33
-rw-r--r--WebCore/svg/graphics/filters/cg/WKPointLightFilter.h38
-rw-r--r--WebCore/svg/graphics/filters/cg/WKPointLightFilter.m73
-rw-r--r--WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.cikernel40
-rw-r--r--WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h42
-rw-r--r--WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.m96
-rw-r--r--WebCore/svg/graphics/filters/cg/WKSpotLightFilter.cikernel34
-rw-r--r--WebCore/svg/graphics/filters/cg/WKSpotLightFilter.h38
-rw-r--r--WebCore/svg/graphics/filters/cg/WKSpotLightFilter.m84
-rw-r--r--WebCore/svg/graphics/filters/cg/WKTableTransferFilter.cikernel38
-rw-r--r--WebCore/svg/graphics/filters/cg/WKTableTransferFilter.h38
-rw-r--r--WebCore/svg/graphics/filters/cg/WKTableTransferFilter.m76
-rw-r--r--WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h65
-rw-r--r--WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm129
-rw-r--r--WebCore/svg/graphics/qt/RenderPathQt.cpp89
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp110
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerLinearGradientQt.cpp65
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp79
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerQt.cpp104
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp98
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp71
-rw-r--r--WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp127
-rw-r--r--WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp48
-rw-r--r--WebCore/svg/graphics/qt/SVGResourceMaskerQt.cpp38
-rw-r--r--WebCore/svg/svgattrs.in247
-rw-r--r--WebCore/svg/svgtags.in107
-rw-r--r--WebCore/svg/xlinkattrs.in7
572 files changed, 46414 insertions, 0 deletions
diff --git a/WebCore/svg/ColorDistance.cpp b/WebCore/svg/ColorDistance.cpp
new file mode 100644
index 0000000..9e632ae
--- /dev/null
+++ b/WebCore/svg/ColorDistance.cpp
@@ -0,0 +1,94 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "ColorDistance.h"
+#include "Color.h"
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+ColorDistance::ColorDistance()
+ : m_redDiff(0)
+ , m_greenDiff(0)
+ , m_blueDiff(0)
+{
+}
+
+ColorDistance::ColorDistance(const Color& fromColor, const Color& toColor)
+ : m_redDiff(toColor.red() - fromColor.red())
+ , m_greenDiff(toColor.green() - fromColor.green())
+ , m_blueDiff(toColor.blue() - fromColor.blue())
+{
+}
+
+ColorDistance::ColorDistance(int redDiff, int greenDiff, int blueDiff)
+ : m_redDiff(redDiff)
+ , m_greenDiff(greenDiff)
+ , m_blueDiff(blueDiff)
+{
+}
+
+static inline int clampColorValue(int v)
+{
+ if (v > 255)
+ v = 255;
+ else if (v < 0)
+ v = 0;
+ return v;
+}
+
+ColorDistance ColorDistance::scaledDistance(float scaleFactor) const
+{
+ return ColorDistance(static_cast<int>(scaleFactor * m_redDiff),
+ static_cast<int>(scaleFactor * m_greenDiff),
+ static_cast<int>(scaleFactor * m_blueDiff));
+}
+
+Color ColorDistance::addColorsAndClamp(const Color& first, const Color& second)
+{
+ return Color(clampColorValue(first.red() + second.red()),
+ clampColorValue(first.green() + second.green()),
+ clampColorValue(first.blue() + second.blue()));
+}
+
+Color ColorDistance::addToColorAndClamp(const Color& color) const
+{
+ return Color(clampColorValue(color.red() + m_redDiff),
+ clampColorValue(color.green() + m_greenDiff),
+ clampColorValue(color.blue() + m_blueDiff));
+}
+
+bool ColorDistance::isZero() const
+{
+ return (m_redDiff == 0 && m_blueDiff == 0 && m_greenDiff == 0);
+}
+
+float ColorDistance::distance() const
+{
+ // This is just a simple distance calculation, not respecting color spaces
+ return sqrtf(m_redDiff * m_redDiff + m_blueDiff * m_blueDiff + m_greenDiff * m_greenDiff);
+}
+
+}
+
+#endif
diff --git a/WebCore/svg/ColorDistance.h b/WebCore/svg/ColorDistance.h
new file mode 100644
index 0000000..b7cc029
--- /dev/null
+++ b/WebCore/svg/ColorDistance.h
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef ColorDistance_h
+#define ColorDistance_h
+#if ENABLE(SVG)
+
+namespace WebCore {
+
+ class Color;
+
+ class ColorDistance {
+ public:
+ ColorDistance();
+ ColorDistance(const Color& fromColor, const Color& toColor);
+ ColorDistance(int redDiff, int blueDiff, int greenDiff);
+
+ ColorDistance scaledDistance(float scaleFactor) const;
+ Color addToColorAndClamp(const Color&) const;
+
+ static Color addColorsAndClamp(const Color&, const Color&);
+
+ bool isZero() const;
+
+ float distance() const;
+
+ private:
+ short m_redDiff;
+ short m_greenDiff;
+ short m_blueDiff;
+ };
+}
+
+#endif // ENABLE(SVG)
+#endif // ColorDistance_h
diff --git a/WebCore/svg/GradientAttributes.h b/WebCore/svg/GradientAttributes.h
new file mode 100644
index 0000000..c16e961
--- /dev/null
+++ b/WebCore/svg/GradientAttributes.h
@@ -0,0 +1,74 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef GradientAttributes_h
+#define GradientAttributes_h
+
+#if ENABLE(SVG)
+
+namespace WebCore
+{
+ struct GradientAttributes {
+ GradientAttributes()
+ : m_spreadMethod(SPREADMETHOD_PAD)
+ , m_boundingBoxMode(true)
+ , m_spreadMethodSet(false)
+ , m_boundingBoxModeSet(false)
+ , m_gradientTransformSet(false)
+ , m_stopsSet(false)
+ {
+ }
+
+ SVGGradientSpreadMethod spreadMethod() const { return m_spreadMethod; }
+ bool boundingBoxMode() const { return m_boundingBoxMode; }
+ AffineTransform gradientTransform() const { return m_gradientTransform; }
+ const Vector<SVGGradientStop>& stops() const { return m_stops; }
+
+ void setSpreadMethod(SVGGradientSpreadMethod value) { m_spreadMethod = value; m_spreadMethodSet = true; }
+ void setBoundingBoxMode(bool value) { m_boundingBoxMode = value; m_boundingBoxModeSet = true; }
+ void setGradientTransform(const AffineTransform& value) { m_gradientTransform = value; m_gradientTransformSet = true; }
+ void setStops(const Vector<SVGGradientStop>& value) { m_stops = value; m_stopsSet = true; }
+
+ bool hasSpreadMethod() const { return m_spreadMethodSet; }
+ bool hasBoundingBoxMode() const { return m_boundingBoxModeSet; }
+ bool hasGradientTransform() const { return m_gradientTransformSet; }
+ bool hasStops() const { return m_stopsSet; }
+
+ private:
+ // Properties
+ SVGGradientSpreadMethod m_spreadMethod;
+ bool m_boundingBoxMode;
+ AffineTransform m_gradientTransform;
+ Vector<SVGGradientStop> m_stops;
+
+ // Property states
+ bool m_spreadMethodSet : 1;
+ bool m_boundingBoxModeSet : 1;
+ bool m_gradientTransformSet : 1;
+ bool m_stopsSet : 1;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/LinearGradientAttributes.h b/WebCore/svg/LinearGradientAttributes.h
new file mode 100644
index 0000000..e640c03
--- /dev/null
+++ b/WebCore/svg/LinearGradientAttributes.h
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef LinearGradientAttributes_h
+#define LinearGradientAttributes_h
+
+#include "GradientAttributes.h"
+
+#if ENABLE(SVG)
+
+namespace WebCore
+{
+ struct LinearGradientAttributes : GradientAttributes {
+ LinearGradientAttributes()
+ : m_x1(0.0)
+ , m_y1(0.0)
+ , m_x2(1.0)
+ , m_y2(0.0)
+ , m_x1Set(false)
+ , m_y1Set(false)
+ , m_x2Set(false)
+ , m_y2Set(false)
+ {
+ }
+
+ double x1() const { return m_x1; }
+ double y1() const { return m_y1; }
+ double x2() const { return m_x2; }
+ double y2() const { return m_y2; }
+
+ void setX1(double value) { m_x1 = value; m_x1Set = true; }
+ void setY1(double value) { m_y1 = value; m_y1Set = true; }
+ void setX2(double value) { m_x2 = value; m_x2Set = true; }
+ void setY2(double value) { m_y2 = value; m_y2Set = true; }
+
+ bool hasX1() const { return m_x1Set; }
+ bool hasY1() const { return m_y1Set; }
+ bool hasX2() const { return m_x2Set; }
+ bool hasY2() const { return m_y2Set; }
+
+ private:
+ // Properties
+ double m_x1;
+ double m_y1;
+ double m_x2;
+ double m_y2;
+
+ // Property states
+ bool m_x1Set : 1;
+ bool m_y1Set : 1;
+ bool m_x2Set : 1;
+ bool m_y2Set : 1;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/PatternAttributes.h b/WebCore/svg/PatternAttributes.h
new file mode 100644
index 0000000..e6a347c
--- /dev/null
+++ b/WebCore/svg/PatternAttributes.h
@@ -0,0 +1,103 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef PatternAttributes_h
+#define PatternAttributes_h
+
+#if ENABLE(SVG)
+
+namespace WebCore
+{
+ struct PatternAttributes {
+ PatternAttributes()
+ : m_x()
+ , m_y()
+ , m_width()
+ , m_height()
+ , m_boundingBoxMode(true)
+ , m_boundingBoxModeContent(false)
+ , m_patternContentElement(0)
+ , m_xSet(false)
+ , m_ySet(false)
+ , m_widthSet(false)
+ , m_heightSet(false)
+ , m_boundingBoxModeSet(false)
+ , m_boundingBoxModeContentSet(false)
+ , m_patternTransformSet(false)
+ , m_patternContentElementSet(false)
+ {
+ }
+
+ SVGLength x() const { return m_x; }
+ SVGLength y() const { return m_y; }
+ SVGLength width() const { return m_width; }
+ SVGLength height() const { return m_height; }
+ bool boundingBoxMode() const { return m_boundingBoxMode; }
+ bool boundingBoxModeContent() const { return m_boundingBoxModeContent; }
+ AffineTransform patternTransform() const { return m_patternTransform; }
+ const SVGPatternElement* patternContentElement() const { return m_patternContentElement; }
+
+ void setX(const SVGLength& value) { m_x = value; m_xSet = true; }
+ void setY(const SVGLength& value) { m_y = value; m_ySet = true; }
+ void setWidth(const SVGLength& value) { m_width = value; m_widthSet = true; }
+ void setHeight(const SVGLength& value) { m_height = value; m_heightSet = true; }
+ void setBoundingBoxMode(bool value) { m_boundingBoxMode = value; m_boundingBoxModeSet = true; }
+ void setBoundingBoxModeContent(bool value) { m_boundingBoxModeContent = value; m_boundingBoxModeContentSet = true; }
+ void setPatternTransform(const AffineTransform& value) { m_patternTransform = value; m_patternTransformSet = true; }
+ void setPatternContentElement(const SVGPatternElement* value) { m_patternContentElement = value; m_patternContentElementSet = true; }
+
+ bool hasX() const { return m_xSet; }
+ bool hasY() const { return m_ySet; }
+ bool hasWidth() const { return m_widthSet; }
+ bool hasHeight() const { return m_heightSet; }
+ bool hasBoundingBoxMode() const { return m_boundingBoxModeSet; }
+ bool hasBoundingBoxModeContent() const { return m_boundingBoxModeContentSet; }
+ bool hasPatternTransform() const { return m_patternTransformSet; }
+ bool hasPatternContentElement() const { return m_patternContentElementSet; }
+
+ private:
+ // Properties
+ SVGLength m_x;
+ SVGLength m_y;
+ SVGLength m_width;
+ SVGLength m_height;
+ bool m_boundingBoxMode;
+ bool m_boundingBoxModeContent;
+ AffineTransform m_patternTransform;
+ const SVGPatternElement* m_patternContentElement;
+
+ // Property states
+ bool m_xSet : 1;
+ bool m_ySet : 1;
+ bool m_widthSet : 1;
+ bool m_heightSet : 1;
+ bool m_boundingBoxModeSet : 1;
+ bool m_boundingBoxModeContentSet : 1;
+ bool m_patternTransformSet : 1;
+ bool m_patternContentElementSet : 1;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/RadialGradientAttributes.h b/WebCore/svg/RadialGradientAttributes.h
new file mode 100644
index 0000000..782ab49
--- /dev/null
+++ b/WebCore/svg/RadialGradientAttributes.h
@@ -0,0 +1,85 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef RadialGradientAttributes_h
+#define RadialGradientAttributes_h
+
+#include "GradientAttributes.h"
+
+#if ENABLE(SVG)
+
+namespace WebCore
+{
+ struct RadialGradientAttributes : GradientAttributes {
+ RadialGradientAttributes()
+ : m_cx(0.5)
+ , m_cy(0.5)
+ , m_r(0.5)
+ , m_fx(0.0)
+ , m_fy(0.0)
+ , m_cxSet(false)
+ , m_cySet(false)
+ , m_rSet(false)
+ , m_fxSet(false)
+ , m_fySet(false)
+ {
+ }
+
+ double cx() const { return m_cx; }
+ double cy() const { return m_cy; }
+ double r() const { return m_r; }
+ double fx() const { return m_fx; }
+ double fy() const { return m_fy; }
+
+ void setCx(double value) { m_cx = value; m_cxSet = true; }
+ void setCy(double value) { m_cy = value; m_cySet = true; }
+ void setR(double value) { m_r = value; m_rSet = true; }
+ void setFx(double value) { m_fx = value; m_fxSet = true; }
+ void setFy(double value) { m_fy = value; m_fySet = true; }
+
+ bool hasCx() const { return m_cxSet; }
+ bool hasCy() const { return m_cySet; }
+ bool hasR() const { return m_rSet; }
+ bool hasFx() const { return m_fxSet; }
+ bool hasFy() const { return m_fySet; }
+
+ private:
+ // Properties
+ double m_cx;
+ double m_cy;
+ double m_r;
+ double m_fx;
+ double m_fy;
+
+ // Property states
+ bool m_cxSet : 1;
+ bool m_cySet : 1;
+ bool m_rSet : 1;
+ bool m_fxSet : 1;
+ bool m_fySet : 1;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGAElement.cpp b/WebCore/svg/SVGAElement.cpp
new file mode 100644
index 0000000..e050475
--- /dev/null
+++ b/WebCore/svg/SVGAElement.cpp
@@ -0,0 +1,198 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2007 Rob Buis <buis@kde.org>
+ 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGAElement.h"
+
+#include "Attr.h"
+#include "CSSHelper.h"
+#include "Document.h"
+#include "EventHandler.h"
+#include "EventNames.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "KeyboardEvent.h"
+#include "MouseEvent.h"
+#include "PlatformMouseEvent.h"
+#include "RenderSVGTransformableContainer.h"
+#include "RenderSVGInline.h"
+#include "ResourceRequest.h"
+#include "SVGNames.h"
+#include "XLinkNames.h"
+
+namespace WebCore {
+
+using namespace EventNames;
+
+SVGAElement::SVGAElement(const QualifiedName& tagName, Document *doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGURIReference()
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+{
+}
+
+SVGAElement::~SVGAElement()
+{
+}
+
+String SVGAElement::title() const
+{
+ return getAttribute(XLinkNames::titleAttr);
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGAElement, String, String, string, Target, target, SVGNames::targetAttr, m_target)
+
+void SVGAElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::targetAttr)
+ setTargetBaseValue(attr->value());
+ else {
+ if (SVGURIReference::parseMappedAttribute(attr))
+ return;
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ SVGStyledTransformableElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGAElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledTransformableElement::svgAttributeChanged(attrName);
+
+ // Unlike other SVG*Element classes, SVGAElement only listens to SVGURIReference changes
+ // as none of the other properties changes the linking behaviour for our <a> element.
+ if (SVGURIReference::isKnownAttribute(attrName)) {
+ bool wasLink = m_isLink;
+ m_isLink = !href().isNull();
+
+ if (wasLink != m_isLink)
+ setChanged();
+ }
+}
+
+RenderObject* SVGAElement::createRenderer(RenderArena* arena, RenderStyle* style)
+{
+ if (static_cast<SVGElement*>(parent())->isTextContent())
+ return new (arena) RenderSVGInline(this);
+
+ return new (arena) RenderSVGTransformableContainer(this);
+}
+
+void SVGAElement::defaultEventHandler(Event* evt)
+{
+ if (m_isLink && (evt->type() == clickEvent || (evt->type() == keydownEvent && m_focused))) {
+ MouseEvent* e = 0;
+ if (evt->type() == clickEvent && evt->isMouseEvent())
+ e = static_cast<MouseEvent*>(evt);
+
+ KeyboardEvent* k = 0;
+ if (evt->type() == keydownEvent && evt->isKeyboardEvent())
+ k = static_cast<KeyboardEvent*>(evt);
+
+ if (e && e->button() == RightButton) {
+ SVGStyledTransformableElement::defaultEventHandler(evt);
+ return;
+ }
+
+ if (k) {
+ if (k->keyIdentifier() != "Enter") {
+ SVGStyledTransformableElement::defaultEventHandler(evt);
+ return;
+ }
+ evt->setDefaultHandled();
+ dispatchSimulatedClick(evt);
+ return;
+ }
+
+ String target = this->target();
+ if (e && e->button() == MiddleButton)
+ target = "_blank";
+ else if (target.isEmpty()) // if target is empty, default to "_self" or use xlink:target if set
+ target = (getAttribute(XLinkNames::showAttr) == "new") ? "_blank" : "_self";
+
+ String url = parseURL(href());
+ if (!evt->defaultPrevented())
+ if (document()->frame())
+ document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt, false, true);
+
+ evt->setDefaultHandled();
+ }
+
+ SVGStyledTransformableElement::defaultEventHandler(evt);
+}
+
+bool SVGAElement::supportsFocus() const
+{
+ if (isContentEditable())
+ return SVGStyledTransformableElement::supportsFocus();
+ return isFocusable() || (document() && !document()->haveStylesheetsLoaded());
+}
+
+bool SVGAElement::isFocusable() const
+{
+ if (isContentEditable())
+ return SVGStyledTransformableElement::isFocusable();
+
+ // FIXME: Even if we are not visible, we might have a child that is visible.
+ // Dave wants to fix that some day with a "has visible content" flag or the like.
+ if (!renderer() || !(renderer()->style()->visibility() == VISIBLE))
+ return false;
+
+ return !renderer()->absoluteClippedOverflowRect().isEmpty();
+}
+
+bool SVGAElement::isMouseFocusable() const
+{
+ return false;
+}
+
+bool SVGAElement::isKeyboardFocusable(KeyboardEvent* event) const
+{
+ if (!isFocusable())
+ return false;
+
+ if (!document()->frame())
+ return false;
+
+ return document()->frame()->eventHandler()->tabsToLinks(event);
+}
+
+bool SVGAElement::childShouldCreateRenderer(Node* child) const
+{
+ if (static_cast<SVGElement*>(parent())->isTextContent())
+ return child->isTextNode();
+
+ return SVGElement::childShouldCreateRenderer(child);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGAElement.h b/WebCore/svg/SVGAElement.h
new file mode 100644
index 0000000..a1509fd
--- /dev/null
+++ b/WebCore/svg/SVGAElement.h
@@ -0,0 +1,76 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGAElement_h
+#define SVGAElement_h
+
+#if ENABLE(SVG)
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTests.h"
+#include "SVGURIReference.h"
+
+namespace WebCore {
+
+ class SVGAElement : public SVGStyledTransformableElement,
+ public SVGURIReference,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired {
+ public:
+ SVGAElement(const QualifiedName&, Document*);
+ virtual ~SVGAElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ virtual String title() const;
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ virtual void defaultEventHandler(Event*);
+
+ virtual bool supportsFocus() const;
+ virtual bool isMouseFocusable() const;
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+ virtual bool isFocusable() const;
+
+ virtual bool childShouldCreateRenderer(Node*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGAElement, String, String, Target, target)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGAElement_h
diff --git a/WebCore/svg/SVGAElement.idl b/WebCore/svg/SVGAElement.idl
new file mode 100644
index 0000000..88b46fc
--- /dev/null
+++ b/WebCore/svg/SVGAElement.idl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAElement : SVGElement,
+ SVGURIReference,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable {
+ readonly attribute SVGAnimatedString target;
+ };
+
+}
diff --git a/WebCore/svg/SVGAngle.cpp b/WebCore/svg/SVGAngle.cpp
new file mode 100644
index 0000000..81cf226
--- /dev/null
+++ b/WebCore/svg/SVGAngle.cpp
@@ -0,0 +1,175 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGAngle.h"
+
+#include <math.h>
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+SVGAngle::SVGAngle()
+ : RefCounted<SVGAngle>(0)
+ , m_unitType(SVG_ANGLETYPE_UNKNOWN)
+ , m_value(0)
+ , m_valueInSpecifiedUnits(0)
+{
+}
+
+SVGAngle::~SVGAngle()
+{
+}
+
+SVGAngle::SVGAngleType SVGAngle::unitType() const
+{
+ return m_unitType;
+}
+
+void SVGAngle::setValue(float value)
+{
+ m_value = value;
+}
+
+float SVGAngle::value() const
+{
+ return m_value;
+}
+
+// calc m_value
+void SVGAngle::calculate()
+{
+ if (m_unitType == SVG_ANGLETYPE_GRAD)
+ m_value = grad2deg(m_valueInSpecifiedUnits);
+ else if (m_unitType == SVG_ANGLETYPE_RAD)
+ m_value = rad2deg(m_valueInSpecifiedUnits);
+ else if (m_unitType == SVG_ANGLETYPE_UNSPECIFIED || m_unitType == SVG_ANGLETYPE_DEG)
+ m_value = m_valueInSpecifiedUnits;
+}
+
+void SVGAngle::setValueInSpecifiedUnits(float valueInSpecifiedUnits)
+{
+ m_valueInSpecifiedUnits = valueInSpecifiedUnits;
+ calculate();
+}
+
+float SVGAngle::valueInSpecifiedUnits() const
+{
+ return m_valueInSpecifiedUnits;
+}
+
+void SVGAngle::setValueAsString(const String& s)
+{
+ m_valueAsString = s;
+
+ bool bOK;
+ m_valueInSpecifiedUnits = m_valueAsString.toFloat(&bOK);
+ m_unitType = SVG_ANGLETYPE_UNSPECIFIED;
+
+ if (!bOK) {
+ if (m_valueAsString.endsWith("deg"))
+ m_unitType = SVG_ANGLETYPE_DEG;
+ else if (m_valueAsString.endsWith("grad"))
+ m_unitType = SVG_ANGLETYPE_GRAD;
+ else if (m_valueAsString.endsWith("rad"))
+ m_unitType = SVG_ANGLETYPE_RAD;
+ }
+
+ calculate();
+}
+
+String SVGAngle::valueAsString() const
+{
+ m_valueAsString = String::number(m_valueInSpecifiedUnits);
+
+ switch (m_unitType) {
+ case SVG_ANGLETYPE_UNSPECIFIED:
+ case SVG_ANGLETYPE_DEG:
+ m_valueAsString += "deg";
+ break;
+ case SVG_ANGLETYPE_RAD:
+ m_valueAsString += "rad";
+ break;
+ case SVG_ANGLETYPE_GRAD:
+ m_valueAsString += "grad";
+ break;
+ case SVG_ANGLETYPE_UNKNOWN:
+ break;
+ }
+
+ return m_valueAsString;
+}
+
+void SVGAngle::newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits)
+{
+ m_unitType = (SVGAngleType)unitType;
+ m_valueInSpecifiedUnits = valueInSpecifiedUnits;
+ calculate();
+}
+
+void SVGAngle::convertToSpecifiedUnits(unsigned short unitType)
+{
+ if (m_unitType == unitType)
+ return;
+
+ if (m_unitType == SVG_ANGLETYPE_DEG && unitType == SVG_ANGLETYPE_RAD)
+ m_valueInSpecifiedUnits = deg2rad(m_valueInSpecifiedUnits);
+ else if (m_unitType == SVG_ANGLETYPE_GRAD && unitType == SVG_ANGLETYPE_RAD)
+ m_valueInSpecifiedUnits = grad2rad(m_valueInSpecifiedUnits);
+ else if (m_unitType == SVG_ANGLETYPE_DEG && unitType == SVG_ANGLETYPE_GRAD)
+ m_valueInSpecifiedUnits = deg2grad(m_valueInSpecifiedUnits);
+ else if (m_unitType == SVG_ANGLETYPE_RAD && unitType == SVG_ANGLETYPE_GRAD)
+ m_valueInSpecifiedUnits = rad2grad(m_valueInSpecifiedUnits);
+ else if (m_unitType == SVG_ANGLETYPE_RAD && unitType == SVG_ANGLETYPE_DEG)
+ m_valueInSpecifiedUnits = rad2deg(m_valueInSpecifiedUnits);
+ else if (m_unitType == SVG_ANGLETYPE_GRAD && unitType == SVG_ANGLETYPE_DEG)
+ m_valueInSpecifiedUnits = grad2deg(m_valueInSpecifiedUnits);
+
+ m_unitType = (SVGAngleType)unitType;
+}
+
+// Helpers
+double SVGAngle::todeg(double rad)
+{
+ return rad2deg(rad);
+}
+
+double SVGAngle::torad(double deg)
+{
+ return deg2rad(deg);
+}
+
+double SVGAngle::shortestArcBisector(double angle1, double angle2)
+{
+ double bisector = (angle1 + angle2) / 2;
+
+ if (fabs(angle1 - angle2) > 180)
+ bisector += 180;
+
+ return bisector;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGAngle.h b/WebCore/svg/SVGAngle.h
new file mode 100644
index 0000000..d281076
--- /dev/null
+++ b/WebCore/svg/SVGAngle.h
@@ -0,0 +1,83 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGAngle_h
+#define SVGAngle_h
+
+#if ENABLE(SVG)
+#include "PlatformString.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+ class SVGStyledElement;
+
+ class SVGAngle : public RefCounted<SVGAngle> {
+ public:
+ SVGAngle();
+ virtual ~SVGAngle();
+
+ enum SVGAngleType {
+ SVG_ANGLETYPE_UNKNOWN = 0,
+ SVG_ANGLETYPE_UNSPECIFIED = 1,
+ SVG_ANGLETYPE_DEG = 2,
+ SVG_ANGLETYPE_RAD = 3,
+ SVG_ANGLETYPE_GRAD = 4
+ };
+
+ SVGAngleType unitType() const;
+
+ void setValue(float);
+ float value() const;
+
+ void setValueInSpecifiedUnits(float valueInSpecifiedUnits);
+ float valueInSpecifiedUnits() const;
+
+ void setValueAsString(const String&);
+ String valueAsString() const;
+
+ void newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits);
+ void convertToSpecifiedUnits(unsigned short unitType);
+
+ // Helpers
+ static double todeg(double rad);
+ static double torad(double deg);
+
+ // Returns the angle that divides the shortest arc between the two angles.
+ static double shortestArcBisector(double angle1, double angle2);
+
+ // Throughout SVG 1.1 'SVGAngle' is only used for 'SVGMarkerElement' (orient-angle)
+ const QualifiedName& associatedAttributeName() const { return SVGNames::orientAttr; }
+
+ private:
+ SVGAngleType m_unitType;
+ float m_value;
+ float m_valueInSpecifiedUnits;
+ mutable String m_valueAsString;
+
+ void calculate();
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGAngle_h
diff --git a/WebCore/svg/SVGAngle.idl b/WebCore/svg/SVGAngle.idl
new file mode 100644
index 0000000..fc7c1e1
--- /dev/null
+++ b/WebCore/svg/SVGAngle.idl
@@ -0,0 +1,45 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor] SVGAngle {
+ // Angle Unit Types
+ const unsigned short SVG_ANGLETYPE_UNKNOWN = 0;
+ const unsigned short SVG_ANGLETYPE_UNSPECIFIED = 1;
+ const unsigned short SVG_ANGLETYPE_DEG = 2;
+ const unsigned short SVG_ANGLETYPE_RAD = 3;
+ const unsigned short SVG_ANGLETYPE_GRAD = 4;
+
+ readonly attribute unsigned short unitType;
+ attribute float value;
+ attribute float valueInSpecifiedUnits;
+ attribute [ConvertNullToNullString] DOMString valueAsString;
+
+ void newValueSpecifiedUnits(in unsigned short unitType,
+ in float valueInSpecifiedUnits);
+ void convertToSpecifiedUnits(in unsigned short unitType);
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimateColorElement.cpp b/WebCore/svg/SVGAnimateColorElement.cpp
new file mode 100644
index 0000000..18135e6
--- /dev/null
+++ b/WebCore/svg/SVGAnimateColorElement.cpp
@@ -0,0 +1,105 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGAnimateColorElement.h"
+
+#include "Document.h"
+#include "TimeScheduler.h"
+#include "PlatformString.h"
+#include "SVGColor.h"
+#include "SVGSVGElement.h"
+#include <math.h>
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+SVGAnimateColorElement::SVGAnimateColorElement(const QualifiedName& tagName, Document* doc)
+ : SVGAnimationElement(tagName, doc)
+{
+}
+
+SVGAnimateColorElement::~SVGAnimateColorElement()
+{
+}
+
+bool SVGAnimateColorElement::updateAnimationBaseValueFromElement()
+{
+ m_baseColor = SVGColor::colorFromRGBColorString(targetAttributeAnimatedValue());
+ m_fromColor = Color();
+ m_toColor = Color();
+ return true;
+}
+
+void SVGAnimateColorElement::applyAnimatedValueToElement()
+{
+ if (isAdditive())
+ setTargetAttributeAnimatedValue(ColorDistance::addColorsAndClamp(m_baseColor, m_animatedColor).name());
+ else
+ setTargetAttributeAnimatedValue(m_animatedColor.name());
+}
+
+bool SVGAnimateColorElement::updateAnimatedValue(EAnimationMode animationMode, float timePercentage, unsigned valueIndex, float percentagePast)
+{
+ if (animationMode == TO_ANIMATION)
+ // to-animations have a special equation: value = (to - base) * (time/duration) + base
+ m_animatedColor = ColorDistance(m_baseColor, m_toColor).scaledDistance(timePercentage).addToColorAndClamp(m_baseColor);
+ else
+ m_animatedColor = ColorDistance(m_fromColor, m_toColor).scaledDistance(percentagePast).addToColorAndClamp(m_fromColor);
+ return (m_animatedColor != m_baseColor);
+}
+
+bool SVGAnimateColorElement::calculateFromAndToValues(EAnimationMode animationMode, unsigned valueIndex)
+{
+ switch (animationMode) {
+ case FROM_TO_ANIMATION:
+ m_fromColor = SVGColor::colorFromRGBColorString(m_from);
+ // fall through
+ case TO_ANIMATION:
+ m_toColor = SVGColor::colorFromRGBColorString(m_to);
+ break;
+ case FROM_BY_ANIMATION:
+ m_fromColor = SVGColor::colorFromRGBColorString(m_from);
+ m_toColor = SVGColor::colorFromRGBColorString(m_by);
+ break;
+ case BY_ANIMATION:
+ m_fromColor = SVGColor::colorFromRGBColorString(m_from);
+ m_toColor = ColorDistance::addColorsAndClamp(m_fromColor, SVGColor::colorFromRGBColorString(m_by));
+ break;
+ case VALUES_ANIMATION:
+ m_fromColor = SVGColor::colorFromRGBColorString(m_values[valueIndex]);
+ m_toColor = ((valueIndex + 1) < m_values.size()) ? SVGColor::colorFromRGBColorString(m_values[valueIndex + 1]) : m_fromColor;
+ break;
+ case NO_ANIMATION:
+ ASSERT_NOT_REACHED();
+ }
+
+ return true;
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGAnimateColorElement.h b/WebCore/svg/SVGAnimateColorElement.h
new file mode 100644
index 0000000..1a9a841
--- /dev/null
+++ b/WebCore/svg/SVGAnimateColorElement.h
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGAnimateColorElement_h
+#define SVGAnimateColorElement_h
+#if ENABLE(SVG)
+
+#include "SVGAnimationElement.h"
+#include "ColorDistance.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+ class SVGColor;
+
+ class SVGAnimateColorElement : public SVGAnimationElement {
+ public:
+ SVGAnimateColorElement(const QualifiedName&, Document*);
+ virtual ~SVGAnimateColorElement();
+
+ virtual bool updateAnimationBaseValueFromElement();
+ virtual void applyAnimatedValueToElement();
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ virtual bool updateAnimatedValue(EAnimationMode, float timePercentage, unsigned valueIndex, float percentagePast);
+ virtual bool calculateFromAndToValues(EAnimationMode, unsigned valueIndex);
+
+ private:
+ Color m_baseColor;
+ Color m_animatedColor;
+
+ Color m_toColor;
+ Color m_fromColor;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // KSVG_SVGAnimateColorElementImpl_H
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGAnimateColorElement.idl b/WebCore/svg/SVGAnimateColorElement.idl
new file mode 100644
index 0000000..ad3a0a8
--- /dev/null
+++ b/WebCore/svg/SVGAnimateColorElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimateColorElement : SVGAnimationElement {
+ }
+
+};
diff --git a/WebCore/svg/SVGAnimateElement.cpp b/WebCore/svg/SVGAnimateElement.cpp
new file mode 100644
index 0000000..4b9cb46
--- /dev/null
+++ b/WebCore/svg/SVGAnimateElement.cpp
@@ -0,0 +1,47 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
+#include "SVGAnimateElement.h"
+
+#include "TimeScheduler.h"
+#include "SVGDocumentExtensions.h"
+#include "SVGSVGElement.h"
+
+namespace WebCore {
+
+SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName, Document* doc)
+ : SVGAnimationElement(tagName, doc)
+ , m_currentItem(-1)
+{
+}
+
+SVGAnimateElement::~SVGAnimateElement()
+{
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGAnimateElement.h b/WebCore/svg/SVGAnimateElement.h
new file mode 100644
index 0000000..2b7cf14
--- /dev/null
+++ b/WebCore/svg/SVGAnimateElement.h
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGAnimateElement_h
+#define SVGAnimateElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
+
+#include "SVGAnimationElement.h"
+
+namespace WebCore {
+
+ class SVGAnimateElement : public SVGAnimationElement {
+ public:
+ SVGAnimateElement(const QualifiedName&, Document*);
+ virtual ~SVGAnimateElement();
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ virtual bool updateAnimatedValue(EAnimationMode, float timePercentage, unsigned valueIndex, float percentagePast) { return false; }
+ virtual bool calculateFromAndToValues(EAnimationMode, unsigned valueIndex) { return false; }
+
+ private:
+ int m_currentItem;
+
+ String m_savedTo;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGAnimateElement_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGAnimateElement.idl b/WebCore/svg/SVGAnimateElement.idl
new file mode 100644
index 0000000..aaf7791
--- /dev/null
+++ b/WebCore/svg/SVGAnimateElement.idl
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_ANIMATION] SVGAnimateElement : SVGAnimationElement {
+ }
+
+};
+
diff --git a/WebCore/svg/SVGAnimateMotionElement.cpp b/WebCore/svg/SVGAnimateMotionElement.cpp
new file mode 100644
index 0000000..85ffc5d
--- /dev/null
+++ b/WebCore/svg/SVGAnimateMotionElement.cpp
@@ -0,0 +1,230 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ (C) 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
+#include "SVGAnimateMotionElement.h"
+
+#include "RenderObject.h"
+#include "SVGMPathElement.h"
+#include "SVGParserUtilities.h"
+#include "SVGPathElement.h"
+#include "SVGTransformList.h"
+
+namespace WebCore {
+
+using namespace SVGNames;
+
+SVGAnimateMotionElement::SVGAnimateMotionElement(const QualifiedName& tagName, Document* doc)
+ : SVGAnimationElement(tagName, doc)
+ , m_rotateMode(AngleMode)
+ , m_angle(0)
+{
+ m_calcMode = CALCMODE_PACED;
+}
+
+SVGAnimateMotionElement::~SVGAnimateMotionElement()
+{
+}
+
+bool SVGAnimateMotionElement::hasValidTarget() const
+{
+ if (!SVGAnimationElement::hasValidTarget())
+ return false;
+ if (!targetElement()->isStyledTransformable())
+ return false;
+ // Spec: SVG 1.1 section 19.2.15
+ if (targetElement()->hasTagName(gTag)
+ || targetElement()->hasTagName(defsTag)
+ || targetElement()->hasTagName(useTag)
+ || targetElement()->hasTagName(imageTag)
+ || targetElement()->hasTagName(switchTag)
+ || targetElement()->hasTagName(pathTag)
+ || targetElement()->hasTagName(rectTag)
+ || targetElement()->hasTagName(circleTag)
+ || targetElement()->hasTagName(ellipseTag)
+ || targetElement()->hasTagName(lineTag)
+ || targetElement()->hasTagName(polylineTag)
+ || targetElement()->hasTagName(polygonTag)
+ || targetElement()->hasTagName(textTag)
+ || targetElement()->hasTagName(clipPathTag)
+ || targetElement()->hasTagName(maskTag)
+ || targetElement()->hasTagName(aTag)
+ || targetElement()->hasTagName(foreignObjectTag))
+ return true;
+ return false;
+}
+
+void SVGAnimateMotionElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::rotateAttr) {
+ if (attr->value() == "auto")
+ m_rotateMode = AutoMode;
+ else if (attr->value() == "auto-reverse")
+ m_rotateMode = AutoReverseMode;
+ else {
+ m_rotateMode = AngleMode;
+ m_angle = attr->value().toFloat();
+ }
+ } else if (attr->name() == SVGNames::keyPointsAttr) {
+ m_keyPoints.clear();
+ parseKeyNumbers(m_keyPoints, attr->value());
+ } else if (attr->name() == SVGNames::dAttr) {
+ m_path = Path();
+ pathFromSVGData(m_path, attr->value());
+ } else
+ SVGAnimationElement::parseMappedAttribute(attr);
+}
+
+Path SVGAnimateMotionElement::animationPath()
+{
+ for (Node* child = firstChild(); child; child->nextSibling()) {
+ if (child->hasTagName(SVGNames::mpathTag)) {
+ SVGMPathElement* mPath = static_cast<SVGMPathElement*>(child);
+ SVGPathElement* pathElement = mPath->pathElement();
+ if (pathElement)
+ return pathElement->toPathData();
+ // The spec would probably have us throw up an error here, but instead we try to fall back to the d value
+ }
+ }
+ if (hasAttribute(SVGNames::dAttr))
+ return m_path;
+ return Path();
+}
+
+bool SVGAnimateMotionElement::updateAnimatedValue(EAnimationMode animationMode, float timePercentage, unsigned valueIndex, float percentagePast)
+{
+ if (animationMode == TO_ANIMATION) {
+ // to-animations have a special equation: value = (to - base) * (time/duration) + base
+ m_animatedTranslation.setWidth((m_toPoint.x() - m_basePoint.x()) * timePercentage + m_basePoint.x());
+ m_animatedTranslation.setHeight((m_toPoint.y() - m_basePoint.y()) * timePercentage + m_basePoint.y());
+ m_animatedAngle = 0.0f;
+ } else {
+ m_animatedTranslation.setWidth(m_pointDiff.width() * percentagePast + m_fromPoint.x());
+ m_animatedTranslation.setHeight(m_pointDiff.height() * percentagePast + m_fromPoint.y());
+ m_animatedAngle = m_angleDiff * percentagePast + m_fromAngle;
+ }
+ return true;
+}
+
+static bool parsePoint(const String& s, FloatPoint& point)
+{
+ if (s.isEmpty())
+ return false;
+ const UChar* cur = s.characters();
+ const UChar* end = cur + s.length();
+
+ if (!skipOptionalSpaces(cur, end))
+ return false;
+
+ float x = 0.0f;
+ if (!parseNumber(cur, end, x))
+ return false;
+
+ float y = 0.0f;
+ if (!parseNumber(cur, end, y))
+ return false;
+
+ point = FloatPoint(x, y);
+
+ // disallow anying except spaces at the end
+ return !skipOptionalSpaces(cur, end);
+}
+
+bool SVGAnimateMotionElement::calculateFromAndToValues(EAnimationMode animationMode, unsigned valueIndex)
+{
+ m_fromAngle = 0.0f;
+ m_toAngle = 0.0f;
+ switch (animationMode) {
+ case FROM_TO_ANIMATION:
+ parsePoint(m_from, m_fromPoint);
+ // fall through
+ case TO_ANIMATION:
+ parsePoint(m_to, m_toPoint);
+ break;
+ case FROM_BY_ANIMATION:
+ parsePoint(m_from, m_fromPoint);
+ parsePoint(m_to, m_toPoint);
+ break;
+ case BY_ANIMATION:
+ {
+ parsePoint(m_from, m_fromPoint);
+ FloatPoint byPoint;
+ parsePoint(m_by, byPoint);
+ m_toPoint = FloatPoint(m_fromPoint.x() + byPoint.x(), m_fromPoint.y() + byPoint.y());
+ break;
+ }
+ case VALUES_ANIMATION:
+ parsePoint(m_values[valueIndex], m_fromPoint);
+ if ((valueIndex + 1) < m_values.size())
+ parsePoint(m_values[valueIndex + 1], m_toPoint);
+ else
+ m_toPoint = m_fromPoint;
+ break;
+ case NO_ANIMATION:
+ ASSERT_NOT_REACHED();
+ }
+
+ m_pointDiff = m_toPoint - m_fromPoint;
+ m_angleDiff = 0.0f;
+ return (m_pointDiff.width() != 0 || m_pointDiff.height() != 0);
+}
+
+bool SVGAnimateMotionElement::updateAnimationBaseValueFromElement()
+{
+ if (!targetElement()->isStyledTransformable())
+ return false;
+
+ m_basePoint = static_cast<SVGStyledTransformableElement*>(targetElement())->getBBox().location();
+ return true;
+}
+
+void SVGAnimateMotionElement::applyAnimatedValueToElement()
+{
+ if (!targetElement()->isStyledTransformable())
+ return;
+
+ SVGStyledTransformableElement* transformableElement = static_cast<SVGStyledTransformableElement*>(targetElement());
+ RefPtr<SVGTransformList> transformList = transformableElement->transform();
+ if (!transformList)
+ return;
+
+ ExceptionCode ec;
+ if (!isAdditive())
+ transformList->clear(ec);
+
+ AffineTransform transform;
+ transform.rotate(m_animatedAngle);
+ transform.translate(m_animatedTranslation.width(), m_animatedTranslation.height());
+ if (!transform.isIdentity()) {
+ transformList->appendItem(SVGTransform(transform), ec);
+ transformableElement->setTransform(transformList.get());
+ if (transformableElement->renderer())
+ transformableElement->renderer()->setNeedsLayout(true); // should be part of setTransform
+ }
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGAnimateMotionElement.h b/WebCore/svg/SVGAnimateMotionElement.h
new file mode 100644
index 0000000..6d9632c
--- /dev/null
+++ b/WebCore/svg/SVGAnimateMotionElement.h
@@ -0,0 +1,82 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGAnimateMotionElement_h
+#define SVGAnimateMotionElement_h
+#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
+
+#include "SVGAnimationElement.h"
+#include "AffineTransform.h"
+#include "Path.h"
+
+namespace WebCore {
+
+ class SVGAnimateMotionElement : public SVGAnimationElement {
+ public:
+ SVGAnimateMotionElement(const QualifiedName&, Document*);
+ virtual ~SVGAnimateMotionElement();
+
+ virtual bool hasValidTarget() const;
+
+ virtual bool updateAnimationBaseValueFromElement();
+ virtual void applyAnimatedValueToElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ Path animationPath();
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ virtual bool updateAnimatedValue(EAnimationMode, float timePercentage, unsigned valueIndex, float percentagePast);
+ virtual bool calculateFromAndToValues(EAnimationMode, unsigned valueIndex);
+
+ private:
+ FloatPoint m_basePoint;
+ FloatSize m_animatedTranslation;
+ float m_animatedAngle;
+
+ // Note: we do not support percentage values for to/from coords as the spec implies we should (opera doesn't either)
+ FloatPoint m_fromPoint;
+ float m_fromAngle;
+ FloatPoint m_toPoint;
+ float m_toAngle;
+
+ FloatSize m_pointDiff;
+ float m_angleDiff;
+
+ Path m_path;
+ Vector<float> m_keyPoints;
+ enum RotateMode {
+ AngleMode,
+ AutoMode,
+ AutoReverseMode
+ };
+ RotateMode m_rotateMode;
+ float m_angle;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGAnimateMotionElement_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGAnimateTransformElement.cpp b/WebCore/svg/SVGAnimateTransformElement.cpp
new file mode 100644
index 0000000..c10b98c
--- /dev/null
+++ b/WebCore/svg/SVGAnimateTransformElement.cpp
@@ -0,0 +1,172 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
+#include "SVGAnimateTransformElement.h"
+
+#include "AffineTransform.h"
+#include "RenderObject.h"
+#include "SVGAngle.h"
+#include "SVGParserUtilities.h"
+#include "SVGSVGElement.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTransform.h"
+#include "SVGTransformList.h"
+#include "TimeScheduler.h"
+
+#include <math.h>
+#include <wtf/MathExtras.h>
+
+using namespace std;
+
+namespace WebCore {
+
+SVGAnimateTransformElement::SVGAnimateTransformElement(const QualifiedName& tagName, Document* doc)
+ : SVGAnimationElement(tagName, doc)
+ , m_type(SVGTransform::SVG_TRANSFORM_UNKNOWN)
+{
+}
+
+SVGAnimateTransformElement::~SVGAnimateTransformElement()
+{
+}
+
+bool SVGAnimateTransformElement::hasValidTarget() const
+{
+ return (SVGAnimationElement::hasValidTarget() && targetElement()->isStyledTransformable());
+}
+
+void SVGAnimateTransformElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::typeAttr) {
+ if (attr->value() == "translate")
+ m_type = SVGTransform::SVG_TRANSFORM_TRANSLATE;
+ else if (attr->value() == "scale")
+ m_type = SVGTransform::SVG_TRANSFORM_SCALE;
+ else if (attr->value() == "rotate")
+ m_type = SVGTransform::SVG_TRANSFORM_ROTATE;
+ else if (attr->value() == "skewX")
+ m_type = SVGTransform::SVG_TRANSFORM_SKEWX;
+ else if (attr->value() == "skewY")
+ m_type = SVGTransform::SVG_TRANSFORM_SKEWY;
+ } else
+ SVGAnimationElement::parseMappedAttribute(attr);
+}
+
+bool SVGAnimateTransformElement::updateAnimatedValue(EAnimationMode animationMode, float timePercentage, unsigned valueIndex, float percentagePast)
+{
+ if (animationMode == TO_ANIMATION)
+ // to-animations have a special equation: value = (to - base) * (time/duration) + base
+ m_animatedTransform = SVGTransformDistance(m_baseTransform, m_toTransform).scaledDistance(timePercentage).addToSVGTransform(m_baseTransform);
+ else
+ m_animatedTransform = SVGTransformDistance(m_fromTransform, m_toTransform).scaledDistance(percentagePast).addToSVGTransform(m_fromTransform);
+ return (m_animatedTransform != m_baseTransform);
+}
+
+bool SVGAnimateTransformElement::updateAnimationBaseValueFromElement()
+{
+ m_baseTransform = SVGTransform();
+ m_toTransform = SVGTransform();
+ m_fromTransform = SVGTransform();
+ m_animatedTransform = SVGTransform();
+
+ if (!targetElement()->isStyledTransformable())
+ return false;
+
+ SVGStyledTransformableElement* transform = static_cast<SVGStyledTransformableElement*>(targetElement());
+ RefPtr<SVGTransformList> transformList = transform->transform();
+ if (!transformList)
+ return false;
+
+ m_baseTransform = transformList->concatenateForType(m_type);
+
+ // If a base value is empty, its type should match m_type instead of being unknown.
+ // It's not certain whether this should be part of SVGTransformList or not -- cying
+ if (m_baseTransform.type() == SVGTransform::SVG_TRANSFORM_UNKNOWN)
+ m_baseTransform = SVGTransform(m_type);
+
+ return true;
+}
+
+void SVGAnimateTransformElement::applyAnimatedValueToElement()
+{
+ if (!targetElement()->isStyledTransformable())
+ return;
+
+ SVGStyledTransformableElement* transform = static_cast<SVGStyledTransformableElement*>(targetElement());
+ RefPtr<SVGTransformList> transformList = transform->transform();
+ if (!transformList)
+ return;
+
+ ExceptionCode ec;
+ if (!isAdditive())
+ transformList->clear(ec);
+
+ transformList->appendItem(m_animatedTransform, ec);
+ transform->setTransform(transformList.get());
+ if (transform->renderer())
+ transform->renderer()->setNeedsLayout(true); // should really be in setTransform
+}
+
+bool SVGAnimateTransformElement::calculateFromAndToValues(EAnimationMode animationMode, unsigned valueIndex)
+{
+ switch (animationMode) {
+ case FROM_TO_ANIMATION:
+ m_fromTransform = parseTransformValue(m_from);
+ // fall through
+ case TO_ANIMATION:
+ m_toTransform = parseTransformValue(m_to);
+ break;
+ case FROM_BY_ANIMATION:
+ m_fromTransform = parseTransformValue(m_from);
+ m_toTransform = parseTransformValue(m_by);
+ break;
+ case BY_ANIMATION:
+ m_fromTransform = parseTransformValue(m_from);
+ m_toTransform = SVGTransformDistance::addSVGTransforms(m_fromTransform, parseTransformValue(m_by));
+ break;
+ case VALUES_ANIMATION:
+ m_fromTransform = parseTransformValue(m_values[valueIndex]);
+ m_toTransform = ((valueIndex + 1) < m_values.size()) ? parseTransformValue(m_values[valueIndex + 1]) : m_fromTransform;
+ break;
+ case NO_ANIMATION:
+ ASSERT_NOT_REACHED();
+ }
+
+ return true;
+}
+
+SVGTransform SVGAnimateTransformElement::parseTransformValue(const String& value) const
+{
+ SVGTransform result;
+ const UChar* ptr = value.characters();
+ SVGTransformable::parseTransformValue(m_type, ptr, ptr + value.length(), result); // ignoring return value
+ return result;
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGAnimateTransformElement.h b/WebCore/svg/SVGAnimateTransformElement.h
new file mode 100644
index 0000000..520e927
--- /dev/null
+++ b/WebCore/svg/SVGAnimateTransformElement.h
@@ -0,0 +1,72 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGAnimateTransformElement_h
+#define SVGAnimateTransformElement_h
+#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
+
+#include "SVGAnimationElement.h"
+#include "SVGTransform.h"
+#include "SVGTransformDistance.h"
+
+namespace WebCore {
+
+ class AffineTransform;
+
+ class SVGAnimateTransformElement : public SVGAnimationElement {
+ public:
+ SVGAnimateTransformElement(const QualifiedName&, Document*);
+ virtual ~SVGAnimateTransformElement();
+
+ virtual bool hasValidTarget() const;
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ virtual bool updateAnimationBaseValueFromElement();
+ virtual void applyAnimatedValueToElement();
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ virtual bool updateAnimatedValue(EAnimationMode, float timePercentage, unsigned valueIndex, float percentagePast);
+ virtual bool calculateFromAndToValues(EAnimationMode, unsigned valueIndex);
+
+ private:
+ SVGTransform parseTransformValue(const String&) const;
+ void calculateRotationFromMatrix(const AffineTransform&, double& angle, double& cx, double& cy) const;
+
+ SVGTransform::SVGTransformType m_type;
+
+ SVGTransform m_toTransform;
+ SVGTransform m_fromTransform;
+
+ SVGTransform m_baseTransform;
+ SVGTransform m_animatedTransform;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGAnimateTransformElement_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGAnimateTransformElement.idl b/WebCore/svg/SVGAnimateTransformElement.idl
new file mode 100644
index 0000000..80d8108
--- /dev/null
+++ b/WebCore/svg/SVGAnimateTransformElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_ANIMATION] SVGAnimateTransformElement : SVGAnimationElement {
+ }
+
+};
diff --git a/WebCore/svg/SVGAnimatedAngle.idl b/WebCore/svg/SVGAnimatedAngle.idl
new file mode 100644
index 0000000..c400c19
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedAngle.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimatedAngle {
+ readonly attribute SVGAngle baseVal;
+ readonly attribute SVGAngle animVal;
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimatedBoolean.idl b/WebCore/svg/SVGAnimatedBoolean.idl
new file mode 100644
index 0000000..4664991
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedBoolean.idl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimatedBoolean {
+ attribute boolean baseVal
+ /*setter raises(DOMException)*/;
+ readonly attribute boolean animVal;
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimatedEnumeration.idl b/WebCore/svg/SVGAnimatedEnumeration.idl
new file mode 100644
index 0000000..5a3988a
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedEnumeration.idl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimatedEnumeration {
+ attribute unsigned short baseVal
+ /*setter raises(DOMException)*/;
+ readonly attribute unsigned short animVal;
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimatedInteger.idl b/WebCore/svg/SVGAnimatedInteger.idl
new file mode 100644
index 0000000..1119008
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedInteger.idl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimatedInteger {
+ attribute long baseVal
+ /*setter raises(DOMException)*/;
+ readonly attribute long animVal;
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimatedLength.idl b/WebCore/svg/SVGAnimatedLength.idl
new file mode 100644
index 0000000..a6a85e4
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedLength.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimatedLength {
+ readonly attribute SVGLength baseVal;
+ readonly attribute SVGLength animVal;
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimatedLengthList.idl b/WebCore/svg/SVGAnimatedLengthList.idl
new file mode 100644
index 0000000..358920f
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedLengthList.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimatedLengthList {
+ readonly attribute SVGLengthList baseVal;
+ readonly attribute SVGLengthList animVal;
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimatedNumber.idl b/WebCore/svg/SVGAnimatedNumber.idl
new file mode 100644
index 0000000..3c3a161
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedNumber.idl
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimatedNumber {
+ attribute float baseVal
+ /*setter raises(DOMException)*/;
+ readonly attribute float animVal;
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimatedNumberList.idl b/WebCore/svg/SVGAnimatedNumberList.idl
new file mode 100644
index 0000000..aaa5919
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedNumberList.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimatedNumberList {
+ readonly attribute SVGNumberList baseVal;
+ readonly attribute SVGNumberList animVal;
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimatedPathData.cpp b/WebCore/svg/SVGAnimatedPathData.cpp
new file mode 100644
index 0000000..be75809
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedPathData.cpp
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGAnimatedPathData.h"
+
+namespace WebCore {
+
+SVGAnimatedPathData::SVGAnimatedPathData()
+{
+}
+
+SVGAnimatedPathData::~SVGAnimatedPathData()
+{
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGAnimatedPathData.h b/WebCore/svg/SVGAnimatedPathData.h
new file mode 100644
index 0000000..6b3faf6
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedPathData.h
@@ -0,0 +1,50 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGAnimatedPathData_h
+#define SVGAnimatedPathData_h
+
+#if ENABLE(SVG)
+
+namespace WebCore
+{
+ class SVGPathSegList;
+
+ class SVGAnimatedPathData
+ {
+ public:
+ SVGAnimatedPathData();
+ virtual ~SVGAnimatedPathData();
+
+ // 'SVGAnimatedPathData' functions
+ virtual SVGPathSegList* pathSegList() const = 0;
+ virtual SVGPathSegList* normalizedPathSegList() const = 0;
+ virtual SVGPathSegList* animatedPathSegList() const = 0;
+ virtual SVGPathSegList* animatedNormalizedPathSegList() const = 0;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGAnimatedPathData.idl b/WebCore/svg/SVGAnimatedPathData.idl
new file mode 100644
index 0000000..46ec7b1
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedPathData.idl
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, ObjCProtocol] SVGAnimatedPathData {
+ readonly attribute SVGPathSegList pathSegList;
+ readonly attribute SVGPathSegList normalizedPathSegList;
+ readonly attribute SVGPathSegList animatedPathSegList;
+ readonly attribute SVGPathSegList animatedNormalizedPathSegList;
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimatedPoints.cpp b/WebCore/svg/SVGAnimatedPoints.cpp
new file mode 100644
index 0000000..584f875
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedPoints.cpp
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGAnimatedPoints.h"
+
+namespace WebCore {
+
+SVGAnimatedPoints::SVGAnimatedPoints()
+{
+}
+
+SVGAnimatedPoints::~SVGAnimatedPoints()
+{
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGAnimatedPoints.h b/WebCore/svg/SVGAnimatedPoints.h
new file mode 100644
index 0000000..58323c0
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedPoints.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGAnimatedPoints_h
+#define SVGAnimatedPoints_h
+
+#if ENABLE(SVG)
+
+namespace WebCore
+{
+ class SVGPointList;
+
+ class SVGAnimatedPoints
+ {
+ public:
+ SVGAnimatedPoints();
+ virtual ~SVGAnimatedPoints();
+
+ // 'SVGAnimatedPoints' functions
+ virtual SVGPointList* points() const = 0;
+ virtual SVGPointList* animatedPoints() const = 0;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGAnimatedPoints.idl b/WebCore/svg/SVGAnimatedPoints.idl
new file mode 100644
index 0000000..877f684
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedPoints.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, ObjCProtocol] SVGAnimatedPoints {
+ readonly attribute SVGPointList points;
+ readonly attribute SVGPointList animatedPoints;
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimatedPreserveAspectRatio.idl b/WebCore/svg/SVGAnimatedPreserveAspectRatio.idl
new file mode 100644
index 0000000..b98ae36
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedPreserveAspectRatio.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimatedPreserveAspectRatio {
+ readonly attribute SVGPreserveAspectRatio baseVal;
+ readonly attribute SVGPreserveAspectRatio animVal;
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimatedRect.idl b/WebCore/svg/SVGAnimatedRect.idl
new file mode 100644
index 0000000..1ba4e29
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedRect.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimatedRect {
+ readonly attribute SVGRect baseVal;
+ readonly attribute SVGRect animVal;
+ }
+
+};
diff --git a/WebCore/svg/SVGAnimatedString.idl b/WebCore/svg/SVGAnimatedString.idl
new file mode 100644
index 0000000..888c762
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedString.idl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimatedString {
+ attribute core::DOMString baseVal
+ /*setter raises(DOMException)*/;
+ readonly attribute core::DOMString animVal;
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimatedTemplate.h b/WebCore/svg/SVGAnimatedTemplate.h
new file mode 100644
index 0000000..9f1b50b
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedTemplate.h
@@ -0,0 +1,177 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGAnimatedTemplate_h
+#define SVGAnimatedTemplate_h
+
+#if ENABLE(SVG)
+#include <wtf/RefCounted.h>
+#include "AtomicString.h"
+#include "Attribute.h"
+
+namespace WebCore {
+
+ class FloatRect;
+ class SVGAngle;
+ class SVGElement;
+ class SVGLength;
+ class SVGLengthList;
+ class SVGNumberList;
+ class SVGPreserveAspectRatio;
+ class SVGTransformList;
+ class String;
+ class QualifiedName;
+
+ struct SVGAnimatedTypeWrapperKey {
+ // Empty value
+ SVGAnimatedTypeWrapperKey()
+ : element(0)
+ , attributeName(0)
+ { }
+
+ // Deleted value
+ explicit SVGAnimatedTypeWrapperKey(bool)
+ : element(reinterpret_cast<SVGElement*>(-1))
+ , attributeName(0)
+ { }
+
+ SVGAnimatedTypeWrapperKey(const SVGElement* _element, const AtomicString& _attributeName)
+ : element(_element)
+ , attributeName(_attributeName.impl())
+ {
+ ASSERT(element);
+ ASSERT(attributeName);
+ }
+
+ bool operator==(const SVGAnimatedTypeWrapperKey& other) const
+ {
+ return element == other.element && attributeName == other.attributeName;
+ }
+
+ const SVGElement* element;
+ AtomicStringImpl* attributeName;
+ };
+
+ struct SVGAnimatedTypeWrapperKeyHash {
+ static unsigned hash(const SVGAnimatedTypeWrapperKey& key)
+ {
+ return StringImpl::computeHash((::UChar*) &key, sizeof(SVGAnimatedTypeWrapperKey) / sizeof(::UChar));
+ }
+
+ static bool equal(const SVGAnimatedTypeWrapperKey& a, const SVGAnimatedTypeWrapperKey& b)
+ {
+ return a == b;
+ }
+
+ static const bool safeToCompareToEmptyOrDeleted = true;
+ };
+
+ struct SVGAnimatedTypeWrapperKeyHashTraits : WTF::GenericHashTraits<SVGAnimatedTypeWrapperKey> {
+ static const bool emptyValueIsZero = true;
+ static const bool needsDestruction = false;
+
+ static const SVGAnimatedTypeWrapperKey& deletedValue()
+ {
+ static SVGAnimatedTypeWrapperKey deletedKey(true);
+ return deletedKey;
+ }
+
+ static const SVGAnimatedTypeWrapperKey& emptyValue()
+ {
+ static SVGAnimatedTypeWrapperKey emptyKey;
+ return emptyKey;
+ }
+ };
+
+ template<typename BareType>
+ class SVGAnimatedTemplate : public RefCounted<SVGAnimatedTemplate<BareType> > {
+ public:
+ SVGAnimatedTemplate(const QualifiedName& attributeName)
+ : RefCounted<SVGAnimatedTemplate<BareType> >(0)
+ , m_associatedAttributeName(attributeName)
+ {
+ }
+
+ virtual ~SVGAnimatedTemplate() { forgetWrapper(this); }
+
+ virtual BareType baseVal() const = 0;
+ virtual void setBaseVal(BareType newBaseVal) = 0;
+
+ virtual BareType animVal() const = 0;
+ virtual void setAnimVal(BareType newAnimVal) = 0;
+
+ typedef HashMap<SVGAnimatedTypeWrapperKey, SVGAnimatedTemplate<BareType>*, SVGAnimatedTypeWrapperKeyHash, SVGAnimatedTypeWrapperKeyHashTraits > ElementToWrapperMap;
+ typedef typename ElementToWrapperMap::const_iterator ElementToWrapperMapIterator;
+
+ static ElementToWrapperMap* wrapperCache()
+ {
+ static ElementToWrapperMap* s_wrapperCache = new ElementToWrapperMap;
+ return s_wrapperCache;
+ }
+
+ static void forgetWrapper(SVGAnimatedTemplate<BareType>* wrapper)
+ {
+ ElementToWrapperMap* cache = wrapperCache();
+ ElementToWrapperMapIterator itr = cache->begin();
+ ElementToWrapperMapIterator end = cache->end();
+ for (; itr != end; ++itr) {
+ if (itr->second == wrapper) {
+ cache->remove(itr->first);
+ break;
+ }
+ }
+ }
+
+ const QualifiedName& associatedAttributeName() const { return m_associatedAttributeName; }
+
+ private:
+ const QualifiedName& m_associatedAttributeName;
+ };
+
+ template <class Type, class SVGElementSubClass>
+ Type* lookupOrCreateWrapper(const SVGElementSubClass* element, const QualifiedName& domAttrName, const AtomicString& attrIdentifier) {
+ SVGAnimatedTypeWrapperKey key(element, attrIdentifier);
+ Type* wrapper = static_cast<Type*>(Type::wrapperCache()->get(key));
+ if (!wrapper) {
+ wrapper = new Type(element, domAttrName);
+ Type::wrapperCache()->set(key, wrapper);
+ }
+ return wrapper;
+ }
+
+ // Common type definitions, to ease IDL generation...
+ typedef SVGAnimatedTemplate<SVGAngle*> SVGAnimatedAngle;
+ typedef SVGAnimatedTemplate<bool> SVGAnimatedBoolean;
+ typedef SVGAnimatedTemplate<int> SVGAnimatedEnumeration;
+ typedef SVGAnimatedTemplate<long> SVGAnimatedInteger;
+ typedef SVGAnimatedTemplate<SVGLength> SVGAnimatedLength;
+ typedef SVGAnimatedTemplate<SVGLengthList*> SVGAnimatedLengthList;
+ typedef SVGAnimatedTemplate<float> SVGAnimatedNumber;
+ typedef SVGAnimatedTemplate<SVGNumberList*> SVGAnimatedNumberList;
+ typedef SVGAnimatedTemplate<SVGPreserveAspectRatio*> SVGAnimatedPreserveAspectRatio;
+ typedef SVGAnimatedTemplate<FloatRect> SVGAnimatedRect;
+ typedef SVGAnimatedTemplate<String> SVGAnimatedString;
+ typedef SVGAnimatedTemplate<SVGTransformList*> SVGAnimatedTransformList;
+}
+
+#endif // ENABLE(SVG)
+#endif // SVGAnimatedTemplate_h
diff --git a/WebCore/svg/SVGAnimatedTransformList.idl b/WebCore/svg/SVGAnimatedTransformList.idl
new file mode 100644
index 0000000..280960e
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedTransformList.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimatedTransformList {
+ readonly attribute SVGTransformList baseVal;
+ readonly attribute SVGTransformList animVal;
+ };
+
+}
diff --git a/WebCore/svg/SVGAnimationElement.cpp b/WebCore/svg/SVGAnimationElement.cpp
new file mode 100644
index 0000000..3574306
--- /dev/null
+++ b/WebCore/svg/SVGAnimationElement.cpp
@@ -0,0 +1,747 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGAnimationElement.h"
+
+#include "CSSPropertyNames.h"
+#include "Document.h"
+#include "FloatConversion.h"
+#include "SVGParserUtilities.h"
+#include "SVGSVGElement.h"
+#include "SVGURIReference.h"
+#include "TimeScheduler.h"
+#include "XLinkNames.h"
+#include <float.h>
+#include <math.h>
+#include <wtf/MathExtras.h>
+#include <wtf/Vector.h>
+
+using namespace std;
+
+namespace WebCore {
+
+SVGAnimationElement::SVGAnimationElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+ , SVGTests()
+ , SVGExternalResourcesRequired()
+ , m_targetElement(0)
+ , m_connectedToTimer(false)
+ , m_currentTime(0.0)
+ , m_simpleDuration(0.0)
+ , m_fill(FILL_REMOVE)
+ , m_restart(RESTART_ALWAYS)
+ , m_calcMode(CALCMODE_LINEAR)
+ , m_additive(ADDITIVE_REPLACE)
+ , m_accumulate(ACCUMULATE_NONE)
+ , m_attributeType(ATTRIBUTETYPE_AUTO)
+ , m_max(0.0)
+ , m_min(0.0)
+ , m_end(0.0)
+ , m_begin(0.0)
+ , m_repetitions(0)
+ , m_repeatCount(0)
+{
+
+}
+
+SVGAnimationElement::~SVGAnimationElement()
+{
+}
+
+bool SVGAnimationElement::hasValidTarget() const
+{
+ return targetElement();
+}
+
+SVGElement* SVGAnimationElement::targetElement() const
+{
+ if (!m_targetElement) {
+ Node *target = 0;
+ if (!m_href.isEmpty()) {
+ target = document()->getElementById(SVGURIReference::getTarget(m_href));
+ } else if (parentNode()) {
+ // TODO : do we really need to skip non element nodes? Can that happen at all?
+ target = parentNode();
+ while (target) {
+ if (target->nodeType() != ELEMENT_NODE)
+ target = target->parentNode();
+ else
+ break;
+ }
+ }
+ if (target && target->isSVGElement())
+ m_targetElement = static_cast<SVGElement*>(target);
+ }
+
+ return m_targetElement;
+}
+
+float SVGAnimationElement::getEndTime() const
+{
+ return narrowPrecisionToFloat(m_end);
+}
+
+float SVGAnimationElement::getStartTime() const
+{
+ return narrowPrecisionToFloat(m_begin);
+}
+
+float SVGAnimationElement::getCurrentTime() const
+{
+ return narrowPrecisionToFloat(m_currentTime);
+}
+
+float SVGAnimationElement::getSimpleDuration(ExceptionCode&) const
+{
+ return narrowPrecisionToFloat(m_simpleDuration);
+}
+
+void SVGAnimationElement::parseKeyNumbers(Vector<float>& keyNumbers, const String& value)
+{
+ float number = 0.0f;
+
+ const UChar* ptr = value.characters();
+ const UChar* end = ptr + value.length();
+ skipOptionalSpaces(ptr, end);
+ while (ptr < end) {
+ if (!parseNumber(ptr, end, number, false))
+ return;
+ keyNumbers.append(number);
+
+ if (!skipOptionalSpaces(ptr, end) || *ptr != ';')
+ return;
+ ptr++;
+ skipOptionalSpaces(ptr, end);
+ }
+}
+
+static void parseKeySplines(Vector<SVGAnimationElement::KeySpline>& keySplines, const String& value)
+{
+ float number = 0.0f;
+ SVGAnimationElement::KeySpline keySpline;
+
+ const UChar* ptr = value.characters();
+ const UChar* end = ptr + value.length();
+ skipOptionalSpaces(ptr, end);
+ while (ptr < end) {
+ if (!(parseNumber(ptr, end, number, false) && skipOptionalSpaces(ptr, end)))
+ return;
+ keySpline.control1.setX(number);
+ if (!(parseNumber(ptr, end, number, false) && skipOptionalSpaces(ptr, end)))
+ return;
+ keySpline.control1.setY(number);
+ if (!(parseNumber(ptr, end, number, false) && skipOptionalSpaces(ptr, end)))
+ return;
+ keySpline.control2.setX(number);
+ if (!parseNumber(ptr, end, number, false))
+ return;
+ keySpline.control2.setY(number);
+ keySplines.append(keySpline);
+
+ if (!skipOptionalSpaces(ptr, end) || *ptr != ';')
+ return;
+ ptr++;
+ skipOptionalSpaces(ptr, end);
+ }
+}
+
+void SVGAnimationElement::parseBeginOrEndValue(double& number, const String& value)
+{
+ // TODO: Don't use SVGStringList for parsing.
+ AtomicString dummy;
+ RefPtr<SVGStringList> valueList = SVGStringList::create(QualifiedName(dummy, dummy, dummy));
+ valueList->parse(value, ';');
+
+ ExceptionCode ec = 0;
+ for (unsigned int i = 0; i < valueList->numberOfItems(); i++) {
+ String current = valueList->getItem(i, ec);
+
+ if (current.startsWith("accessKey")) {
+ // Register keyDownEventListener for the character
+ String character = current.substring(current.length() - 2, 1);
+ // FIXME: Not implemented! Supposed to register accessKey character
+ } else if (current.startsWith("wallclock")) {
+ int firstBrace = current.find('(');
+ int secondBrace = current.find(')');
+
+ String wallclockValue = current.substring(firstBrace + 1, secondBrace - firstBrace - 2);
+ // FIXME: Not implemented! Supposed to use wallClock value
+ } else if (current.contains('.')) {
+ int dotPosition = current.find('.');
+
+ String element = current.substring(0, dotPosition);
+ String clockValue;
+ if (current.contains("begin"))
+ clockValue = current.substring(dotPosition + 6);
+ else if (current.contains("end"))
+ clockValue = current.substring(dotPosition + 4);
+ else if (current.contains("repeat"))
+ clockValue = current.substring(dotPosition + 7);
+ else { // DOM2 Event Reference
+ int plusMinusPosition = -1;
+
+ if (current.contains('+'))
+ plusMinusPosition = current.find('+');
+ else if (current.contains('-'))
+ plusMinusPosition = current.find('-');
+
+ String event = current.substring(dotPosition + 1, plusMinusPosition - dotPosition - 1);
+ clockValue = current.substring(dotPosition + event.length() + 1);
+ // FIXME: supposed to use DOM Event
+ }
+ } else {
+ number = parseClockValue(current);
+ if (!isIndefinite(number))
+ number *= 1000.0;
+ // FIXME: supposed to set begin/end time
+ }
+ }
+}
+
+void SVGAnimationElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name().matches(XLinkNames::hrefAttr))
+ m_href = attr->value();
+ else if (attr->name() == SVGNames::attributeNameAttr)
+ m_attributeName = attr->value();
+ else if (attr->name() == SVGNames::attributeTypeAttr) {
+ if (attr->value() == "CSS")
+ m_attributeType = ATTRIBUTETYPE_CSS;
+ else if (attr->value() == "XML")
+ m_attributeType = ATTRIBUTETYPE_XML;
+ else if (attr->value() == "auto")
+ m_attributeType = ATTRIBUTETYPE_AUTO;
+ } else if (attr->name() == SVGNames::beginAttr)
+ parseBeginOrEndValue(m_begin, attr->value());
+ else if (attr->name() == SVGNames::endAttr)
+ parseBeginOrEndValue(m_end, attr->value());
+ else if (attr->name() == SVGNames::durAttr) {
+ m_simpleDuration = parseClockValue(attr->value());
+ if (!isIndefinite(m_simpleDuration))
+ m_simpleDuration *= 1000.0;
+ } else if (attr->name() == SVGNames::minAttr) {
+ m_min = parseClockValue(attr->value());
+ if (!isIndefinite(m_min))
+ m_min *= 1000.0;
+ } else if (attr->name() == SVGNames::maxAttr) {
+ m_max = parseClockValue(attr->value());
+ if (!isIndefinite(m_max))
+ m_max *= 1000.0;
+ } else if (attr->name() == SVGNames::restartAttr) {
+ if (attr->value() == "whenNotActive")
+ m_restart = RESTART_WHENNOTACTIVE;
+ else if (attr->value() == "never")
+ m_restart = RESTART_NEVER;
+ else if (attr->value() == "always")
+ m_restart = RESTART_ALWAYS;
+ } else if (attr->name() == SVGNames::repeatCountAttr) {
+ if (attr->value() == "indefinite")
+ m_repeatCount = DBL_MAX;
+ else
+ m_repeatCount = attr->value().toDouble();
+ } else if (attr->name() == SVGNames::repeatDurAttr)
+ m_repeatDur = attr->value();
+ else if (attr->name() == SVGNames::fillAttr) {
+ if (attr->value() == "freeze")
+ m_fill = FILL_FREEZE;
+ else if (attr->value() == "remove")
+ m_fill = FILL_REMOVE;
+ } else if (attr->name() == SVGNames::calcModeAttr) {
+ if (attr->value() == "discrete")
+ m_calcMode = CALCMODE_DISCRETE;
+ else if (attr->value() == "linear")
+ m_calcMode = CALCMODE_LINEAR;
+ else if (attr->value() == "spline")
+ m_calcMode = CALCMODE_SPLINE;
+ else if (attr->value() == "paced")
+ m_calcMode = CALCMODE_PACED;
+ } else if (attr->name() == SVGNames::valuesAttr) {
+ m_values.clear();
+ m_values = parseDelimitedString(attr->value(), ';');
+ } else if (attr->name() == SVGNames::keyTimesAttr) {
+ m_keyTimes.clear();
+ parseKeyNumbers(m_keyTimes, attr->value());
+ } else if (attr->name() == SVGNames::keySplinesAttr) {
+ m_keySplines.clear();
+ parseKeySplines(m_keySplines, attr->value());
+ } else if (attr->name() == SVGNames::fromAttr)
+ m_from = attr->value();
+ else if (attr->name() == SVGNames::toAttr)
+ m_to = attr->value();
+ else if (attr->name() == SVGNames::byAttr)
+ m_by = attr->value();
+ else if (attr->name() == SVGNames::additiveAttr) {
+ if (attr->value() == "sum")
+ m_additive = ADDITIVE_SUM;
+ else if (attr->value() == "replace")
+ m_additive = ADDITIVE_REPLACE;
+ } else if (attr->name() == SVGNames::accumulateAttr) {
+ if (attr->value() == "sum")
+ m_accumulate = ACCUMULATE_SUM;
+ else if (attr->value() == "none")
+ m_accumulate = ACCUMULATE_NONE;
+ } else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ SVGElement::parseMappedAttribute(attr);
+ }
+}
+
+double SVGAnimationElement::parseClockValue(const String& data)
+{
+ String parse = data.stripWhiteSpace();
+
+ if (parse == "indefinite")
+ return DBL_MAX;
+
+ double result;
+
+ int doublePointOne = parse.find(':');
+ int doublePointTwo = parse.find(':', doublePointOne + 1);
+
+ if (doublePointOne != -1 && doublePointTwo != -1) { // Spec: "Full clock values"
+ unsigned hours = parse.substring(0, 2).toUIntStrict();
+ unsigned minutes = parse.substring(3, 2).toUIntStrict();
+ unsigned seconds = parse.substring(6, 2).toUIntStrict();
+ unsigned milliseconds = 0;
+
+ result = (3600 * hours) + (60 * minutes) + seconds;
+
+ if (parse.find('.') != -1) {
+ String temp = parse.substring(9, 2);
+ milliseconds = temp.toUIntStrict();
+ result += (milliseconds * (1 / pow(10.0, int(temp.length()))));
+ }
+ } else if (doublePointOne != -1 && doublePointTwo == -1) { // Spec: "Partial clock values"
+ unsigned minutes = parse.substring(0, 2).toUIntStrict();
+ unsigned seconds = parse.substring(3, 2).toUIntStrict();
+ unsigned milliseconds = 0;
+
+ result = (60 * minutes) + seconds;
+
+ if (parse.find('.') != -1) {
+ String temp = parse.substring(6, 2);
+ milliseconds = temp.toUIntStrict();
+ result += (milliseconds * (1 / pow(10.0, int(temp.length()))));
+ }
+ } else { // Spec: "Timecount values"
+ int dotPosition = parse.find('.');
+
+ if (parse.endsWith("h")) {
+ if (dotPosition == -1)
+ result = parse.substring(0, parse.length() - 1).toUIntStrict() * 3600;
+ else {
+ result = parse.substring(0, dotPosition).toUIntStrict() * 3600;
+ String temp = parse.substring(dotPosition + 1, parse.length() - dotPosition - 2);
+ result += (3600.0 * temp.toUIntStrict()) * (1 / pow(10.0, int(temp.length())));
+ }
+ } else if (parse.endsWith("min")) {
+ if (dotPosition == -1)
+ result = parse.substring(0, parse.length() - 3).toUIntStrict() * 60;
+ else {
+ result = parse.substring(0, dotPosition).toUIntStrict() * 60;
+ String temp = parse.substring(dotPosition + 1, parse.length() - dotPosition - 4);
+ result += (60.0 * temp.toUIntStrict()) * (1 / pow(10.0, int(temp.length())));
+ }
+ } else if (parse.endsWith("ms")) {
+ if (dotPosition == -1)
+ result = parse.substring(0, parse.length() - 2).toUIntStrict() / 1000.0;
+ else {
+ result = parse.substring(0, dotPosition).toUIntStrict() / 1000.0;
+ String temp = parse.substring(dotPosition + 1, parse.length() - dotPosition - 3);
+ result += (temp.toUIntStrict() / 1000.0) * (1 / pow(10.0, int(temp.length())));
+ }
+ } else if (parse.endsWith("s")) {
+ if (dotPosition == -1)
+ result = parse.substring(0, parse.length() - 1).toUIntStrict();
+ else {
+ result = parse.substring(0, dotPosition).toUIntStrict();
+ String temp = parse.substring(dotPosition + 1, parse.length() - dotPosition - 2);
+ result += temp.toUIntStrict() * (1 / pow(10.0, int(temp.length())));
+ }
+ } else
+ result = parse.toDouble();
+ }
+
+ return result;
+}
+
+void SVGAnimationElement::finishParsingChildren()
+{
+ if (ownerSVGElement())
+ ownerSVGElement()->timeScheduler()->addTimer(this, lround(getStartTime()));
+ SVGElement::finishParsingChildren();
+}
+
+String SVGAnimationElement::targetAttributeAnimatedValue() const
+{
+ // FIXME: This method is not entirely correct
+ // It does not properly grab the true "animVal" instead grabs the baseVal (or something very close)
+
+ if (!targetElement())
+ return String();
+
+ SVGElement* target = targetElement();
+ SVGStyledElement* styled = 0;
+ if (target && target->isStyled())
+ styled = static_cast<SVGStyledElement*>(target);
+
+ String ret;
+
+ EAttributeType attributeType = static_cast<EAttributeType>(m_attributeType);
+ if (attributeType == ATTRIBUTETYPE_AUTO) {
+ attributeType = ATTRIBUTETYPE_XML;
+
+ // Spec: The implementation should match the attributeName to an attribute
+ // for the target element. The implementation must first search through the
+ // list of CSS properties for a matching property name, and if none is found,
+ // search the default XML namespace for the element.
+ if (styled && styled->style()) {
+ if (styled->style()->getPropertyCSSValue(m_attributeName))
+ attributeType = ATTRIBUTETYPE_CSS;
+ }
+ }
+
+ if (attributeType == ATTRIBUTETYPE_CSS) {
+ if (styled && styled->style())
+ ret = styled->style()->getPropertyValue(m_attributeName);
+ }
+
+ if (attributeType == ATTRIBUTETYPE_XML || ret.isEmpty())
+ ret = targetElement()->getAttribute(m_attributeName);
+
+ return ret;
+}
+
+void SVGAnimationElement::setTargetAttributeAnimatedValue(const String& value)
+{
+ // FIXME: This method is not entirely correct
+ // It does not properly set the "animVal", rather it sets the "baseVal"
+ SVGAnimationElement::setTargetAttribute(targetElement(), m_attributeName, value, static_cast<EAttributeType>(m_attributeType));
+}
+
+void SVGAnimationElement::setTargetAttribute(SVGElement* target, const String& name, const String& value, EAttributeType type)
+{
+ if (!target || name.isNull() || value.isNull())
+ return;
+
+ SVGStyledElement* styled = (target && target->isStyled()) ? static_cast<SVGStyledElement*>(target) : 0;
+
+ EAttributeType attributeType = type;
+ if (type == ATTRIBUTETYPE_AUTO) {
+ // Spec: The implementation should match the attributeName to an attribute
+ // for the target element. The implementation must first search through the
+ // list of CSS properties for a matching property name, and if none is found,
+ // search the default XML namespace for the element.
+ if (styled && styled->style() && styled->style()->getPropertyCSSValue(name))
+ attributeType = ATTRIBUTETYPE_CSS;
+ else
+ attributeType = ATTRIBUTETYPE_XML;
+ }
+ ExceptionCode ec = 0;
+ if (attributeType == ATTRIBUTETYPE_CSS && styled && styled->style())
+ styled->style()->setProperty(name, value, "", ec);
+ else if (attributeType == ATTRIBUTETYPE_XML)
+ target->setAttribute(name, value, ec);
+}
+
+String SVGAnimationElement::attributeName() const
+{
+ return m_attributeName;
+}
+
+bool SVGAnimationElement::connectedToTimer() const
+{
+ return m_connectedToTimer;
+}
+
+bool SVGAnimationElement::isFrozen() const
+{
+ return (m_fill == FILL_FREEZE);
+}
+
+bool SVGAnimationElement::isAdditive() const
+{
+ return (m_additive == ADDITIVE_SUM) || (detectAnimationMode() == BY_ANIMATION);
+}
+
+bool SVGAnimationElement::isAccumulated() const
+{
+ return (m_accumulate == ACCUMULATE_SUM) && (detectAnimationMode() != TO_ANIMATION);
+}
+
+EAnimationMode SVGAnimationElement::detectAnimationMode() const
+{
+ if (hasAttribute(SVGNames::valuesAttr))
+ return VALUES_ANIMATION;
+ else if ((!m_from.isEmpty() && !m_to.isEmpty()) || (!m_to.isEmpty())) { // to/from-to animation
+ if (!m_from.isEmpty()) // from-to animation
+ return FROM_TO_ANIMATION;
+ else
+ return TO_ANIMATION;
+ } else if ((m_from.isEmpty() && m_to.isEmpty() && !m_by.isEmpty()) ||
+ (!m_from.isEmpty() && !m_by.isEmpty())) { // by/from-by animation
+ if (!m_from.isEmpty()) // from-by animation
+ return FROM_BY_ANIMATION;
+ else
+ return BY_ANIMATION;
+ }
+
+ return NO_ANIMATION;
+}
+
+double SVGAnimationElement::repeations() const
+{
+ return m_repetitions;
+}
+
+bool SVGAnimationElement::isIndefinite(double value)
+{
+ return (value == DBL_MAX);
+}
+
+void SVGAnimationElement::connectTimer()
+{
+ ASSERT(!m_connectedToTimer);
+ ownerSVGElement()->timeScheduler()->connectIntervalTimer(this);
+ m_connectedToTimer = true;
+}
+
+void SVGAnimationElement::disconnectTimer()
+{
+ ASSERT(m_connectedToTimer);
+ ownerSVGElement()->timeScheduler()->disconnectIntervalTimer(this);
+ m_connectedToTimer = false;
+}
+
+static double calculateTimePercentage(double elapsedSeconds, double start, double end, double duration, double repetitions)
+{
+ double percentage = 0.0;
+ double useElapsed = elapsedSeconds - (duration * repetitions);
+
+ if (duration > 0.0 && end == 0.0)
+ percentage = 1.0 - (((start + duration) - useElapsed) / duration);
+ else if (duration > 0.0 && end != 0.0) {
+ if (duration > end)
+ percentage = 1.0 - (((start + end) - useElapsed) / end);
+ else
+ percentage = 1.0 - (((start + duration) - useElapsed) / duration);
+ } else if (duration == 0.0 && end != 0.0)
+ percentage = 1.0 - (((start + end) - useElapsed) / end);
+
+ return percentage;
+}
+
+static inline void adjustPercentagePastForKeySplines(const Vector<SVGAnimationElement::KeySpline>& keySplines, unsigned valueIndex, float& percentagePast)
+{
+ if (percentagePast == 0.0f) // values at key times need no spline adjustment
+ return;
+ const SVGAnimationElement::KeySpline& keySpline = keySplines[valueIndex];
+ Path path;
+ path.moveTo(FloatPoint());
+ path.addBezierCurveTo(keySpline.control1, keySpline.control2, FloatPoint(1.0f, 1.0f));
+ // FIXME: This needs to use a y-at-x function on path, to compute the y value then multiply percentagePast by that value
+}
+
+void SVGAnimationElement::valueIndexAndPercentagePastForDistance(float distancePercentage, unsigned& valueIndex, float& percentagePast)
+{
+ // Unspecified: animation elements which do not support CALCMODE_PACED, we just always show the first value
+ valueIndex = 0;
+ percentagePast = 0;
+}
+
+float SVGAnimationElement::calculateTotalDistance()
+{
+ return 0;
+}
+
+static inline void caculateValueIndexForKeyTimes(float timePercentage, const Vector<float>& keyTimes, unsigned& valueIndex, float& lastKeyTime, float& nextKeyTime)
+{
+ unsigned keyTimesCountMinusOne = keyTimes.size() - 1;
+ valueIndex = 0;
+ ASSERT(timePercentage >= keyTimes.first());
+ while ((valueIndex < keyTimesCountMinusOne) && (timePercentage >= keyTimes[valueIndex + 1]))
+ valueIndex++;
+
+ lastKeyTime = keyTimes[valueIndex];
+ if (valueIndex < keyTimesCountMinusOne)
+ nextKeyTime = keyTimes[valueIndex + 1];
+ else
+ nextKeyTime = lastKeyTime;
+}
+
+bool SVGAnimationElement::isValidAnimation() const
+{
+ EAnimationMode animationMode = detectAnimationMode();
+ if (!hasValidTarget() || (animationMode == NO_ANIMATION))
+ return false;
+ if (animationMode == VALUES_ANIMATION) {
+ if (!m_values.size())
+ return false;
+ if (m_keyTimes.size()) {
+ if ((m_values.size() != m_keyTimes.size()) || (m_keyTimes.first() != 0))
+ return false;
+ if (((m_calcMode == CALCMODE_SPLINE) || (m_calcMode == CALCMODE_LINEAR)) && (m_keyTimes.last() != 1))
+ return false;
+ float lastKeyTime = 0;
+ for (unsigned x = 0; x < m_keyTimes.size(); x++) {
+ if (m_keyTimes[x] < lastKeyTime || m_keyTimes[x] > 1)
+ return false;
+ }
+ }
+ if (m_keySplines.size()) {
+ if ((m_values.size() - 1) != m_keySplines.size())
+ return false;
+ for (unsigned x = 0; x < m_keyTimes.size(); x++)
+ if (m_keyTimes[x] < 0 || m_keyTimes[x] > 1)
+ return false;
+ }
+ }
+ return true;
+}
+
+void SVGAnimationElement::calculateValueIndexAndPercentagePast(float timePercentage, unsigned& valueIndex, float& percentagePast)
+{
+ ASSERT(timePercentage <= 1.0f);
+ ASSERT(isValidAnimation());
+ EAnimationMode animationMode = detectAnimationMode();
+
+ // to-animations have their own special handling
+ if (animationMode == TO_ANIMATION)
+ return;
+
+ // paced is special, caculates values based on distance instead of time
+ if (m_calcMode == CALCMODE_PACED) {
+ float totalDistance = calculateTotalDistance();
+ float distancePercentage = totalDistance * timePercentage;
+ valueIndexAndPercentagePastForDistance(distancePercentage, valueIndex, percentagePast);
+ return;
+ }
+
+ // Figure out what our current index is based on on time
+ // all further calculations are based on time percentages, to allow unifying keyTimes handling & normal animation
+ float lastKeyTimePercentage = 0;
+ float nextKeyTimePercentage = 0;
+ if (m_keyTimes.size() && (m_keyTimes.size() == m_values.size()))
+ caculateValueIndexForKeyTimes(timePercentage, m_keyTimes, valueIndex, lastKeyTimePercentage, nextKeyTimePercentage);
+ else {
+ unsigned lastPossibleIndex = (m_values.size() ? m_values.size() - 1: 1);
+ unsigned flooredValueIndex = static_cast<unsigned>(timePercentage * lastPossibleIndex);
+ valueIndex = flooredValueIndex;
+ lastKeyTimePercentage = flooredValueIndex / (float)lastPossibleIndex;
+ nextKeyTimePercentage = (flooredValueIndex + 1) / (float)lastPossibleIndex;
+ }
+
+ // No further caculation is needed if we're exactly on an index.
+ if (timePercentage == lastKeyTimePercentage || lastKeyTimePercentage == nextKeyTimePercentage) {
+ percentagePast = 0.0f;
+ return;
+ }
+
+ // otherwise we decide what percent after that index
+ if ((m_calcMode == CALCMODE_SPLINE) && (m_keySplines.size() == (m_values.size() - 1)))
+ adjustPercentagePastForKeySplines(m_keySplines, valueIndex, percentagePast);
+ else if (m_calcMode == CALCMODE_DISCRETE)
+ percentagePast = 0.0f;
+ else { // default (and fallback) mode: linear
+ float keyTimeSpan = nextKeyTimePercentage - lastKeyTimePercentage;
+ float timeSinceLastKeyTime = timePercentage - lastKeyTimePercentage;
+ percentagePast = (timeSinceLastKeyTime / keyTimeSpan);
+ }
+}
+
+bool SVGAnimationElement::updateAnimationBaseValueFromElement()
+{
+ m_baseValue = targetAttributeAnimatedValue();
+ return true;
+}
+
+void SVGAnimationElement::applyAnimatedValueToElement()
+{
+ setTargetAttributeAnimatedValue(m_animatedValue);
+}
+
+void SVGAnimationElement::handleTimerEvent(double elapsedSeconds, double timePercentage)
+{
+ timePercentage = min(timePercentage, 1.0);
+ if (!connectedToTimer()) {
+ connectTimer();
+ return;
+ }
+
+ // FIXME: accumulate="sum" will not work w/o code similar to this:
+// if (isAccumulated() && repeations() != 0.0)
+// accumulateForRepetitions(m_repetitions);
+
+ EAnimationMode animationMode = detectAnimationMode();
+
+ unsigned valueIndex = 0;
+ float percentagePast = 0;
+ calculateValueIndexAndPercentagePast(narrowPrecisionToFloat(timePercentage), valueIndex, percentagePast);
+
+ calculateFromAndToValues(animationMode, valueIndex);
+
+ updateAnimatedValue(animationMode, narrowPrecisionToFloat(timePercentage), valueIndex, percentagePast);
+
+ if (timePercentage == 1.0) {
+ if ((m_repeatCount > 0 && m_repetitions < m_repeatCount - 1) || isIndefinite(m_repeatCount)) {
+ m_repetitions++;
+ return;
+ } else
+ disconnectTimer();
+ }
+}
+
+bool SVGAnimationElement::updateAnimatedValueForElapsedSeconds(double elapsedSeconds)
+{
+ // FIXME: fill="freeze" will not work without saving off the m_stoppedTime in a stop() method and having code similar to this:
+// if (isStopped()) {
+// if (m_fill == FILL_FREEZE)
+// elapsedSeconds = m_stoppedTime;
+// else
+// return false;
+// }
+
+ // Validate animation timing settings:
+ // #1 (duration > 0) -> fine
+ // #2 (duration <= 0.0 && end > 0) -> fine
+ if ((m_simpleDuration <= 0.0 && m_end <= 0.0) || (isIndefinite(m_simpleDuration) && m_end <= 0.0))
+ return false; // Ignore dur="0" or dur="-neg"
+
+ double percentage = calculateTimePercentage(elapsedSeconds, m_begin, m_end, m_simpleDuration, m_repetitions);
+
+ if (percentage <= 1.0 || connectedToTimer())
+ handleTimerEvent(elapsedSeconds, percentage);
+
+ return true; // value was updated, need to apply
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGAnimationElement.h b/WebCore/svg/SVGAnimationElement.h
new file mode 100644
index 0000000..23d1e88
--- /dev/null
+++ b/WebCore/svg/SVGAnimationElement.h
@@ -0,0 +1,193 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGAnimationElement_h
+#define SVGAnimationElement_h
+#if ENABLE(SVG)
+
+#include "SVGExternalResourcesRequired.h"
+#include "SVGStringList.h"
+#include "SVGTests.h"
+
+namespace WebCore {
+
+ enum EFillMode {
+ FILL_REMOVE = 0,
+ FILL_FREEZE
+ };
+
+ enum EAdditiveMode {
+ ADDITIVE_REPLACE = 0,
+ ADDITIVE_SUM
+ };
+
+ enum EAccumulateMode {
+ ACCUMULATE_NONE = 0,
+ ACCUMULATE_SUM
+ };
+
+ enum ECalcMode {
+ CALCMODE_DISCRETE = 0,
+ CALCMODE_LINEAR,
+ CALCMODE_PACED,
+ CALCMODE_SPLINE
+ };
+
+ enum ERestart {
+ RESTART_ALWAYS = 0,
+ RESTART_WHENNOTACTIVE,
+ RESTART_NEVER
+ };
+
+ enum EAttributeType {
+ ATTRIBUTETYPE_CSS = 0,
+ ATTRIBUTETYPE_XML,
+ ATTRIBUTETYPE_AUTO
+ };
+
+ // internal
+ enum EAnimationMode {
+ NO_ANIMATION = 0,
+ TO_ANIMATION,
+ BY_ANIMATION,
+ VALUES_ANIMATION,
+ FROM_TO_ANIMATION,
+ FROM_BY_ANIMATION
+ };
+
+ class SVGAnimationElement : public SVGElement,
+ public SVGTests,
+ public SVGExternalResourcesRequired
+ {
+ public:
+ SVGAnimationElement(const QualifiedName&, Document*);
+ virtual ~SVGAnimationElement();
+
+ // 'SVGAnimationElement' functions
+ SVGElement* targetElement() const;
+
+ virtual bool hasValidTarget() const;
+ bool isValidAnimation() const;
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ float getEndTime() const;
+ float getStartTime() const;
+ float getCurrentTime() const;
+ float getSimpleDuration(ExceptionCode&) const;
+
+ virtual void parseMappedAttribute(MappedAttribute* attr);
+
+ virtual void finishParsingChildren();
+
+ virtual bool updateAnimationBaseValueFromElement();
+ bool updateAnimatedValueForElapsedSeconds(double elapsedSeconds);
+ virtual void applyAnimatedValueToElement();
+
+ String attributeName() const;
+
+ bool connectedToTimer() const;
+
+ bool isFrozen() const;
+ bool isAdditive() const;
+ bool isAccumulated() const;
+
+ double repeations() const;
+ static bool isIndefinite(double value);
+
+ protected:
+ mutable SVGElement* m_targetElement;
+
+ EAnimationMode detectAnimationMode() const;
+
+ static double parseClockValue(const String&);
+ static void setTargetAttribute(SVGElement* target, const String& name, const String& value, EAttributeType = ATTRIBUTETYPE_AUTO);
+
+ String targetAttributeAnimatedValue() const;
+ void setTargetAttributeAnimatedValue(const String&);
+
+ void connectTimer();
+ void disconnectTimer();
+
+ virtual float calculateTotalDistance();
+ virtual void valueIndexAndPercentagePastForDistance(float distancePercentage, unsigned& valueIndex, float& percentagePast);
+
+ void calculateValueIndexAndPercentagePast(float timePercentage, unsigned& valueIndex, float& percentagePast);
+
+ void handleTimerEvent(double elapsedSeconds, double timePercentage);
+
+ virtual bool updateAnimatedValue(EAnimationMode, float timePercentage, unsigned valueIndex, float percentagePast) = 0;
+ virtual bool calculateFromAndToValues(EAnimationMode, unsigned valueIndex) = 0;
+
+ static void parseKeyNumbers(Vector<float>& keyNumbers, const String& value);
+ static void parseBeginOrEndValue(double& number, const String& value);
+
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ bool m_connectedToTimer : 1;
+
+ double m_currentTime;
+ double m_simpleDuration;
+
+ // Shared animation properties
+ unsigned m_fill : 1; // EFillMode m_fill
+ unsigned m_restart : 2; // ERestart
+ unsigned m_calcMode : 2; // ECalcMode
+ unsigned m_additive : 1; // EAdditiveMode
+ unsigned m_accumulate : 1; // EAccumulateMode
+ unsigned m_attributeType : 2; // EAttributeType
+
+ String m_to;
+ String m_by;
+ String m_from;
+ String m_href;
+ String m_repeatDur;
+ String m_attributeName;
+
+ String m_baseValue;
+ String m_animatedValue;
+
+ double m_max;
+ double m_min;
+ double m_end;
+ double m_begin;
+
+ double m_repetitions;
+ double m_repeatCount;
+
+ Vector<String> m_values;
+ Vector<float> m_keyTimes;
+
+ struct KeySpline {
+ FloatPoint control1;
+ FloatPoint control2;
+ };
+ Vector<KeySpline> m_keySplines;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGAnimationElement_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGAnimationElement.idl b/WebCore/svg/SVGAnimationElement.idl
new file mode 100644
index 0000000..6a9e94f
--- /dev/null
+++ b/WebCore/svg/SVGAnimationElement.idl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGAnimationElement : SVGElement,
+ SVGTests,
+ SVGExternalResourcesRequired {
+ readonly attribute SVGElement targetElement;
+
+ float getStartTime();
+ float getCurrentTime();
+ float getSimpleDuration()
+ raises(DOMException);
+ };
+
+}
diff --git a/WebCore/svg/SVGCircleElement.cpp b/WebCore/svg/SVGCircleElement.cpp
new file mode 100644
index 0000000..9d82960
--- /dev/null
+++ b/WebCore/svg/SVGCircleElement.cpp
@@ -0,0 +1,102 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGCircleElement.h"
+
+#include "FloatPoint.h"
+#include "RenderPath.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+SVGCircleElement::SVGCircleElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_cx(SVGLength(this, LengthModeWidth))
+ , m_cy(SVGLength(this, LengthModeHeight))
+ , m_r(SVGLength(this, LengthModeOther))
+{
+}
+
+SVGCircleElement::~SVGCircleElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGCircleElement, SVGLength, Length, length, Cx, cx, SVGNames::cxAttr, m_cx)
+ANIMATED_PROPERTY_DEFINITIONS(SVGCircleElement, SVGLength, Length, length, Cy, cy, SVGNames::cyAttr, m_cy)
+ANIMATED_PROPERTY_DEFINITIONS(SVGCircleElement, SVGLength, Length, length, R, r, SVGNames::rAttr, m_r)
+
+void SVGCircleElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::cxAttr)
+ setCxBaseValue(SVGLength(this, LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::cyAttr)
+ setCyBaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::rAttr) {
+ setRBaseValue(SVGLength(this, LengthModeOther, attr->value()));
+ if (r().value() < 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 SVGCircleElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledTransformableElement::svgAttributeChanged(attrName);
+
+ if (!renderer())
+ return;
+
+ if (attrName == SVGNames::cxAttr || attrName == SVGNames::cyAttr ||
+ attrName == SVGNames::rAttr ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledTransformableElement::isKnownAttribute(attrName))
+ renderer()->setNeedsLayout(true);
+}
+
+Path SVGCircleElement::toPathData() const
+{
+ return Path::createCircle(FloatPoint(cx().value(), cy().value()), r().value());
+}
+
+bool SVGCircleElement::hasRelativeValues() const
+{
+ return (cx().isRelative() || cy().isRelative() || r().isRelative());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGCircleElement.h b/WebCore/svg/SVGCircleElement.h
new file mode 100644
index 0000000..2e0e8c8
--- /dev/null
+++ b/WebCore/svg/SVGCircleElement.h
@@ -0,0 +1,64 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGCircleElement_h
+#define SVGCircleElement_h
+
+#if ENABLE(SVG)
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTests.h"
+
+namespace WebCore {
+
+ class SVGCircleElement : public SVGStyledTransformableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired {
+ public:
+ SVGCircleElement(const QualifiedName&, Document*);
+ virtual ~SVGCircleElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ virtual Path toPathData() const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+ virtual bool hasRelativeValues() const;
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGCircleElement, SVGLength, SVGLength, Cx, cx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGCircleElement, SVGLength, SVGLength, Cy, cy)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGCircleElement, SVGLength, SVGLength, R, r)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGCircleElement_h
diff --git a/WebCore/svg/SVGCircleElement.idl b/WebCore/svg/SVGCircleElement.idl
new file mode 100644
index 0000000..a6cb2b2
--- /dev/null
+++ b/WebCore/svg/SVGCircleElement.idl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGCircleElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable {
+ readonly attribute SVGAnimatedLength cx;
+ readonly attribute SVGAnimatedLength cy;
+ readonly attribute SVGAnimatedLength r;
+ };
+
+}
diff --git a/WebCore/svg/SVGClipPathElement.cpp b/WebCore/svg/SVGClipPathElement.cpp
new file mode 100644
index 0000000..0e8ddbf
--- /dev/null
+++ b/WebCore/svg/SVGClipPathElement.cpp
@@ -0,0 +1,127 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGClipPathElement.h"
+
+#include "CSSStyleSelector.h"
+#include "Document.h"
+#include "SVGNames.h"
+#include "SVGTransformList.h"
+#include "SVGUnitTypes.h"
+
+namespace WebCore {
+
+SVGClipPathElement::SVGClipPathElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_clipPathUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
+{
+}
+
+SVGClipPathElement::~SVGClipPathElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGClipPathElement, int, Enumeration, enumeration, ClipPathUnits, clipPathUnits, SVGNames::clipPathUnitsAttr, m_clipPathUnits)
+
+void SVGClipPathElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::clipPathUnitsAttr) {
+ if (attr->value() == "userSpaceOnUse")
+ setClipPathUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE);
+ else if (attr->value() == "objectBoundingBox")
+ setClipPathUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
+ } else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ SVGStyledTransformableElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGClipPathElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledTransformableElement::svgAttributeChanged(attrName);
+
+ if (!m_clipper)
+ return;
+
+ if (attrName == SVGNames::clipPathUnitsAttr ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledTransformableElement::isKnownAttribute(attrName))
+ m_clipper->invalidate();
+}
+
+void SVGClipPathElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGStyledTransformableElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+
+ if (!m_clipper)
+ return;
+
+ m_clipper->invalidate();
+}
+
+SVGResource* SVGClipPathElement::canvasResource()
+{
+ if (!m_clipper)
+ m_clipper = SVGResourceClipper::create();
+ else
+ m_clipper->resetClipData();
+
+ bool bbox = clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX;
+
+ RenderStyle* clipPathStyle = styleForRenderer(parent()->renderer()); // FIXME: Manual style resolution is a hack
+ for (Node* n = firstChild(); n; n = n->nextSibling()) {
+ if (n->isSVGElement() && static_cast<SVGElement*>(n)->isStyledTransformable()) {
+ SVGStyledTransformableElement* styled = static_cast<SVGStyledTransformableElement*>(n);
+ RenderStyle* pathStyle = document()->styleSelector()->styleForElement(styled, clipPathStyle);
+ Path pathData = styled->toClipPath();
+ // FIXME: How do we know the element has done a layout?
+ pathData.transform(styled->animatedLocalTransform());
+ if (!pathData.isEmpty())
+ m_clipper->addClipData(pathData, pathStyle->svgStyle()->clipRule(), bbox);
+ pathStyle->deref(document()->renderArena());
+ }
+ }
+ if (m_clipper->clipData().isEmpty()) {
+ Path pathData;
+ pathData.addRect(FloatRect());
+ m_clipper->addClipData(pathData, RULE_EVENODD, bbox);
+ }
+ clipPathStyle->deref(document()->renderArena());
+ return m_clipper.get();
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGClipPathElement.h b/WebCore/svg/SVGClipPathElement.h
new file mode 100644
index 0000000..845aea6
--- /dev/null
+++ b/WebCore/svg/SVGClipPathElement.h
@@ -0,0 +1,67 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGClipPathElement_h
+#define SVGClipPathElement_h
+
+#if ENABLE(SVG)
+#include "SVGResourceClipper.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTests.h"
+
+namespace WebCore {
+
+ class SVGClipPathElement : public SVGStyledTransformableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired
+ {
+ public:
+ SVGClipPathElement(const QualifiedName&, Document*);
+ virtual ~SVGClipPathElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+
+ virtual SVGResource* canvasResource();
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGClipPathElement, int, int, ClipPathUnits, clipPathUnits)
+
+ RefPtr<SVGResourceClipper> m_clipper;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGClipPathElement.idl b/WebCore/svg/SVGClipPathElement.idl
new file mode 100644
index 0000000..40eca87
--- /dev/null
+++ b/WebCore/svg/SVGClipPathElement.idl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGClipPathElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable
+ /* SVGUnitTypes */ {
+ readonly attribute SVGAnimatedEnumeration clipPathUnits;
+ };
+
+}
diff --git a/WebCore/svg/SVGColor.cpp b/WebCore/svg/SVGColor.cpp
new file mode 100644
index 0000000..12e9739
--- /dev/null
+++ b/WebCore/svg/SVGColor.cpp
@@ -0,0 +1,123 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGColor.h"
+
+#include "CSSParser.h"
+#include "SVGException.h"
+
+namespace WebCore {
+
+SVGColor::SVGColor()
+ : CSSValue()
+ , m_colorType(SVG_COLORTYPE_UNKNOWN)
+{
+}
+
+SVGColor::SVGColor(const String& rgbColor)
+ : CSSValue()
+ , m_colorType(SVG_COLORTYPE_RGBCOLOR)
+{
+ setRGBColor(rgbColor);
+}
+
+SVGColor::SVGColor(unsigned short colorType)
+ : CSSValue()
+ , m_colorType(colorType)
+{
+}
+
+SVGColor::SVGColor(const Color& c)
+ : CSSValue()
+ , m_color(c)
+ , m_colorType(SVG_COLORTYPE_RGBCOLOR)
+{
+}
+
+
+SVGColor::~SVGColor()
+{
+}
+
+unsigned short SVGColor::colorType() const
+{
+ return m_colorType;
+}
+
+unsigned SVGColor::rgbColor() const
+{
+ return m_color.rgb();
+}
+
+void SVGColor::setRGBColor(const String& rgbColor, ExceptionCode& ec)
+{
+ Color color = SVGColor::colorFromRGBColorString(rgbColor);
+ if (color.isValid())
+ m_color = color;
+ else
+ ec = SVGException::SVG_INVALID_VALUE_ERR;
+}
+
+Color SVGColor::colorFromRGBColorString(const String& colorString)
+{
+ String s = colorString.stripWhiteSpace();
+ // hsl, hsla and rgba are not in the SVG spec.
+ // FIXME: rework css parser so it is more svg aware
+ if (s.startsWith("hsl") || s.startsWith("rgba"))
+ return Color();
+ RGBA32 color;
+ if (CSSParser::parseColor(color, s))
+ return color;
+ return Color();
+}
+
+void SVGColor::setRGBColorICCColor(const String& /* rgbColor */, const String& /* iccColor */, ExceptionCode& ec)
+{
+ // TODO: implement me!
+}
+
+void SVGColor::setColor(unsigned short colorType, const String& /* rgbColor */ , const String& /* iccColor */, ExceptionCode& ec)
+{
+ // TODO: implement me!
+ m_colorType = colorType;
+}
+
+String SVGColor::cssText() const
+{
+ if (m_colorType == SVG_COLORTYPE_RGBCOLOR)
+ return m_color.name();
+
+ return String();
+}
+
+const Color& SVGColor::color() const
+{
+ return m_color;
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGColor.h b/WebCore/svg/SVGColor.h
new file mode 100644
index 0000000..213b2bc
--- /dev/null
+++ b/WebCore/svg/SVGColor.h
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGColor_h
+#define SVGColor_h
+#if ENABLE(SVG)
+
+#include "CSSValue.h"
+#include "Color.h"
+#include "PlatformString.h"
+
+namespace WebCore {
+
+ typedef int ExceptionCode;
+
+ class SVGColor : public CSSValue {
+ public:
+ SVGColor();
+ SVGColor(const String& rgbColor);
+ SVGColor(const Color& c);
+ SVGColor(unsigned short colorType);
+ virtual ~SVGColor();
+
+ enum SVGColorType {
+ SVG_COLORTYPE_UNKNOWN = 0,
+ SVG_COLORTYPE_RGBCOLOR = 1,
+ SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2,
+ SVG_COLORTYPE_CURRENTCOLOR = 3
+ };
+
+ // 'SVGColor' functions
+ unsigned short colorType() const;
+
+ unsigned rgbColor() const;
+
+ static Color colorFromRGBColorString(const String&);
+
+ void setRGBColor(const String& rgbColor) { ExceptionCode ignored = 0; setRGBColor(rgbColor, ignored); }
+ void setRGBColor(const String& rgbColor, ExceptionCode&);
+ void setRGBColorICCColor(const String& rgbColor, const String& iccColor, ExceptionCode&);
+ void setColor(unsigned short colorType, const String& rgbColor, const String& iccColor, ExceptionCode&);
+
+ virtual String cssText() const;
+
+ // Helpers
+ const Color& color() const;
+
+ virtual bool isSVGColor() const { return true; }
+
+ private:
+ Color m_color;
+ unsigned short m_colorType;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGColor_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGColor.idl b/WebCore/svg/SVGColor.idl
new file mode 100644
index 0000000..320a9b7
--- /dev/null
+++ b/WebCore/svg/SVGColor.idl
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor] SVGColor : css::CSSValue {
+ // Color Types
+ const unsigned short SVG_COLORTYPE_UNKNOWN = 0;
+ const unsigned short SVG_COLORTYPE_RGBCOLOR = 1;
+ const unsigned short SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2;
+ const unsigned short SVG_COLORTYPE_CURRENTCOLOR = 3;
+
+ readonly attribute unsigned short colorType;
+ readonly attribute css::RGBColor rgbColor;
+ /*readonly attribute SVGICCColor iccColor;*/
+
+ void setRGBColor(in core::DOMString rgbColor)
+ raises(SVGException);
+ void setRGBColorICCColor(in core::DOMString rgbColor,
+ in core::DOMString iccColor)
+ raises(SVGException);
+ void setColor(in unsigned short colorType,
+ in core::DOMString rgbColor,
+ in core::DOMString iccColor)
+ raises(SVGException);
+ };
+
+}
diff --git a/WebCore/svg/SVGComponentTransferFunctionElement.cpp b/WebCore/svg/SVGComponentTransferFunctionElement.cpp
new file mode 100644
index 0000000..07b348d
--- /dev/null
+++ b/WebCore/svg/SVGComponentTransferFunctionElement.cpp
@@ -0,0 +1,112 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGComponentTransferFunctionElement.h"
+
+#include "SVGFEComponentTransferElement.h"
+#include "SVGNames.h"
+#include "SVGNumberList.h"
+
+namespace WebCore {
+
+SVGComponentTransferFunctionElement::SVGComponentTransferFunctionElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+ , m_type(SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN)
+ , m_tableValues(new SVGNumberList)
+ , m_slope(1.0f)
+ , m_intercept(0.0f)
+ , m_amplitude(1.0f)
+ , m_exponent(1.0f)
+ , m_offset(0.0f)
+{
+}
+
+SVGComponentTransferFunctionElement::~SVGComponentTransferFunctionElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, int, Enumeration, enumeration, Type, type, SVGNames::typeAttr, m_type)
+ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, SVGNumberList*, NumberList, numberList, TableValues, tableValues, SVGNames::tableValuesAttr, m_tableValues.get())
+ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, float, Number, number, Slope, slope, SVGNames::slopeAttr, m_slope)
+ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, float, Number, number, Intercept, intercept, SVGNames::interceptAttr, m_intercept)
+ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, float, Number, number, Amplitude, amplitude, SVGNames::amplitudeAttr, m_amplitude)
+ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, float, Number, number, Exponent, exponent, SVGNames::exponentAttr, m_exponent)
+ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, float, Number, number, Offset, offset, SVGNames::offsetAttr, m_offset)
+
+void SVGComponentTransferFunctionElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::typeAttr)
+ {
+ if (value == "identity")
+ setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY);
+ else if (value == "table")
+ setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_TABLE);
+ else if (value == "discrete")
+ setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE);
+ else if (value == "linear")
+ setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_LINEAR);
+ else if (value == "gamma")
+ setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_GAMMA);
+ }
+ else if (attr->name() == SVGNames::tableValuesAttr)
+ tableValuesBaseValue()->parse(value);
+ else if (attr->name() == SVGNames::slopeAttr)
+ setSlopeBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::interceptAttr)
+ setInterceptBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::amplitudeAttr)
+ setAmplitudeBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::exponentAttr)
+ setExponentBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::offsetAttr)
+ setOffsetBaseValue(value.toFloat());
+ else
+ SVGElement::parseMappedAttribute(attr);
+}
+
+SVGComponentTransferFunction SVGComponentTransferFunctionElement::transferFunction() const
+{
+ SVGComponentTransferFunction func;
+ func.type = (SVGComponentTransferType) type();
+ func.slope = slope();
+ func.intercept = intercept();
+ func.amplitude = amplitude();
+ func.exponent = exponent();
+ func.offset = offset();
+ SVGNumberList* numbers = tableValues();
+
+ ExceptionCode ec = 0;
+ unsigned int nr = numbers->numberOfItems();
+ for (unsigned int i = 0; i < nr; i++)
+ func.tableValues.append(numbers->getItem(i, ec));
+ return func;
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGComponentTransferFunctionElement.h b/WebCore/svg/SVGComponentTransferFunctionElement.h
new file mode 100644
index 0000000..eadff18
--- /dev/null
+++ b/WebCore/svg/SVGComponentTransferFunctionElement.h
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGComponentTransferFunctionElement_h
+#define SVGComponentTransferFunctionElement_h
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#include "SVGElement.h"
+#include "SVGFEComponentTransfer.h"
+
+namespace WebCore
+{
+ class SVGNumberList;
+
+ class SVGComponentTransferFunctionElement : public SVGElement
+ {
+ public:
+ SVGComponentTransferFunctionElement(const QualifiedName&, Document*);
+ virtual ~SVGComponentTransferFunctionElement();
+
+ // 'SVGComponentTransferFunctionElement' functions
+ // Derived from: 'Element'
+ virtual void parseMappedAttribute(MappedAttribute* attr);
+
+ SVGComponentTransferFunction transferFunction() const;
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, int, int, Type, type)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, SVGNumberList*, RefPtr<SVGNumberList>, TableValues, tableValues)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, float, float, Slope, slope)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, float, float, Intercept, intercept)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, float, float, Amplitude, amplitude)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, float, float, Exponent, exponent)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, float, float, Offset, offset)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGComponentTransferFunctionElement.idl b/WebCore/svg/SVGComponentTransferFunctionElement.idl
new file mode 100644
index 0000000..a479aa2
--- /dev/null
+++ b/WebCore/svg/SVGComponentTransferFunctionElement.idl
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS, GenerateConstructor] SVGComponentTransferFunctionElement : SVGElement {
+ // Component Transfer Types
+ const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN = 0;
+ const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY = 1;
+ const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_TABLE = 2;
+ const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE = 3;
+ const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_LINEAR = 4;
+ const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_GAMMA = 5;
+
+ readonly attribute SVGAnimatedEnumeration type;
+ readonly attribute SVGAnimatedNumberList tableValues;
+ readonly attribute SVGAnimatedNumber slope;
+ readonly attribute SVGAnimatedNumber intercept;
+ readonly attribute SVGAnimatedNumber amplitude;
+ readonly attribute SVGAnimatedNumber exponent;
+ readonly attribute SVGAnimatedNumber offset;
+ };
+
+}
diff --git a/WebCore/svg/SVGCursorElement.cpp b/WebCore/svg/SVGCursorElement.cpp
new file mode 100644
index 0000000..7a3e66c
--- /dev/null
+++ b/WebCore/svg/SVGCursorElement.cpp
@@ -0,0 +1,97 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGCursorElement.h"
+
+#include "Attr.h"
+#include "SVGNames.h"
+#include "SVGLength.h"
+
+namespace WebCore {
+
+SVGCursorElement::SVGCursorElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+ , SVGTests()
+ , SVGExternalResourcesRequired()
+ , SVGURIReference()
+ , m_x(0, LengthModeWidth)
+ , m_y(0, LengthModeHeight)
+{
+}
+
+SVGCursorElement::~SVGCursorElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGCursorElement, SVGLength, Length, length, X, x, SVGNames::xAttr, m_x)
+ANIMATED_PROPERTY_DEFINITIONS(SVGCursorElement, SVGLength, Length, length, Y, y, SVGNames::yAttr, m_y)
+
+void SVGCursorElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::xAttr)
+ setXBaseValue(SVGLength(0, LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(0, LengthModeHeight, attr->value()));
+ else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ if (SVGURIReference::parseMappedAttribute(attr))
+ return;
+
+ SVGElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGCursorElement::addClient(SVGElement* element)
+{
+ m_clients.add(element);
+}
+
+void SVGCursorElement::removeClient(SVGElement* element)
+{
+ m_clients.remove(element);
+}
+
+void SVGCursorElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGElement::svgAttributeChanged(attrName);
+
+ if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGURIReference::isKnownAttribute(attrName)) {
+ HashSet<SVGElement*>::const_iterator it = m_clients.begin();
+ HashSet<SVGElement*>::const_iterator end = m_clients.end();
+
+ for (; it != end; ++it)
+ (*it)->setChanged();
+ }
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGCursorElement.h b/WebCore/svg/SVGCursorElement.h
new file mode 100644
index 0000000..23a5894
--- /dev/null
+++ b/WebCore/svg/SVGCursorElement.h
@@ -0,0 +1,67 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGCursorElement_h
+#define SVGCursorElement_h
+
+#if ENABLE(SVG)
+#include "SVGLength.h"
+#include "SVGElement.h"
+#include "SVGTests.h"
+#include "SVGURIReference.h"
+#include "SVGExternalResourcesRequired.h"
+
+namespace WebCore {
+
+ class SVGCursorElement : public SVGElement,
+ public SVGTests,
+ public SVGExternalResourcesRequired,
+ public SVGURIReference {
+ public:
+ SVGCursorElement(const QualifiedName&, Document*);
+ virtual ~SVGCursorElement();
+
+ void addClient(SVGElement*);
+ void removeClient(SVGElement*);
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGCursorElement, SVGLength, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGCursorElement, SVGLength, SVGLength, Y, y)
+
+ HashSet<SVGElement*> m_clients;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGCursorElement.idl b/WebCore/svg/SVGCursorElement.idl
new file mode 100644
index 0000000..f307933
--- /dev/null
+++ b/WebCore/svg/SVGCursorElement.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGCursorElement : SVGElement,
+ SVGURIReference,
+ SVGTests,
+ SVGExternalResourcesRequired {
+ readonly attribute SVGAnimatedLength x;
+ readonly attribute SVGAnimatedLength y;
+ };
+
+}
diff --git a/WebCore/svg/SVGDefinitionSrcElement.cpp b/WebCore/svg/SVGDefinitionSrcElement.cpp
new file mode 100644
index 0000000..1419ec0
--- /dev/null
+++ b/WebCore/svg/SVGDefinitionSrcElement.cpp
@@ -0,0 +1,45 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG_FONTS)
+#include "SVGDefinitionSrcElement.h"
+
+#include "SVGFontFaceElement.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+SVGDefinitionSrcElement::SVGDefinitionSrcElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+{
+}
+
+void SVGDefinitionSrcElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+ if (parentNode() && parentNode()->hasTagName(SVGNames::font_faceTag))
+ static_cast<SVGFontFaceElement*>(parentNode())->rebuildFontFace();
+}
+
+}
+
+#endif // ENABLE(SVG_FONTS)
+
diff --git a/WebCore/svg/SVGDefinitionSrcElement.h b/WebCore/svg/SVGDefinitionSrcElement.h
new file mode 100644
index 0000000..aaefd05
--- /dev/null
+++ b/WebCore/svg/SVGDefinitionSrcElement.h
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGDefinitionSrcElement_h
+#define SVGDefinitionSrcElement_h
+
+#if ENABLE(SVG_FONTS)
+#include "SVGElement.h"
+
+namespace WebCore {
+ class SVGDefinitionSrcElement : public SVGElement {
+ public:
+ SVGDefinitionSrcElement(const QualifiedName&, Document*);
+
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_FONTS)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGDefinitionSrcElement.idl b/WebCore/svg/SVGDefinitionSrcElement.idl
new file mode 100644
index 0000000..f221895
--- /dev/null
+++ b/WebCore/svg/SVGDefinitionSrcElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FONTS] SVGDefinitionSrcElement : SVGElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGDefsElement.cpp b/WebCore/svg/SVGDefsElement.cpp
new file mode 100644
index 0000000..b084bb2
--- /dev/null
+++ b/WebCore/svg/SVGDefsElement.cpp
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGDefsElement.h"
+
+#include "RenderSVGHiddenContainer.h"
+
+namespace WebCore {
+
+SVGDefsElement::SVGDefsElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+{
+}
+
+SVGDefsElement::~SVGDefsElement()
+{
+}
+
+bool SVGDefsElement::isValid() const
+{
+ return SVGTests::isValid();
+}
+
+RenderObject* SVGDefsElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+ return new (arena) RenderSVGHiddenContainer(this);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGDefsElement.h b/WebCore/svg/SVGDefsElement.h
new file mode 100644
index 0000000..8113a99
--- /dev/null
+++ b/WebCore/svg/SVGDefsElement.h
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGDefsElement_h
+#define SVGDefsElement_h
+
+#if ENABLE(SVG)
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTests.h"
+
+namespace WebCore {
+
+ class SVGDefsElement : public SVGStyledTransformableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired {
+ public:
+ SVGDefsElement(const QualifiedName&, Document*);
+ virtual ~SVGDefsElement();
+
+ virtual bool isValid() const;
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGDefsElement.idl b/WebCore/svg/SVGDefsElement.idl
new file mode 100644
index 0000000..ed432cc
--- /dev/null
+++ b/WebCore/svg/SVGDefsElement.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGDefsElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable {
+ };
+
+}
diff --git a/WebCore/svg/SVGDescElement.cpp b/WebCore/svg/SVGDescElement.cpp
new file mode 100644
index 0000000..0297ad2
--- /dev/null
+++ b/WebCore/svg/SVGDescElement.cpp
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGDescElement.h"
+
+namespace WebCore {
+
+SVGDescElement::SVGDescElement(const QualifiedName& tagName, Document *doc)
+ : SVGStyledElement(tagName, doc)
+ , SVGLangSpace()
+{
+}
+
+SVGDescElement::~SVGDescElement()
+{
+}
+
+String SVGDescElement::description() const
+{
+ return textContent().simplifyWhiteSpace();
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGDescElement.h b/WebCore/svg/SVGDescElement.h
new file mode 100644
index 0000000..c8bc501
--- /dev/null
+++ b/WebCore/svg/SVGDescElement.h
@@ -0,0 +1,46 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGDescElement_h
+#define SVGDescElement_h
+
+#if ENABLE(SVG)
+#include "SVGLangSpace.h"
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+ class SVGDescElement : public SVGStyledElement,
+ public SVGLangSpace {
+ public:
+ SVGDescElement(const QualifiedName&, Document*);
+ virtual ~SVGDescElement();
+
+ String description() const;
+
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGDescElement.idl b/WebCore/svg/SVGDescElement.idl
new file mode 100644
index 0000000..720f487
--- /dev/null
+++ b/WebCore/svg/SVGDescElement.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGDescElement : SVGElement,
+ SVGLangSpace,
+ SVGStylable {
+ };
+
+}
diff --git a/WebCore/svg/SVGDocument.cpp b/WebCore/svg/SVGDocument.cpp
new file mode 100644
index 0000000..f347b4d
--- /dev/null
+++ b/WebCore/svg/SVGDocument.cpp
@@ -0,0 +1,107 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGDocument.h"
+
+#include "EventNames.h"
+#include "ExceptionCode.h"
+#include "FrameView.h"
+#include "RenderView.h"
+#include "SVGElement.h"
+#include "SVGNames.h"
+#include "SVGSVGElement.h"
+#include "SVGViewSpec.h"
+#include "SVGZoomEvent.h"
+#include "SVGZoomAndPan.h"
+
+namespace WebCore {
+
+SVGDocument::SVGDocument(DOMImplementation* i, Frame* frame)
+ : Document(i, frame)
+{
+}
+
+SVGDocument::~SVGDocument()
+{
+}
+
+SVGSVGElement* SVGDocument::rootElement() const
+{
+ Element* elem = documentElement();
+ if (elem && elem->hasTagName(SVGNames::svgTag))
+ return static_cast<SVGSVGElement*>(elem);
+
+ return 0;
+}
+
+void SVGDocument::dispatchZoomEvent(float prevScale, float newScale)
+{
+ ExceptionCode ec = 0;
+ RefPtr<SVGZoomEvent> event = static_pointer_cast<SVGZoomEvent>(createEvent("SVGZoomEvents", ec));
+ event->initEvent(EventNames::zoomEvent, true, false);
+ event->setPreviousScale(prevScale);
+ event->setNewScale(newScale);
+ rootElement()->dispatchEvent(event.release(), ec);
+}
+
+void SVGDocument::dispatchScrollEvent()
+{
+ ExceptionCode ec = 0;
+ RefPtr<Event> event = createEvent("SVGEvents", ec);
+ event->initEvent(EventNames::scrollEvent, true, false);
+ rootElement()->dispatchEvent(event.release(), ec);
+}
+
+bool SVGDocument::zoomAndPanEnabled() const
+{
+ if (rootElement()) {
+ if (rootElement()->useCurrentView()) {
+ if (rootElement()->currentView())
+ return rootElement()->currentView()->zoomAndPan() == SVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY;
+ } else
+ return rootElement()->zoomAndPan() == SVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY;
+ }
+
+ return false;
+}
+
+void SVGDocument::startPan(const FloatPoint& start)
+{
+ if (rootElement())
+ m_translate = FloatPoint(start.x() - rootElement()->currentTranslate().x(), rootElement()->currentTranslate().y() + start.y());
+}
+
+void SVGDocument::updatePan(const FloatPoint& pos) const
+{
+ if (rootElement()) {
+ rootElement()->setCurrentTranslate(FloatPoint(pos.x() - m_translate.x(), m_translate.y() - pos.y()));
+ if (renderer())
+ renderer()->repaint();
+ }
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGDocument.h b/WebCore/svg/SVGDocument.h
new file mode 100644
index 0000000..f8bcdbf
--- /dev/null
+++ b/WebCore/svg/SVGDocument.h
@@ -0,0 +1,62 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGDocument_h
+#define SVGDocument_h
+#if ENABLE(SVG)
+
+#include "Document.h"
+#include "FloatPoint.h"
+
+namespace WebCore {
+
+ class DOMImplementation;
+ class SVGElement;
+ class SVGSVGElement;
+
+ class SVGDocument : public Document {
+ public:
+ SVGDocument(DOMImplementation*, Frame*);
+ virtual ~SVGDocument();
+
+ virtual bool isSVGDocument() const { return true; }
+
+ SVGSVGElement* rootElement() const;
+
+ void dispatchZoomEvent(float prevScale, float newScale);
+ void dispatchScrollEvent();
+
+ bool zoomAndPanEnabled() const;
+
+ void startPan(const FloatPoint& start);
+ void updatePan(const FloatPoint& pos) const;
+
+ private:
+ FloatPoint m_translate;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGDocument_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGDocument.idl b/WebCore/svg/SVGDocument.idl
new file mode 100644
index 0000000..61f4e2e
--- /dev/null
+++ b/WebCore/svg/SVGDocument.idl
@@ -0,0 +1,34 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+module svg {
+
+ interface [Conditional=SVG] SVGDocument : core::Document {
+ readonly attribute SVGSVGElement rootElement;
+
+ // Overwrite the one in events::DocumentEvent
+ events::Event createEvent(in core::DOMString eventType)
+ raises(core::DOMException);
+ };
+
+}
diff --git a/WebCore/svg/SVGDocumentExtensions.cpp b/WebCore/svg/SVGDocumentExtensions.cpp
new file mode 100644
index 0000000..46a27c7
--- /dev/null
+++ b/WebCore/svg/SVGDocumentExtensions.cpp
@@ -0,0 +1,178 @@
+/*
+ Copyright (C) 2006 Apple Computer, Inc.
+ 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGDocumentExtensions.h"
+
+#include "AtomicString.h"
+#include "Chrome.h"
+#include "Document.h"
+#include "EventListener.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "Page.h"
+#include "SVGSVGElement.h"
+#include "TimeScheduler.h"
+#include "XMLTokenizer.h"
+#include "kjs_proxy.h"
+
+namespace WebCore {
+
+SVGDocumentExtensions::SVGDocumentExtensions(Document* doc)
+ : m_doc(doc)
+{
+}
+
+SVGDocumentExtensions::~SVGDocumentExtensions()
+{
+ deleteAllValues(m_pendingResources);
+ deleteAllValues(m_elementInstances);
+}
+
+PassRefPtr<EventListener> SVGDocumentExtensions::createSVGEventListener(const String& functionName, const String& code, Node *node)
+{
+ if (Frame* frame = m_doc->frame())
+ if (frame->scriptProxy()->isEnabled())
+ return frame->scriptProxy()->createSVGEventHandler(functionName, code, node);
+ return 0;
+}
+
+void SVGDocumentExtensions::addTimeContainer(SVGSVGElement* element)
+{
+ m_timeContainers.add(element);
+}
+
+void SVGDocumentExtensions::removeTimeContainer(SVGSVGElement* element)
+{
+ m_timeContainers.remove(element);
+}
+
+void SVGDocumentExtensions::startAnimations()
+{
+ // FIXME: Eventually every "Time Container" will need a way to latch on to some global timer
+ // starting animations for a document will do this "latching"
+#if ENABLE(SVG_ANIMATION)
+ HashSet<SVGSVGElement*>::iterator end = m_timeContainers.end();
+ for (HashSet<SVGSVGElement*>::iterator itr = m_timeContainers.begin(); itr != end; ++itr)
+ (*itr)->timeScheduler()->startAnimations();
+#endif
+}
+
+void SVGDocumentExtensions::pauseAnimations()
+{
+ HashSet<SVGSVGElement*>::iterator end = m_timeContainers.end();
+ for (HashSet<SVGSVGElement*>::iterator itr = m_timeContainers.begin(); itr != end; ++itr)
+ (*itr)->pauseAnimations();
+}
+
+void SVGDocumentExtensions::unpauseAnimations()
+{
+ HashSet<SVGSVGElement*>::iterator end = m_timeContainers.end();
+ for (HashSet<SVGSVGElement*>::iterator itr = m_timeContainers.begin(); itr != end; ++itr)
+ (*itr)->unpauseAnimations();
+}
+
+void SVGDocumentExtensions::reportWarning(const String& message)
+{
+ if (Frame* frame = m_doc->frame())
+ if (Page* page = frame->page())
+ page->chrome()->addMessageToConsole(JSMessageSource, ErrorMessageLevel, "Warning: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String());
+}
+
+void SVGDocumentExtensions::reportError(const String& message)
+{
+ if (Frame* frame = m_doc->frame())
+ if (Page* page = frame->page())
+ page->chrome()->addMessageToConsole(JSMessageSource, ErrorMessageLevel, "Error: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String());
+}
+
+void SVGDocumentExtensions::addPendingResource(const AtomicString& id, SVGStyledElement* obj)
+{
+ ASSERT(obj);
+
+ if (id.isEmpty())
+ return;
+
+ if (m_pendingResources.contains(id))
+ m_pendingResources.get(id)->add(obj);
+ else {
+ HashSet<SVGStyledElement*>* set = new HashSet<SVGStyledElement*>();
+ set->add(obj);
+
+ m_pendingResources.add(id, set);
+ }
+}
+
+bool SVGDocumentExtensions::isPendingResource(const AtomicString& id) const
+{
+ if (id.isEmpty())
+ return false;
+
+ return m_pendingResources.contains(id);
+}
+
+std::auto_ptr<HashSet<SVGStyledElement*> > SVGDocumentExtensions::removePendingResource(const AtomicString& id)
+{
+ ASSERT(m_pendingResources.contains(id));
+
+ std::auto_ptr<HashSet<SVGStyledElement*> > set(m_pendingResources.get(id));
+ m_pendingResources.remove(id);
+ return set;
+}
+
+void SVGDocumentExtensions::mapInstanceToElement(SVGElementInstance* instance, SVGElement* element)
+{
+ ASSERT(instance);
+ ASSERT(element);
+
+ if (m_elementInstances.contains(element))
+ m_elementInstances.get(element)->add(instance);
+ else {
+ HashSet<SVGElementInstance*>* set = new HashSet<SVGElementInstance*>();
+ set->add(instance);
+
+ m_elementInstances.add(element, set);
+ }
+}
+
+void SVGDocumentExtensions::removeInstanceMapping(SVGElementInstance* instance, SVGElement* element)
+{
+ ASSERT(instance);
+
+ if (!m_elementInstances.contains(element))
+ return;
+
+ m_elementInstances.get(element)->remove(instance);
+}
+
+HashSet<SVGElementInstance*>* SVGDocumentExtensions::instancesForElement(SVGElement* element) const
+{
+ ASSERT(element);
+ return m_elementInstances.get(element);
+}
+
+}
+
+#endif
diff --git a/WebCore/svg/SVGDocumentExtensions.h b/WebCore/svg/SVGDocumentExtensions.h
new file mode 100644
index 0000000..0b1ed89
--- /dev/null
+++ b/WebCore/svg/SVGDocumentExtensions.h
@@ -0,0 +1,190 @@
+/*
+ Copyright (C) 2006 Apple Computer, Inc.
+ 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGDocumentExtensions_h
+#define SVGDocumentExtensions_h
+
+#if ENABLE(SVG)
+
+#include <memory>
+#include <wtf/Forward.h>
+#include <wtf/HashSet.h>
+#include <wtf/HashMap.h>
+
+#include "FloatRect.h"
+#include "StringHash.h"
+#include "StringImpl.h"
+#include "AtomicString.h"
+
+namespace WebCore {
+
+class AtomicString;
+class Document;
+class EventListener;
+class Node;
+class String;
+class SVGElement;
+class SVGElementInstance;
+class SVGStyledElement;
+class SVGSVGElement;
+class TimeScheduler;
+
+class SVGDocumentExtensions {
+public:
+ SVGDocumentExtensions(Document*);
+ ~SVGDocumentExtensions();
+
+ PassRefPtr<EventListener> createSVGEventListener(const String& functionName, const String& code, Node*);
+
+ void addTimeContainer(SVGSVGElement*);
+ void removeTimeContainer(SVGSVGElement*);
+
+ void startAnimations();
+ void pauseAnimations();
+ void unpauseAnimations();
+
+ void reportWarning(const String&);
+ void reportError(const String&);
+
+private:
+ Document* m_doc; // weak reference
+ HashSet<SVGSVGElement*> m_timeContainers; // For SVG 1.2 support this will need to be made more general.
+ HashMap<String, HashSet<SVGStyledElement*>*> m_pendingResources;
+ HashMap<SVGElement*, HashSet<SVGElementInstance*>*> m_elementInstances;
+
+ SVGDocumentExtensions(const SVGDocumentExtensions&);
+ SVGDocumentExtensions& operator=(const SVGDocumentExtensions&);
+
+ template<typename ValueType>
+ HashMap<const SVGElement*, HashMap<StringImpl*, ValueType>*>* baseValueMap() const
+ {
+ static HashMap<const SVGElement*, HashMap<StringImpl*, ValueType>*>* s_baseValueMap = new HashMap<const SVGElement*, HashMap<StringImpl*, ValueType>*>();
+ return s_baseValueMap;
+ }
+
+public:
+ // This HashMap contains a list of pending resources. Pending resources, are such
+ // which are referenced by any object in the SVG document, but do NOT exist yet.
+ // For instance, dynamically build gradients / patterns / clippers...
+ void addPendingResource(const AtomicString& id, SVGStyledElement*);
+ bool isPendingResource(const AtomicString& id) const;
+ std::auto_ptr<HashSet<SVGStyledElement*> > removePendingResource(const AtomicString& id);
+
+ // This HashMap maps elements to their instances, when they are used by <use> elements.
+ // This is needed to synchronize the original element with the internally cloned one.
+ void mapInstanceToElement(SVGElementInstance*, SVGElement*);
+ void removeInstanceMapping(SVGElementInstance*, SVGElement*);
+ HashSet<SVGElementInstance*>* instancesForElement(SVGElement*) const;
+
+ // Used by the ANIMATED_PROPERTY_* macros
+ template<typename ValueType>
+ ValueType baseValue(const SVGElement* element, const AtomicString& propertyName) const
+ {
+ HashMap<StringImpl*, ValueType>* propertyMap = baseValueMap<ValueType>()->get(element);
+ if (propertyMap)
+ return propertyMap->get(propertyName.impl());
+
+ return 0;
+ }
+
+ template<typename ValueType>
+ void setBaseValue(const SVGElement* element, const AtomicString& propertyName, ValueType newValue)
+ {
+ HashMap<StringImpl*, ValueType>* propertyMap = baseValueMap<ValueType>()->get(element);
+ if (!propertyMap) {
+ propertyMap = new HashMap<StringImpl*, ValueType>();
+ baseValueMap<ValueType>()->set(element, propertyMap);
+ }
+
+ propertyMap->set(propertyName.impl(), newValue);
+ }
+
+ template<typename ValueType>
+ void removeBaseValue(const SVGElement* element, const AtomicString& propertyName)
+ {
+ HashMap<StringImpl*, ValueType>* propertyMap = baseValueMap<ValueType>()->get(element);
+ if (!propertyMap)
+ return;
+
+ propertyMap->remove(propertyName.impl());
+ }
+
+ template<typename ValueType>
+ bool hasBaseValue(const SVGElement* element, const AtomicString& propertyName) const
+ {
+ HashMap<StringImpl*, ValueType>* propertyMap = baseValueMap<ValueType>()->get(element);
+ if (propertyMap)
+ return propertyMap->contains(propertyName.impl());
+
+ return false;
+ }
+};
+
+// Special handling for WebCore::String
+template<>
+inline String SVGDocumentExtensions::baseValue<String>(const SVGElement* element, const AtomicString& propertyName) const
+{
+ HashMap<StringImpl*, String>* propertyMap = baseValueMap<String>()->get(element);
+ if (propertyMap)
+ return propertyMap->get(propertyName.impl());
+
+ return String();
+}
+
+// Special handling for WebCore::FloatRect
+template<>
+inline FloatRect SVGDocumentExtensions::baseValue<FloatRect>(const SVGElement* element, const AtomicString& propertyName) const
+{
+ HashMap<StringImpl*, FloatRect>* propertyMap = baseValueMap<FloatRect>()->get(element);
+ if (propertyMap)
+ return propertyMap->get(propertyName.impl());
+
+ return FloatRect();
+}
+
+// Special handling for booleans
+template<>
+inline bool SVGDocumentExtensions::baseValue<bool>(const SVGElement* element, const AtomicString& propertyName) const
+{
+ HashMap<StringImpl*, bool>* propertyMap = baseValueMap<bool>()->get(element);
+ if (propertyMap)
+ return propertyMap->get(propertyName.impl());
+
+ return false;
+}
+
+// Special handling for doubles
+template<>
+inline double SVGDocumentExtensions::baseValue<double>(const SVGElement* element, const AtomicString& propertyName) const
+{
+ HashMap<StringImpl*, double>* propertyMap = baseValueMap<double>()->get(element);
+ if (propertyMap)
+ return propertyMap->get(propertyName.impl());
+
+ return 0.0;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+#endif
diff --git a/WebCore/svg/SVGElement.cpp b/WebCore/svg/SVGElement.cpp
new file mode 100644
index 0000000..41a62c3
--- /dev/null
+++ b/WebCore/svg/SVGElement.cpp
@@ -0,0 +1,259 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGElement.h"
+
+#include "DOMImplementation.h"
+#include "Document.h"
+#include "Event.h"
+#include "EventListener.h"
+#include "EventNames.h"
+#include "FrameView.h"
+#include "HTMLNames.h"
+#include "PlatformString.h"
+#include "RenderObject.h"
+#include "SVGDocumentExtensions.h"
+#include "SVGElementInstance.h"
+#include "SVGNames.h"
+#include "SVGSVGElement.h"
+#include "SVGURIReference.h"
+#include "SVGUseElement.h"
+#include "XMLNames.h"
+
+namespace WebCore {
+
+using namespace HTMLNames;
+using namespace EventNames;
+
+SVGElement::SVGElement(const QualifiedName& tagName, Document* doc)
+ : StyledElement(tagName, doc)
+ , m_shadowParent(0)
+{
+}
+
+SVGElement::~SVGElement()
+{
+}
+
+bool SVGElement::isSupported(StringImpl* feature, StringImpl* version) const
+{
+ if (DOMImplementation::instance()->hasFeature(feature, version))
+ return true;
+
+ return DOMImplementation::instance()->hasFeature(feature, version);
+}
+
+String SVGElement::id() const
+{
+ return getAttribute(idAttr);
+}
+
+void SVGElement::setId(const String& value, ExceptionCode&)
+{
+ setAttribute(idAttr, value);
+}
+
+String SVGElement::xmlbase() const
+{
+ return getAttribute(XMLNames::baseAttr);
+}
+
+void SVGElement::setXmlbase(const String& value, ExceptionCode&)
+{
+ setAttribute(XMLNames::baseAttr, value);
+}
+
+SVGSVGElement* SVGElement::ownerSVGElement() const
+{
+ Node* n = parentNode();
+ while (n) {
+ if (n->hasTagName(SVGNames::svgTag))
+ return static_cast<SVGSVGElement*>(n);
+
+ n = n->parentNode();
+ }
+
+ return 0;
+}
+
+SVGElement* SVGElement::viewportElement() const
+{
+ // This function needs shadow tree support - as RenderSVGContainer uses this function
+ // to determine the "overflow" property. <use> on <symbol> wouldn't work otherwhise.
+ Node* n = isShadowNode() ? const_cast<SVGElement*>(this)->shadowParentNode() : parentNode();
+ while (n) {
+ if (n->hasTagName(SVGNames::svgTag) || n->hasTagName(SVGNames::imageTag) || n->hasTagName(SVGNames::symbolTag))
+ return static_cast<SVGElement*>(n);
+
+ n = n->isShadowNode() ? n->shadowParentNode() : n->parentNode();
+ }
+
+ return 0;
+}
+
+void SVGElement::addSVGEventListener(const AtomicString& eventType, const Attribute* attr)
+{
+ Element::setHTMLEventListener(eventType, document()->accessSVGExtensions()->
+ createSVGEventListener(attr->localName().string(), attr->value(), this));
+}
+
+void SVGElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ // standard events
+ if (attr->name() == onloadAttr)
+ addSVGEventListener(loadEvent, attr);
+ else if (attr->name() == onclickAttr)
+ addSVGEventListener(clickEvent, attr);
+ else if (attr->name() == onmousedownAttr)
+ addSVGEventListener(mousedownEvent, attr);
+ else if (attr->name() == onmousemoveAttr)
+ addSVGEventListener(mousemoveEvent, attr);
+ else if (attr->name() == onmouseoutAttr)
+ addSVGEventListener(mouseoutEvent, attr);
+ else if (attr->name() == onmouseoverAttr)
+ addSVGEventListener(mouseoverEvent, attr);
+ else if (attr->name() == onmouseupAttr)
+ addSVGEventListener(mouseupEvent, attr);
+ else if (attr->name() == SVGNames::onfocusinAttr)
+ addSVGEventListener(DOMFocusInEvent, attr);
+ else if (attr->name() == SVGNames::onfocusoutAttr)
+ addSVGEventListener(DOMFocusOutEvent, attr);
+ else if (attr->name() == SVGNames::onactivateAttr)
+ addSVGEventListener(DOMActivateEvent, attr);
+ else
+ StyledElement::parseMappedAttribute(attr);
+}
+
+bool SVGElement::haveLoadedRequiredResources()
+{
+ Node* child = firstChild();
+ while (child) {
+ if (child->isSVGElement() && !static_cast<SVGElement*>(child)->haveLoadedRequiredResources())
+ return false;
+ child = child->nextSibling();
+ }
+ return true;
+}
+
+void SVGElement::sendSVGLoadEventIfPossible(bool sendParentLoadEvents)
+{
+ RefPtr<SVGElement> currentTarget = this;
+ while (currentTarget && currentTarget->haveLoadedRequiredResources()) {
+ RefPtr<Node> parent;
+ if (sendParentLoadEvents)
+ parent = currentTarget->parentNode(); // save the next parent to dispatch too incase dispatching the event changes the tree
+
+ // FIXME: This malloc could be avoided by walking the tree first to check if any listeners are present: http://bugs.webkit.org/show_bug.cgi?id=10264
+ RefPtr<Event> event = new Event(loadEvent, false, false);
+ event->setTarget(currentTarget);
+ ExceptionCode ignored = 0;
+ dispatchGenericEvent(this, event.release(), ignored, false);
+ currentTarget = (parent && parent->isSVGElement()) ? static_pointer_cast<SVGElement>(parent) : 0;
+ }
+}
+
+void SVGElement::finishParsingChildren()
+{
+ // finishParsingChildren() is called when the close tag is reached for an element (e.g. </svg>)
+ // we send SVGLoad events here if we can, otherwise they'll be sent when any required loads finish
+ sendSVGLoadEventIfPossible();
+}
+
+bool SVGElement::childShouldCreateRenderer(Node* child) const
+{
+ if (child->isSVGElement())
+ return static_cast<SVGElement*>(child)->isValid();
+ return false;
+}
+
+void SVGElement::insertedIntoDocument()
+{
+ StyledElement::insertedIntoDocument();
+ SVGDocumentExtensions* extensions = document()->accessSVGExtensions();
+
+ String resourceId = SVGURIReference::getTarget(id());
+ if (extensions->isPendingResource(resourceId)) {
+ std::auto_ptr<HashSet<SVGStyledElement*> > clients(extensions->removePendingResource(resourceId));
+ if (clients->isEmpty())
+ return;
+
+ HashSet<SVGStyledElement*>::const_iterator it = clients->begin();
+ const HashSet<SVGStyledElement*>::const_iterator end = clients->end();
+
+ for (; it != end; ++it)
+ (*it)->buildPendingResource();
+
+ SVGResource::invalidateClients(*clients);
+ }
+}
+
+static Node* shadowTreeParentElementForShadowTreeElement(Node* node)
+{
+ for (Node* n = node; n; n = n->parentNode()) {
+ if (n->isShadowNode())
+ return n->shadowParentNode();
+ }
+
+ return 0;
+}
+
+bool SVGElement::dispatchEvent(PassRefPtr<Event> e, ExceptionCode& ec, bool tempEvent)
+{
+ // TODO: This function will be removed in a follow-up patch!
+
+ EventTarget* target = this;
+ Node* useNode = shadowTreeParentElementForShadowTreeElement(this);
+
+ // If we are a hidden shadow tree element, the target must
+ // point to our corresponding SVGElementInstance object
+ if (useNode) {
+ ASSERT(useNode->hasTagName(SVGNames::useTag));
+ SVGUseElement* use = static_cast<SVGUseElement*>(useNode);
+
+ SVGElementInstance* instance = use->instanceForShadowTreeElement(this);
+
+ if (instance)
+ target = instance;
+ }
+
+ e->setTarget(target);
+
+ RefPtr<FrameView> view = document()->view();
+ return EventTargetNode::dispatchGenericEvent(this, e, ec, tempEvent);
+}
+
+void SVGElement::attributeChanged(Attribute* attr, bool preserveDecls)
+{
+ ASSERT(attr);
+ if (!attr)
+ return;
+
+ StyledElement::attributeChanged(attr, preserveDecls);
+ svgAttributeChanged(attr->name());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGElement.h b/WebCore/svg/SVGElement.h
new file mode 100644
index 0000000..a4672be
--- /dev/null
+++ b/WebCore/svg/SVGElement.h
@@ -0,0 +1,252 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGElement_h
+#define SVGElement_h
+
+#if ENABLE(SVG)
+#include "Document.h"
+#include "FloatRect.h"
+#include "StyledElement.h"
+#include "SVGAnimatedTemplate.h"
+#include "SVGDocumentExtensions.h"
+#include "SVGNames.h"
+
+#define ANIMATED_PROPERTY_EMPTY_DECLARATIONS(BareType, NullType, UpperProperty, LowerProperty) \
+public: \
+ virtual BareType LowerProperty() const { ASSERT_NOT_REACHED(); return NullType; } \
+ virtual void set##UpperProperty(BareType newValue) { ASSERT_NOT_REACHED(); }\
+ virtual BareType LowerProperty##BaseValue() const { ASSERT_NOT_REACHED(); return NullType; } \
+ virtual void set##UpperProperty##BaseValue(BareType newValue) { ASSERT_NOT_REACHED(); } \
+ virtual void start##UpperProperty() const { ASSERT_NOT_REACHED(); } \
+ virtual void stop##UpperProperty() { ASSERT_NOT_REACHED(); }
+
+#define ANIMATED_PROPERTY_FORWARD_DECLARATIONS(ForwardClass, BareType, UpperProperty, LowerProperty) \
+public: \
+ virtual BareType LowerProperty() const { return ForwardClass::LowerProperty(); } \
+ virtual void set##UpperProperty(BareType newValue) { ForwardClass::set##UpperProperty(newValue); } \
+ virtual BareType LowerProperty##BaseValue() const { return ForwardClass::LowerProperty##BaseValue(); } \
+ virtual void set##UpperProperty##BaseValue(BareType newValue) { ForwardClass::set##UpperProperty##BaseValue(newValue); } \
+ virtual void start##UpperProperty() const { ForwardClass::start##UpperProperty(); } \
+ virtual void stop##UpperProperty() { ForwardClass::stop##UpperProperty(); }
+
+#define ANIMATED_PROPERTY_DECLARATIONS_INTERNAL(ClassType, ClassStorageType, BareType, StorageType, UpperProperty, LowerProperty) \
+class SVGAnimatedTemplate##UpperProperty \
+: public SVGAnimatedTemplate<BareType> \
+{ \
+public: \
+ SVGAnimatedTemplate##UpperProperty(const ClassType*, const QualifiedName&); \
+ virtual ~SVGAnimatedTemplate##UpperProperty() { } \
+ virtual BareType baseVal() const; \
+ virtual void setBaseVal(BareType); \
+ virtual BareType animVal() const; \
+ virtual void setAnimVal(BareType); \
+ \
+protected: \
+ ClassStorageType m_element; \
+}; \
+public: \
+ BareType LowerProperty() const; \
+ void set##UpperProperty(BareType); \
+ BareType LowerProperty##BaseValue() const; \
+ void set##UpperProperty##BaseValue(BareType); \
+ PassRefPtr<SVGAnimatedTemplate##UpperProperty> LowerProperty##Animated() const; \
+ void start##UpperProperty() const; \
+ void stop##UpperProperty(); \
+\
+private: \
+ StorageType m_##LowerProperty;
+
+#define ANIMATED_PROPERTY_DEFINITIONS_INTERNAL(ClassName, ClassType, BareType, UpperClassName, LowerClassName, UpperProperty, LowerProperty, AttrName, StorageGetter, ContextElement) \
+ClassName::SVGAnimatedTemplate##UpperProperty::SVGAnimatedTemplate##UpperProperty(const ClassType* element, const QualifiedName& attributeName) \
+: SVGAnimatedTemplate<BareType>(attributeName), m_element(const_cast<ClassType*>(element)) { } \
+\
+BareType ClassName::SVGAnimatedTemplate##UpperProperty::baseVal() const \
+{ \
+ return m_element->LowerProperty##BaseValue(); \
+} \
+void ClassName::SVGAnimatedTemplate##UpperProperty::setBaseVal(BareType newBaseVal) \
+{ \
+ m_element->set##UpperProperty##BaseValue(newBaseVal); \
+} \
+BareType ClassName::SVGAnimatedTemplate##UpperProperty::animVal() const \
+{ \
+ return m_element->LowerProperty(); \
+} \
+void ClassName::SVGAnimatedTemplate##UpperProperty::setAnimVal(BareType newAnimVal) \
+{ \
+ m_element->set##UpperProperty(newAnimVal); \
+} \
+BareType ClassName::LowerProperty() const \
+{ \
+ return StorageGetter; \
+} \
+void ClassName::set##UpperProperty(BareType newValue) \
+{ \
+ m_##LowerProperty = newValue; \
+} \
+BareType ClassName::LowerProperty##BaseValue() const \
+{ \
+ const SVGElement* context = ContextElement; \
+ ASSERT(context); \
+ SVGDocumentExtensions* extensions = (context->document() ? context->document()->accessSVGExtensions() : 0); \
+ if (extensions && extensions->hasBaseValue<BareType>(context, AttrName)) \
+ return extensions->baseValue<BareType>(context, AttrName); \
+ return LowerProperty(); \
+} \
+void ClassName::set##UpperProperty##BaseValue(BareType newValue) \
+{ \
+ const SVGElement* context = ContextElement; \
+ ASSERT(context); \
+ SVGDocumentExtensions* extensions = (context->document() ? context->document()->accessSVGExtensions() : 0); \
+ if (extensions && extensions->hasBaseValue<BareType>(context, AttrName)) { \
+ extensions->setBaseValue<BareType>(context, AttrName, newValue); \
+ return; \
+ } \
+ /* Only update stored property, if not animating */ \
+ set##UpperProperty(newValue); \
+} \
+\
+void ClassName::start##UpperProperty() const \
+{ \
+ const SVGElement* context = ContextElement; \
+ ASSERT(context); \
+ SVGDocumentExtensions* extensions = (context->document() ? context->document()->accessSVGExtensions() : 0); \
+ if (extensions) { \
+ ASSERT(!extensions->hasBaseValue<BareType>(context, AttrName)); \
+ extensions->setBaseValue<BareType>(context, AttrName, LowerProperty()); \
+ } \
+} \
+\
+void ClassName::stop##UpperProperty() \
+{ \
+ const SVGElement* context = ContextElement; \
+ ASSERT(context); \
+ SVGDocumentExtensions* extensions = (context->document() ? context->document()->accessSVGExtensions() : 0); \
+ if (extensions) { \
+ ASSERT(extensions->hasBaseValue<BareType>(context, AttrName)); \
+ set##UpperProperty(extensions->baseValue<BareType>(context, AttrName)); \
+ extensions->removeBaseValue<BareType>(context, AttrName); \
+ } \
+}
+
+// These are the macros which will be used to declare/implement the svg animated properties...
+#define ANIMATED_PROPERTY_DECLARATIONS_WITH_CONTEXT(ClassName, BareType, StorageType, UpperProperty, LowerProperty) \
+ANIMATED_PROPERTY_DECLARATIONS_INTERNAL(SVGElement, RefPtr<SVGElement>, BareType, StorageType, UpperProperty, LowerProperty)
+
+#define ANIMATED_PROPERTY_DECLARATIONS(ClassName, BareType, StorageType, UpperProperty, LowerProperty) \
+ANIMATED_PROPERTY_DECLARATIONS_INTERNAL(ClassName, RefPtr<ClassName>, BareType, StorageType, UpperProperty, LowerProperty)
+
+#define ANIMATED_PROPERTY_DEFINITIONS_WITH_CONTEXT(ClassName, BareType, UpperClassName, LowerClassName, UpperProperty, LowerProperty, AttrName, StorageGetter) \
+ANIMATED_PROPERTY_DEFINITIONS_INTERNAL(ClassName, SVGElement, BareType, UpperClassName, LowerClassName, UpperProperty, LowerProperty, AttrName.localName(), StorageGetter, contextElement()) \
+PassRefPtr<ClassName::SVGAnimatedTemplate##UpperProperty> ClassName::LowerProperty##Animated() const \
+{ \
+ const SVGElement* context = contextElement(); \
+ ASSERT(context); \
+ return lookupOrCreateWrapper<ClassName::SVGAnimatedTemplate##UpperProperty, SVGElement>(context, AttrName, AttrName.localName()); \
+}
+
+#define ANIMATED_PROPERTY_DEFINITIONS_WITH_CUSTOM_IDENTIFIER(ClassName, BareType, UpperClassName, LowerClassName, UpperProperty, LowerProperty, AttrName, AttrIdentifier, StorageGetter) \
+ANIMATED_PROPERTY_DEFINITIONS_INTERNAL(ClassName, ClassName, BareType, UpperClassName, LowerClassName, UpperProperty, LowerProperty, AttrName.localName(), StorageGetter, this) \
+PassRefPtr<ClassName::SVGAnimatedTemplate##UpperProperty> ClassName::LowerProperty##Animated() const \
+{ \
+ return lookupOrCreateWrapper<ClassName::SVGAnimatedTemplate##UpperProperty, ClassName>(this, AttrName, AttrIdentifier); \
+}
+
+#define ANIMATED_PROPERTY_DEFINITIONS(ClassName, BareType, UpperClassName, LowerClassName, UpperProperty, LowerProperty, AttrName, StorageGetter) \
+ANIMATED_PROPERTY_DEFINITIONS_WITH_CUSTOM_IDENTIFIER(ClassName, BareType, UpperClassName, LowerClassName, UpperProperty, LowerProperty, AttrName, AttrName.localName(), StorageGetter)
+
+namespace WebCore {
+
+ class SVGPreserveAspectRatio;
+ class SVGSVGElement;
+
+ class SVGElement : public StyledElement {
+ public:
+ SVGElement(const QualifiedName&, Document*);
+ virtual ~SVGElement();
+ virtual bool isSVGElement() const { return true; }
+ virtual bool isSupported(StringImpl* feature, StringImpl* version) const;
+
+ String id() const;
+ void setId(const String&, ExceptionCode&);
+ String xmlbase() const;
+ void setXmlbase(const String&, ExceptionCode&);
+
+ SVGSVGElement* ownerSVGElement() const;
+ SVGElement* viewportElement() const;
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ virtual bool isStyled() const { return false; }
+ virtual bool isStyledTransformable() const { return false; }
+ virtual bool isStyledLocatable() const { return false; }
+ virtual bool isSVG() const { return false; }
+ virtual bool isFilterEffect() const { return false; }
+ virtual bool isGradientStop() const { return false; }
+ virtual bool isTextContent() const { return false; }
+
+ virtual bool isShadowNode() const { return m_shadowParent; }
+ virtual Node* shadowParentNode() { return m_shadowParent; }
+ void setShadowParentNode(Node* node) { m_shadowParent = node; }
+ virtual Node* eventParentNode() { return isShadowNode() ? shadowParentNode() : parentNode(); }
+
+ // For SVGTests
+ virtual bool isValid() const { return true; }
+
+ virtual void finishParsingChildren();
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+ virtual bool childShouldCreateRenderer(Node*) const;
+
+ virtual void insertedIntoDocument();
+ virtual void buildPendingResource() { }
+
+ virtual void svgAttributeChanged(const QualifiedName&) { }
+ virtual void attributeChanged(Attribute*, bool preserveDecls = false);
+
+ void sendSVGLoadEventIfPossible(bool sendParentLoadEvents = false);
+
+ // Forwarded properties (declared/defined anywhere else in the inheritance structure)
+
+ // -> For SVGURIReference
+ ANIMATED_PROPERTY_EMPTY_DECLARATIONS(String, String(), Href, href)
+
+ // -> For SVGFitToViewBox
+ ANIMATED_PROPERTY_EMPTY_DECLARATIONS(FloatRect, FloatRect(), ViewBox, viewBox)
+ ANIMATED_PROPERTY_EMPTY_DECLARATIONS(SVGPreserveAspectRatio*, 0, PreserveAspectRatio, preserveAspectRatio)
+
+ // -> For SVGExternalResourcesRequired
+ ANIMATED_PROPERTY_EMPTY_DECLARATIONS(bool, false, ExternalResourcesRequired, externalResourcesRequired)
+
+ virtual bool dispatchEvent(PassRefPtr<Event> e, ExceptionCode& ec, bool tempEvent = false);
+
+ private:
+ void addSVGEventListener(const AtomicString& eventType, const Attribute*);
+ virtual bool haveLoadedRequiredResources();
+
+ Node* m_shadowParent;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGElement_h
diff --git a/WebCore/svg/SVGElement.idl b/WebCore/svg/SVGElement.idl
new file mode 100644
index 0000000..a1f331f
--- /dev/null
+++ b/WebCore/svg/SVGElement.idl
@@ -0,0 +1,36 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+module svg {
+
+ interface [GenerateNativeConverter, Conditional=SVG] SVGElement : Element {
+ attribute [ConvertNullToNullString] DOMString id
+ setter raises(DOMException);
+ attribute [ConvertNullToNullString] DOMString xmlbase
+ setter raises(DOMException);
+ readonly attribute SVGSVGElement ownerSVGElement;
+ readonly attribute SVGElement viewportElement;
+ };
+
+}
diff --git a/WebCore/svg/SVGElementInstance.cpp b/WebCore/svg/SVGElementInstance.cpp
new file mode 100644
index 0000000..a416d9a
--- /dev/null
+++ b/WebCore/svg/SVGElementInstance.cpp
@@ -0,0 +1,208 @@
+/*
+ Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGElementInstance.h"
+
+#include "Event.h"
+#include "EventListener.h"
+#include "SVGElementInstanceList.h"
+#include "SVGUseElement.h"
+
+#include <wtf/Assertions.h>
+
+namespace WebCore {
+
+SVGElementInstance::SVGElementInstance(SVGUseElement* useElement, PassRefPtr<SVGElement> originalElement)
+ : m_refCount(0)
+ , m_parent(0)
+ , m_useElement(useElement)
+ , m_element(originalElement)
+ , m_shadowTreeElement(0)
+ , m_previousSibling(0)
+ , m_nextSibling(0)
+ , m_firstChild(0)
+ , m_lastChild(0)
+{
+ ASSERT(m_useElement);
+ ASSERT(m_element);
+
+ // Register as instance for passed element.
+ m_element->document()->accessSVGExtensions()->mapInstanceToElement(this, m_element.get());
+}
+
+SVGElementInstance::~SVGElementInstance()
+{
+ for (RefPtr<SVGElementInstance> child = m_firstChild; child; child = child->m_nextSibling)
+ child->setParent(0);
+
+ // Deregister as instance for passed element.
+ m_element->document()->accessSVGExtensions()->removeInstanceMapping(this, m_element.get());
+}
+
+SVGElement* SVGElementInstance::correspondingElement() const
+{
+ return m_element.get();
+}
+
+SVGUseElement* SVGElementInstance::correspondingUseElement() const
+{
+ return m_useElement;
+}
+
+SVGElementInstance* SVGElementInstance::parentNode() const
+{
+ return parent();
+}
+
+PassRefPtr<SVGElementInstanceList> SVGElementInstance::childNodes()
+{
+ return SVGElementInstanceList::create(this);
+}
+
+SVGElementInstance* SVGElementInstance::previousSibling() const
+{
+ return m_previousSibling;
+}
+
+SVGElementInstance* SVGElementInstance::nextSibling() const
+{
+ return m_nextSibling;
+}
+
+SVGElementInstance* SVGElementInstance::firstChild() const
+{
+ return m_firstChild;
+}
+
+SVGElementInstance* SVGElementInstance::lastChild() const
+{
+ return m_lastChild;
+}
+
+SVGElement* SVGElementInstance::shadowTreeElement() const
+{
+ return m_shadowTreeElement;
+}
+
+void SVGElementInstance::setShadowTreeElement(SVGElement* element)
+{
+ ASSERT(element);
+ m_shadowTreeElement = element;
+}
+
+void SVGElementInstance::appendChild(PassRefPtr<SVGElementInstance> child)
+{
+ child->setParent(this);
+
+ if (m_lastChild) {
+ child->m_previousSibling = m_lastChild;
+ m_lastChild->m_nextSibling = child.get();
+ } else
+ m_firstChild = child.get();
+
+ m_lastChild = child.get();
+}
+
+// Helper function for updateInstance
+static bool containsUseChildNode(Node* start)
+{
+ if (start->hasTagName(SVGNames::useTag))
+ return true;
+
+ for (Node* current = start->firstChild(); current; current = current->nextSibling()) {
+ if (containsUseChildNode(current))
+ return true;
+ }
+
+ return false;
+}
+
+void SVGElementInstance::updateInstance(SVGElement* element)
+{
+ ASSERT(element == m_element);
+ ASSERT(m_shadowTreeElement);
+
+ // TODO: Eventually come up with a more optimized updating logic for the cases below:
+ //
+ // <symbol>: We can't just clone the original element, we need to apply
+ // the same "replace by generated content" logic that SVGUseElement does.
+ //
+ // <svg>: <use> on <svg> is too rare to actually implement it faster.
+ // If someone still wants to do it: recloning, adjusting width/height attributes is enough.
+ //
+ // <use>: Too hard to get it right in a fast way. Recloning seems the only option.
+
+ if (m_element->hasTagName(SVGNames::symbolTag) ||
+ m_element->hasTagName(SVGNames::svgTag) ||
+ containsUseChildNode(m_element.get())) {
+ m_useElement->buildPendingResource();
+ return;
+ }
+
+ // For all other nodes this logic is sufficient.
+ RefPtr<Node> clone = m_element->cloneNode(true);
+ SVGElement* svgClone = 0;
+ if (clone && clone->isSVGElement())
+ svgClone = static_cast<SVGElement*>(clone.get());
+ ASSERT(svgClone);
+
+ // Replace node in the <use> shadow tree
+ ExceptionCode ec = 0;
+ m_shadowTreeElement->parentNode()->replaceChild(clone.release(), m_shadowTreeElement, ec);
+ ASSERT(ec == 0);
+
+ m_shadowTreeElement = svgClone;
+}
+
+SVGElementInstance* SVGElementInstance::toSVGElementInstance()
+{
+ return this;
+}
+
+EventTargetNode* SVGElementInstance::toNode()
+{
+ return m_element.get();
+}
+
+void SVGElementInstance::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> eventListener, bool useCapture)
+{
+ // FIXME!
+}
+
+void SVGElementInstance::removeEventListener(const AtomicString& eventType, EventListener* eventListener, bool useCapture)
+{
+ // FIXME!
+}
+
+bool SVGElementInstance::dispatchEvent(PassRefPtr<Event>, ExceptionCode& ec, bool tempEvent)
+{
+ // FIXME!
+ return false;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGElementInstance.h b/WebCore/svg/SVGElementInstance.h
new file mode 100644
index 0000000..0e74812
--- /dev/null
+++ b/WebCore/svg/SVGElementInstance.h
@@ -0,0 +1,108 @@
+/*
+ Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGElementInstance_h
+#define SVGElementInstance_h
+
+#if ENABLE(SVG)
+
+#include "EventTarget.h"
+
+#include <wtf/RefPtr.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+ class SVGElement;
+ class SVGUseElement;
+ class SVGElementInstanceList;
+
+ class SVGElementInstance : public EventTarget {
+ public:
+ SVGElementInstance(SVGUseElement*, PassRefPtr<SVGElement> originalElement);
+ virtual ~SVGElementInstance();
+
+ // 'SVGElementInstance' functions
+ SVGElement* correspondingElement() const;
+ SVGUseElement* correspondingUseElement() const;
+
+ SVGElementInstance* parentNode() const;
+ PassRefPtr<SVGElementInstanceList> childNodes();
+
+ SVGElementInstance* previousSibling() const;
+ SVGElementInstance* nextSibling() const;
+
+ SVGElementInstance* firstChild() const;
+ SVGElementInstance* lastChild() const;
+
+ // Internal usage only!
+ SVGElement* shadowTreeElement() const;
+ void setShadowTreeElement(SVGElement*);
+
+ // Model the TreeShared concept, integrated within EventTarget inheritance.
+ virtual void refEventTarget() { ++m_refCount; }
+ virtual void derefEventTarget() { if (--m_refCount <= 0 && !m_parent) delete this; }
+
+ bool hasOneRef() { return m_refCount == 1; }
+ int refCount() const { return m_refCount; }
+
+ void setParent(SVGElementInstance* parent) { m_parent = parent; }
+ SVGElementInstance* parent() const { return m_parent; }
+
+ // SVGElementInstance supports both toSVGElementInstance and toNode since so much mouse handling code depends on toNode returning a valid node.
+ virtual EventTargetNode* toNode();
+ virtual SVGElementInstance* toSVGElementInstance();
+
+ virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
+ virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
+ virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&, bool tempEvent = false);
+
+ private:
+ SVGElementInstance(const SVGElementInstance&);
+ SVGElementInstance& operator=(const SVGElementInstance&);
+
+ private: // Helper methods
+ friend class SVGUseElement;
+ void appendChild(PassRefPtr<SVGElementInstance> child);
+
+ friend class SVGStyledElement;
+ void updateInstance(SVGElement*);
+
+ private:
+ int m_refCount;
+ SVGElementInstance* m_parent;
+
+ SVGUseElement* m_useElement;
+ RefPtr<SVGElement> m_element;
+ SVGElement* m_shadowTreeElement;
+
+ SVGElementInstance* m_previousSibling;
+ SVGElementInstance* m_nextSibling;
+
+ SVGElementInstance* m_firstChild;
+ SVGElementInstance* m_lastChild;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGElementInstance.idl b/WebCore/svg/SVGElementInstance.idl
new file mode 100644
index 0000000..fb54e90
--- /dev/null
+++ b/WebCore/svg/SVGElementInstance.idl
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+ interface [Conditional=SVG] SVGElementInstance {
+ readonly attribute SVGElement correspondingElement;
+ readonly attribute SVGUseElement correspondingUseElement;
+ readonly attribute SVGElementInstance parentNode;
+ readonly attribute SVGElementInstanceList childNodes;
+ readonly attribute SVGElementInstance firstChild;
+ readonly attribute SVGElementInstance lastChild;
+ readonly attribute SVGElementInstance previousSibling;
+ readonly attribute SVGElementInstance nextSibling;
+
+#if defined(LANGUAGE_OBJECTIVE_JAVASCRIPT)
+ // A manual copy of the EventTarget interface - including it in
+ // the class inheritance above gives troubles. This works.
+ void addEventListener(in DOMString type,
+ in EventListener listener,
+ in boolean useCapture);
+ void removeEventListener(in DOMString type,
+ in EventListener listener,
+ in boolean useCapture);
+ boolean dispatchEvent(in Event event) raises(EventException);
+#endif
+ };
+}
diff --git a/WebCore/svg/SVGElementInstanceList.cpp b/WebCore/svg/SVGElementInstanceList.cpp
new file mode 100644
index 0000000..3942599
--- /dev/null
+++ b/WebCore/svg/SVGElementInstanceList.cpp
@@ -0,0 +1,66 @@
+/*
+ Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGElementInstanceList.h"
+
+namespace WebCore {
+
+SVGElementInstanceList::SVGElementInstanceList(PassRefPtr<SVGElementInstance> rootInstance)
+ : m_rootInstance(rootInstance)
+{
+}
+
+SVGElementInstanceList::~SVGElementInstanceList()
+{
+}
+
+unsigned int SVGElementInstanceList::length() const
+{
+ // NOTE: We could use the same caching facilities, "ChildNodeList" uses.
+ unsigned length = 0;
+ SVGElementInstance* instance;
+ for (instance = m_rootInstance->firstChild(); instance; instance = instance->nextSibling())
+ length++;
+
+ return length;
+}
+
+RefPtr<SVGElementInstance> SVGElementInstanceList::item(unsigned int index)
+{
+ unsigned int pos = 0;
+ SVGElementInstance* instance = m_rootInstance->firstChild();
+
+ while (instance && pos < index) {
+ instance = instance->nextSibling();
+ pos++;
+ }
+
+ return instance;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGElementInstanceList.h b/WebCore/svg/SVGElementInstanceList.h
new file mode 100644
index 0000000..6fb9412
--- /dev/null
+++ b/WebCore/svg/SVGElementInstanceList.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGElementInstanceList_h
+#define SVGElementInstanceList_h
+
+#if ENABLE(SVG)
+
+#include <wtf/RefCounted.h>
+#include "SVGElementInstance.h"
+
+namespace WebCore {
+ class SVGElementInstanceList : public RefCounted<SVGElementInstanceList> {
+ public:
+ static PassRefPtr<SVGElementInstanceList> create(PassRefPtr<SVGElementInstance> rootInstance) { return adoptRef(new SVGElementInstanceList(rootInstance)); }
+ virtual ~SVGElementInstanceList();
+
+ unsigned int length() const;
+ RefPtr<SVGElementInstance> item(unsigned int index);
+
+ private:
+ SVGElementInstanceList(PassRefPtr<SVGElementInstance> rootInstance);
+ RefPtr<SVGElementInstance> m_rootInstance;
+ };
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGElementInstanceList.idl b/WebCore/svg/SVGElementInstanceList.idl
new file mode 100644
index 0000000..434ad19
--- /dev/null
+++ b/WebCore/svg/SVGElementInstanceList.idl
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+ interface [Conditional=SVG] SVGElementInstanceList {
+ readonly attribute unsigned long length;
+
+ SVGElementInstance item(in unsigned long index);
+ };
+}
diff --git a/WebCore/svg/SVGEllipseElement.cpp b/WebCore/svg/SVGEllipseElement.cpp
new file mode 100644
index 0000000..0f32ed2
--- /dev/null
+++ b/WebCore/svg/SVGEllipseElement.cpp
@@ -0,0 +1,111 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGEllipseElement.h"
+
+#include "FloatPoint.h"
+#include "RenderPath.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+SVGEllipseElement::SVGEllipseElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_cx(this, LengthModeWidth)
+ , m_cy(this, LengthModeHeight)
+ , m_rx(this, LengthModeWidth)
+ , m_ry(this, LengthModeHeight)
+{
+}
+
+SVGEllipseElement::~SVGEllipseElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGEllipseElement, SVGLength, Length, length, Cx, cx, SVGNames::cxAttr, m_cx)
+ANIMATED_PROPERTY_DEFINITIONS(SVGEllipseElement, SVGLength, Length, length, Cy, cy, SVGNames::cyAttr, m_cy)
+ANIMATED_PROPERTY_DEFINITIONS(SVGEllipseElement, SVGLength, Length, length, Rx, rx, SVGNames::rxAttr, m_rx)
+ANIMATED_PROPERTY_DEFINITIONS(SVGEllipseElement, SVGLength, Length, length, Ry, ry, SVGNames::ryAttr, m_ry)
+
+void SVGEllipseElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::cxAttr)
+ setCxBaseValue(SVGLength(this, LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::cyAttr)
+ setCyBaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::rxAttr) {
+ setRxBaseValue(SVGLength(this, LengthModeWidth, attr->value()));
+ if (rx().value() < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for ellipse <rx> is not allowed");
+ } else if (attr->name() == SVGNames::ryAttr) {
+ setRyBaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ if (ry().value() < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for ellipse <ry> is not allowed");
+ } else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ SVGStyledTransformableElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGEllipseElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledTransformableElement::svgAttributeChanged(attrName);
+
+ if (!renderer())
+ return;
+
+ if (attrName == SVGNames::cxAttr || attrName == SVGNames::cyAttr ||
+ attrName == SVGNames::rxAttr || attrName == SVGNames::ryAttr ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledTransformableElement::isKnownAttribute(attrName))
+ renderer()->setNeedsLayout(true);
+}
+
+Path SVGEllipseElement::toPathData() const
+{
+ return Path::createEllipse(FloatPoint(cx().value(), cy().value()),
+ rx().value(), ry().value());
+}
+
+bool SVGEllipseElement::hasRelativeValues() const
+{
+ return (cx().isRelative() || cy().isRelative() ||
+ rx().isRelative() || ry().isRelative());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGEllipseElement.h b/WebCore/svg/SVGEllipseElement.h
new file mode 100644
index 0000000..01e8ef5
--- /dev/null
+++ b/WebCore/svg/SVGEllipseElement.h
@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGEllipseElement_h
+#define SVGEllipseElement_h
+
+#if ENABLE(SVG)
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTests.h"
+
+namespace WebCore {
+
+ class SVGEllipseElement : public SVGStyledTransformableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired {
+ public:
+ SVGEllipseElement(const QualifiedName&, Document*);
+ virtual ~SVGEllipseElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ virtual Path toPathData() const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+ virtual bool hasRelativeValues() const;
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGEllipseElement, SVGLength, SVGLength, Cx, cx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGEllipseElement, SVGLength, SVGLength, Cy, cy)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGEllipseElement, SVGLength, SVGLength, Rx, rx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGEllipseElement, SVGLength, SVGLength, Ry, ry)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGEllipseElement.idl b/WebCore/svg/SVGEllipseElement.idl
new file mode 100644
index 0000000..d3b2422
--- /dev/null
+++ b/WebCore/svg/SVGEllipseElement.idl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGEllipseElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable {
+ readonly attribute SVGAnimatedLength cx;
+ readonly attribute SVGAnimatedLength cy;
+ readonly attribute SVGAnimatedLength rx;
+ readonly attribute SVGAnimatedLength ry;
+ };
+
+}
diff --git a/WebCore/svg/SVGException.h b/WebCore/svg/SVGException.h
new file mode 100644
index 0000000..aa82e70
--- /dev/null
+++ b/WebCore/svg/SVGException.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SVGException_h
+#define SVGException_h
+
+#if ENABLE(SVG)
+
+#include "ExceptionBase.h"
+
+namespace WebCore {
+
+ class SVGException : public ExceptionBase {
+ public:
+ SVGException(const ExceptionCodeDescription& description)
+ : ExceptionBase(description)
+ {
+ }
+
+ static const int SVGExceptionOffset = 300;
+ static const int SVGExceptionMax = 399;
+
+ enum SVGExceptionCode {
+ SVG_WRONG_TYPE_ERR = SVGExceptionOffset,
+ SVG_INVALID_VALUE_ERR = SVGExceptionOffset + 1,
+ SVG_MATRIX_NOT_INVERTABLE = SVGExceptionOffset + 2
+ };
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+
+#endif // SVGException_h
diff --git a/WebCore/svg/SVGException.idl b/WebCore/svg/SVGException.idl
new file mode 100644
index 0000000..b7e97c7
--- /dev/null
+++ b/WebCore/svg/SVGException.idl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2007 Rob Buis <buis@kde.org>
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+module svg {
+
+ interface [
+ Conditional=SVG,
+ GenerateConstructor
+ ] SVGException {
+
+ readonly attribute unsigned short code;
+ readonly attribute DOMString name;
+ readonly attribute DOMString message;
+
+#if defined(LANGUAGE_JAVASCRIPT)
+ // Override in a Mozilla compatible format
+ [DontEnum] DOMString toString();
+#endif
+
+ // SVGExceptionCode
+ const unsigned short SVG_WRONG_TYPE_ERR = 0;
+ const unsigned short SVG_INVALID_VALUE_ERR = 1;
+ const unsigned short SVG_MATRIX_NOT_INVERTABLE = 2;
+ };
+}
diff --git a/WebCore/svg/SVGExternalResourcesRequired.cpp b/WebCore/svg/SVGExternalResourcesRequired.cpp
new file mode 100644
index 0000000..f6327e7
--- /dev/null
+++ b/WebCore/svg/SVGExternalResourcesRequired.cpp
@@ -0,0 +1,62 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGExternalResourcesRequired.h"
+
+#include "Attr.h"
+#include "SVGNames.h"
+#include "SVGElement.h"
+
+namespace WebCore {
+
+SVGExternalResourcesRequired::SVGExternalResourcesRequired()
+ : m_externalResourcesRequired(false)
+{
+}
+
+SVGExternalResourcesRequired::~SVGExternalResourcesRequired()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS_WITH_CONTEXT(SVGExternalResourcesRequired, bool, Boolean, boolean, ExternalResourcesRequired, externalResourcesRequired, SVGNames::externalResourcesRequiredAttr, m_externalResourcesRequired)
+
+bool SVGExternalResourcesRequired::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::externalResourcesRequiredAttr) {
+ setExternalResourcesRequiredBaseValue(attr->value() == "true");
+ return true;
+ }
+
+ return false;
+}
+
+bool SVGExternalResourcesRequired::isKnownAttribute(const QualifiedName& attrName)
+{
+ return attrName == SVGNames::externalResourcesRequiredAttr;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGExternalResourcesRequired.h b/WebCore/svg/SVGExternalResourcesRequired.h
new file mode 100644
index 0000000..4078794
--- /dev/null
+++ b/WebCore/svg/SVGExternalResourcesRequired.h
@@ -0,0 +1,62 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGExternalResourcesRequired_h
+#define SVGExternalResourcesRequired_h
+
+#if ENABLE(SVG)
+#include <wtf/RefPtr.h>
+#include "SVGElement.h"
+
+namespace WebCore {
+
+ class MappedAttribute;
+
+ // FIXME: This is wrong for several reasons:
+ // 1. externalResourcesRequired is not animateable according to SVG 1.1 section 5.9
+ // 2. externalResourcesRequired should just be part of SVGElement, and default to "false" for all elements
+ /*
+ SPEC: Note that the SVG DOM
+ defines the attribute externalResourcesRequired as being of type SVGAnimatedBoolean, whereas the
+ SVG language definition says that externalResourcesRequired is not animated. Because the SVG
+ language definition states that externalResourcesRequired cannot be animated, the animVal will
+ always be the same as the baseVal.
+ */
+ class SVGExternalResourcesRequired {
+ public:
+ SVGExternalResourcesRequired();
+ virtual ~SVGExternalResourcesRequired();
+
+ bool parseMappedAttribute(MappedAttribute*);
+ bool isKnownAttribute(const QualifiedName&);
+
+ protected:
+ virtual const SVGElement* contextElement() const = 0;
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS_WITH_CONTEXT(SVGExternalResourcesRequired, bool, bool, ExternalResourcesRequired, externalResourcesRequired)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGExternalResourcesRequired.idl b/WebCore/svg/SVGExternalResourcesRequired.idl
new file mode 100644
index 0000000..6600939
--- /dev/null
+++ b/WebCore/svg/SVGExternalResourcesRequired.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, ObjCProtocol] SVGExternalResourcesRequired {
+ readonly attribute SVGAnimatedBoolean externalResourcesRequired;
+ };
+
+}
diff --git a/WebCore/svg/SVGFEBlendElement.cpp b/WebCore/svg/SVGFEBlendElement.cpp
new file mode 100644
index 0000000..317b92b
--- /dev/null
+++ b/WebCore/svg/SVGFEBlendElement.cpp
@@ -0,0 +1,86 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEBlendElement.h"
+
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFEBlendElement::SVGFEBlendElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_mode(SVG_FEBLEND_MODE_NORMAL)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEBlendElement::~SVGFEBlendElement()
+{
+ delete m_filterEffect;
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEBlendElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEBlendElement, String, String, string, In2, in2, SVGNames::in2Attr, m_in2)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEBlendElement, int, Enumeration, enumeration, Mode, mode, SVGNames::modeAttr, m_mode)
+
+void SVGFEBlendElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::modeAttr) {
+ if (value == "normal")
+ setModeBaseValue(SVG_FEBLEND_MODE_NORMAL);
+ else if (value == "multiply")
+ setModeBaseValue(SVG_FEBLEND_MODE_MULTIPLY);
+ else if (value == "screen")
+ setModeBaseValue(SVG_FEBLEND_MODE_SCREEN);
+ else if (value == "darken")
+ setModeBaseValue(SVG_FEBLEND_MODE_DARKEN);
+ else if (value == "lighten")
+ setModeBaseValue(SVG_FEBLEND_MODE_LIGHTEN);
+ } else if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else if (attr->name() == SVGNames::in2Attr)
+ setIn2BaseValue(value);
+ else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFEBlend* SVGFEBlendElement::filterEffect(SVGResourceFilter* filter) const
+{
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFEBlend(filter);
+
+ m_filterEffect->setBlendMode((SVGBlendModeType) mode());
+ m_filterEffect->setIn(in1());
+ m_filterEffect->setIn2(in2());
+ setStandardAttributes(m_filterEffect);
+ return m_filterEffect;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEBlendElement.h b/WebCore/svg/SVGFEBlendElement.h
new file mode 100644
index 0000000..88d2e6f
--- /dev/null
+++ b/WebCore/svg/SVGFEBlendElement.h
@@ -0,0 +1,57 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEBlendElement_h
+#define SVGFEBlendElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEBlend.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore
+{
+ class SVGFEBlendElement : public SVGFilterPrimitiveStandardAttributes
+ {
+ public:
+ SVGFEBlendElement(const QualifiedName&, Document*);
+ virtual ~SVGFEBlendElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFEBlend* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEBlendElement, String, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEBlendElement, String, String, In2, in2)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEBlendElement, int, int, Mode, mode)
+
+ mutable SVGFEBlend* m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEBlendElement.idl b/WebCore/svg/SVGFEBlendElement.idl
new file mode 100644
index 0000000..b45b57f
--- /dev/null
+++ b/WebCore/svg/SVGFEBlendElement.idl
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS, GenerateConstructor] SVGFEBlendElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ // Blend Mode Types
+ const unsigned short SVG_FEBLEND_MODE_UNKNOWN = 0;
+ const unsigned short SVG_FEBLEND_MODE_NORMAL = 1;
+ const unsigned short SVG_FEBLEND_MODE_MULTIPLY = 2;
+ const unsigned short SVG_FEBLEND_MODE_SCREEN = 3;
+ const unsigned short SVG_FEBLEND_MODE_DARKEN = 4;
+ const unsigned short SVG_FEBLEND_MODE_LIGHTEN = 5;
+
+ readonly attribute SVGAnimatedString in1;
+ readonly attribute SVGAnimatedString in2;
+ readonly attribute SVGAnimatedEnumeration mode;
+ };
+
+}
diff --git a/WebCore/svg/SVGFEColorMatrixElement.cpp b/WebCore/svg/SVGFEColorMatrixElement.cpp
new file mode 100644
index 0000000..6a9474c
--- /dev/null
+++ b/WebCore/svg/SVGFEColorMatrixElement.cpp
@@ -0,0 +1,98 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEColorMatrixElement.h"
+
+#include "SVGNames.h"
+#include "SVGNumberList.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFEColorMatrixElement::SVGFEColorMatrixElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_type(SVG_FECOLORMATRIX_TYPE_UNKNOWN)
+ , m_values(new SVGNumberList(SVGNames::valuesAttr))
+ , m_filterEffect(0)
+{
+}
+
+SVGFEColorMatrixElement::~SVGFEColorMatrixElement()
+{
+ delete m_filterEffect;
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEColorMatrixElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEColorMatrixElement, int, Enumeration, enumeration, Type, type, SVGNames::typeAttr, m_type)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEColorMatrixElement, SVGNumberList*, NumberList, numberList, Values, values, SVGNames::valuesAttr, m_values.get())
+
+void SVGFEColorMatrixElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::typeAttr) {
+ if (value == "matrix")
+ setTypeBaseValue(SVG_FECOLORMATRIX_TYPE_MATRIX);
+ else if (value == "saturate")
+ setTypeBaseValue(SVG_FECOLORMATRIX_TYPE_SATURATE);
+ else if (value == "hueRotate")
+ setTypeBaseValue(SVG_FECOLORMATRIX_TYPE_HUEROTATE);
+ else if (value == "luminanceToAlpha")
+ setTypeBaseValue(SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA);
+ }
+ else if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else if (attr->name() == SVGNames::valuesAttr)
+ valuesBaseValue()->parse(value);
+ else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFEColorMatrix* SVGFEColorMatrixElement::filterEffect(SVGResourceFilter* filter) const
+{
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFEColorMatrix(filter);
+
+ m_filterEffect->setIn(in1());
+ setStandardAttributes(m_filterEffect);
+
+ Vector<float> _values;
+ SVGNumberList* numbers = values();
+
+ ExceptionCode ec = 0;
+ unsigned int nr = numbers->numberOfItems();
+ for (unsigned int i = 0;i < nr;i++)
+ _values.append(numbers->getItem(i, ec));
+
+ m_filterEffect->setValues(_values);
+ m_filterEffect->setType((SVGColorMatrixType) type());
+
+ return m_filterEffect;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEColorMatrixElement.h b/WebCore/svg/SVGFEColorMatrixElement.h
new file mode 100644
index 0000000..0015002
--- /dev/null
+++ b/WebCore/svg/SVGFEColorMatrixElement.h
@@ -0,0 +1,59 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEColorMatrixElement_h
+#define SVGFEColorMatrixElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEColorMatrix.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore
+{
+ class SVGNumberList;
+
+ class SVGFEColorMatrixElement : public SVGFilterPrimitiveStandardAttributes
+ {
+ public:
+ SVGFEColorMatrixElement(const QualifiedName&, Document*);
+ virtual ~SVGFEColorMatrixElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFEColorMatrix* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEColorMatrixElement, String, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEColorMatrixElement, int, int, Type, type)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEColorMatrixElement, SVGNumberList*, RefPtr<SVGNumberList>, Values, values)
+
+ mutable SVGFEColorMatrix* m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEColorMatrixElement.idl b/WebCore/svg/SVGFEColorMatrixElement.idl
new file mode 100644
index 0000000..ae0e293
--- /dev/null
+++ b/WebCore/svg/SVGFEColorMatrixElement.idl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS, GenerateConstructor] SVGFEColorMatrixElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ // Color Matrix Types
+ const unsigned short SVG_FECOLORMATRIX_TYPE_UNKNOWN = 0;
+ const unsigned short SVG_FECOLORMATRIX_TYPE_MATRIX = 1;
+ const unsigned short SVG_FECOLORMATRIX_TYPE_SATURATE = 2;
+ const unsigned short SVG_FECOLORMATRIX_TYPE_HUEROTATE = 3;
+ const unsigned short SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA = 4;
+
+ readonly attribute SVGAnimatedString in1;
+ readonly attribute SVGAnimatedEnumeration type;
+ readonly attribute SVGAnimatedNumberList values;
+ };
+
+}
diff --git a/WebCore/svg/SVGFEComponentTransferElement.cpp b/WebCore/svg/SVGFEComponentTransferElement.cpp
new file mode 100644
index 0000000..2e9ec2e
--- /dev/null
+++ b/WebCore/svg/SVGFEComponentTransferElement.cpp
@@ -0,0 +1,87 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEComponentTransferElement.h"
+
+#include "Attr.h"
+#include "SVGNames.h"
+#include "SVGRenderStyle.h"
+#include "SVGFEFuncRElement.h"
+#include "SVGFEFuncGElement.h"
+#include "SVGFEFuncBElement.h"
+#include "SVGFEFuncAElement.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFEComponentTransferElement::SVGFEComponentTransferElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEComponentTransferElement::~SVGFEComponentTransferElement()
+{
+ delete m_filterEffect;
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEComponentTransferElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
+
+void SVGFEComponentTransferElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFEComponentTransfer* SVGFEComponentTransferElement::filterEffect(SVGResourceFilter* filter) const
+{
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFEComponentTransfer(filter);
+
+ m_filterEffect->setIn(in1());
+ setStandardAttributes(m_filterEffect);
+
+ for (Node* n = firstChild(); n != 0; n = n->nextSibling()) {
+ if (n->hasTagName(SVGNames::feFuncRTag))
+ m_filterEffect->setRedFunction(static_cast<SVGFEFuncRElement*>(n)->transferFunction());
+ else if (n->hasTagName(SVGNames::feFuncGTag))
+ m_filterEffect->setGreenFunction(static_cast<SVGFEFuncGElement*>(n)->transferFunction());
+ else if (n->hasTagName(SVGNames::feFuncBTag))
+ m_filterEffect->setBlueFunction(static_cast<SVGFEFuncBElement*>(n)->transferFunction());
+ else if (n->hasTagName(SVGNames::feFuncATag))
+ m_filterEffect->setAlphaFunction(static_cast<SVGFEFuncAElement*>(n)->transferFunction());
+ }
+
+ return m_filterEffect;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEComponentTransferElement.h b/WebCore/svg/SVGFEComponentTransferElement.h
new file mode 100644
index 0000000..74827c5
--- /dev/null
+++ b/WebCore/svg/SVGFEComponentTransferElement.h
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEComponentTransferElement_h
+#define SVGFEComponentTransferElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterPrimitiveStandardAttributes.h"
+#include "SVGFEComponentTransfer.h"
+
+namespace WebCore
+{
+
+ class SVGFEComponentTransferElement : public SVGFilterPrimitiveStandardAttributes
+ {
+ public:
+ SVGFEComponentTransferElement(const QualifiedName&, Document*);
+ virtual ~SVGFEComponentTransferElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFEComponentTransfer* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEComponentTransferElement, String, String, In1, in1)
+
+ mutable SVGFEComponentTransfer *m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGFEComponentTransferElement.idl b/WebCore/svg/SVGFEComponentTransferElement.idl
new file mode 100644
index 0000000..783c9b7
--- /dev/null
+++ b/WebCore/svg/SVGFEComponentTransferElement.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEComponentTransferElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ readonly attribute SVGAnimatedString in1;
+ };
+
+}
diff --git a/WebCore/svg/SVGFECompositeElement.cpp b/WebCore/svg/SVGFECompositeElement.cpp
new file mode 100644
index 0000000..d21aeec
--- /dev/null
+++ b/WebCore/svg/SVGFECompositeElement.cpp
@@ -0,0 +1,111 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFECompositeElement.h"
+
+#include "SVGNames.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFECompositeElement::SVGFECompositeElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m__operator(SVG_FECOMPOSITE_OPERATOR_OVER)
+ , m_k1(0.0f)
+ , m_k2(0.0f)
+ , m_k3(0.0f)
+ , m_k4(0.0f)
+ , m_filterEffect(0)
+{
+}
+
+SVGFECompositeElement::~SVGFECompositeElement()
+{
+ delete m_filterEffect;
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, String, String, string, In2, in2, SVGNames::in2Attr, m_in2)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, int, Enumeration, enumeration, _operator, _operator, SVGNames::operatorAttr, m__operator)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, float, Number, number, K1, k1, SVGNames::k1Attr, m_k1)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, float, Number, number, K2, k2, SVGNames::k2Attr, m_k2)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, float, Number, number, K3, k3, SVGNames::k3Attr, m_k3)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, float, Number, number, K4, k4, SVGNames::k4Attr, m_k4)
+
+void SVGFECompositeElement::parseMappedAttribute(MappedAttribute *attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::operatorAttr) {
+ if (value == "over")
+ set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_OVER);
+ else if (value == "in")
+ set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_IN);
+ else if (value == "out")
+ set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_OUT);
+ else if (value == "atop")
+ set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_ATOP);
+ else if (value == "xor")
+ set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_XOR);
+ else if (value == "arithmetic")
+ set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_ARITHMETIC);
+ }
+ else if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else if (attr->name() == SVGNames::in2Attr)
+ setIn2BaseValue(value);
+ else if (attr->name() == SVGNames::k1Attr)
+ setK1BaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::k2Attr)
+ setK2BaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::k3Attr)
+ setK3BaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::k4Attr)
+ setK4BaseValue(value.toFloat());
+ else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFEComposite* SVGFECompositeElement::filterEffect(SVGResourceFilter* filter) const
+{
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFEComposite(filter);
+
+ m_filterEffect->setOperation((SVGCompositeOperationType) _operator());
+ m_filterEffect->setIn(in1());
+ m_filterEffect->setIn2(in2());
+ m_filterEffect->setK1(k1());
+ m_filterEffect->setK2(k2());
+ m_filterEffect->setK3(k3());
+ m_filterEffect->setK4(k4());
+
+ setStandardAttributes(m_filterEffect);
+ return m_filterEffect;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFECompositeElement.h b/WebCore/svg/SVGFECompositeElement.h
new file mode 100644
index 0000000..24fe6ae
--- /dev/null
+++ b/WebCore/svg/SVGFECompositeElement.h
@@ -0,0 +1,62 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFECompositeElement_h
+#define SVGFECompositeElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEComposite.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore
+{
+
+ class SVGFECompositeElement : public SVGFilterPrimitiveStandardAttributes
+ {
+ public:
+ SVGFECompositeElement(const QualifiedName&, Document*);
+ virtual ~SVGFECompositeElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFEComposite* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, String, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, String, String, In2, in2)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, int, int, _operator, _operator)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, float, float, K1, k1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, float, float, K2, k2)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, float, float, K3, k3)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, float, float, K4, k4)
+
+ mutable SVGFEComposite* m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFECompositeElement.idl b/WebCore/svg/SVGFECompositeElement.idl
new file mode 100644
index 0000000..01821e8
--- /dev/null
+++ b/WebCore/svg/SVGFECompositeElement.idl
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS, GenerateConstructor] SVGFECompositeElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ // Composite Operators
+ const unsigned short SVG_FECOMPOSITE_OPERATOR_UNKNOWN = 0;
+ const unsigned short SVG_FECOMPOSITE_OPERATOR_OVER = 1;
+ const unsigned short SVG_FECOMPOSITE_OPERATOR_IN = 2;
+ const unsigned short SVG_FECOMPOSITE_OPERATOR_OUT = 3;
+ const unsigned short SVG_FECOMPOSITE_OPERATOR_ATOP = 4;
+ const unsigned short SVG_FECOMPOSITE_OPERATOR_XOR = 5;
+ const unsigned short SVG_FECOMPOSITE_OPERATOR_ARITHMETIC = 6;
+
+ readonly attribute SVGAnimatedString in1;
+ readonly attribute SVGAnimatedString in2;
+ readonly attribute SVGAnimatedEnumeration _operator;
+ readonly attribute SVGAnimatedNumber k1;
+ readonly attribute SVGAnimatedNumber k2;
+ readonly attribute SVGAnimatedNumber k3;
+ readonly attribute SVGAnimatedNumber k4;
+ };
+
+}
diff --git a/WebCore/svg/SVGFEDiffuseLightingElement.cpp b/WebCore/svg/SVGFEDiffuseLightingElement.cpp
new file mode 100644
index 0000000..d1b3ebd
--- /dev/null
+++ b/WebCore/svg/SVGFEDiffuseLightingElement.cpp
@@ -0,0 +1,126 @@
+/*
+ Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEDiffuseLightingElement.h"
+
+#include "Attr.h"
+#include "RenderObject.h"
+#include "SVGColor.h"
+#include "SVGFELightElement.h"
+#include "SVGNames.h"
+#include "SVGParserUtilities.h"
+#include "SVGRenderStyle.h"
+#include "SVGFEDiffuseLighting.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFEDiffuseLightingElement::SVGFEDiffuseLightingElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_diffuseConstant(1.0f)
+ , m_surfaceScale(1.0f)
+ , m_kernelUnitLengthX(0.0f)
+ , m_kernelUnitLengthY(0.0f)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEDiffuseLightingElement::~SVGFEDiffuseLightingElement()
+{
+ delete m_filterEffect;
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEDiffuseLightingElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEDiffuseLightingElement, float, Number, number, DiffuseConstant, diffuseConstant, SVGNames::diffuseConstantAttr, m_diffuseConstant)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEDiffuseLightingElement, float, Number, number, SurfaceScale, surfaceScale, SVGNames::surfaceScaleAttr, m_surfaceScale)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEDiffuseLightingElement, float, Number, number, KernelUnitLengthX, kernelUnitLengthX, "kernelUnitLengthX", m_kernelUnitLengthX)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEDiffuseLightingElement, float, Number, number, KernelUnitLengthY, kernelUnitLengthY, "kernelUnitLengthY", m_kernelUnitLengthY)
+
+void SVGFEDiffuseLightingElement::parseMappedAttribute(MappedAttribute *attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else if (attr->name() == SVGNames::surfaceScaleAttr)
+ setSurfaceScaleBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::diffuseConstantAttr)
+ setDiffuseConstantBaseValue(value.toInt());
+ else if (attr->name() == SVGNames::kernelUnitLengthAttr) {
+ float x, y;
+ if (parseNumberOptionalNumber(value, x, y)) {
+ setKernelUnitLengthXBaseValue(x);
+ setKernelUnitLengthYBaseValue(y);
+ }
+ } else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFilterEffect* SVGFEDiffuseLightingElement::filterEffect(SVGResourceFilter* filter) const
+{
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFEDiffuseLighting(filter);
+
+ m_filterEffect->setIn(in1());
+ m_filterEffect->setDiffuseConstant(diffuseConstant());
+ m_filterEffect->setSurfaceScale(surfaceScale());
+ m_filterEffect->setKernelUnitLengthX(kernelUnitLengthX());
+ m_filterEffect->setKernelUnitLengthY(kernelUnitLengthY());
+
+ SVGFEDiffuseLightingElement* nonConstThis = const_cast<SVGFEDiffuseLightingElement*>(this);
+
+ RenderStyle* parentStyle = nonConstThis->styleForRenderer(parent()->renderer());
+ RenderStyle* filterStyle = nonConstThis->resolveStyle(parentStyle);
+
+ m_filterEffect->setLightingColor(filterStyle->svgStyle()->lightingColor());
+ setStandardAttributes(m_filterEffect);
+
+ parentStyle->deref(document()->renderArena());
+ filterStyle->deref(document()->renderArena());
+
+ updateLights();
+ return m_filterEffect;
+}
+
+void SVGFEDiffuseLightingElement::updateLights() const
+{
+ if (!m_filterEffect)
+ return;
+
+ SVGLightSource* light = 0;
+ for (Node* n = firstChild(); n; n = n->nextSibling()) {
+ if (n->hasTagName(SVGNames::feDistantLightTag) ||
+ n->hasTagName(SVGNames::fePointLightTag) ||
+ n->hasTagName(SVGNames::feSpotLightTag)) {
+ SVGFELightElement* lightNode = static_cast<SVGFELightElement*>(n);
+ light = lightNode->lightSource();
+ break;
+ }
+ }
+
+ m_filterEffect->setLightSource(light);
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEDiffuseLightingElement.h b/WebCore/svg/SVGFEDiffuseLightingElement.h
new file mode 100644
index 0000000..4d038b3
--- /dev/null
+++ b/WebCore/svg/SVGFEDiffuseLightingElement.h
@@ -0,0 +1,59 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Oliver Hunt <oliver@nerget.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGFEDiffuseLightingElement_h
+#define SVGFEDiffuseLightingElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore {
+ class SVGFEDiffuseLighting;
+ class SVGColor;
+
+ class SVGFEDiffuseLightingElement : public SVGFilterPrimitiveStandardAttributes
+ {
+ public:
+ SVGFEDiffuseLightingElement(const QualifiedName&, Document*);
+ virtual ~SVGFEDiffuseLightingElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDiffuseLightingElement, String, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDiffuseLightingElement, float, float, DiffuseConstant, diffuseConstant)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDiffuseLightingElement, float, float, SurfaceScale, surfaceScale)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDiffuseLightingElement, float, float, KernelUnitLengthX, kernelUnitLengthX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDiffuseLightingElement, float, float, KernelUnitLengthY, kernelUnitLengthY)
+
+ mutable SVGFEDiffuseLighting* m_filterEffect;
+
+ void updateLights() const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGFEDiffuseLightingElement.idl b/WebCore/svg/SVGFEDiffuseLightingElement.idl
new file mode 100644
index 0000000..ca54f8b
--- /dev/null
+++ b/WebCore/svg/SVGFEDiffuseLightingElement.idl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEDiffuseLightingElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ readonly attribute SVGAnimatedString in1;
+ readonly attribute SVGAnimatedNumber surfaceScale;
+ readonly attribute SVGAnimatedNumber diffuseConstant;
+ readonly attribute SVGAnimatedNumber kernelUnitLengthX;
+ readonly attribute SVGAnimatedNumber kernelUnitLengthY;
+ };
+
+}
diff --git a/WebCore/svg/SVGFEDisplacementMapElement.cpp b/WebCore/svg/SVGFEDisplacementMapElement.cpp
new file mode 100644
index 0000000..8852a65
--- /dev/null
+++ b/WebCore/svg/SVGFEDisplacementMapElement.cpp
@@ -0,0 +1,100 @@
+/*
+ Copyright (C) 2006 Oliver Hunt <oliver@nerget.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEDisplacementMapElement.h"
+
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFEDisplacementMapElement::SVGFEDisplacementMapElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_xChannelSelector(SVG_CHANNEL_A)
+ , m_yChannelSelector(SVG_CHANNEL_A)
+ , m_scale(0.0f)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEDisplacementMapElement::~SVGFEDisplacementMapElement()
+{
+ delete m_filterEffect;
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, String, String, string, In2, in2, SVGNames::in2Attr, m_in2)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, int, Enumeration, enumeration, XChannelSelector, xChannelSelector, SVGNames::xChannelSelectorAttr, m_xChannelSelector)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, int, Enumeration, enumeration, YChannelSelector, yChannelSelector, SVGNames::yChannelSelectorAttr, m_yChannelSelector)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, float, Number, number, Scale, scale, SVGNames::scaleAttr, m_scale)
+
+SVGChannelSelectorType SVGFEDisplacementMapElement::stringToChannel(const String& key)
+{
+ if (key == "R")
+ return SVG_CHANNEL_R;
+ else if (key == "G")
+ return SVG_CHANNEL_G;
+ else if (key == "B")
+ return SVG_CHANNEL_B;
+ else if (key == "A")
+ return SVG_CHANNEL_A;
+
+ return SVG_CHANNEL_UNKNOWN;
+}
+
+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);
+}
+
+SVGFEDisplacementMap* SVGFEDisplacementMapElement::filterEffect(SVGResourceFilter* filter) const
+{
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFEDisplacementMap(filter);
+
+ m_filterEffect->setXChannelSelector((SVGChannelSelectorType) xChannelSelector());
+ m_filterEffect->setYChannelSelector((SVGChannelSelectorType) yChannelSelector());
+ m_filterEffect->setIn(in1());
+ m_filterEffect->setIn2(in2());
+ m_filterEffect->setScale(scale());
+
+ setStandardAttributes(m_filterEffect);
+ return m_filterEffect;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEDisplacementMapElement.h b/WebCore/svg/SVGFEDisplacementMapElement.h
new file mode 100644
index 0000000..7f6a109
--- /dev/null
+++ b/WebCore/svg/SVGFEDisplacementMapElement.h
@@ -0,0 +1,55 @@
+/*
+ Copyright (C) 2006 Oliver Hunt <oliver@nerget.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGFEDisplacementMapElement_h
+#define SVGFEDisplacementMapElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEDisplacementMap.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore {
+
+ class SVGFEDisplacementMapElement : public SVGFilterPrimitiveStandardAttributes {
+ public:
+ SVGFEDisplacementMapElement(const QualifiedName& tagName, Document*);
+ virtual ~SVGFEDisplacementMapElement();
+
+ static SVGChannelSelectorType stringToChannel(const String&);
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFEDisplacementMap* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDisplacementMapElement, String, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDisplacementMapElement, String, String, In2, in2)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDisplacementMapElement, int, int, XChannelSelector, xChannelSelector)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDisplacementMapElement, int, int, YChannelSelector, yChannelSelector)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDisplacementMapElement, float, float, Scale, scale)
+
+ mutable SVGFEDisplacementMap* m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGFEDisplacementMapElement_h
diff --git a/WebCore/svg/SVGFEDisplacementMapElement.idl b/WebCore/svg/SVGFEDisplacementMapElement.idl
new file mode 100644
index 0000000..d819794
--- /dev/null
+++ b/WebCore/svg/SVGFEDisplacementMapElement.idl
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS, GenerateConstructor] SVGFEDisplacementMapElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ // Channel Selectors
+ const unsigned short SVG_CHANNEL_UNKNOWN = 0;
+ const unsigned short SVG_CHANNEL_R = 1;
+ const unsigned short SVG_CHANNEL_G = 2;
+ const unsigned short SVG_CHANNEL_B = 3;
+ const unsigned short SVG_CHANNEL_A = 4;
+
+ readonly attribute SVGAnimatedString in1;
+ readonly attribute SVGAnimatedString in2;
+ readonly attribute SVGAnimatedNumber scale;
+ readonly attribute SVGAnimatedEnumeration xChannelSelector;
+ readonly attribute SVGAnimatedEnumeration yChannelSelector;
+ };
+
+}
diff --git a/WebCore/svg/SVGFEDistantLightElement.cpp b/WebCore/svg/SVGFEDistantLightElement.cpp
new file mode 100644
index 0000000..e45b447
--- /dev/null
+++ b/WebCore/svg/SVGFEDistantLightElement.cpp
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEDistantLightElement.h"
+#include "SVGDistantLightSource.h"
+
+namespace WebCore {
+
+SVGFEDistantLightElement::SVGFEDistantLightElement(const QualifiedName& tagName, Document* doc)
+ : SVGFELightElement(tagName, doc)
+{
+}
+
+SVGFEDistantLightElement::~SVGFEDistantLightElement()
+{
+}
+
+SVGLightSource* SVGFEDistantLightElement::lightSource() const
+{
+ return new SVGDistantLightSource(azimuth(), elevation());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFEDistantLightElement.h b/WebCore/svg/SVGFEDistantLightElement.h
new file mode 100644
index 0000000..fd51e08
--- /dev/null
+++ b/WebCore/svg/SVGFEDistantLightElement.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGFEDistantLightElement_h
+#define SVGFEDistantLightElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFELightElement.h"
+
+namespace WebCore
+{
+ class SVGFEDistantLightElement : public SVGFELightElement
+ {
+ public:
+ SVGFEDistantLightElement(const QualifiedName&, Document*);
+ virtual ~SVGFEDistantLightElement();
+
+ virtual SVGLightSource* lightSource() const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGFEDistantLightElement.idl b/WebCore/svg/SVGFEDistantLightElement.idl
new file mode 100644
index 0000000..8bd6067
--- /dev/null
+++ b/WebCore/svg/SVGFEDistantLightElement.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEDistantLightElement : SVGElement {
+ readonly attribute SVGAnimatedNumber azimuth;
+ readonly attribute SVGAnimatedNumber elevation;
+ };
+
+}
diff --git a/WebCore/svg/SVGFEFloodElement.cpp b/WebCore/svg/SVGFEFloodElement.cpp
new file mode 100644
index 0000000..e9eff9d
--- /dev/null
+++ b/WebCore/svg/SVGFEFloodElement.cpp
@@ -0,0 +1,84 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEFloodElement.h"
+
+#include "Attr.h"
+#include "RenderStyle.h"
+#include "SVGNames.h"
+#include "SVGRenderStyle.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFEFloodElement::SVGFEFloodElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEFloodElement::~SVGFEFloodElement()
+{
+ delete m_filterEffect;
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEFloodElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
+
+void SVGFEFloodElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFEFlood* SVGFEFloodElement::filterEffect(SVGResourceFilter* filter) const
+{
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFEFlood(filter);
+
+ m_filterEffect->setIn(in1());
+ setStandardAttributes(m_filterEffect);
+
+ SVGFEFloodElement* nonConstThis = const_cast<SVGFEFloodElement*>(this);
+
+ RenderStyle* parentStyle = nonConstThis->styleForRenderer(parent()->renderer());
+ RenderStyle* filterStyle = nonConstThis->resolveStyle(parentStyle);
+
+ m_filterEffect->setFloodColor(filterStyle->svgStyle()->floodColor());
+ m_filterEffect->setFloodOpacity(filterStyle->svgStyle()->floodOpacity());
+
+ parentStyle->deref(document()->renderArena());
+ filterStyle->deref(document()->renderArena());
+
+ return m_filterEffect;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEFloodElement.h b/WebCore/svg/SVGFEFloodElement.h
new file mode 100644
index 0000000..9094d5e
--- /dev/null
+++ b/WebCore/svg/SVGFEFloodElement.h
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEFloodElement_h
+#define SVGFEFloodElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterPrimitiveStandardAttributes.h"
+#include "SVGFEFlood.h"
+
+namespace WebCore
+{
+ class SVGFEFloodElement : public SVGFilterPrimitiveStandardAttributes
+ {
+ public:
+ SVGFEFloodElement(const QualifiedName&, Document*);
+ virtual ~SVGFEFloodElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFEFlood* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEFloodElement, String, String, In1, in1)
+
+ mutable SVGFEFlood *m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGFEFloodElement.idl b/WebCore/svg/SVGFEFloodElement.idl
new file mode 100644
index 0000000..406c275
--- /dev/null
+++ b/WebCore/svg/SVGFEFloodElement.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEFloodElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ readonly attribute SVGAnimatedString in1;
+ };
+
+}
diff --git a/WebCore/svg/SVGFEFuncAElement.cpp b/WebCore/svg/SVGFEFuncAElement.cpp
new file mode 100644
index 0000000..595e2e6
--- /dev/null
+++ b/WebCore/svg/SVGFEFuncAElement.cpp
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEFuncAElement.h"
+
+namespace WebCore {
+
+SVGFEFuncAElement::SVGFEFuncAElement(const QualifiedName& tagName, Document* doc)
+ : SVGComponentTransferFunctionElement(tagName, doc)
+{
+}
+
+SVGFEFuncAElement::~SVGFEFuncAElement()
+{
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEFuncAElement.h b/WebCore/svg/SVGFEFuncAElement.h
new file mode 100644
index 0000000..3fd6816
--- /dev/null
+++ b/WebCore/svg/SVGFEFuncAElement.h
@@ -0,0 +1,41 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEFuncAElement_h
+#define SVGFEFuncAElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGComponentTransferFunctionElement.h"
+
+namespace WebCore
+{
+ class SVGFEFuncAElement : public SVGComponentTransferFunctionElement
+ {
+ public:
+ SVGFEFuncAElement(const QualifiedName&, Document*);
+ virtual ~SVGFEFuncAElement();
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGFEFuncAElement.idl b/WebCore/svg/SVGFEFuncAElement.idl
new file mode 100644
index 0000000..7675f7d
--- /dev/null
+++ b/WebCore/svg/SVGFEFuncAElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEFuncAElement : SVGComponentTransferFunctionElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGFEFuncBElement.cpp b/WebCore/svg/SVGFEFuncBElement.cpp
new file mode 100644
index 0000000..de6cb88
--- /dev/null
+++ b/WebCore/svg/SVGFEFuncBElement.cpp
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEFuncBElement.h"
+
+namespace WebCore {
+
+SVGFEFuncBElement::SVGFEFuncBElement(const QualifiedName& tagName, Document *doc)
+ : SVGComponentTransferFunctionElement(tagName, doc)
+{
+}
+
+SVGFEFuncBElement::~SVGFEFuncBElement()
+{
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEFuncBElement.h b/WebCore/svg/SVGFEFuncBElement.h
new file mode 100644
index 0000000..2dd9615
--- /dev/null
+++ b/WebCore/svg/SVGFEFuncBElement.h
@@ -0,0 +1,41 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEFuncBElement_h
+#define SVGFEFuncBElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGComponentTransferFunctionElement.h"
+
+namespace WebCore
+{
+ class SVGFEFuncBElement : public SVGComponentTransferFunctionElement
+ {
+ public:
+ SVGFEFuncBElement(const QualifiedName&, Document*);
+ virtual ~SVGFEFuncBElement();
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGFEFuncBElement.idl b/WebCore/svg/SVGFEFuncBElement.idl
new file mode 100644
index 0000000..7717f6a
--- /dev/null
+++ b/WebCore/svg/SVGFEFuncBElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEFuncBElement : SVGComponentTransferFunctionElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGFEFuncGElement.cpp b/WebCore/svg/SVGFEFuncGElement.cpp
new file mode 100644
index 0000000..958f547
--- /dev/null
+++ b/WebCore/svg/SVGFEFuncGElement.cpp
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEFuncGElement.h"
+
+namespace WebCore {
+
+SVGFEFuncGElement::SVGFEFuncGElement(const QualifiedName& tagName, Document* doc)
+ : SVGComponentTransferFunctionElement(tagName, doc)
+{
+}
+
+SVGFEFuncGElement::~SVGFEFuncGElement()
+{
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEFuncGElement.h b/WebCore/svg/SVGFEFuncGElement.h
new file mode 100644
index 0000000..8f1c368
--- /dev/null
+++ b/WebCore/svg/SVGFEFuncGElement.h
@@ -0,0 +1,41 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEFuncGElement_h
+#define SVGFEFuncGElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGComponentTransferFunctionElement.h"
+
+namespace WebCore
+{
+ class SVGFEFuncGElement : public SVGComponentTransferFunctionElement
+ {
+ public:
+ SVGFEFuncGElement(const QualifiedName&, Document*);
+ virtual ~SVGFEFuncGElement();
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGFEFuncGElement.idl b/WebCore/svg/SVGFEFuncGElement.idl
new file mode 100644
index 0000000..1ec24fa
--- /dev/null
+++ b/WebCore/svg/SVGFEFuncGElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEFuncGElement : SVGComponentTransferFunctionElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGFEFuncRElement.cpp b/WebCore/svg/SVGFEFuncRElement.cpp
new file mode 100644
index 0000000..e376781
--- /dev/null
+++ b/WebCore/svg/SVGFEFuncRElement.cpp
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEFuncRElement.h"
+
+namespace WebCore {
+
+SVGFEFuncRElement::SVGFEFuncRElement(const QualifiedName& tagName, Document* doc)
+ : SVGComponentTransferFunctionElement(tagName, doc)
+{
+}
+
+SVGFEFuncRElement::~SVGFEFuncRElement()
+{
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEFuncRElement.h b/WebCore/svg/SVGFEFuncRElement.h
new file mode 100644
index 0000000..4921488
--- /dev/null
+++ b/WebCore/svg/SVGFEFuncRElement.h
@@ -0,0 +1,41 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEFuncRElement_h
+#define SVGFEFuncRElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGComponentTransferFunctionElement.h"
+
+namespace WebCore
+{
+ class SVGFEFuncRElement : public SVGComponentTransferFunctionElement
+ {
+ public:
+ SVGFEFuncRElement(const QualifiedName&, Document*);
+ virtual ~SVGFEFuncRElement();
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGFEFuncRElement.idl b/WebCore/svg/SVGFEFuncRElement.idl
new file mode 100644
index 0000000..0a6ac30
--- /dev/null
+++ b/WebCore/svg/SVGFEFuncRElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEFuncRElement : SVGComponentTransferFunctionElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGFEGaussianBlurElement.cpp b/WebCore/svg/SVGFEGaussianBlurElement.cpp
new file mode 100644
index 0000000..e6d0b39
--- /dev/null
+++ b/WebCore/svg/SVGFEGaussianBlurElement.cpp
@@ -0,0 +1,87 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEGaussianBlurElement.h"
+
+#include "SVGNames.h"
+#include "SVGParserUtilities.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFEGaussianBlurElement::SVGFEGaussianBlurElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_stdDeviationX(0.0f)
+ , m_stdDeviationY(0.0f)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEGaussianBlurElement::~SVGFEGaussianBlurElement()
+{
+ delete m_filterEffect;
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEGaussianBlurElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEGaussianBlurElement, float, Number, number, StdDeviationX, stdDeviationX, "stdDeviationX", m_stdDeviationX)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEGaussianBlurElement, float, Number, number, StdDeviationY, stdDeviationY, "stdDeviationY", m_stdDeviationY)
+
+void SVGFEGaussianBlurElement::setStdDeviation(float stdDeviationX, float stdDeviationY)
+{
+}
+
+void SVGFEGaussianBlurElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::stdDeviationAttr) {
+ float x, y;
+ if (parseNumberOptionalNumber(value, x, y)) {
+ setStdDeviationXBaseValue(x);
+ setStdDeviationYBaseValue(y);
+ }
+ } else if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFEGaussianBlur* SVGFEGaussianBlurElement::filterEffect(SVGResourceFilter* filter) const
+{
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFEGaussianBlur(filter);
+
+ m_filterEffect->setIn(in1());
+ m_filterEffect->setStdDeviationX(stdDeviationX());
+ m_filterEffect->setStdDeviationY(stdDeviationY());
+
+ setStandardAttributes(m_filterEffect);
+ return m_filterEffect;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEGaussianBlurElement.h b/WebCore/svg/SVGFEGaussianBlurElement.h
new file mode 100644
index 0000000..c1e9292
--- /dev/null
+++ b/WebCore/svg/SVGFEGaussianBlurElement.h
@@ -0,0 +1,60 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEGaussianBlurElement_h
+#define SVGFEGaussianBlurElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEGaussianBlur.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore
+{
+
+ class SVGFEGaussianBlurElement : public SVGFilterPrimitiveStandardAttributes
+ {
+ public:
+ SVGFEGaussianBlurElement(const QualifiedName&, Document*);
+ virtual ~SVGFEGaussianBlurElement();
+
+ void setStdDeviation(float stdDeviationX, float stdDeviationY);
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFEGaussianBlur* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEGaussianBlurElement, String, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEGaussianBlurElement, float, float, StdDeviationX, stdDeviationX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEGaussianBlurElement, float, float, StdDeviationY, stdDeviationY)
+
+ mutable SVGFEGaussianBlur* m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEGaussianBlurElement.idl b/WebCore/svg/SVGFEGaussianBlurElement.idl
new file mode 100644
index 0000000..7dc7526
--- /dev/null
+++ b/WebCore/svg/SVGFEGaussianBlurElement.idl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEGaussianBlurElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ readonly attribute SVGAnimatedString in1;
+ readonly attribute SVGAnimatedNumber stdDeviationX;
+ readonly attribute SVGAnimatedNumber stdDeviationY;
+
+ void setStdDeviation(in float stdDeviationX, in float stdDeviationY);
+ };
+
+}
diff --git a/WebCore/svg/SVGFEImageElement.cpp b/WebCore/svg/SVGFEImageElement.cpp
new file mode 100644
index 0000000..6ff83ee
--- /dev/null
+++ b/WebCore/svg/SVGFEImageElement.cpp
@@ -0,0 +1,110 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEImageElement.h"
+
+#include "Attr.h"
+#include "CachedImage.h"
+#include "DocLoader.h"
+#include "Document.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+#include "SVGPreserveAspectRatio.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFEImageElement::SVGFEImageElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , SVGURIReference()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_preserveAspectRatio(new SVGPreserveAspectRatio())
+ , m_cachedImage(0)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEImageElement::~SVGFEImageElement()
+{
+ delete m_filterEffect;
+ if (m_cachedImage)
+ m_cachedImage->deref(this);
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEImageElement, SVGPreserveAspectRatio*, PreserveAspectRatio, preserveAspectRatio, PreserveAspectRatio, preserveAspectRatio, SVGNames::preserveAspectRatioAttr, m_preserveAspectRatio.get())
+
+void SVGFEImageElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::preserveAspectRatioAttr) {
+ const UChar* c = value.characters();
+ const UChar* end = c + value.length();
+ preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
+ } else {
+ if (SVGURIReference::parseMappedAttribute(attr)) {
+ if (!href().startsWith("#")) {
+ // FIXME: this code needs to special-case url fragments and later look them up using getElementById instead of loading them here
+ if (m_cachedImage)
+ m_cachedImage->deref(this);
+ m_cachedImage = ownerDocument()->docLoader()->requestImage(href());
+ if (m_cachedImage)
+ m_cachedImage->ref(this);
+ }
+ return;
+ }
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+ }
+}
+
+void SVGFEImageElement::notifyFinished(CachedResource* finishedObj)
+{
+ if (finishedObj == m_cachedImage && m_filterEffect)
+ m_filterEffect->setCachedImage(m_cachedImage);
+}
+
+SVGFEImage* SVGFEImageElement::filterEffect(SVGResourceFilter* filter) const
+{
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFEImage(filter);
+
+ // The resource may already be loaded!
+ if (m_cachedImage)
+ m_filterEffect->setCachedImage(m_cachedImage);
+
+ setStandardAttributes(m_filterEffect);
+ return m_filterEffect;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEImageElement.h b/WebCore/svg/SVGFEImageElement.h
new file mode 100644
index 0000000..1488a64
--- /dev/null
+++ b/WebCore/svg/SVGFEImageElement.h
@@ -0,0 +1,70 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEImageElement_h
+#define SVGFEImageElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterPrimitiveStandardAttributes.h"
+#include "SVGURIReference.h"
+#include "SVGLangSpace.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGFEImage.h"
+
+namespace WebCore {
+ class SVGPreserveAspectRatio;
+
+ class SVGFEImageElement : public SVGFilterPrimitiveStandardAttributes,
+ public SVGURIReference,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired,
+ public CachedResourceClient
+ {
+ public:
+ SVGFEImageElement(const QualifiedName&, Document*);
+ virtual ~SVGFEImageElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void notifyFinished(CachedResource*);
+
+ protected:
+ virtual SVGFEImage* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEImageElement, SVGPreserveAspectRatio*, RefPtr<SVGPreserveAspectRatio>, PreserveAspectRatio, preserveAspectRatio)
+
+ CachedImage* m_cachedImage;
+ mutable SVGFEImage* m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEImageElement.idl b/WebCore/svg/SVGFEImageElement.idl
new file mode 100644
index 0000000..c9ee669
--- /dev/null
+++ b/WebCore/svg/SVGFEImageElement.idl
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEImageElement : SVGElement,
+ SVGURIReference,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGFilterPrimitiveStandardAttributes {
+ };
+
+}
diff --git a/WebCore/svg/SVGFELightElement.cpp b/WebCore/svg/SVGFELightElement.cpp
new file mode 100644
index 0000000..52c0287
--- /dev/null
+++ b/WebCore/svg/SVGFELightElement.cpp
@@ -0,0 +1,93 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ 2005 Oliver Hunt <oliver@nerget.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFELightElement.h"
+
+#include "SVGNames.h"
+
+namespace WebCore {
+
+SVGFELightElement::SVGFELightElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+ , m_azimuth(0.0f)
+ , m_elevation(0.0f)
+ , m_x(0.0f)
+ , m_y(0.0f)
+ , m_z(0.0f)
+ , m_pointsAtX(0.0f)
+ , m_pointsAtY(0.0f)
+ , m_pointsAtZ(0.0f)
+ , m_specularExponent(1.0f)
+ , m_limitingConeAngle(0.0f)
+{
+}
+
+SVGFELightElement::~SVGFELightElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFELightElement, float, Number, number, Azimuth, azimuth, SVGNames::azimuthAttr, m_azimuth)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFELightElement, float, Number, number, Elevation, elevation, SVGNames::elevationAttr, m_elevation)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFELightElement, float, Number, number, X, x, SVGNames::xAttr, m_x)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFELightElement, float, Number, number, Y, y, SVGNames::yAttr, m_y)
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFELightElement, float, Number, number, Z, z, SVGNames::zAttr, m_z)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFELightElement, float, Number, number, PointsAtX, pointsAtX, SVGNames::pointsAtXAttr, m_pointsAtX)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFELightElement, float, Number, number, PointsAtY, pointsAtY, SVGNames::pointsAtYAttr, m_pointsAtY)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFELightElement, float, Number, number, PointsAtZ, pointsAtZ, SVGNames::pointsAtZAttr, m_pointsAtZ)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFELightElement, float, Number, number, SpecularExponent, specularExponent, SVGNames::specularExponentAttr, m_specularExponent)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFELightElement, float, Number, number, LimitingConeAngle, limitingConeAngle, SVGNames::limitingConeAngleAttr, m_limitingConeAngle)
+
+void SVGFELightElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::azimuthAttr)
+ setAzimuthBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::elevationAttr)
+ setElevationBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::xAttr)
+ setXBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::zAttr)
+ setZBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::pointsAtXAttr)
+ setPointsAtXBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::pointsAtYAttr)
+ setPointsAtYBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::pointsAtZAttr)
+ setPointsAtZBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::specularExponentAttr)
+ setSpecularExponentBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::limitingConeAngleAttr)
+ setLimitingConeAngleBaseValue(value.toFloat());
+ else
+ SVGElement::parseMappedAttribute(attr);
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFELightElement.h b/WebCore/svg/SVGFELightElement.h
new file mode 100644
index 0000000..e0b28e7
--- /dev/null
+++ b/WebCore/svg/SVGFELightElement.h
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ 2005 Oliver Hunt <oliver@nerget.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGFELightElement_h
+#define SVGFELightElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGElement.h"
+#include "SVGLightSource.h"
+
+namespace WebCore
+{
+ class SVGNumberList;
+
+ class SVGFELightElement : public SVGElement
+ {
+ public:
+ SVGFELightElement(const QualifiedName&, Document*);
+ virtual ~SVGFELightElement();
+
+ virtual SVGLightSource* lightSource() const = 0;
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, float, float, Azimuth, azimuth)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, float, float, Elevation, elevation)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, float, float, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, float, float, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, float, float, Z, z)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, float, float, PointsAtX, pointsAtX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, float, float, PointsAtY, pointsAtY)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, float, float, PointsAtZ, pointsAtZ)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, float, float, SpecularExponent, specularExponent)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, float, float, LimitingConeAngle, limitingConeAngle)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#endif
diff --git a/WebCore/svg/SVGFEMergeElement.cpp b/WebCore/svg/SVGFEMergeElement.cpp
new file mode 100644
index 0000000..7c7fd75
--- /dev/null
+++ b/WebCore/svg/SVGFEMergeElement.cpp
@@ -0,0 +1,64 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEMergeElement.h"
+
+#include "SVGFEMergeNodeElement.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFEMergeElement::SVGFEMergeElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEMergeElement::~SVGFEMergeElement()
+{
+ delete m_filterEffect;
+}
+
+SVGFEMerge* SVGFEMergeElement::filterEffect(SVGResourceFilter* filter) const
+{
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFEMerge(filter);
+ setStandardAttributes(m_filterEffect);
+
+ Vector<String> mergeInputs;
+ for (Node* n = firstChild(); n != 0; n = n->nextSibling()) {
+ if (n->hasTagName(SVGNames::feMergeNodeTag))
+ mergeInputs.append(static_cast<SVGFEMergeNodeElement*>(n)->in1());
+ }
+
+ m_filterEffect->setMergeInputs(mergeInputs);
+ return m_filterEffect;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEMergeElement.h b/WebCore/svg/SVGFEMergeElement.h
new file mode 100644
index 0000000..59898bb
--- /dev/null
+++ b/WebCore/svg/SVGFEMergeElement.h
@@ -0,0 +1,50 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEMergeElement_h
+#define SVGFEMergeElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEMerge.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore
+{
+ class SVGFEMergeElement : public SVGFilterPrimitiveStandardAttributes
+ {
+ public:
+ SVGFEMergeElement(const QualifiedName&, Document*);
+ virtual ~SVGFEMergeElement();
+
+ virtual SVGFEMerge* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ mutable SVGFEMerge* m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGFEMergeElement.idl b/WebCore/svg/SVGFEMergeElement.idl
new file mode 100644
index 0000000..6cec2fc
--- /dev/null
+++ b/WebCore/svg/SVGFEMergeElement.idl
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEMergeElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ };
+
+}
diff --git a/WebCore/svg/SVGFEMergeNodeElement.cpp b/WebCore/svg/SVGFEMergeNodeElement.cpp
new file mode 100644
index 0000000..d46ee25
--- /dev/null
+++ b/WebCore/svg/SVGFEMergeNodeElement.cpp
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEMergeNodeElement.h"
+
+namespace WebCore {
+
+SVGFEMergeNodeElement::SVGFEMergeNodeElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+{
+}
+
+SVGFEMergeNodeElement::~SVGFEMergeNodeElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEMergeNodeElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
+
+void SVGFEMergeNodeElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else
+ SVGElement::parseMappedAttribute(attr);
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEMergeNodeElement.h b/WebCore/svg/SVGFEMergeNodeElement.h
new file mode 100644
index 0000000..c601fde
--- /dev/null
+++ b/WebCore/svg/SVGFEMergeNodeElement.h
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEMergeNodeElement_h
+#define SVGFEMergeNodeElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGElement.h"
+
+namespace WebCore
+{
+ class SVGFEMergeNodeElement : public SVGElement
+ {
+ public:
+ SVGFEMergeNodeElement(const QualifiedName&, Document*);
+ virtual ~SVGFEMergeNodeElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEMergeNodeElement, String, String, In1, in1)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEMergeNodeElement.idl b/WebCore/svg/SVGFEMergeNodeElement.idl
new file mode 100644
index 0000000..f385755
--- /dev/null
+++ b/WebCore/svg/SVGFEMergeNodeElement.idl
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEMergeNodeElement : SVGElement {
+ readonly attribute SVGAnimatedString in1;
+ };
+
+}
diff --git a/WebCore/svg/SVGFEOffsetElement.cpp b/WebCore/svg/SVGFEOffsetElement.cpp
new file mode 100644
index 0000000..1442159
--- /dev/null
+++ b/WebCore/svg/SVGFEOffsetElement.cpp
@@ -0,0 +1,80 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEOffsetElement.h"
+
+#include "Attr.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFEOffsetElement::SVGFEOffsetElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_dx(0.0f)
+ , m_dy(0.0f)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEOffsetElement::~SVGFEOffsetElement()
+{
+ delete m_filterEffect;
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEOffsetElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEOffsetElement, float, Number, number, Dx, dx, SVGNames::dxAttr, m_dx)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFEOffsetElement, float, Number, number, Dy, dy, SVGNames::dyAttr, m_dy)
+
+void SVGFEOffsetElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::dxAttr)
+ setDxBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::dyAttr)
+ setDyBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFEOffset* SVGFEOffsetElement::filterEffect(SVGResourceFilter* filter) const
+{
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFEOffset(filter);
+
+ m_filterEffect->setIn(in1());
+ m_filterEffect->setDx(dx());
+ m_filterEffect->setDy(dy());
+
+ setStandardAttributes(m_filterEffect);
+ return m_filterEffect;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEOffsetElement.h b/WebCore/svg/SVGFEOffsetElement.h
new file mode 100644
index 0000000..01ee9ea
--- /dev/null
+++ b/WebCore/svg/SVGFEOffsetElement.h
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEOffsetElement_h
+#define SVGFEOffsetElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterPrimitiveStandardAttributes.h"
+#include "SVGFEOffset.h"
+
+namespace WebCore
+{
+
+ class SVGFEOffsetElement : public SVGFilterPrimitiveStandardAttributes
+ {
+ public:
+ SVGFEOffsetElement(const QualifiedName&, Document*);
+ virtual ~SVGFEOffsetElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFEOffset* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEOffsetElement, String, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEOffsetElement, float, float, Dx, dx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEOffsetElement, float, float, Dy, dy)
+
+ mutable SVGFEOffset* m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEOffsetElement.idl b/WebCore/svg/SVGFEOffsetElement.idl
new file mode 100644
index 0000000..a62d8da
--- /dev/null
+++ b/WebCore/svg/SVGFEOffsetElement.idl
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEOffsetElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ readonly attribute SVGAnimatedString in1;
+ readonly attribute SVGAnimatedNumber dx;
+ readonly attribute SVGAnimatedNumber dy;
+ };
+
+}
diff --git a/WebCore/svg/SVGFEPointLightElement.cpp b/WebCore/svg/SVGFEPointLightElement.cpp
new file mode 100644
index 0000000..ff33330
--- /dev/null
+++ b/WebCore/svg/SVGFEPointLightElement.cpp
@@ -0,0 +1,47 @@
+/*
+ Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEPointLightElement.h"
+#include "SVGPointLightSource.h"
+
+namespace WebCore {
+
+SVGFEPointLightElement::SVGFEPointLightElement(const QualifiedName& tagName, Document* doc)
+ : SVGFELightElement(tagName, doc)
+{
+}
+
+SVGFEPointLightElement::~SVGFEPointLightElement()
+{
+}
+
+SVGLightSource* SVGFEPointLightElement::lightSource() const
+{
+ FloatPoint3D pos(x(), y(), z());
+ return new SVGPointLightSource(pos);
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFEPointLightElement.h b/WebCore/svg/SVGFEPointLightElement.h
new file mode 100644
index 0000000..191f7f6
--- /dev/null
+++ b/WebCore/svg/SVGFEPointLightElement.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGFEPointLightElement_h
+#define SVGFEPointLightElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFELightElement.h"
+
+namespace WebCore
+{
+ class SVGFEPointLightElement : public SVGFELightElement
+ {
+ public:
+ SVGFEPointLightElement(const QualifiedName&, Document*);
+ virtual ~SVGFEPointLightElement();
+
+ virtual SVGLightSource* lightSource() const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGFEPointLightElement.idl b/WebCore/svg/SVGFEPointLightElement.idl
new file mode 100644
index 0000000..12dbe2f
--- /dev/null
+++ b/WebCore/svg/SVGFEPointLightElement.idl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFEPointLightElement : SVGElement {
+ readonly attribute SVGAnimatedNumber x;
+ readonly attribute SVGAnimatedNumber y;
+ readonly attribute SVGAnimatedNumber z;
+ };
+
+}
diff --git a/WebCore/svg/SVGFESpecularLightingElement.cpp b/WebCore/svg/SVGFESpecularLightingElement.cpp
new file mode 100644
index 0000000..509794a
--- /dev/null
+++ b/WebCore/svg/SVGFESpecularLightingElement.cpp
@@ -0,0 +1,131 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ 2005 Oliver Hunt <oliver@nerget.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFESpecularLightingElement.h"
+
+#include "RenderObject.h"
+#include "SVGColor.h"
+#include "SVGNames.h"
+#include "SVGFELightElement.h"
+#include "SVGParserUtilities.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFESpecularLightingElement::SVGFESpecularLightingElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_specularConstant(1.0f)
+ , m_specularExponent(1.0f)
+ , m_surfaceScale(1.0f)
+ , m_kernelUnitLengthX(0.0f)
+ , m_kernelUnitLengthY(0.0f)
+ , m_filterEffect(0)
+{
+}
+
+SVGFESpecularLightingElement::~SVGFESpecularLightingElement()
+{
+ delete m_filterEffect;
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFESpecularLightingElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFESpecularLightingElement, float, Number, number, SpecularConstant, specularConstant, SVGNames::specularConstantAttr, m_specularConstant)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFESpecularLightingElement, float, Number, number, SpecularExponent, specularExponent, SVGNames::specularExponentAttr, m_specularExponent)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFESpecularLightingElement, float, Number, number, SurfaceScale, surfaceScale, SVGNames::surfaceScaleAttr, m_surfaceScale)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFESpecularLightingElement, float, Number, number, KernelUnitLengthX, kernelUnitLengthX, "kernelUnitLengthX", m_kernelUnitLengthX)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFESpecularLightingElement, float, Number, number, KernelUnitLengthY, kernelUnitLengthY, "kernelUnitLengthY", m_kernelUnitLengthY)
+
+void SVGFESpecularLightingElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else if (attr->name() == SVGNames::surfaceScaleAttr)
+ setSurfaceScaleBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::specularConstantAttr)
+ setSpecularConstantBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::specularExponentAttr)
+ setSpecularExponentBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::kernelUnitLengthAttr) {
+ float x, y;
+ if (parseNumberOptionalNumber(value, x, y)) {
+ setKernelUnitLengthXBaseValue(x);
+ setKernelUnitLengthYBaseValue(y);
+ }
+ } else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFESpecularLighting* SVGFESpecularLightingElement::filterEffect(SVGResourceFilter* filter) const
+{
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFESpecularLighting(filter);
+
+ m_filterEffect->setIn(in1());
+ m_filterEffect->setSpecularConstant((specularConstant()));
+ m_filterEffect->setSpecularExponent((specularExponent()));
+ m_filterEffect->setSurfaceScale((surfaceScale()));
+ m_filterEffect->setKernelUnitLengthX((kernelUnitLengthX()));
+ m_filterEffect->setKernelUnitLengthY((kernelUnitLengthY()));
+
+ SVGFESpecularLightingElement* nonConstThis = const_cast<SVGFESpecularLightingElement*>(this);
+
+ RenderStyle* parentStyle = nonConstThis->styleForRenderer(parent()->renderer());
+ RenderStyle* filterStyle = nonConstThis->resolveStyle(parentStyle);
+
+ m_filterEffect->setLightingColor(filterStyle->svgStyle()->lightingColor());
+
+ parentStyle->deref(document()->renderArena());
+ filterStyle->deref(document()->renderArena());
+
+ setStandardAttributes(m_filterEffect);
+
+ updateLights();
+ return m_filterEffect;
+}
+
+void SVGFESpecularLightingElement::updateLights() const
+{
+ if (!m_filterEffect)
+ return;
+
+ SVGLightSource* light = 0;
+ for (Node* n = firstChild(); n; n = n->nextSibling()) {
+ if (n->hasTagName(SVGNames::feDistantLightTag) ||
+ n->hasTagName(SVGNames::fePointLightTag) ||
+ n->hasTagName(SVGNames::feSpotLightTag)) {
+ SVGFELightElement* lightNode = static_cast<SVGFELightElement*>(n);
+ light = lightNode->lightSource();
+ break;
+ }
+ }
+
+ m_filterEffect->setLightSource(light);
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFESpecularLightingElement.h b/WebCore/svg/SVGFESpecularLightingElement.h
new file mode 100644
index 0000000..435882e
--- /dev/null
+++ b/WebCore/svg/SVGFESpecularLightingElement.h
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ 2005 Oliver Hunt <oliver@nerget.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGFESpecularLightingElement_h
+#define SVGFESpecularLightingElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFESpecularLighting.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore
+{
+ class SVGColor;
+
+ class SVGFESpecularLightingElement : public SVGFilterPrimitiveStandardAttributes
+ {
+ public:
+ SVGFESpecularLightingElement(const QualifiedName&, Document*);
+ virtual ~SVGFESpecularLightingElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFESpecularLighting* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, String, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, float, float, SpecularConstant, specularConstant)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, float, float, SpecularExponent, specularExponent)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, float, float, SurfaceScale, surfaceScale)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, float, float, KernelUnitLengthX, kernelUnitLengthX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, float, float, KernelUnitLengthY, kernelUnitLengthY)
+
+ mutable SVGFESpecularLighting* m_filterEffect;
+
+ void updateLights() const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGFESpecularLightingElement.idl b/WebCore/svg/SVGFESpecularLightingElement.idl
new file mode 100644
index 0000000..d79a70e
--- /dev/null
+++ b/WebCore/svg/SVGFESpecularLightingElement.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFESpecularLightingElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ readonly attribute SVGAnimatedString in1;
+ readonly attribute SVGAnimatedNumber surfaceScale;
+ readonly attribute SVGAnimatedNumber specularConstant;
+ readonly attribute SVGAnimatedNumber specularExponent;
+ };
+
+}
diff --git a/WebCore/svg/SVGFESpotLightElement.cpp b/WebCore/svg/SVGFESpotLightElement.cpp
new file mode 100644
index 0000000..7d89f78
--- /dev/null
+++ b/WebCore/svg/SVGFESpotLightElement.cpp
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFESpotLightElement.h"
+#include "SVGSpotLightSource.h"
+
+namespace WebCore {
+
+SVGFESpotLightElement::SVGFESpotLightElement(const QualifiedName& tagName, Document* doc)
+ : SVGFELightElement(tagName, doc)
+{
+}
+
+SVGFESpotLightElement::~SVGFESpotLightElement()
+{
+}
+
+SVGLightSource* SVGFESpotLightElement::lightSource() const
+{
+ FloatPoint3D pos(x(), y(), z());
+
+ // convert lookAt to a direction
+ FloatPoint3D direction(pointsAtX() - pos.x(),
+ pointsAtY() - pos.y(),
+ pointsAtZ() - pos.z());
+
+ direction.normalize();
+ return new SVGSpotLightSource(pos, direction, specularExponent(), limitingConeAngle());
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFESpotLightElement.h b/WebCore/svg/SVGFESpotLightElement.h
new file mode 100644
index 0000000..5738201
--- /dev/null
+++ b/WebCore/svg/SVGFESpotLightElement.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGFESpotLightElement_h
+#define SVGFESpotLightElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFELightElement.h"
+
+namespace WebCore
+{
+ class SVGFESpotLightElement : public SVGFELightElement
+ {
+ public:
+ SVGFESpotLightElement(const QualifiedName&, Document*);
+ virtual ~SVGFESpotLightElement();
+
+ virtual SVGLightSource* lightSource() const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGFESpotLightElement.idl b/WebCore/svg/SVGFESpotLightElement.idl
new file mode 100644
index 0000000..339d545
--- /dev/null
+++ b/WebCore/svg/SVGFESpotLightElement.idl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFESpotLightElement : SVGElement {
+ readonly attribute SVGAnimatedNumber x;
+ readonly attribute SVGAnimatedNumber y;
+ readonly attribute SVGAnimatedNumber z;
+ readonly attribute SVGAnimatedNumber pointsAtX;
+ readonly attribute SVGAnimatedNumber pointsAtY;
+ readonly attribute SVGAnimatedNumber pointsAtZ;
+ readonly attribute SVGAnimatedNumber specularExponent;
+ readonly attribute SVGAnimatedNumber limitingConeAngle;
+ };
+
+}
diff --git a/WebCore/svg/SVGFETileElement.cpp b/WebCore/svg/SVGFETileElement.cpp
new file mode 100644
index 0000000..62fc05b
--- /dev/null
+++ b/WebCore/svg/SVGFETileElement.cpp
@@ -0,0 +1,71 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFETileElement.h"
+
+#include "Attr.h"
+#include "SVGRenderStyle.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFETileElement::SVGFETileElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_filterEffect(0)
+{
+}
+
+SVGFETileElement::~SVGFETileElement()
+{
+ delete m_filterEffect;
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFETileElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
+
+void SVGFETileElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFETile* SVGFETileElement::filterEffect(SVGResourceFilter* filter) const
+{
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFETile(filter);
+
+ m_filterEffect->setIn(in1());
+
+ setStandardAttributes(m_filterEffect);
+ return m_filterEffect;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFETileElement.h b/WebCore/svg/SVGFETileElement.h
new file mode 100644
index 0000000..256e8a0
--- /dev/null
+++ b/WebCore/svg/SVGFETileElement.h
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFETileElement_h
+#define SVGFETileElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterPrimitiveStandardAttributes.h"
+#include "SVGFETile.h"
+
+namespace WebCore
+{
+
+ class SVGFETileElement : public SVGFilterPrimitiveStandardAttributes
+ {
+ public:
+ SVGFETileElement(const QualifiedName&, Document*);
+ virtual ~SVGFETileElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFETile* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETileElement, String, String, In1, in1)
+
+ mutable SVGFETile* m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGFETileElement.idl b/WebCore/svg/SVGFETileElement.idl
new file mode 100644
index 0000000..68bfcc5
--- /dev/null
+++ b/WebCore/svg/SVGFETileElement.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFETileElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ readonly attribute SVGAnimatedString in1;
+ };
+
+}
diff --git a/WebCore/svg/SVGFETurbulenceElement.cpp b/WebCore/svg/SVGFETurbulenceElement.cpp
new file mode 100644
index 0000000..e047e8a
--- /dev/null
+++ b/WebCore/svg/SVGFETurbulenceElement.cpp
@@ -0,0 +1,105 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFETurbulenceElement.h"
+
+#include "SVGParserUtilities.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFETurbulenceElement::SVGFETurbulenceElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_baseFrequencyX(0.0f)
+ , m_baseFrequencyY(0.0f)
+ , m_numOctaves(1)
+ , m_seed(0.0f)
+ , m_stitchTiles(SVG_STITCHTYPE_NOSTITCH)
+ , m_type(SVG_TURBULENCE_TYPE_TURBULENCE)
+ , m_filterEffect(0)
+{
+}
+
+SVGFETurbulenceElement::~SVGFETurbulenceElement()
+{
+ delete m_filterEffect;
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFETurbulenceElement, float, Number, number, BaseFrequencyX, baseFrequencyX, "baseFrequencyX", m_baseFrequencyX)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFETurbulenceElement, float, Number, number, BaseFrequencyY, baseFrequencyY, "baseFrequencyY", m_baseFrequencyY)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFETurbulenceElement, float, Number, number, Seed, seed, SVGNames::seedAttr, m_seed)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFETurbulenceElement, long, Integer, integer, NumOctaves, numOctaves, SVGNames::numOctavesAttr, m_numOctaves)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFETurbulenceElement, int, Enumeration, enumeration, StitchTiles, stitchTiles, SVGNames::stitchTilesAttr, m_stitchTiles)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFETurbulenceElement, int, Enumeration, enumeration, Type, type, SVGNames::typeAttr, m_type)
+
+void SVGFETurbulenceElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::typeAttr) {
+ if (value == "fractalNoise")
+ setTypeBaseValue(SVG_TURBULENCE_TYPE_FRACTALNOISE);
+ else if (value == "turbulence")
+ setTypeBaseValue(SVG_TURBULENCE_TYPE_TURBULENCE);
+ } else if (attr->name() == SVGNames::stitchTilesAttr) {
+ if (value == "stitch")
+ setStitchTilesBaseValue(SVG_STITCHTYPE_STITCH);
+ else if (value == "nostitch")
+ setStitchTilesBaseValue(SVG_STITCHTYPE_NOSTITCH);
+ } else if (attr->name() == SVGNames::baseFrequencyAttr) {
+ float x, y;
+ if (parseNumberOptionalNumber(value, x, y)) {
+ setBaseFrequencyXBaseValue(x);
+ setBaseFrequencyYBaseValue(y);
+ }
+ } else if (attr->name() == SVGNames::seedAttr)
+ setSeedBaseValue(value.toFloat());
+ else if (attr->name() == SVGNames::numOctavesAttr)
+ setNumOctavesBaseValue(value.toUIntStrict());
+ else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFETurbulence* SVGFETurbulenceElement::filterEffect(SVGResourceFilter* filter) const
+{
+
+ if (!m_filterEffect)
+ m_filterEffect = new SVGFETurbulence(filter);
+
+ m_filterEffect->setType((SVGTurbulanceType) type());
+ m_filterEffect->setBaseFrequencyX(baseFrequencyX());
+ m_filterEffect->setBaseFrequencyY(baseFrequencyY());
+ m_filterEffect->setNumOctaves(numOctaves());
+ m_filterEffect->setSeed(seed());
+ m_filterEffect->setStitchTiles(stitchTiles() == SVG_STITCHTYPE_STITCH);
+
+ setStandardAttributes(m_filterEffect);
+ return m_filterEffect;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFETurbulenceElement.h b/WebCore/svg/SVGFETurbulenceElement.h
new file mode 100644
index 0000000..a62bf15
--- /dev/null
+++ b/WebCore/svg/SVGFETurbulenceElement.h
@@ -0,0 +1,66 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFETurbulenceElement_h
+#define SVGFETurbulenceElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFETurbulence.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore
+{
+ enum SVGStitchOptions {
+ SVG_STITCHTYPE_UNKNOWN = 0,
+ SVG_STITCHTYPE_STITCH = 1,
+ SVG_STITCHTYPE_NOSTITCH = 2
+ };
+
+ class SVGFETurbulenceElement : public SVGFilterPrimitiveStandardAttributes
+ {
+ public:
+ SVGFETurbulenceElement(const QualifiedName&, Document*);
+ virtual ~SVGFETurbulenceElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFETurbulence* filterEffect(SVGResourceFilter*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETurbulenceElement, float, float, BaseFrequencyX, baseFrequencyX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETurbulenceElement, float, float, BaseFrequencyY, baseFrequencyY)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETurbulenceElement, long, long, NumOctaves, numOctaves)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETurbulenceElement, float, float, Seed, seed)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETurbulenceElement, int, int, StitchTiles, stitchTiles)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETurbulenceElement, int, int, Type, type)
+
+ mutable SVGFETurbulence* m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFETurbulenceElement.idl b/WebCore/svg/SVGFETurbulenceElement.idl
new file mode 100644
index 0000000..79fc63f
--- /dev/null
+++ b/WebCore/svg/SVGFETurbulenceElement.idl
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS, GenerateConstructor] SVGFETurbulenceElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ // Turbulence Types
+ const unsigned short SVG_TURBULENCE_TYPE_UNKNOWN = 0;
+ const unsigned short SVG_TURBULENCE_TYPE_FRACTALNOISE = 1;
+ const unsigned short SVG_TURBULENCE_TYPE_TURBULENCE = 2;
+
+ // Stitch Options
+ const unsigned short SVG_STITCHTYPE_UNKNOWN = 0;
+ const unsigned short SVG_STITCHTYPE_STITCH = 1;
+ const unsigned short SVG_STITCHTYPE_NOSTITCH = 2;
+
+ readonly attribute SVGAnimatedNumber baseFrequencyX;
+ readonly attribute SVGAnimatedNumber baseFrequencyY;
+ readonly attribute SVGAnimatedInteger numOctaves;
+ readonly attribute SVGAnimatedNumber seed;
+ readonly attribute SVGAnimatedEnumeration stitchTiles;
+ readonly attribute SVGAnimatedEnumeration type;
+ };
+
+}
diff --git a/WebCore/svg/SVGFilterElement.cpp b/WebCore/svg/SVGFilterElement.cpp
new file mode 100644
index 0000000..125d084
--- /dev/null
+++ b/WebCore/svg/SVGFilterElement.cpp
@@ -0,0 +1,164 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterElement.h"
+
+#include "Attr.h"
+#include "SVGResourceFilter.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+#include "SVGUnitTypes.h"
+
+namespace WebCore {
+
+SVGFilterElement::SVGFilterElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , SVGURIReference()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_filterUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
+ , m_primitiveUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
+ , m_x(this, LengthModeWidth)
+ , m_y(this, LengthModeHeight)
+ , m_width(this, LengthModeWidth)
+ , m_height(this, LengthModeHeight)
+ , m_filterResX(0)
+ , m_filterResY(0)
+{
+ // Spec: If the attribute is not specified, the effect is as if a value of "-10%" were specified.
+ setXBaseValue(SVGLength(this, LengthModeWidth, "-10%"));
+ setYBaseValue(SVGLength(this, LengthModeHeight, "-10%"));
+
+ // Spec: If the attribute is not specified, the effect is as if a value of "120%" were specified.
+ setWidthBaseValue(SVGLength(this, LengthModeWidth, "120%"));
+ setHeightBaseValue(SVGLength(this, LengthModeHeight, "120%"));
+}
+
+SVGFilterElement::~SVGFilterElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement, int, Enumeration, enumeration, FilterUnits, filterUnits, SVGNames::filterUnitsAttr, m_filterUnits)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement, int, Enumeration, enumeration, PrimitiveUnits, primitiveUnits, SVGNames::primitiveUnitsAttr, m_primitiveUnits)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement, SVGLength, Length, length, X, x, SVGNames::xAttr, m_x)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement, SVGLength, Length, length, Y, y, SVGNames::yAttr, m_y)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement, SVGLength, Length, length, Width, width, SVGNames::widthAttr, m_width)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement, SVGLength, Length, length, Height, height, SVGNames::heightAttr, m_height)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement, long, Integer, integer, FilterResX, filterResX, "filterResX", m_filterResX)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement, long, Integer, integer, FilterResY, filterResY, "filterResY", m_filterResY)
+
+void SVGFilterElement::setFilterRes(unsigned long, unsigned long) const
+{
+}
+
+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(this, LengthModeWidth, value));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(this, LengthModeHeight, value));
+ else if (attr->name() == SVGNames::widthAttr)
+ setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
+ else if (attr->name() == SVGNames::heightAttr)
+ setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
+ else {
+ if (SVGURIReference::parseMappedAttribute(attr)) return;
+ if (SVGLangSpace::parseMappedAttribute(attr)) return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return;
+
+ SVGStyledElement::parseMappedAttribute(attr);
+ }
+}
+
+SVGResource* SVGFilterElement::canvasResource()
+{
+ if (!attached())
+ return 0;
+
+ if (!m_filter)
+ m_filter = new SVGResourceFilter();
+
+ bool filterBBoxMode = filterUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX;
+ m_filter->setFilterBoundingBoxMode(filterBBoxMode);
+
+ float _x, _y, _width, _height;
+
+ if (filterBBoxMode) {
+ _x = x().valueAsPercentage();
+ _y = y().valueAsPercentage();
+ _width = width().valueAsPercentage();
+ _height = height().valueAsPercentage();
+ } else {
+ m_filter->setXBoundingBoxMode(x().unitType() == LengthTypePercentage);
+ m_filter->setYBoundingBoxMode(y().unitType() == LengthTypePercentage);
+
+ _x = x().value();
+ _y = y().value();
+ _width = width().value();
+ _height = height().value();
+ }
+
+ m_filter->setFilterRect(FloatRect(_x, _y, _width, _height));
+
+ bool primitiveBBoxMode = primitiveUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX;
+ m_filter->setEffectBoundingBoxMode(primitiveBBoxMode);
+
+ // TODO : use switch/case instead?
+ m_filter->clearEffects();
+ for (Node* n = firstChild(); n != 0; n = n->nextSibling()) {
+ SVGElement* element = 0;
+ if (n->isSVGElement())
+ element = static_cast<SVGElement*>(n);
+ if (element && element->isFilterEffect()) {
+ SVGFilterPrimitiveStandardAttributes* filterAttributes = static_cast<SVGFilterPrimitiveStandardAttributes*>(element);
+ SVGFilterEffect* filterEffect = filterAttributes->filterEffect(m_filter.get());
+ if (!filterEffect)
+ continue;
+
+ m_filter->addFilterEffect(filterEffect);
+ }
+ }
+
+ return m_filter.get();
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFilterElement.h b/WebCore/svg/SVGFilterElement.h
new file mode 100644
index 0000000..f2d9773
--- /dev/null
+++ b/WebCore/svg/SVGFilterElement.h
@@ -0,0 +1,77 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFilterElement_h
+#define SVGFilterElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGResourceFilter.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledElement.h"
+#include "SVGURIReference.h"
+
+namespace WebCore {
+ class SVGLength;
+
+ class SVGFilterElement : public SVGStyledElement,
+ public SVGURIReference,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired
+ {
+ public:
+ SVGFilterElement(const QualifiedName&, Document*);
+ virtual ~SVGFilterElement();
+
+ virtual SVGResource* canvasResource();
+
+ void setFilterRes(unsigned long filterResX, unsigned long filterResY) const;
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, int, int, FilterUnits, filterUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, int, int, PrimitiveUnits, primitiveUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGLength, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGLength, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGLength, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGLength, SVGLength, Height, height)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, long, long, FilterResX, filterResX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, long, long, FilterResY, filterResY)
+
+ RefPtr<SVGResourceFilter> m_filter;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFilterElement.idl b/WebCore/svg/SVGFilterElement.idl
new file mode 100644
index 0000000..9d1e15a
--- /dev/null
+++ b/WebCore/svg/SVGFilterElement.idl
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FILTERS] SVGFilterElement : SVGElement,
+ SVGURIReference,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable
+ /* SVGUnitTypes */ {
+ readonly attribute SVGAnimatedEnumeration filterUnits;
+ readonly attribute SVGAnimatedEnumeration primitiveUnits;
+ readonly attribute SVGAnimatedLength x;
+ readonly attribute SVGAnimatedLength y;
+ readonly attribute SVGAnimatedLength width;
+ readonly attribute SVGAnimatedLength height;
+ readonly attribute SVGAnimatedInteger filterResX;
+ readonly attribute SVGAnimatedInteger filterResY;
+
+ void setFilterRes(in unsigned long filterResX, in unsigned long filterResY);
+ };
+
+}
diff --git a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp
new file mode 100644
index 0000000..59f67e1
--- /dev/null
+++ b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp
@@ -0,0 +1,138 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+#include "SVGFilterElement.h"
+#include "SVGFilterEffect.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+#include "SVGStyledElement.h"
+#include "SVGUnitTypes.h"
+
+namespace WebCore {
+
+SVGFilterPrimitiveStandardAttributes::SVGFilterPrimitiveStandardAttributes(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , m_x(this, LengthModeWidth)
+ , m_y(this, LengthModeHeight)
+ , m_width(this, LengthModeWidth)
+ , m_height(this, LengthModeHeight)
+{
+ // Spec: If the attribute is not specified, the effect is as if a value of "0%" were specified.
+ setXBaseValue(SVGLength(this, LengthModeWidth, "0%"));
+ setYBaseValue(SVGLength(this, LengthModeHeight, "0%"));
+
+ // Spec: If the attribute is not specified, the effect is as if a value of "100%" were specified.
+ setWidthBaseValue(SVGLength(this, LengthModeWidth, "100%"));
+ setHeightBaseValue(SVGLength(this, LengthModeHeight, "100%"));
+}
+
+SVGFilterPrimitiveStandardAttributes::~SVGFilterPrimitiveStandardAttributes()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGFilterPrimitiveStandardAttributes, SVGLength, Length, length, X, x, SVGNames::xAttr.localName(), m_x)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFilterPrimitiveStandardAttributes, SVGLength, Length, length, Y, y, SVGNames::yAttr.localName(), m_y)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFilterPrimitiveStandardAttributes, SVGLength, Length, length, Width, width, SVGNames::widthAttr.localName(), m_width)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFilterPrimitiveStandardAttributes, SVGLength, Length, length, Height, height, SVGNames::heightAttr.localName(), m_height)
+ANIMATED_PROPERTY_DEFINITIONS(SVGFilterPrimitiveStandardAttributes, String, String, string, Result, result, SVGNames::resultAttr.localName(), m_result)
+
+void SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(MappedAttribute* attr)
+{
+ const AtomicString& value = attr->value();
+ if (attr->name() == SVGNames::xAttr)
+ setXBaseValue(SVGLength(this, LengthModeWidth, value));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(this, LengthModeHeight, value));
+ else if (attr->name() == SVGNames::widthAttr)
+ setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
+ else if (attr->name() == SVGNames::heightAttr)
+ setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
+ else if (attr->name() == SVGNames::resultAttr)
+ setResultBaseValue(value);
+ else
+ return SVGStyledElement::parseMappedAttribute(attr);
+}
+
+void SVGFilterPrimitiveStandardAttributes::setStandardAttributes(SVGFilterEffect* filterEffect) const
+{
+ ASSERT(filterEffect);
+ if (!filterEffect)
+ return;
+
+ ASSERT(filterEffect->filter());
+
+ float _x, _y, _width, _height;
+
+ if (filterEffect->filter()->effectBoundingBoxMode()) {
+ _x = x().valueAsPercentage();
+ _y = y().valueAsPercentage();
+ _width = width().valueAsPercentage();
+ _height = height().valueAsPercentage();
+ } else {
+ // We need to resolve any percentages in filter rect space.
+ if (x().unitType() == LengthTypePercentage) {
+ filterEffect->setXBoundingBoxMode(true);
+ _x = x().valueAsPercentage();
+ } else {
+ filterEffect->setXBoundingBoxMode(false);
+ _x = x().value();
+ }
+
+ if (y().unitType() == LengthTypePercentage) {
+ filterEffect->setYBoundingBoxMode(true);
+ _y = y().valueAsPercentage();
+ } else {
+ filterEffect->setYBoundingBoxMode(false);
+ _y = y().value();
+ }
+
+ if (width().unitType() == LengthTypePercentage) {
+ filterEffect->setWidthBoundingBoxMode(true);
+ _width = width().valueAsPercentage();
+ } else {
+ filterEffect->setWidthBoundingBoxMode(false);
+ _width = width().value();
+ }
+
+ if (height().unitType() == LengthTypePercentage) {
+ filterEffect->setHeightBoundingBoxMode(true);
+ _height = height().valueAsPercentage();
+ } else {
+ filterEffect->setHeightBoundingBoxMode(false);
+ _height = height().value();
+ }
+ }
+
+ filterEffect->setSubRegion(FloatRect(_x, _y, _width, _height));
+ filterEffect->setResult(result());
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h
new file mode 100644
index 0000000..b639282
--- /dev/null
+++ b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h
@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFilterPrimitiveStandardAttributes_h
+#define SVGFilterPrimitiveStandardAttributes_h
+
+#if ENABLE(SVG)
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+ class SVGFilterEffect;
+ class SVGResourceFilter;
+
+ class SVGFilterPrimitiveStandardAttributes : public SVGStyledElement
+ {
+ public:
+ SVGFilterPrimitiveStandardAttributes(const QualifiedName&, Document*);
+ virtual ~SVGFilterPrimitiveStandardAttributes();
+
+ virtual bool isFilterEffect() const { return true; }
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const = 0;
+
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+
+ protected:
+ void setStandardAttributes(SVGFilterEffect*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterPrimitiveStandardAttributes, SVGLength, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterPrimitiveStandardAttributes, SVGLength, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterPrimitiveStandardAttributes, SVGLength, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterPrimitiveStandardAttributes, SVGLength, SVGLength, Height, height)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterPrimitiveStandardAttributes, String, String, Result, result)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.idl b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.idl
new file mode 100644
index 0000000..194147c
--- /dev/null
+++ b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.idl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, ObjCProtocol] SVGFilterPrimitiveStandardAttributes : SVGStylable {
+ readonly attribute SVGAnimatedLength x;
+ readonly attribute SVGAnimatedLength y;
+ readonly attribute SVGAnimatedLength width;
+ readonly attribute SVGAnimatedLength height;
+ readonly attribute SVGAnimatedString result;
+ };
+
+}
diff --git a/WebCore/svg/SVGFitToViewBox.cpp b/WebCore/svg/SVGFitToViewBox.cpp
new file mode 100644
index 0000000..2cf3dd7
--- /dev/null
+++ b/WebCore/svg/SVGFitToViewBox.cpp
@@ -0,0 +1,122 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGFitToViewBox.h"
+
+#include "AffineTransform.h"
+#include "FloatRect.h"
+#include "SVGDocumentExtensions.h"
+#include "SVGNames.h"
+#include "SVGParserUtilities.h"
+#include "SVGPreserveAspectRatio.h"
+#include "StringImpl.h"
+
+namespace WebCore {
+
+SVGFitToViewBox::SVGFitToViewBox()
+ : m_viewBox()
+ , m_preserveAspectRatio(SVGPreserveAspectRatio::create())
+{
+}
+
+SVGFitToViewBox::~SVGFitToViewBox()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS_WITH_CONTEXT(SVGFitToViewBox, FloatRect, Rect, rect, ViewBox, viewBox, SVGNames::viewBoxAttr, m_viewBox)
+ANIMATED_PROPERTY_DEFINITIONS_WITH_CONTEXT(SVGFitToViewBox, SVGPreserveAspectRatio*, PreserveAspectRatio, preserveAspectRatio, PreserveAspectRatio, preserveAspectRatio, SVGNames::preserveAspectRatioAttr, m_preserveAspectRatio.get())
+
+bool SVGFitToViewBox::parseViewBox(const UChar*& c, const UChar* end, float& x, float& y, float& w, float& h, bool validate)
+{
+ Document* doc = contextElement()->document();
+ String str(c, end - c);
+
+ skipOptionalSpaces(c, end);
+
+ bool valid = (parseNumber(c, end, x) && parseNumber(c, end, y) &&
+ parseNumber(c, end, w) && parseNumber(c, end, h, false));
+ if (!validate)
+ return true;
+ if (!valid) {
+ doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\"");
+ return false;
+ }
+
+ if (w < 0.0) { // check that width is positive
+ doc->accessSVGExtensions()->reportError("A negative value for ViewBox width is not allowed");
+ return false;
+ } else if (h < 0.0) { // check that height is positive
+ doc->accessSVGExtensions()->reportError("A negative value for ViewBox height is not allowed");
+ return false;
+ } else {
+ skipOptionalSpaces(c, end);
+ if (c < end) { // nothing should come after the last, fourth number
+ doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\"");
+ return false;
+ }
+ }
+
+ return true;
+}
+
+AffineTransform SVGFitToViewBox::viewBoxToViewTransform(float viewWidth, float viewHeight) const
+{
+ FloatRect viewBoxRect = viewBox();
+ if (!viewBoxRect.width() || !viewBoxRect.height())
+ return AffineTransform();
+
+ return preserveAspectRatio()->getCTM(viewBoxRect.x(),
+ viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(),
+ 0, 0, viewWidth, viewHeight);
+}
+
+bool SVGFitToViewBox::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::viewBoxAttr) {
+ float x = 0.0f, y = 0.0f, w = 0.0f, h = 0.0f;
+ const UChar* c = attr->value().characters();
+ const UChar* end = c + attr->value().length();
+ if (parseViewBox(c, end, x, y, w, h))
+ setViewBoxBaseValue(FloatRect(x, y, w, h));
+ return true;
+ } else if (attr->name() == SVGNames::preserveAspectRatioAttr) {
+ const UChar* c = attr->value().characters();
+ const UChar* end = c + attr->value().length();
+ preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
+ return true;
+ }
+
+ return false;
+}
+
+bool SVGFitToViewBox::isKnownAttribute(const QualifiedName& attrName)
+{
+ return (attrName == SVGNames::viewBoxAttr ||
+ attrName == SVGNames::preserveAspectRatioAttr);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFitToViewBox.h b/WebCore/svg/SVGFitToViewBox.h
new file mode 100644
index 0000000..16ea1c2
--- /dev/null
+++ b/WebCore/svg/SVGFitToViewBox.h
@@ -0,0 +1,57 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFitToViewBox_h
+#define SVGFitToViewBox_h
+
+#if ENABLE(SVG)
+#include "SVGElement.h"
+
+namespace WebCore {
+
+ class AffineTransform;
+ class SVGPreserveAspectRatio;
+
+ class SVGFitToViewBox {
+ public:
+ SVGFitToViewBox();
+ virtual ~SVGFitToViewBox();
+
+ // 'SVGFitToViewBox' functions
+ bool parseViewBox(const UChar*& start, const UChar* end, float& x, float& y, float& w, float& h, bool validate = true);
+ virtual AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) const;
+
+ bool parseMappedAttribute(MappedAttribute*);
+ bool isKnownAttribute(const QualifiedName&);
+
+ protected:
+ virtual const SVGElement* contextElement() const = 0;
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS_WITH_CONTEXT(SVGFitToViewBox, FloatRect, FloatRect, ViewBox, viewBox)
+ ANIMATED_PROPERTY_DECLARATIONS_WITH_CONTEXT(SVGFitToViewBox, SVGPreserveAspectRatio*, RefPtr<SVGPreserveAspectRatio>, PreserveAspectRatio, preserveAspectRatio)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGFitToViewBox_h
diff --git a/WebCore/svg/SVGFitToViewBox.idl b/WebCore/svg/SVGFitToViewBox.idl
new file mode 100644
index 0000000..a747fc8
--- /dev/null
+++ b/WebCore/svg/SVGFitToViewBox.idl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, ObjCProtocol] SVGFitToViewBox {
+ readonly attribute SVGAnimatedRect viewBox;
+ readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio;
+ };
+
+}
diff --git a/WebCore/svg/SVGFont.cpp b/WebCore/svg/SVGFont.cpp
new file mode 100644
index 0000000..0511acb
--- /dev/null
+++ b/WebCore/svg/SVGFont.cpp
@@ -0,0 +1,537 @@
+/**
+ * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG_FONTS)
+#include "Font.h"
+
+#include "CSSFontSelector.h"
+#include "GraphicsContext.h"
+#include "RenderObject.h"
+#include "SimpleFontData.h"
+#include "SVGFontData.h"
+#include "SVGGlyphElement.h"
+#include "SVGFontElement.h"
+#include "SVGFontFaceElement.h"
+#include "SVGMissingGlyphElement.h"
+#include "SVGPaintServer.h"
+#include "SVGPaintServerSolid.h"
+#include "XMLNames.h"
+
+using namespace WTF::Unicode;
+
+namespace WebCore {
+
+static inline float convertEmUnitToPixel(float fontSize, float unitsPerEm, float value)
+{
+ if (unitsPerEm == 0.0f)
+ return 0.0f;
+
+ return value * fontSize / unitsPerEm;
+}
+
+static inline bool isVerticalWritingMode(const SVGRenderStyle* style)
+{
+ return style->writingMode() == WM_TBRL || style->writingMode() == WM_TB;
+}
+
+// Helper functions to determine the arabic character forms (initial, medial, terminal, isolated)
+enum ArabicCharShapingMode {
+ SNone = 0,
+ SRight = 1,
+ SDual = 2
+};
+
+static const ArabicCharShapingMode s_arabicCharShapingMode[222] = {
+ SRight, SRight, SRight, SRight, SDual , SRight, SDual , SRight, SDual , SDual , SDual , SDual , SDual , SRight, /* 0x0622 - 0x062F */
+ SRight, SRight, SRight, SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SNone , SNone , SNone , SNone , SNone , /* 0x0630 - 0x063F */
+ SNone , SDual , SDual , SDual , SDual , SDual , SDual , SRight, SDual , SDual , SNone , SNone , SNone , SNone , SNone , SNone , /* 0x0640 - 0x064F */
+ SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , /* 0x0650 - 0x065F */
+ SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , /* 0x0660 - 0x066F */
+ SNone , SRight, SRight, SRight, SNone , SRight, SRight, SRight, SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , /* 0x0670 - 0x067F */
+ SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, /* 0x0680 - 0x068F */
+ SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, SDual , SDual , SDual , SDual , SDual , SDual , /* 0x0690 - 0x069F */
+ SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , /* 0x06A0 - 0x06AF */
+ SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , /* 0x06B0 - 0x06BF */
+ SRight, SDual , SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, SDual , SRight, SDual , SRight, /* 0x06C0 - 0x06CF */
+ SDual , SDual , SRight, SRight, SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , /* 0x06D0 - 0x06DF */
+ SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , /* 0x06E0 - 0x06EF */
+ SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SDual , SDual , SDual , SNone , SNone , SNone /* 0x06F0 - 0x06FF */
+};
+
+static inline SVGGlyphIdentifier::ArabicForm processArabicFormDetection(const UChar& curChar, bool& lastCharShapesRight, SVGGlyphIdentifier::ArabicForm* prevForm)
+{
+ SVGGlyphIdentifier::ArabicForm curForm;
+
+ ArabicCharShapingMode shapingMode = SNone;
+ if (curChar >= 0x0622 && curChar <= 0x06FF)
+ shapingMode = s_arabicCharShapingMode[curChar - 0x0622];
+
+ // Use a simple state machine to identify the actual arabic form
+ // It depends on the order of the arabic form enum:
+ // enum ArabicForm { None = 0, Isolated, Terminal, Initial, Medial };
+
+ if (lastCharShapesRight && shapingMode == SDual) {
+ if (prevForm) {
+ int correctedForm = (int) *prevForm + 1;
+ ASSERT(correctedForm >= SVGGlyphIdentifier::None && correctedForm <= SVGGlyphIdentifier::Medial);
+ *prevForm = static_cast<SVGGlyphIdentifier::ArabicForm>(correctedForm);
+ }
+
+ curForm = SVGGlyphIdentifier::Initial;
+ } else
+ curForm = shapingMode == SNone ? SVGGlyphIdentifier::None : SVGGlyphIdentifier::Isolated;
+
+ lastCharShapesRight = shapingMode != SNone;
+ return curForm;
+}
+
+static Vector<SVGGlyphIdentifier::ArabicForm> charactersWithArabicForm(const String& input, bool rtl)
+{
+ Vector<SVGGlyphIdentifier::ArabicForm> forms;
+ unsigned int length = input.length();
+
+ bool containsArabic = false;
+ for (unsigned int i = 0; i < length; ++i) {
+ if (isArabicChar(input[i])) {
+ containsArabic = true;
+ break;
+ }
+ }
+
+ if (!containsArabic)
+ return forms;
+
+ bool lastCharShapesRight = false;
+
+ // Start identifying arabic forms
+ if (rtl)
+ for (int i = length - 1; i >= 0; --i)
+ forms.prepend(processArabicFormDetection(input[i], lastCharShapesRight, forms.isEmpty() ? 0 : &forms.first()));
+ else
+ for (unsigned int i = 0; i < length; ++i)
+ forms.append(processArabicFormDetection(input[i], lastCharShapesRight, forms.isEmpty() ? 0 : &forms.last()));
+
+ return forms;
+}
+
+static inline bool isCompatibleArabicForm(const SVGGlyphIdentifier& identifier, const Vector<SVGGlyphIdentifier::ArabicForm>& chars, unsigned int startPosition, unsigned int endPosition)
+{
+ if (chars.isEmpty())
+ return true;
+
+ Vector<SVGGlyphIdentifier::ArabicForm>::const_iterator it = chars.begin() + startPosition;
+ Vector<SVGGlyphIdentifier::ArabicForm>::const_iterator end = chars.begin() + endPosition;
+
+ ASSERT(end <= chars.end());
+ for (; it != end; ++it) {
+ if ((*it) != identifier.arabicForm && (*it) != SVGGlyphIdentifier::None)
+ return false;
+ }
+
+ return true;
+}
+
+static inline bool isCompatibleGlyph(const SVGGlyphIdentifier& identifier, bool isVerticalText, const String& language,
+ const Vector<SVGGlyphIdentifier::ArabicForm>& chars, unsigned int startPosition, unsigned int endPosition)
+{
+ bool valid = true;
+
+ // Check wheter orientation if glyph fits within the request
+ switch (identifier.orientation) {
+ case SVGGlyphIdentifier::Vertical:
+ valid = isVerticalText;
+ break;
+ case SVGGlyphIdentifier::Horizontal:
+ valid = !isVerticalText;
+ break;
+ case SVGGlyphIdentifier::Both:
+ break;
+ }
+
+ if (!valid)
+ return false;
+
+ // Check wheter languages are compatible
+ if (!identifier.languages.isEmpty()) {
+ // This glyph exists only in certain languages, if we're not specifying a
+ // language on the referencing element we're unable to use this glyph.
+ if (language.isEmpty())
+ return false;
+
+ // Split subcode from language, if existant.
+ String languagePrefix;
+
+ int subCodeSeparator = language.find('-');
+ if (subCodeSeparator != -1)
+ languagePrefix = language.left(subCodeSeparator);
+
+ Vector<String>::const_iterator it = identifier.languages.begin();
+ Vector<String>::const_iterator end = identifier.languages.end();
+
+ bool found = false;
+ for (; it != end; ++it) {
+ String cur = (*it);
+
+ if (cur == language || cur == languagePrefix) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ return false;
+ }
+
+ // Check wheter arabic form is compatible
+ return isCompatibleArabicForm(identifier, chars, startPosition, endPosition);
+}
+
+static inline const SVGFontData* svgFontAndFontFaceElementForFontData(const SimpleFontData* fontData, SVGFontFaceElement*& fontFace, SVGFontElement*& font)
+{
+ ASSERT(fontData->isCustomFont());
+ ASSERT(fontData->isSVGFont());
+
+ const SVGFontData* svgFontData = static_cast<const SVGFontData*>(fontData->svgFontData());
+
+ fontFace = svgFontData->svgFontFaceElement();
+ ASSERT(fontFace);
+
+ font = fontFace->associatedFontElement();
+ return svgFontData;
+}
+
+// Helper class to walk a text run. Lookup a SVGGlyphIdentifier for each character
+// - also respecting possibly defined ligatures - and invoke a callback for each found glyph.
+template<typename SVGTextRunData>
+struct SVGTextRunWalker {
+ typedef bool (*SVGTextRunWalkerCallback)(const SVGGlyphIdentifier&, SVGTextRunData&);
+ typedef void (*SVGTextRunWalkerMissingGlyphCallback)(const TextRun&, SVGTextRunData&);
+
+ SVGTextRunWalker(const SVGFontData* fontData, SVGFontElement* fontElement, SVGTextRunData& data,
+ SVGTextRunWalkerCallback callback, SVGTextRunWalkerMissingGlyphCallback missingGlyphCallback)
+ : m_fontData(fontData)
+ , m_fontElement(fontElement)
+ , m_walkerData(data)
+ , m_walkerCallback(callback)
+ , m_walkerMissingGlyphCallback(missingGlyphCallback)
+ {
+ }
+
+ void walk(const TextRun& run, bool isVerticalText, const String& language, int from, int to)
+ {
+ // Should hold true for SVG text, otherwhise sth. is wrong
+ ASSERT(to - from == run.length());
+
+ int maximumHashKeyLength = m_fontElement->maximumHashKeyLength();
+ ASSERT(maximumHashKeyLength >= 0);
+
+ Vector<SVGGlyphIdentifier::ArabicForm> chars(charactersWithArabicForm(String(run.data(from), run.length()), run.rtl()));
+
+ SVGGlyphIdentifier identifier;
+ bool foundGlyph = false;
+ int characterLookupRange;
+
+ for (int i = from; i < to; ++i) {
+ // If characterLookupRange is > 0, then the font defined ligatures (length of unicode property value > 1).
+ // We have to check wheter the current character & the next character define a ligature. This needs to be
+ // extended to the n-th next character (where n is 'characterLookupRange'), to check for any possible ligature.
+ characterLookupRange = maximumHashKeyLength + i >= to ? to - i : maximumHashKeyLength;
+
+ while (characterLookupRange > 0 && !foundGlyph) {
+ String lookupString(run.data(run.rtl() ? run.length() - (i + characterLookupRange) : i), characterLookupRange);
+
+ Vector<SVGGlyphIdentifier> glyphs = m_fontElement->glyphIdentifiersForString(lookupString);
+ Vector<SVGGlyphIdentifier>::iterator it = glyphs.begin();
+ Vector<SVGGlyphIdentifier>::iterator end = glyphs.end();
+
+ for (; it != end; ++it) {
+ identifier = *it;
+
+ unsigned int startPosition = run.rtl() ? run.length() - (i + lookupString.length()) : i;
+ unsigned int endPosition = startPosition + lookupString.length();
+
+ if (identifier.isValid && isCompatibleGlyph(identifier, isVerticalText, language, chars, startPosition, endPosition)) {
+ ASSERT(characterLookupRange > 0);
+ i += characterLookupRange - 1;
+
+ foundGlyph = true;
+ SVGGlyphElement::inheritUnspecifiedAttributes(identifier, m_fontData);
+ break;
+ }
+ }
+
+ characterLookupRange--;
+ }
+
+ if (!foundGlyph) {
+ if (SVGMissingGlyphElement* element = m_fontElement->firstMissingGlyphElement()) {
+ // <missing-glyph> element support
+ identifier = SVGGlyphElement::buildGenericGlyphIdentifier(element);
+ SVGGlyphElement::inheritUnspecifiedAttributes(identifier, m_fontData);
+ } else {
+ // Fallback to system font fallback
+ TextRun subRun(run);
+ subRun.setText(subRun.data(i), 1);
+
+ (*m_walkerMissingGlyphCallback)(subRun, m_walkerData);
+ continue;
+ }
+ }
+
+ if (!(*m_walkerCallback)(identifier, m_walkerData))
+ break;
+
+ foundGlyph = false;
+ }
+ }
+
+private:
+ const SVGFontData* m_fontData;
+ SVGFontElement* m_fontElement;
+ SVGTextRunData& m_walkerData;
+ SVGTextRunWalkerCallback m_walkerCallback;
+ SVGTextRunWalkerMissingGlyphCallback m_walkerMissingGlyphCallback;
+};
+
+// Callback & data structures to compute the width of text using SVG Fonts
+struct SVGTextRunWalkerMeasuredLengthData {
+ int at;
+ int from;
+ int to;
+
+ float scale;
+ float length;
+ const Font* font;
+};
+
+bool floatWidthUsingSVGFontCallback(const SVGGlyphIdentifier& identifier, SVGTextRunWalkerMeasuredLengthData& data)
+{
+ if (data.at >= data.from && data.at < data.to)
+ data.length += identifier.horizontalAdvanceX * data.scale;
+
+ data.at++;
+ return data.at < data.to;
+}
+
+void floatWidthMissingGlyphCallback(const TextRun& run, SVGTextRunWalkerMeasuredLengthData& data)
+{
+ // Handle system font fallback
+ FontDescription fontDescription(data.font->fontDescription());
+ fontDescription.setFamily(FontFamily());
+ Font font(fontDescription, 0, 0); // spacing handled by SVG text code.
+ font.update(data.font->fontSelector());
+
+ data.length += font.floatWidth(run);
+}
+
+static float floatWidthOfSubStringUsingSVGFont(const Font* font, const TextRun& run, int from, int to)
+{
+ int newFrom = to > from ? from : to;
+ int newTo = to > from ? to : from;
+
+ from = newFrom;
+ to = newTo;
+
+ SVGFontElement* fontElement = 0;
+ SVGFontFaceElement* fontFaceElement = 0;
+
+ if (const SVGFontData* fontData = svgFontAndFontFaceElementForFontData(font->primaryFont(), fontFaceElement, fontElement)) {
+ if (!fontElement)
+ return 0.0f;
+
+ SVGTextRunWalkerMeasuredLengthData data;
+
+ data.font = font;
+ data.at = from;
+ data.from = from;
+ data.to = to;
+ data.scale = convertEmUnitToPixel(font->size(), fontFaceElement->unitsPerEm(), 1.0f);
+ data.length = 0.0f;
+
+ String language;
+ bool isVerticalText = false; // Holds true for HTML text
+
+ // TODO: language matching & svg glyphs should be possible for HTML text, too.
+ if (RenderObject* renderObject = run.referencingRenderObject()) {
+ isVerticalText = isVerticalWritingMode(renderObject->style()->svgStyle());
+
+ if (SVGElement* element = static_cast<SVGElement*>(renderObject->element()))
+ language = element->getAttribute(XMLNames::langAttr);
+ }
+
+ SVGTextRunWalker<SVGTextRunWalkerMeasuredLengthData> runWalker(fontData, fontElement, data, floatWidthUsingSVGFontCallback, floatWidthMissingGlyphCallback);
+ runWalker.walk(run, isVerticalText, language, 0, run.length());
+ return data.length;
+ }
+
+ return 0.0f;
+}
+
+float Font::floatWidthUsingSVGFont(const TextRun& run) const
+{
+ return floatWidthOfSubStringUsingSVGFont(this, run, 0, run.length());
+}
+
+// Callback & data structures to draw text using SVG Fonts
+struct SVGTextRunWalkerDrawTextData {
+ float scale;
+ bool isVerticalText;
+
+ float xStartOffset;
+ FloatPoint currentPoint;
+ FloatPoint glyphOrigin;
+
+ GraphicsContext* context;
+ RenderObject* renderObject;
+
+ SVGPaintServer* activePaintServer;
+};
+
+bool drawTextUsingSVGFontCallback(const SVGGlyphIdentifier& identifier, SVGTextRunWalkerDrawTextData& data)
+{
+ // TODO: Support arbitary SVG content as glyph (currently limited to <glyph d="..."> situations)
+ if (!identifier.pathData.isEmpty()) {
+ data.context->save();
+
+ if (data.isVerticalText) {
+ data.glyphOrigin.setX(identifier.verticalOriginX * data.scale);
+ data.glyphOrigin.setY(identifier.verticalOriginY * data.scale);
+ }
+
+ data.context->translate(data.xStartOffset + data.currentPoint.x() + data.glyphOrigin.x(), data.currentPoint.y() + data.glyphOrigin.y());
+ data.context->scale(FloatSize(data.scale, -data.scale));
+
+ data.context->beginPath();
+ data.context->addPath(identifier.pathData);
+
+ SVGPaintTargetType targetType = data.context->textDrawingMode() == cTextStroke ? ApplyToStrokeTargetType : ApplyToFillTargetType;
+ if (data.activePaintServer->setup(data.context, data.renderObject, targetType)) {
+ // Spec: Any properties specified on a text elements which represents a length, such as the
+ // 'stroke-width' property, might produce surprising results since the length value will be
+ // processed in the coordinate system of the glyph. (TODO: What other lengths? miter-limit? dash-offset?)
+ if (targetType == ApplyToStrokeTargetType && data.scale != 0.0f)
+ data.context->setStrokeThickness(data.context->strokeThickness() / data.scale);
+
+ data.activePaintServer->renderPath(data.context, data.renderObject, targetType);
+ data.activePaintServer->teardown(data.context, data.renderObject, targetType);
+ }
+
+ data.context->restore();
+ }
+
+ if (data.isVerticalText)
+ data.currentPoint.move(0.0f, identifier.verticalAdvanceY * data.scale);
+ else
+ data.currentPoint.move(identifier.horizontalAdvanceX * data.scale, 0.0f);
+
+ return true;
+}
+
+void drawTextMissingGlyphCallback(const TextRun& run, SVGTextRunWalkerDrawTextData& data)
+{
+ // Handle system font fallback
+ FontDescription fontDescription(data.context->font().fontDescription());
+ fontDescription.setFamily(FontFamily());
+ Font font(fontDescription, 0, 0); // spacing handled by SVG text code.
+ font.update(data.context->font().fontSelector());
+
+ font.drawText(data.context, run, data.currentPoint);
+
+ if (data.isVerticalText)
+ data.currentPoint.move(0.0f, font.floatWidth(run));
+ else
+ data.currentPoint.move(font.floatWidth(run), 0.0f);
+}
+
+void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
+ const FloatPoint& point, int from, int to) const
+{
+ SVGFontElement* fontElement = 0;
+ SVGFontFaceElement* fontFaceElement = 0;
+
+ if (const SVGFontData* fontData = svgFontAndFontFaceElementForFontData(primaryFont(), fontFaceElement, fontElement)) {
+ if (!fontElement)
+ return;
+
+ SVGTextRunWalkerDrawTextData data;
+ data.currentPoint = point;
+ data.scale = convertEmUnitToPixel(size(), fontFaceElement->unitsPerEm(), 1.0f);
+
+ // Required to be valid for SVG text only.
+ data.renderObject = run.referencingRenderObject();
+ data.activePaintServer = run.activePaintServer();
+
+ // If renderObject is not set, we're dealing for HTML text rendered using SVG Fonts.
+ if (!data.renderObject) {
+ ASSERT(!data.activePaintServer);
+
+ // TODO: We're only supporting simple filled HTML text so far.
+ SVGPaintServerSolid* solidPaintServer = SVGPaintServer::sharedSolidPaintServer();
+ solidPaintServer->setColor(context->fillColor());
+
+ data.activePaintServer = solidPaintServer;
+ }
+
+ ASSERT(data.activePaintServer);
+
+ data.isVerticalText = false;
+ data.xStartOffset = floatWidthOfSubStringUsingSVGFont(this, run, run.rtl() ? to : 0, run.rtl() ? run.length() : from);
+ data.glyphOrigin = FloatPoint();
+ data.context = context;
+
+ String language;
+
+ // TODO: language matching & svg glyphs should be possible for HTML text, too.
+ if (data.renderObject) {
+ data.isVerticalText = isVerticalWritingMode(data.renderObject->style()->svgStyle());
+
+ if (SVGElement* element = static_cast<SVGElement*>(data.renderObject->element()))
+ language = element->getAttribute(XMLNames::langAttr);
+ }
+
+ if (!data.isVerticalText) {
+ data.glyphOrigin.setX(fontData->horizontalOriginX() * data.scale);
+ data.glyphOrigin.setY(fontData->horizontalOriginY() * data.scale);
+ }
+
+ SVGTextRunWalker<SVGTextRunWalkerDrawTextData> runWalker(fontData, fontElement, data, drawTextUsingSVGFontCallback, drawTextMissingGlyphCallback);
+ runWalker.walk(run, data.isVerticalText, language, from, to);
+ }
+}
+
+FloatRect Font::selectionRectForTextUsingSVGFont(const TextRun& run, const IntPoint& point, int height, int from, int to) const
+{
+ return FloatRect(point.x() + floatWidthOfSubStringUsingSVGFont(this, run, run.rtl() ? to : 0, run.rtl() ? run.length() : from),
+ point.y(), floatWidthOfSubStringUsingSVGFont(this, run, from, to), height);
+}
+
+int Font::offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const
+{
+ // TODO: Fix text selection when HTML text is drawn using a SVG Font
+ // We need to integrate the SVG text selection code in the offsetForPosition() framework.
+ // This will also fix a major issue, that SVG Text code can't select arabic strings properly.
+ return 0;
+}
+
+}
+
+#endif
diff --git a/WebCore/svg/SVGFontData.cpp b/WebCore/svg/SVGFontData.cpp
new file mode 100644
index 0000000..dc8ae4e
--- /dev/null
+++ b/WebCore/svg/SVGFontData.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG_FONTS)
+#include "SVGFontData.h"
+
+namespace WebCore {
+
+SVGFontData::SVGFontData(SVGFontFaceElement* fontFaceElement)
+ : m_svgFontFaceElement(fontFaceElement)
+ , m_horizontalOriginX(fontFaceElement->horizontalOriginX())
+ , m_horizontalOriginY(fontFaceElement->horizontalOriginY())
+ , m_horizontalAdvanceX(fontFaceElement->horizontalAdvanceX())
+ , m_verticalOriginX(fontFaceElement->verticalOriginX())
+ , m_verticalOriginY(fontFaceElement->verticalOriginY())
+ , m_verticalAdvanceY(fontFaceElement->verticalAdvanceY())
+{
+}
+
+SVGFontData::~SVGFontData()
+{
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/SVGFontData.h b/WebCore/svg/SVGFontData.h
new file mode 100644
index 0000000..cb2192c
--- /dev/null
+++ b/WebCore/svg/SVGFontData.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SVGFontData_h
+#define SVGFontData_h
+
+#if ENABLE(SVG_FONTS)
+#include "SVGFontFaceElement.h"
+
+namespace WebCore {
+
+class SVGFontData {
+public:
+ SVGFontData(SVGFontFaceElement*);
+ virtual ~SVGFontData();
+
+ SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement.get(); }
+
+ float horizontalOriginX() const { return m_horizontalOriginX; }
+ float horizontalOriginY() const { return m_horizontalOriginY; }
+ float horizontalAdvanceX() const { return m_horizontalAdvanceX; }
+
+ float verticalOriginX() const { return m_verticalOriginX; }
+ float verticalOriginY() const { return m_verticalOriginY; }
+ float verticalAdvanceY() const { return m_verticalAdvanceY; }
+
+private:
+ RefPtr<SVGFontFaceElement> m_svgFontFaceElement;
+
+ float m_horizontalOriginX;
+ float m_horizontalOriginY;
+ float m_horizontalAdvanceX;
+
+ float m_verticalOriginX;
+ float m_verticalOriginY;
+ float m_verticalAdvanceY;
+};
+
+} // namespace WebCore
+
+#endif
+#endif // SVGFontData_h
diff --git a/WebCore/svg/SVGFontElement.cpp b/WebCore/svg/SVGFontElement.cpp
new file mode 100644
index 0000000..a214509
--- /dev/null
+++ b/WebCore/svg/SVGFontElement.cpp
@@ -0,0 +1,146 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG_FONTS)
+#include "SVGFontElement.h"
+
+#include "Font.h"
+#include "GlyphPageTreeNode.h"
+#include "SVGGlyphElement.h"
+#include "SVGMissingGlyphElement.h"
+#include "SVGNames.h"
+#include "SVGParserUtilities.h"
+
+namespace WebCore {
+
+using namespace SVGNames;
+
+SVGFontElement::SVGFontElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , m_maximumHashKeyLength(0)
+{
+}
+
+SVGFontElement::~SVGFontElement()
+{
+}
+
+void SVGFontElement::addGlyphToCache(SVGGlyphElement* glyphElement)
+{
+ ASSERT(glyphElement);
+
+ String glyphString = glyphElement->getAttribute(unicodeAttr);
+ if (glyphString.isEmpty()) // No unicode property, means that glyph will be used in <altGlyph> situations!
+ return;
+
+ SVGGlyphIdentifier identifier = glyphElement->buildGlyphIdentifier();
+ identifier.isValid = true;
+
+ if (glyphString.length() > m_maximumHashKeyLength)
+ m_maximumHashKeyLength = glyphString.length();
+
+ GlyphHashMap::iterator glyphsIt = m_glyphMap.find(glyphString);
+ if (glyphsIt == m_glyphMap.end()) {
+ Vector<SVGGlyphIdentifier> glyphs;
+ glyphs.append(identifier);
+
+ m_glyphMap.add(glyphString, glyphs);
+ } else {
+ Vector<SVGGlyphIdentifier>& glyphs = (*glyphsIt).second;
+ glyphs.append(identifier);
+ }
+}
+
+void SVGFontElement::removeGlyphFromCache(SVGGlyphElement* glyphElement)
+{
+ ASSERT(glyphElement);
+
+ String glyphString = glyphElement->getAttribute(unicodeAttr);
+ if (glyphString.isEmpty()) // No unicode property, means that glyph will be used in <altGlyph> situations!
+ return;
+
+ GlyphHashMap::iterator glyphsIt = m_glyphMap.find(glyphString);
+ ASSERT(glyphsIt != m_glyphMap.end());
+
+ Vector<SVGGlyphIdentifier>& glyphs = (*glyphsIt).second;
+
+ if (glyphs.size() == 1)
+ m_glyphMap.remove(glyphString);
+ else {
+ SVGGlyphIdentifier identifier = glyphElement->buildGlyphIdentifier();
+ identifier.isValid = true;
+
+ Vector<SVGGlyphIdentifier>::iterator it = glyphs.begin();
+ Vector<SVGGlyphIdentifier>::iterator end = glyphs.end();
+
+ unsigned int position = 0;
+ for (; it != end; ++it) {
+ if ((*it) == identifier)
+ break;
+
+ position++;
+ }
+
+ ASSERT(position < glyphs.size());
+ glyphs.remove(position);
+ }
+
+ // If we remove a glyph from cache, whose unicode property length is equal to
+ // m_maximumHashKeyLength then we need to recalculate the hash key length, because there
+ // is either no more glyph with that length, or there are still more glyphs with the maximum length.
+ if (glyphString.length() == m_maximumHashKeyLength) {
+ m_maximumHashKeyLength = 0;
+
+ GlyphHashMap::iterator it = m_glyphMap.begin();
+ GlyphHashMap::iterator end = m_glyphMap.end();
+
+ for (; it != end; ++it) {
+ if ((*it).first.length() > m_maximumHashKeyLength)
+ m_maximumHashKeyLength = (*it).first.length();
+ }
+ }
+}
+
+SVGMissingGlyphElement* SVGFontElement::firstMissingGlyphElement() const
+{
+ for (Node* child = firstChild(); child; child = child->nextSibling()) {
+ if (child->hasTagName(missing_glyphTag))
+ return static_cast<SVGMissingGlyphElement*>(child);
+ }
+
+ return 0;
+}
+
+const Vector<SVGGlyphIdentifier>& SVGFontElement::glyphIdentifiersForString(const String& string) const
+{
+ GlyphHashMap::const_iterator it = m_glyphMap.find(string);
+ if (it == m_glyphMap.end()) {
+ static Vector<SVGGlyphIdentifier> s_emptyGlyphList;
+ return s_emptyGlyphList;
+ }
+
+ return (*it).second;
+}
+
+}
+
+#endif // ENABLE(SVG_FONTS)
diff --git a/WebCore/svg/SVGFontElement.h b/WebCore/svg/SVGFontElement.h
new file mode 100644
index 0000000..1005654
--- /dev/null
+++ b/WebCore/svg/SVGFontElement.h
@@ -0,0 +1,64 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGFontElement_h
+#define SVGFontElement_h
+
+#if ENABLE(SVG_FONTS)
+#include "SVGExternalResourcesRequired.h"
+#include "SVGGlyphElement.h"
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+ class SVGMissingGlyphElement;
+ class SVGFontElement : public SVGStyledElement
+ , public SVGExternalResourcesRequired {
+ public:
+ SVGFontElement(const QualifiedName&, Document*);
+ virtual ~SVGFontElement();
+
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+ virtual const SVGElement* contextElement() const { return this; }
+
+ void addGlyphToCache(SVGGlyphElement*);
+ void removeGlyphFromCache(SVGGlyphElement*);
+
+ const Vector<SVGGlyphIdentifier>& glyphIdentifiersForString(const String&) const;
+
+ // Returns the longest hash key length (the 'unicode' property value with the
+ // highest amount of characters) - ie. for <glyph unicode="ffl"/> it will return 3.
+ unsigned int maximumHashKeyLength() const { return m_maximumHashKeyLength; }
+
+ SVGMissingGlyphElement* firstMissingGlyphElement() const;
+
+ private:
+ typedef HashMap<String, Vector<SVGGlyphIdentifier> > GlyphHashMap;
+ GlyphHashMap m_glyphMap;
+
+ unsigned int m_maximumHashKeyLength;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_FONTS)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFontElement.idl b/WebCore/svg/SVGFontElement.idl
new file mode 100644
index 0000000..92bd512
--- /dev/null
+++ b/WebCore/svg/SVGFontElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FONTS] SVGFontElement : SVGElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGFontFaceElement.cpp b/WebCore/svg/SVGFontFaceElement.cpp
new file mode 100644
index 0000000..41db763
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceElement.cpp
@@ -0,0 +1,363 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG_FONTS)
+#include "SVGFontFaceElement.h"
+#include "CString.h"
+#include "CSSFontFaceRule.h"
+#include "CSSFontFaceSrcValue.h"
+#include "CSSParser.h"
+#include "CSSProperty.h"
+#include "CSSPropertyNames.h"
+#include "CSSStyleSelector.h"
+#include "CSSStyleSheet.h"
+#include "CSSValueKeywords.h"
+#include "CSSValueList.h"
+#include "FontCache.h"
+#include "FontPlatformData.h"
+#include "SimpleFontData.h"
+#include "SVGDefinitionSrcElement.h"
+#include "SVGFontElement.h"
+#include "SVGFontFaceSrcElement.h"
+#include "SVGGlyphElement.h"
+#include "SVGNames.h"
+
+#include <math.h>
+
+namespace WebCore {
+
+using namespace SVGNames;
+
+SVGFontFaceElement::SVGFontFaceElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+ , m_fontFaceRule(new CSSFontFaceRule(0))
+ , m_styleDeclaration(new CSSMutableStyleDeclaration)
+{
+ m_styleDeclaration->setParent(document()->mappedElementSheet());
+ m_styleDeclaration->setStrictParsing(true);
+ m_fontFaceRule->setDeclaration(m_styleDeclaration.get());
+ document()->mappedElementSheet()->append(m_fontFaceRule);
+}
+
+SVGFontFaceElement::~SVGFontFaceElement()
+{
+}
+
+static void mapAttributeToCSSProperty(HashMap<AtomicStringImpl*, int>* propertyNameToIdMap, const QualifiedName& attrName)
+{
+ int propertyId = cssPropertyID(attrName.localName());
+ ASSERT(propertyId > 0);
+ propertyNameToIdMap->set(attrName.localName().impl(), propertyId);
+}
+
+static int cssPropertyIdForSVGAttributeName(const QualifiedName& attrName)
+{
+ if (!attrName.namespaceURI().isNull())
+ return 0;
+
+ static HashMap<AtomicStringImpl*, int>* propertyNameToIdMap = 0;
+ if (!propertyNameToIdMap) {
+ propertyNameToIdMap = new HashMap<AtomicStringImpl*, int>;
+ // This is a list of all @font-face CSS properties which are exposed as SVG XML attributes
+ // Those commented out are not yet supported by WebCore's style system
+ //mapAttributeToCSSProperty(propertyNameToIdMap, accent_heightAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, alphabeticAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, ascentAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, bboxAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, cap_heightAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, descentAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, font_familyAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, font_sizeAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, font_stretchAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, font_styleAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, font_variantAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, font_weightAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, hangingAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, ideographicAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, mathematicalAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, overline_positionAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, overline_thicknessAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, panose_1Attr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, slopeAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, stemhAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, stemvAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, strikethrough_positionAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, strikethrough_thicknessAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, underline_positionAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, underline_thicknessAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, unicode_rangeAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, units_per_emAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, v_alphabeticAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, v_hangingAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, v_ideographicAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, v_mathematicalAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, widthsAttr);
+ //mapAttributeToCSSProperty(propertyNameToIdMap, x_heightAttr);
+ }
+
+ return propertyNameToIdMap->get(attrName.localName().impl());
+}
+
+void SVGFontFaceElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ int propId = cssPropertyIdForSVGAttributeName(attr->name());
+ if (propId > 0) {
+ m_styleDeclaration->setProperty(propId, attr->value(), false);
+ rebuildFontFace();
+ return;
+ }
+
+ SVGElement::parseMappedAttribute(attr);
+}
+
+unsigned SVGFontFaceElement::unitsPerEm() const
+{
+ AtomicString value(getAttribute(units_per_emAttr));
+ if (value.isEmpty())
+ return 1000;
+
+ return static_cast<unsigned>(ceilf(value.toFloat()));
+}
+
+int SVGFontFaceElement::xHeight() const
+{
+ AtomicString value(getAttribute(x_heightAttr));
+ if (value.isEmpty())
+ return 0;
+
+ return static_cast<int>(ceilf(value.toFloat()));
+}
+
+float SVGFontFaceElement::horizontalOriginX() const
+{
+ if (!m_fontElement)
+ return 0.0f;
+
+ // Spec: The X-coordinate in the font coordinate system of the origin of a glyph to be used when
+ // drawing horizontally oriented text. (Note that the origin applies to all glyphs in the font.)
+ // If the attribute is not specified, the effect is as if a value of "0" were specified.
+ AtomicString value(m_fontElement->getAttribute(horiz_origin_xAttr));
+ if (value.isEmpty())
+ return 0.0f;
+
+ return value.toFloat();
+}
+
+float SVGFontFaceElement::horizontalOriginY() const
+{
+ if (!m_fontElement)
+ return 0.0f;
+
+ // Spec: The Y-coordinate in the font coordinate system of the origin of a glyph to be used when
+ // drawing horizontally oriented text. (Note that the origin applies to all glyphs in the font.)
+ // If the attribute is not specified, the effect is as if a value of "0" were specified.
+ AtomicString value(m_fontElement->getAttribute(horiz_origin_yAttr));
+ if (value.isEmpty())
+ return 0.0f;
+
+ return value.toFloat();
+}
+
+float SVGFontFaceElement::horizontalAdvanceX() const
+{
+ if (!m_fontElement)
+ return 0.0f;
+
+ // Spec: The default horizontal advance after rendering a glyph in horizontal orientation. Glyph
+ // widths are required to be non-negative, even if the glyph is typically rendered right-to-left,
+ // as in Hebrew and Arabic scripts.
+ AtomicString value(m_fontElement->getAttribute(horiz_adv_xAttr));
+ if (value.isEmpty())
+ return 0.0f;
+
+ return value.toFloat();
+}
+
+float SVGFontFaceElement::verticalOriginX() const
+{
+ if (!m_fontElement)
+ return 0.0f;
+
+ // Spec: The default X-coordinate in the font coordinate system of the origin of a glyph to be used when
+ // drawing vertically oriented text. If the attribute is not specified, the effect is as if the attribute
+ // were set to half of the effective value of attribute horiz-adv-x.
+ AtomicString value(m_fontElement->getAttribute(vert_origin_xAttr));
+ if (value.isEmpty())
+ return horizontalAdvanceX() / 2.0f;
+
+ return value.toFloat();
+}
+
+float SVGFontFaceElement::verticalOriginY() const
+{
+ if (!m_fontElement)
+ return 0.0f;
+
+ // Spec: The default Y-coordinate in the font coordinate system of the origin of a glyph to be used when
+ // drawing vertically oriented text. If the attribute is not specified, the effect is as if the attribute
+ // were set to the position specified by the font's ascent attribute.
+ AtomicString value(m_fontElement->getAttribute(vert_origin_yAttr));
+ if (value.isEmpty())
+ return ascent();
+
+ return value.toFloat();
+}
+
+float SVGFontFaceElement::verticalAdvanceY() const
+{
+ if (!m_fontElement)
+ return 0.0f;
+
+ // Spec: The default vertical advance after rendering a glyph in vertical orientation. If the attribute is
+ // not specified, the effect is as if a value equivalent of one em were specified (see units-per-em).
+ AtomicString value(m_fontElement->getAttribute(vert_adv_yAttr));
+ if (value.isEmpty())
+ return 1.0f;
+
+ return value.toFloat();
+}
+
+int SVGFontFaceElement::ascent() const
+{
+ if (!m_fontElement)
+ return 0.0f;
+
+ // Spec: Same syntax and semantics as the 'ascent' descriptor within an @font-face rule. The maximum
+ // unaccented height of the font within the font coordinate system. If the attribute is not specified,
+ // the effect is as if the attribute were set to the difference between the units-per-em value and the
+ // vert-origin-y value for the corresponding font.
+ AtomicString value(m_fontElement->getAttribute(ascentAttr));
+ if (!value.isEmpty())
+ return static_cast<int>(ceilf(value.toFloat()));
+
+ value = m_fontElement->getAttribute(vert_origin_yAttr);
+ if (!value.isEmpty())
+ return static_cast<int>(unitsPerEm()) - static_cast<int>(ceilf(value.toFloat()));
+
+ // Match Batiks default value
+ return static_cast<int>(ceilf(unitsPerEm() * 0.8f));
+}
+
+int SVGFontFaceElement::descent() const
+{
+ if (!m_fontElement)
+ return 0.0f;
+
+ // Spec: Same syntax and semantics as the 'descent' descriptor within an @font-face rule. The maximum
+ // unaccented depth of the font within the font coordinate system. If the attribute is not specified,
+ // the effect is as if the attribute were set to the vert-origin-y value for the corresponding font.
+ AtomicString value(m_fontElement->getAttribute(descentAttr));
+ if (!value.isEmpty()) {
+ // Some testcases use a negative descent value, where a positive was meant to be used :(
+ int descent = static_cast<int>(ceilf(value.toFloat()));
+ return descent < 0 ? -descent : descent;
+ }
+
+ value = m_fontElement->getAttribute(vert_origin_yAttr);
+ if (!value.isEmpty())
+ return static_cast<int>(ceilf(value.toFloat()));
+
+ // Match Batiks default value
+ return static_cast<int>(ceilf(unitsPerEm() * 0.2f));
+}
+
+String SVGFontFaceElement::fontFamily() const
+{
+ return m_styleDeclaration->getPropertyValue(CSS_PROP_FONT_FAMILY);
+}
+
+SVGFontElement* SVGFontFaceElement::associatedFontElement() const
+{
+ return m_fontElement.get();
+}
+
+void SVGFontFaceElement::rebuildFontFace()
+{
+ // Ignore changes until we live in the tree
+ if (!parentNode())
+ return;
+
+ // we currently ignore all but the first src element, alternatively we could concat them
+ SVGFontFaceSrcElement* srcElement = 0;
+ SVGDefinitionSrcElement* definitionSrc = 0;
+
+ for (Node* child = firstChild(); child; child = child->nextSibling()) {
+ if (child->hasTagName(font_face_srcTag) && !srcElement)
+ srcElement = static_cast<SVGFontFaceSrcElement*>(child);
+ else if (child->hasTagName(definition_srcTag) && !definitionSrc)
+ definitionSrc = static_cast<SVGDefinitionSrcElement*>(child);
+ }
+
+#if 0
+ // @font-face (CSSFontFace) does not yet support definition-src, as soon as it does this code should do the trick!
+ if (definitionSrc)
+ m_styleDeclaration->setProperty(CSS_PROP_DEFINITION_SRC, definitionSrc->getAttribute(XLinkNames::hrefAttr), false);
+#endif
+
+ bool describesParentFont = parentNode()->hasTagName(fontTag);
+ RefPtr<CSSValueList> list;
+
+ if (describesParentFont) {
+ m_fontElement = static_cast<SVGFontElement*>(parentNode());
+
+ list = new CSSValueList;
+ list->append(new CSSFontFaceSrcValue(fontFamily(), true));
+ } else if (srcElement)
+ list = srcElement->srcValue();
+
+ if (!list)
+ return;
+
+ // Parse in-memory CSS rules
+ CSSProperty srcProperty(CSS_PROP_SRC, list);
+ const CSSProperty* srcPropertyRef = &srcProperty;
+ m_styleDeclaration->addParsedProperties(&srcPropertyRef, 1);
+
+ if (describesParentFont) {
+ // Traverse parsed CSS values and associate CSSFontFaceSrcValue elements with ourselves.
+ RefPtr<CSSValue> src = m_styleDeclaration->getPropertyCSSValue(CSS_PROP_SRC);
+ CSSValueList* srcList = static_cast<CSSValueList*>(src.get());
+
+ unsigned srcLength = srcList ? srcList->length() : 0;
+ for (unsigned i = 0; i < srcLength; i++) {
+ if (CSSFontFaceSrcValue* item = static_cast<CSSFontFaceSrcValue*>(srcList->item(i)))
+ item->setSVGFontFaceElement(this);
+ }
+ }
+
+ document()->updateStyleSelector();
+}
+
+void SVGFontFaceElement::insertedIntoDocument()
+{
+ rebuildFontFace();
+}
+
+void SVGFontFaceElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+ rebuildFontFace();
+}
+
+}
+
+#endif // ENABLE(SVG_FONTS)
diff --git a/WebCore/svg/SVGFontFaceElement.h b/WebCore/svg/SVGFontFaceElement.h
new file mode 100644
index 0000000..71e517f
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceElement.h
@@ -0,0 +1,70 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFontFaceElement_h
+#define SVGFontFaceElement_h
+
+#if ENABLE(SVG_FONTS)
+#include "SVGElement.h"
+
+namespace WebCore {
+
+ class CSSFontFaceRule;
+ class CSSMutableStyleDeclaration;
+ class SVGFontElement;
+
+ class SVGFontFaceElement : public SVGElement {
+ public:
+ SVGFontFaceElement(const QualifiedName&, Document*);
+ virtual ~SVGFontFaceElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+ virtual void insertedIntoDocument();
+
+ unsigned unitsPerEm() const;
+ int xHeight() const;
+ float horizontalOriginX() const;
+ float horizontalOriginY() const;
+ float horizontalAdvanceX() const;
+ float verticalOriginX() const;
+ float verticalOriginY() const;
+ float verticalAdvanceY() const;
+ int ascent() const;
+ int descent() const;
+ String fontFamily() const;
+
+ SVGFontElement* associatedFontElement() const;
+ void rebuildFontFace();
+
+ private:
+ RefPtr<CSSFontFaceRule> m_fontFaceRule;
+ RefPtr<CSSMutableStyleDeclaration> m_styleDeclaration;
+
+ RefPtr<SVGFontElement> m_fontElement;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_FONTS)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFontFaceElement.idl b/WebCore/svg/SVGFontFaceElement.idl
new file mode 100644
index 0000000..0097f49
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FONTS] SVGFontFaceElement : SVGElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGFontFaceFormatElement.cpp b/WebCore/svg/SVGFontFaceFormatElement.cpp
new file mode 100644
index 0000000..e6dd94b
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceFormatElement.cpp
@@ -0,0 +1,55 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG_FONTS)
+#include "SVGFontFaceFormatElement.h"
+
+#include "SVGFontFaceElement.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+using namespace SVGNames;
+
+SVGFontFaceFormatElement::SVGFontFaceFormatElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+{
+}
+
+void SVGFontFaceFormatElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+
+ if (!parentNode() || !parentNode()->hasTagName(font_face_uriTag))
+ return;
+
+ Node* ancestor = parentNode()->parentNode();
+ if (!ancestor || !ancestor->hasTagName(font_face_srcTag))
+ return;
+
+ ancestor = ancestor->parentNode();
+ if (ancestor && ancestor->hasTagName(font_faceTag))
+ static_cast<SVGFontFaceElement*>(ancestor)->rebuildFontFace();
+}
+
+}
+
+#endif // ENABLE(SVG_FONTS)
diff --git a/WebCore/svg/SVGFontFaceFormatElement.h b/WebCore/svg/SVGFontFaceFormatElement.h
new file mode 100644
index 0000000..97828cb
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceFormatElement.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGFontFaceFormatElement_h
+#define SVGFontFaceFormatElement_h
+
+#if ENABLE(SVG_FONTS)
+#include "SVGElement.h"
+
+namespace WebCore {
+
+class SVGFontFaceFormatElement : public SVGElement {
+public:
+ SVGFontFaceFormatElement(const QualifiedName&, Document*);
+
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_FONTS)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFontFaceFormatElement.idl b/WebCore/svg/SVGFontFaceFormatElement.idl
new file mode 100644
index 0000000..cac29d7
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceFormatElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FONTS] SVGFontFaceFormatElement : SVGElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGFontFaceNameElement.cpp b/WebCore/svg/SVGFontFaceNameElement.cpp
new file mode 100644
index 0000000..1825802
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceNameElement.cpp
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG_FONTS)
+#include "SVGFontFaceNameElement.h"
+
+#include "CSSFontFaceSrcValue.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+SVGFontFaceNameElement::SVGFontFaceNameElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+{
+}
+
+PassRefPtr<CSSFontFaceSrcValue> SVGFontFaceNameElement::srcValue() const
+{
+ return new CSSFontFaceSrcValue(getAttribute(SVGNames::nameAttr), true);
+}
+
+}
+
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGFontFaceNameElement.h b/WebCore/svg/SVGFontFaceNameElement.h
new file mode 100644
index 0000000..1e07b13
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceNameElement.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGFontFaceNameElement_h
+#define SVGFontFaceNameElement_h
+
+#if ENABLE(SVG_FONTS)
+#include "SVGElement.h"
+
+namespace WebCore {
+ class CSSFontFaceSrcValue;
+ class SVGFontFaceNameElement : public SVGElement {
+ public:
+ SVGFontFaceNameElement(const QualifiedName&, Document*);
+
+ PassRefPtr<CSSFontFaceSrcValue> srcValue() const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_FONTS)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFontFaceNameElement.idl b/WebCore/svg/SVGFontFaceNameElement.idl
new file mode 100644
index 0000000..0dd0c90
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceNameElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FONTS] SVGFontFaceNameElement : SVGElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGFontFaceSrcElement.cpp b/WebCore/svg/SVGFontFaceSrcElement.cpp
new file mode 100644
index 0000000..5762cd9
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceSrcElement.cpp
@@ -0,0 +1,62 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG_FONTS)
+#include "SVGFontFaceSrcElement.h"
+
+#include "CSSValueList.h"
+#include "CSSFontFaceSrcValue.h"
+#include "SVGFontFaceElement.h"
+#include "SVGFontFaceNameElement.h"
+#include "SVGFontFaceUriElement.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+using namespace SVGNames;
+
+SVGFontFaceSrcElement::SVGFontFaceSrcElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+{
+}
+
+PassRefPtr<CSSValueList> SVGFontFaceSrcElement::srcValue() const
+{
+ RefPtr<CSSValueList> list = new CSSValueList;
+ for (Node* child = firstChild(); child; child = child->nextSibling()) {
+ if (child->hasTagName(font_face_uriTag))
+ list->append(static_cast<SVGFontFaceUriElement*>(child)->srcValue());
+ else if (child->hasTagName(font_face_nameTag))
+ list->append(static_cast<SVGFontFaceNameElement*>(child)->srcValue());
+ }
+ return list;
+}
+
+void SVGFontFaceSrcElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+ if (parentNode() && parentNode()->hasTagName(font_faceTag))
+ static_cast<SVGFontFaceElement*>(parentNode())->rebuildFontFace();
+}
+
+}
+
+#endif // ENABLE(SVG_FONTS)
diff --git a/WebCore/svg/SVGFontFaceSrcElement.h b/WebCore/svg/SVGFontFaceSrcElement.h
new file mode 100644
index 0000000..b86f689
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceSrcElement.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGFontFaceSrcElement_h
+#define SVGFontFaceSrcElement_h
+
+#if ENABLE(SVG_FONTS)
+#include "SVGElement.h"
+
+namespace WebCore {
+ class CSSValueList;
+ class SVGFontFaceSrcElement : public SVGElement {
+ public:
+ SVGFontFaceSrcElement(const QualifiedName&, Document*);
+
+ PassRefPtr<CSSValueList> srcValue() const;
+
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_FONTS)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFontFaceSrcElement.idl b/WebCore/svg/SVGFontFaceSrcElement.idl
new file mode 100644
index 0000000..4887bb8
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceSrcElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FONTS] SVGFontFaceSrcElement : SVGElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGFontFaceUriElement.cpp b/WebCore/svg/SVGFontFaceUriElement.cpp
new file mode 100644
index 0000000..2f4b99f
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceUriElement.cpp
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG_FONTS)
+#include "SVGFontFaceUriElement.h"
+
+#include "CSSFontFaceSrcValue.h"
+#include "SVGFontFaceElement.h"
+#include "SVGNames.h"
+#include "XLinkNames.h"
+
+namespace WebCore {
+
+using namespace SVGNames;
+
+SVGFontFaceUriElement::SVGFontFaceUriElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+{
+}
+
+PassRefPtr<CSSFontFaceSrcValue> SVGFontFaceUriElement::srcValue() const
+{
+ RefPtr<CSSFontFaceSrcValue> src = new CSSFontFaceSrcValue(getAttribute(XLinkNames::hrefAttr), false);
+ AtomicString value(getAttribute(formatAttr));
+ src->setFormat(value.isEmpty() ? "svg" : value); // Default format
+ return src.release();
+}
+
+void SVGFontFaceUriElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+
+ if (!parentNode() || !parentNode()->hasTagName(font_face_srcTag))
+ return;
+
+ Node* grandParent = parentNode()->parentNode();
+ if (grandParent && grandParent->hasTagName(font_faceTag))
+ static_cast<SVGFontFaceElement*>(grandParent)->rebuildFontFace();
+}
+
+}
+
+#endif // ENABLE(SVG_FONTS)
diff --git a/WebCore/svg/SVGFontFaceUriElement.h b/WebCore/svg/SVGFontFaceUriElement.h
new file mode 100644
index 0000000..cdeb743
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceUriElement.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGFontFaceUriElement_h
+#define SVGFontFaceUriElement_h
+
+#if ENABLE(SVG_FONTS)
+#include "SVGElement.h"
+
+namespace WebCore {
+ class CSSFontFaceSrcValue;
+ class SVGFontFaceUriElement : public SVGElement {
+ public:
+ SVGFontFaceUriElement(const QualifiedName&, Document*);
+
+ PassRefPtr<CSSFontFaceSrcValue> srcValue() const;
+
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_FONTS)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGFontFaceUriElement.idl b/WebCore/svg/SVGFontFaceUriElement.idl
new file mode 100644
index 0000000..6c194ba
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceUriElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FONTS] SVGFontFaceUriElement : SVGElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGForeignObjectElement.cpp b/WebCore/svg/SVGForeignObjectElement.cpp
new file mode 100644
index 0000000..688a916
--- /dev/null
+++ b/WebCore/svg/SVGForeignObjectElement.cpp
@@ -0,0 +1,170 @@
+/*
+ Copyright (C) 2006 Apple Computer, Inc.
+ (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT)
+#include "SVGForeignObjectElement.h"
+
+#include "CSSPropertyNames.h"
+#include "RenderForeignObject.h"
+#include "SVGNames.h"
+#include "SVGLength.h"
+
+#include <wtf/Assertions.h>
+
+namespace WebCore {
+
+SVGForeignObjectElement::SVGForeignObjectElement(const QualifiedName& tagName, Document *doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_x(this, LengthModeWidth)
+ , m_y(this, LengthModeHeight)
+ , m_width(this, LengthModeWidth)
+ , m_height(this, LengthModeHeight)
+{
+}
+
+SVGForeignObjectElement::~SVGForeignObjectElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGForeignObjectElement, SVGLength, Length, length, X, x, SVGNames::xAttr, m_x)
+ANIMATED_PROPERTY_DEFINITIONS(SVGForeignObjectElement, SVGLength, Length, length, Y, y, SVGNames::yAttr, m_y)
+ANIMATED_PROPERTY_DEFINITIONS(SVGForeignObjectElement, SVGLength, Length, length, Width, width, SVGNames::widthAttr, m_width)
+ANIMATED_PROPERTY_DEFINITIONS(SVGForeignObjectElement, SVGLength, Length, length, Height, height, SVGNames::heightAttr, m_height)
+
+void SVGForeignObjectElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const AtomicString& value = attr->value();
+ if (attr->name() == SVGNames::xAttr)
+ setXBaseValue(SVGLength(this, LengthModeWidth, value));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(this, LengthModeHeight, value));
+ else if (attr->name() == SVGNames::widthAttr)
+ setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
+ else if (attr->name() == SVGNames::heightAttr)
+ setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
+ else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ SVGStyledTransformableElement::parseMappedAttribute(attr);
+ }
+}
+
+// TODO: Move this function in some SVG*Element base class, as SVGSVGElement / SVGImageElement will need the same logic!
+
+// This function mimics addCSSProperty and StyledElement::attributeChanged.
+// In HTML code, you'd always call addCSSProperty from your derived parseMappedAttribute()
+// function - though in SVG code we need to move this logic into svgAttributeChanged, in
+// order to support SVG DOM changes (which don't use the parseMappedAttribute/attributeChanged).
+// If we'd ignore SVG DOM, we could use _exactly_ the same logic as HTML.
+static inline void addCSSPropertyAndNotifyAttributeMap(StyledElement* element, const QualifiedName& name, int cssProperty, const String& value)
+{
+ ASSERT(element);
+
+ if (!element)
+ return;
+
+ NamedMappedAttrMap* attrs = element->mappedAttributes();
+ ASSERT(attrs);
+
+ if (!attrs)
+ return;
+
+ MappedAttribute* mappedAttr = attrs->getAttributeItem(name);
+ if (!mappedAttr)
+ return;
+
+ // This logic is only meant to be used for entries that have to be parsed and are mapped to eNone. Assert that.
+ MappedAttributeEntry entry;
+ bool needToParse = element->mapToEntry(mappedAttr->name(), entry);
+
+ ASSERT(needToParse);
+ ASSERT(entry == eNone);
+
+ if (!needToParse || entry != eNone)
+ return;
+
+ if (mappedAttr->decl()) {
+ mappedAttr->setDecl(0);
+ attrs->declRemoved();
+ }
+
+ element->setChanged();
+ element->addCSSProperty(mappedAttr, cssProperty, value);
+
+ if (CSSMappedAttributeDeclaration* decl = mappedAttr->decl()) {
+ // Add the decl to the table in the appropriate spot.
+ element->setMappedAttributeDecl(entry, mappedAttr, decl);
+
+ decl->setMappedState(entry, mappedAttr->name(), mappedAttr->value());
+ decl->setParent(0);
+ decl->setNode(0);
+
+ attrs->declAdded();
+ }
+}
+
+void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledTransformableElement::svgAttributeChanged(attrName);
+
+ if (attrName == SVGNames::widthAttr) {
+ addCSSPropertyAndNotifyAttributeMap(this, attrName, CSS_PROP_WIDTH, width().valueAsString());
+ return;
+ } else if (attrName == SVGNames::heightAttr) {
+ addCSSPropertyAndNotifyAttributeMap(this, attrName, CSS_PROP_HEIGHT, height().valueAsString());
+ return;
+ }
+
+ if (!renderer())
+ return;
+
+ if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledTransformableElement::isKnownAttribute(attrName))
+ renderer()->setNeedsLayout(true);
+}
+
+RenderObject* SVGForeignObjectElement::createRenderer(RenderArena* arena, RenderStyle* style)
+{
+ return new (arena) RenderForeignObject(this);
+}
+
+bool SVGForeignObjectElement::childShouldCreateRenderer(Node* child) const
+{
+ // Skip over SVG rules which disallow non-SVG kids
+ return StyledElement::childShouldCreateRenderer(child);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT)
diff --git a/WebCore/svg/SVGForeignObjectElement.h b/WebCore/svg/SVGForeignObjectElement.h
new file mode 100644
index 0000000..f0c9830
--- /dev/null
+++ b/WebCore/svg/SVGForeignObjectElement.h
@@ -0,0 +1,67 @@
+/*
+ Copyright (C) 2006 Apple Computer, Inc.
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGForeignObjectElement_h
+#define SVGForeignObjectElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT)
+#include "SVGTests.h"
+#include "SVGLangSpace.h"
+#include "SVGURIReference.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGExternalResourcesRequired.h"
+
+namespace WebCore {
+ class SVGLength;
+
+ class SVGForeignObjectElement : public SVGStyledTransformableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired,
+ public SVGURIReference {
+ public:
+ SVGForeignObjectElement(const QualifiedName&, Document*);
+ virtual ~SVGForeignObjectElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ bool childShouldCreateRenderer(Node*) const;
+ virtual RenderObject* createRenderer(RenderArena* arena, RenderStyle* style);
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGForeignObjectElement, SVGLength, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGForeignObjectElement, SVGLength, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGForeignObjectElement, SVGLength, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGForeignObjectElement, SVGLength, SVGLength, Height, height)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT)
+#endif
diff --git a/WebCore/svg/SVGForeignObjectElement.idl b/WebCore/svg/SVGForeignObjectElement.idl
new file mode 100644
index 0000000..f5226e3
--- /dev/null
+++ b/WebCore/svg/SVGForeignObjectElement.idl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FOREIGN_OBJECT] SVGForeignObjectElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable {
+ readonly attribute SVGAnimatedLength x;
+ readonly attribute SVGAnimatedLength y;
+ readonly attribute SVGAnimatedLength width;
+ readonly attribute SVGAnimatedLength height;
+ };
+
+}
diff --git a/WebCore/svg/SVGGElement.cpp b/WebCore/svg/SVGGElement.cpp
new file mode 100644
index 0000000..2b50d74
--- /dev/null
+++ b/WebCore/svg/SVGGElement.cpp
@@ -0,0 +1,85 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGGElement.h"
+
+#include "RenderSVGTransformableContainer.h"
+
+namespace WebCore {
+
+SVGGElement::SVGGElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+{
+}
+
+SVGGElement::~SVGGElement()
+{
+}
+
+void SVGGElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+
+ SVGStyledTransformableElement::parseMappedAttribute(attr);
+}
+
+void SVGGElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledTransformableElement::svgAttributeChanged(attrName);
+
+ if (!renderer())
+ return;
+
+ if (SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledTransformableElement::isKnownAttribute(attrName))
+ renderer()->setNeedsLayout(true);
+}
+
+void SVGGElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGStyledTransformableElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+
+ if (renderer())
+ renderer()->setNeedsLayout(true);
+}
+
+RenderObject* SVGGElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+ return new (arena) RenderSVGTransformableContainer(this);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGGElement.h b/WebCore/svg/SVGGElement.h
new file mode 100644
index 0000000..9237ef8
--- /dev/null
+++ b/WebCore/svg/SVGGElement.h
@@ -0,0 +1,64 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGGElement_h
+#define SVGGElement_h
+
+#if ENABLE(SVG)
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTests.h"
+
+namespace WebCore {
+
+ class SVGGElement : public SVGStyledTransformableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired {
+ public:
+ SVGGElement(const QualifiedName&, Document*);
+ virtual ~SVGGElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ private:
+ friend class SVGUseElement;
+ AffineTransform localMatrix() const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGGElement.idl b/WebCore/svg/SVGGElement.idl
new file mode 100644
index 0000000..d03466d
--- /dev/null
+++ b/WebCore/svg/SVGGElement.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGGElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable {
+ };
+
+}
diff --git a/WebCore/svg/SVGGlyphElement.cpp b/WebCore/svg/SVGGlyphElement.cpp
new file mode 100644
index 0000000..34c8f3a
--- /dev/null
+++ b/WebCore/svg/SVGGlyphElement.cpp
@@ -0,0 +1,166 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG_FONTS)
+#include "SVGGlyphElement.h"
+
+#include "SVGFontElement.h"
+#include "SVGFontFaceElement.h"
+#include "SVGFontData.h"
+#include "SVGNames.h"
+#include "SVGParserUtilities.h"
+#include "SimpleFontData.h"
+#include "XMLNames.h"
+
+namespace WebCore {
+
+using namespace SVGNames;
+
+SVGGlyphElement::SVGGlyphElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+{
+}
+
+SVGGlyphElement::~SVGGlyphElement()
+{
+}
+
+void SVGGlyphElement::insertedIntoDocument()
+{
+ Node* fontNode = parentNode();
+ if (fontNode && fontNode->hasTagName(fontTag)) {
+ if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
+ element->addGlyphToCache(this);
+ }
+}
+
+void SVGGlyphElement::removedFromDocument()
+{
+ Node* fontNode = parentNode();
+ if (fontNode && fontNode->hasTagName(fontTag)) {
+ if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
+ element->removeGlyphFromCache(this);
+ }
+}
+
+static inline SVGGlyphIdentifier::ArabicForm parseArabicForm(const AtomicString& value)
+{
+ if (value == "medial")
+ return SVGGlyphIdentifier::Medial;
+ else if (value == "terminal")
+ return SVGGlyphIdentifier::Terminal;
+ else if (value == "isolated")
+ return SVGGlyphIdentifier::Isolated;
+ else if (value == "initial")
+ return SVGGlyphIdentifier::Initial;
+
+ return SVGGlyphIdentifier::None;
+}
+
+static inline SVGGlyphIdentifier::Orientation parseOrientation(const AtomicString& value)
+{
+ if (value == "h")
+ return SVGGlyphIdentifier::Horizontal;
+ else if (value == "v")
+ return SVGGlyphIdentifier::Vertical;
+
+ return SVGGlyphIdentifier::Both;
+}
+
+static inline Path parsePathData(const AtomicString& value)
+{
+ Path result;
+ pathFromSVGData(result, value);
+
+ return result;
+}
+
+void SVGGlyphElement::inheritUnspecifiedAttributes(SVGGlyphIdentifier& identifier, const SVGFontData* svgFontData)
+{
+ if (identifier.horizontalAdvanceX == SVGGlyphIdentifier::inheritedValue())
+ identifier.horizontalAdvanceX = svgFontData->horizontalAdvanceX();
+
+ if (identifier.verticalOriginX == SVGGlyphIdentifier::inheritedValue())
+ identifier.verticalOriginX = svgFontData->verticalOriginX();
+
+ if (identifier.verticalOriginY == SVGGlyphIdentifier::inheritedValue())
+ identifier.verticalOriginY = svgFontData->verticalOriginY();
+
+ if (identifier.verticalAdvanceY == SVGGlyphIdentifier::inheritedValue())
+ identifier.verticalAdvanceY = svgFontData->verticalAdvanceY();
+}
+
+static inline float parseSVGGlyphAttribute(const SVGElement* element, const WebCore::QualifiedName& name)
+{
+ AtomicString value(element->getAttribute(name));
+ if (value.isEmpty())
+ return SVGGlyphIdentifier::inheritedValue();
+
+ return value.toFloat();
+}
+
+SVGGlyphIdentifier SVGGlyphElement::buildGenericGlyphIdentifier(const SVGElement* element)
+{
+ SVGGlyphIdentifier identifier;
+ identifier.pathData = parsePathData(element->getAttribute(dAttr));
+
+ // Spec: The horizontal advance after rendering the glyph in horizontal orientation.
+ // If the attribute is not specified, the effect is as if the attribute were set to the
+ // value of the font's horiz-adv-x attribute. Glyph widths are required to be non-negative,
+ // even if the glyph is typically rendered right-to-left, as in Hebrew and Arabic scripts.
+ identifier.horizontalAdvanceX = parseSVGGlyphAttribute(element, horiz_adv_xAttr);
+
+ // Spec: The X-coordinate in the font coordinate system of the origin of the glyph to be
+ // used when drawing vertically oriented text. If the attribute is not specified, the effect
+ // is as if the attribute were set to the value of the font's vert-origin-x attribute.
+ identifier.verticalOriginX = parseSVGGlyphAttribute(element, vert_origin_xAttr);
+
+ // Spec: The Y-coordinate in the font coordinate system of the origin of a glyph to be
+ // used when drawing vertically oriented text. If the attribute is not specified, the effect
+ // is as if the attribute were set to the value of the font's vert-origin-y attribute.
+ identifier.verticalOriginY = parseSVGGlyphAttribute(element, vert_origin_yAttr);
+
+ // Spec: The vertical advance after rendering a glyph in vertical orientation.
+ // If the attribute is not specified, the effect is as if the attribute were set to the
+ // value of the font's vert-adv-y attribute.
+ identifier.verticalAdvanceY = parseSVGGlyphAttribute(element, vert_adv_yAttr);
+
+ return identifier;
+}
+
+SVGGlyphIdentifier SVGGlyphElement::buildGlyphIdentifier() const
+{
+ SVGGlyphIdentifier identifier(buildGenericGlyphIdentifier(this));
+ identifier.glyphName = getAttribute(glyph_nameAttr);
+ identifier.orientation = parseOrientation(getAttribute(orientationAttr));
+ identifier.arabicForm = parseArabicForm(getAttribute(arabic_formAttr));
+
+ String language = getAttribute(langAttr);
+ if (!language.isEmpty())
+ identifier.languages = parseDelimitedString(language, ',');
+
+ return identifier;
+}
+
+}
+
+#endif // ENABLE(SVG_FONTS)
diff --git a/WebCore/svg/SVGGlyphElement.h b/WebCore/svg/SVGGlyphElement.h
new file mode 100644
index 0000000..54069bd
--- /dev/null
+++ b/WebCore/svg/SVGGlyphElement.h
@@ -0,0 +1,122 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGGlyphElement_h
+#define SVGGlyphElement_h
+
+#if ENABLE(SVG_FONTS)
+#include "SVGStyledElement.h"
+
+#include <limits>
+#include "Path.h"
+
+namespace WebCore {
+
+ class AtomicString;
+ struct SVGFontData;
+
+ // Describe a SVG <glyph> element
+ struct SVGGlyphIdentifier {
+ enum Orientation {
+ Vertical,
+ Horizontal,
+ Both
+ };
+
+ // SVG Font depends on exactly this order.
+ enum ArabicForm {
+ None = 0,
+ Isolated,
+ Terminal,
+ Initial,
+ Medial
+ };
+
+ SVGGlyphIdentifier()
+ : isValid(false)
+ , orientation(Both)
+ , arabicForm(None)
+ , horizontalAdvanceX(0.0f)
+ , verticalOriginX(0.0f)
+ , verticalOriginY(0.0f)
+ , verticalAdvanceY(0.0f)
+ {
+ }
+
+ // Used to mark our float properties as "to be inherited from SVGFontData"
+ static float inheritedValue()
+ {
+ static float s_inheritedValue = std::numeric_limits<float>::infinity();
+ return s_inheritedValue;
+ }
+
+ bool operator==(const SVGGlyphIdentifier& other) const
+ {
+ return isValid == other.isValid &&
+ orientation == other.orientation &&
+ arabicForm == other.arabicForm &&
+ glyphName == other.glyphName &&
+ horizontalAdvanceX == other.horizontalAdvanceX &&
+ verticalOriginX == other.verticalOriginX &&
+ verticalOriginY == other.verticalOriginY &&
+ verticalAdvanceY == other.verticalAdvanceY &&
+ pathData.debugString() == other.pathData.debugString() &&
+ languages == other.languages;
+ }
+
+ bool isValid : 1;
+
+ Orientation orientation : 2;
+ ArabicForm arabicForm : 3;
+ String glyphName;
+
+ float horizontalAdvanceX;
+ float verticalOriginX;
+ float verticalOriginY;
+ float verticalAdvanceY;
+
+ Path pathData;
+ Vector<String> languages;
+ };
+
+ class SVGGlyphElement : public SVGStyledElement {
+ public:
+ SVGGlyphElement(const QualifiedName&, Document*);
+ virtual ~SVGGlyphElement();
+
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
+
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+
+ SVGGlyphIdentifier buildGlyphIdentifier() const;
+
+ // Helper function used by SVGFont
+ static void inheritUnspecifiedAttributes(SVGGlyphIdentifier&, const SVGFontData*);
+ static String querySVGFontLanguage(const SVGElement*);
+
+ // Helper function shared between SVGGlyphElement & SVGMissingGlyphElement
+ static SVGGlyphIdentifier buildGenericGlyphIdentifier(const SVGElement*);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_FONTS)
+#endif
diff --git a/WebCore/svg/SVGGlyphElement.idl b/WebCore/svg/SVGGlyphElement.idl
new file mode 100644
index 0000000..2d77fcd
--- /dev/null
+++ b/WebCore/svg/SVGGlyphElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FONTS] SVGGlyphElement : SVGElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGGradientElement.cpp b/WebCore/svg/SVGGradientElement.cpp
new file mode 100644
index 0000000..4cd527f
--- /dev/null
+++ b/WebCore/svg/SVGGradientElement.cpp
@@ -0,0 +1,176 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGGradientElement.h"
+
+#include "CSSStyleSelector.h"
+#include "RenderPath.h"
+#include "RenderSVGHiddenContainer.h"
+#include "SVGNames.h"
+#include "SVGPaintServerLinearGradient.h"
+#include "SVGPaintServerRadialGradient.h"
+#include "SVGStopElement.h"
+#include "SVGTransformList.h"
+#include "SVGTransformable.h"
+#include "SVGUnitTypes.h"
+
+namespace WebCore {
+
+SVGGradientElement::SVGGradientElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , SVGURIReference()
+ , SVGExternalResourcesRequired()
+ , m_spreadMethod(0)
+ , m_gradientUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
+ , m_gradientTransform(SVGTransformList::create(SVGNames::gradientTransformAttr))
+{
+}
+
+SVGGradientElement::~SVGGradientElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGGradientElement, int, Enumeration, enumeration, GradientUnits, gradientUnits, SVGNames::gradientUnitsAttr, m_gradientUnits)
+ANIMATED_PROPERTY_DEFINITIONS(SVGGradientElement, SVGTransformList*, TransformList, transformList, GradientTransform, gradientTransform, SVGNames::gradientTransformAttr, m_gradientTransform.get())
+ANIMATED_PROPERTY_DEFINITIONS(SVGGradientElement, int, Enumeration, enumeration, SpreadMethod, spreadMethod, SVGNames::spreadMethodAttr, m_spreadMethod)
+
+void SVGGradientElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::gradientUnitsAttr) {
+ if (attr->value() == "userSpaceOnUse")
+ setGradientUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE);
+ else if (attr->value() == "objectBoundingBox")
+ setGradientUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
+ } else if (attr->name() == SVGNames::gradientTransformAttr) {
+ SVGTransformList* gradientTransforms = gradientTransformBaseValue();
+ if (!SVGTransformable::parseTransformAttribute(gradientTransforms, attr->value())) {
+ ExceptionCode ec = 0;
+ gradientTransforms->clear(ec);
+ }
+ } else if (attr->name() == SVGNames::spreadMethodAttr) {
+ if (attr->value() == "reflect")
+ setSpreadMethodBaseValue(SVG_SPREADMETHOD_REFLECT);
+ else if (attr->value() == "repeat")
+ setSpreadMethodBaseValue(SVG_SPREADMETHOD_REPEAT);
+ else if (attr->value() == "pad")
+ setSpreadMethodBaseValue(SVG_SPREADMETHOD_PAD);
+ } else {
+ if (SVGURIReference::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+
+ SVGStyledElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGGradientElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledElement::svgAttributeChanged(attrName);
+
+ if (!m_resource)
+ return;
+
+ if (attrName == SVGNames::gradientUnitsAttr ||
+ attrName == SVGNames::gradientTransformAttr ||
+ attrName == SVGNames::spreadMethodAttr ||
+ SVGURIReference::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledElement::isKnownAttribute(attrName))
+ m_resource->invalidate();
+}
+
+void SVGGradientElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+
+ if (m_resource)
+ m_resource->invalidate();
+}
+
+RenderObject* SVGGradientElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+ return new (arena) RenderSVGHiddenContainer(this);
+}
+
+SVGResource* SVGGradientElement::canvasResource()
+{
+ if (!m_resource) {
+ if (gradientType() == LinearGradientPaintServer)
+ m_resource = SVGPaintServerLinearGradient::create(this);
+ else
+ m_resource = SVGPaintServerRadialGradient::create(this);
+ }
+
+ return m_resource.get();
+}
+
+Vector<SVGGradientStop> SVGGradientElement::buildStops() const
+{
+ Vector<SVGGradientStop> stops;
+ RenderStyle* gradientStyle = 0;
+
+ for (Node* n = firstChild(); n; n = n->nextSibling()) {
+ SVGElement* element = n->isSVGElement() ? static_cast<SVGElement*>(n) : 0;
+
+ if (element && element->isGradientStop()) {
+ SVGStopElement* stop = static_cast<SVGStopElement*>(element);
+ float stopOffset = stop->offset();
+
+ Color color;
+ float opacity;
+
+ if (stop->renderer()) {
+ RenderStyle* stopStyle = stop->renderer()->style();
+ color = stopStyle->svgStyle()->stopColor();
+ opacity = stopStyle->svgStyle()->stopOpacity();
+ } else {
+ // If there is no renderer for this stop element, then a parent element
+ // set display="none" - ie. <g display="none"><linearGradient><stop>..
+ // Unfortunately we have to manually rebuild the stop style. See pservers-grad-19-b.svg
+ if (!gradientStyle)
+ gradientStyle = const_cast<SVGGradientElement*>(this)->styleForRenderer(parent()->renderer());
+
+ RenderStyle* stopStyle = stop->resolveStyle(gradientStyle);
+
+ color = stopStyle->svgStyle()->stopColor();
+ opacity = stopStyle->svgStyle()->stopOpacity();
+
+ stopStyle->deref(document()->renderArena());
+ }
+
+ stops.append(makeGradientStop(stopOffset, makeRGBA(color.red(), color.green(), color.blue(), int(opacity * 255.))));
+ }
+ }
+
+ if (gradientStyle)
+ gradientStyle->deref(document()->renderArena());
+
+ return stops;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGGradientElement.h b/WebCore/svg/SVGGradientElement.h
new file mode 100644
index 0000000..25579d0
--- /dev/null
+++ b/WebCore/svg/SVGGradientElement.h
@@ -0,0 +1,82 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGGradientElement_h
+#define SVGGradientElement_h
+
+#if ENABLE(SVG)
+#include "SVGPaintServerGradient.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGStyledElement.h"
+#include "SVGURIReference.h"
+
+namespace WebCore {
+
+ class SVGGradientElement;
+ class SVGTransformList;
+
+ class SVGGradientElement : public SVGStyledElement,
+ public SVGURIReference,
+ public SVGExternalResourcesRequired {
+ public:
+ enum SVGGradientType {
+ SVG_SPREADMETHOD_UNKNOWN = 0,
+ SVG_SPREADMETHOD_PAD = 1,
+ SVG_SPREADMETHOD_REFLECT = 2,
+ SVG_SPREADMETHOD_REPEAT = 3
+ };
+
+ SVGGradientElement(const QualifiedName&, Document*);
+ virtual ~SVGGradientElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ virtual SVGResource* canvasResource();
+
+ protected:
+ friend class SVGPaintServerGradient;
+ friend class SVGLinearGradientElement;
+ friend class SVGRadialGradientElement;
+
+ virtual void buildGradient() const = 0;
+ virtual SVGPaintServerType gradientType() const = 0;
+
+ Vector<SVGGradientStop> buildStops() const;
+ mutable RefPtr<SVGPaintServerGradient> m_resource;
+
+ protected:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGGradientElement, int, int, SpreadMethod, spreadMethod)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGGradientElement, int, int, GradientUnits, gradientUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGGradientElement, SVGTransformList*, RefPtr<SVGTransformList>, GradientTransform, gradientTransform)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGGradientElement.idl b/WebCore/svg/SVGGradientElement.idl
new file mode 100644
index 0000000..8b09d82
--- /dev/null
+++ b/WebCore/svg/SVGGradientElement.idl
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor] SVGGradientElement : SVGElement,
+ SVGURIReference,
+ SVGExternalResourcesRequired,
+ SVGStylable
+ /* SVGUnitTypes */ {
+ // Spread Method Types
+ const unsigned short SVG_SPREADMETHOD_UNKNOWN = 0;
+ const unsigned short SVG_SPREADMETHOD_PAD = 1;
+ const unsigned short SVG_SPREADMETHOD_REFLECT = 2;
+ const unsigned short SVG_SPREADMETHOD_REPEAT = 3;
+
+ readonly attribute SVGAnimatedEnumeration gradientUnits;
+ readonly attribute SVGAnimatedTransformList gradientTransform;
+ readonly attribute SVGAnimatedEnumeration spreadMethod;
+ };
+
+}
diff --git a/WebCore/svg/SVGImageElement.cpp b/WebCore/svg/SVGImageElement.cpp
new file mode 100644
index 0000000..c17d978
--- /dev/null
+++ b/WebCore/svg/SVGImageElement.cpp
@@ -0,0 +1,147 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+ 2006 Alexander Kellett <lypanov@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGImageElement.h"
+
+#include "CSSPropertyNames.h"
+#include "RenderSVGImage.h"
+#include "SVGDocument.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+#include "SVGPreserveAspectRatio.h"
+#include "SVGSVGElement.h"
+#include "XLinkNames.h"
+
+namespace WebCore {
+
+SVGImageElement::SVGImageElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , SVGURIReference()
+ , m_x(this, LengthModeWidth)
+ , m_y(this, LengthModeHeight)
+ , m_width(this, LengthModeWidth)
+ , m_height(this, LengthModeHeight)
+ , m_preserveAspectRatio(SVGPreserveAspectRatio::create())
+ , m_imageLoader(this)
+{
+}
+
+SVGImageElement::~SVGImageElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGImageElement, SVGLength, Length, length, X, x, SVGNames::xAttr, m_x)
+ANIMATED_PROPERTY_DEFINITIONS(SVGImageElement, SVGLength, Length, length, Y, y, SVGNames::yAttr, m_y)
+ANIMATED_PROPERTY_DEFINITIONS(SVGImageElement, SVGLength, Length, length, Width, width, SVGNames::widthAttr, m_width)
+ANIMATED_PROPERTY_DEFINITIONS(SVGImageElement, SVGLength, Length, length, Height, height, SVGNames::heightAttr, m_height)
+ANIMATED_PROPERTY_DEFINITIONS(SVGImageElement, SVGPreserveAspectRatio*, PreserveAspectRatio, preserveAspectRatio, PreserveAspectRatio, preserveAspectRatio, SVGNames::preserveAspectRatioAttr, m_preserveAspectRatio.get())
+
+void SVGImageElement::parseMappedAttribute(MappedAttribute *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::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(this, LengthModeWidth, attr->value()));
+ addCSSProperty(attr, CSS_PROP_WIDTH, attr->value());
+ if (width().value() < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for image 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 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);
+ }
+}
+
+void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledTransformableElement::svgAttributeChanged(attrName);
+
+ if (!renderer())
+ return;
+
+ bool isURIAttribute = SVGURIReference::isKnownAttribute(attrName);
+
+ if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr ||
+ attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ isURIAttribute ||
+ SVGStyledTransformableElement::isKnownAttribute(attrName)) {
+ renderer()->setNeedsLayout(true);
+
+ if (isURIAttribute)
+ m_imageLoader.updateFromElement();
+ }
+}
+
+bool SVGImageElement::hasRelativeValues() const
+{
+ return (x().isRelative() || width().isRelative() ||
+ y().isRelative() || height().isRelative());
+}
+
+RenderObject* SVGImageElement::createRenderer(RenderArena* arena, RenderStyle* style)
+{
+ return new (arena) RenderSVGImage(this);
+}
+
+bool SVGImageElement::haveLoadedRequiredResources()
+{
+ return (!externalResourcesRequiredBaseValue() || m_imageLoader.imageComplete());
+}
+
+void SVGImageElement::attach()
+{
+ SVGStyledTransformableElement::attach();
+ m_imageLoader.updateFromElement();
+ if (RenderSVGImage* imageObj = static_cast<RenderSVGImage*>(renderer()))
+ imageObj->setCachedImage(m_imageLoader.image());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGImageElement.h b/WebCore/svg/SVGImageElement.h
new file mode 100644
index 0000000..c069f0f
--- /dev/null
+++ b/WebCore/svg/SVGImageElement.h
@@ -0,0 +1,81 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGImageElement_h
+#define SVGImageElement_h
+
+#if ENABLE(SVG)
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGImageLoader.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTests.h"
+#include "SVGURIReference.h"
+
+namespace WebCore {
+
+ class SVGPreserveAspectRatio;
+ class SVGLength;
+
+ class SVGImageElement : public SVGStyledTransformableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired,
+ public SVGURIReference {
+ public:
+ SVGImageElement(const QualifiedName&, Document*);
+ virtual ~SVGImageElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ virtual void attach();
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ protected:
+ virtual bool haveLoadedRequiredResources();
+
+ virtual bool hasRelativeValues() const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGLength, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGLength, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGLength, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGLength, SVGLength, Height, height)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGPreserveAspectRatio*, RefPtr<SVGPreserveAspectRatio>, PreserveAspectRatio, preserveAspectRatio)
+
+ SVGImageLoader m_imageLoader;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGImageElement.idl b/WebCore/svg/SVGImageElement.idl
new file mode 100644
index 0000000..8e2e140
--- /dev/null
+++ b/WebCore/svg/SVGImageElement.idl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGImageElement : SVGElement,
+ SVGURIReference,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable {
+ readonly attribute SVGAnimatedLength x;
+ readonly attribute SVGAnimatedLength y;
+ readonly attribute SVGAnimatedLength width;
+ readonly attribute SVGAnimatedLength height;
+ readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio;
+ };
+
+}
diff --git a/WebCore/svg/SVGImageLoader.cpp b/WebCore/svg/SVGImageLoader.cpp
new file mode 100644
index 0000000..6377266
--- /dev/null
+++ b/WebCore/svg/SVGImageLoader.cpp
@@ -0,0 +1,88 @@
+/*
+ Copyright (C) 2005, 2005 Alexander Kellett <lypanov@kde.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+
+#include "Attr.h"
+#include "DocLoader.h"
+#include "Document.h"
+
+#include "SVGImageElement.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+
+#include "RenderImage.h"
+
+namespace WebCore {
+
+SVGImageLoader::SVGImageLoader(SVGImageElement* node)
+ : HTMLImageLoader(node)
+{
+}
+
+SVGImageLoader::~SVGImageLoader()
+{
+}
+
+// FIXME - Refactor most of this code into WebCore::HTMLImageLoader or a shared WebCore::ImageLoader base class
+void SVGImageLoader::updateFromElement()
+{
+ SVGImageElement *imageElement = static_cast<SVGImageElement *>(element());
+ WebCore::Document* doc = imageElement->ownerDocument();
+
+ CachedImage *newImage = 0;
+ if (!imageElement->href().isEmpty()) {
+ KURL uri = imageElement->baseURI();
+ if (!uri.isEmpty())
+ uri = KURL(uri, imageElement->href());
+ else
+ uri = KURL(imageElement->href());
+ newImage = doc->docLoader()->requestImage(uri.string());
+ }
+
+ CachedImage* oldImage = image();
+ if (newImage != oldImage) {
+ setLoadingImage(newImage);
+ if (newImage)
+ newImage->ref(this);
+ if (oldImage)
+ oldImage->deref(this);
+ }
+
+ if (RenderImage* renderer = static_cast<RenderImage*>(imageElement->renderer()))
+ renderer->resetAnimation();
+}
+
+void SVGImageLoader::dispatchLoadEvent()
+{
+ if (!haveFiredLoadEvent() && image()) {
+ setHaveFiredLoadEvent(true);
+ if (image()->errorOccurred()) {
+ // FIXME: We're supposed to put the document in an "error state" per the spec.
+ } else
+ static_cast<SVGElement*>(element())->sendSVGLoadEventIfPossible(true);
+ }
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGImageLoader.h b/WebCore/svg/SVGImageLoader.h
new file mode 100644
index 0000000..a6497c9
--- /dev/null
+++ b/WebCore/svg/SVGImageLoader.h
@@ -0,0 +1,46 @@
+/*
+ Copyright (C) 2006 Alexander Kellett <lypanov@kde.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGImageLoader_h
+#define SVGImageLoader_h
+#if ENABLE(SVG)
+
+#include "HTMLImageLoader.h"
+
+namespace WebCore {
+
+ class SVGImageElement;
+
+ class SVGImageLoader : public HTMLImageLoader {
+ public:
+ SVGImageLoader(SVGImageElement*);
+ virtual ~SVGImageLoader();
+
+ virtual void updateFromElement();
+ virtual void dispatchLoadEvent();
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGImageLoader_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGLangSpace.cpp b/WebCore/svg/SVGLangSpace.cpp
new file mode 100644
index 0000000..638f0c1
--- /dev/null
+++ b/WebCore/svg/SVGLangSpace.cpp
@@ -0,0 +1,87 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGLangSpace.h"
+
+#include "SVGElement.h"
+#include "XMLNames.h"
+
+namespace WebCore {
+
+SVGLangSpace::SVGLangSpace()
+{
+}
+
+SVGLangSpace::~SVGLangSpace()
+{
+}
+
+const AtomicString& SVGLangSpace::xmllang() const
+{
+ return m_lang;
+}
+
+void SVGLangSpace::setXmllang(const AtomicString& xmlLang)
+{
+ m_lang = xmlLang;
+}
+
+const AtomicString& SVGLangSpace::xmlspace() const
+{
+ if (!m_space) {
+ static const AtomicString defaultString("default");
+ return defaultString;
+ }
+
+ return m_space;
+}
+
+void SVGLangSpace::setXmlspace(const AtomicString& xmlSpace)
+{
+ m_space = xmlSpace;
+}
+
+bool SVGLangSpace::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name().matches(XMLNames::langAttr)) {
+ setXmllang(attr->value());
+ return true;
+ } else if (attr->name().matches(XMLNames::spaceAttr)) {
+ setXmlspace(attr->value());
+ return true;
+ }
+
+ return false;
+}
+
+bool SVGLangSpace::isKnownAttribute(const QualifiedName& attrName)
+{
+ return (attrName.matches(XMLNames::langAttr) ||
+ attrName.matches(XMLNames::spaceAttr));
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGLangSpace.h b/WebCore/svg/SVGLangSpace.h
new file mode 100644
index 0000000..df8606e
--- /dev/null
+++ b/WebCore/svg/SVGLangSpace.h
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGLangSpace_h
+#define SVGLangSpace_h
+
+#if ENABLE(SVG)
+#include "AtomicString.h"
+
+namespace WebCore {
+
+ class MappedAttribute;
+ class QualifiedName;
+
+ class SVGLangSpace {
+ public:
+ SVGLangSpace();
+ virtual ~SVGLangSpace();
+
+ const AtomicString& xmllang() const;
+ void setXmllang(const AtomicString& xmlLang);
+
+ const AtomicString& xmlspace() const;
+ void setXmlspace(const AtomicString& xmlSpace);
+
+ bool parseMappedAttribute(MappedAttribute*);
+ bool isKnownAttribute(const QualifiedName&);
+
+ private:
+ AtomicString m_lang;
+ AtomicString m_space;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGLangSpace_h
diff --git a/WebCore/svg/SVGLangSpace.idl b/WebCore/svg/SVGLangSpace.idl
new file mode 100644
index 0000000..a10867e
--- /dev/null
+++ b/WebCore/svg/SVGLangSpace.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, ObjCProtocol] SVGLangSpace {
+ attribute core::DOMString xmllang
+ /*setter raises(DOMException)*/;
+ attribute core::DOMString xmlspace
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGLength.cpp b/WebCore/svg/SVGLength.cpp
new file mode 100644
index 0000000..e6ecb82
--- /dev/null
+++ b/WebCore/svg/SVGLength.cpp
@@ -0,0 +1,325 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+ 2007 Apple Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGLength.h"
+
+#include "CSSHelper.h"
+#include "FloatConversion.h"
+#include "FrameView.h"
+#include "RenderObject.h"
+#include "RenderView.h"
+#include "SVGParserUtilities.h"
+#include "SVGSVGElement.h"
+#include "SVGStyledElement.h"
+
+#include <math.h>
+#include <wtf/Assertions.h>
+
+namespace WebCore {
+
+// Helper functions
+static inline unsigned int storeUnit(SVGLengthMode mode, SVGLengthType type)
+{
+ return (mode << 4) | type;
+}
+
+static inline SVGLengthMode extractMode(unsigned int unit)
+{
+ unsigned int mode = unit >> 4;
+ return static_cast<SVGLengthMode>(mode);
+}
+
+static inline SVGLengthType extractType(unsigned int unit)
+{
+ unsigned int mode = unit >> 4;
+ unsigned int type = unit ^ (mode << 4);
+ return static_cast<SVGLengthType>(type);
+}
+
+static inline String lengthTypeToString(SVGLengthType type)
+{
+ switch (type) {
+ case LengthTypeUnknown:
+ case LengthTypeNumber:
+ return "";
+ case LengthTypePercentage:
+ return "%";
+ case LengthTypeEMS:
+ return "em";
+ case LengthTypeEXS:
+ return "ex";
+ case LengthTypePX:
+ return "px";
+ case LengthTypeCM:
+ return "cm";
+ case LengthTypeMM:
+ return "mm";
+ case LengthTypeIN:
+ return "in";
+ case LengthTypePT:
+ return "pt";
+ case LengthTypePC:
+ return "pc";
+ }
+
+ return String();
+}
+
+inline SVGLengthType stringToLengthType(const String& string)
+{
+ if (string.endsWith("%"))
+ return LengthTypePercentage;
+ else if (string.endsWith("em"))
+ return LengthTypeEMS;
+ else if (string.endsWith("ex"))
+ return LengthTypeEXS;
+ else if (string.endsWith("px"))
+ return LengthTypePX;
+ else if (string.endsWith("cm"))
+ return LengthTypeCM;
+ else if (string.endsWith("mm"))
+ return LengthTypeMM;
+ else if (string.endsWith("in"))
+ return LengthTypeIN;
+ else if (string.endsWith("pt"))
+ return LengthTypePT;
+ else if (string.endsWith("pc"))
+ return LengthTypePC;
+ else if (!string.isEmpty())
+ return LengthTypeNumber;
+
+ return LengthTypeUnknown;
+}
+
+SVGLength::SVGLength(const SVGStyledElement* context, SVGLengthMode mode, const String& valueAsString)
+ : m_valueInSpecifiedUnits(0.0f)
+ , m_unit(storeUnit(mode, LengthTypeNumber))
+ , m_context(context)
+{
+ setValueAsString(valueAsString);
+}
+
+SVGLengthType SVGLength::unitType() const
+{
+ return extractType(m_unit);
+}
+
+float SVGLength::value() const
+{
+ SVGLengthType type = extractType(m_unit);
+ if (type == LengthTypeUnknown)
+ return 0.0f;
+
+ switch (type) {
+ case LengthTypeNumber:
+ return m_valueInSpecifiedUnits;
+ case LengthTypePercentage:
+ return SVGLength::PercentageOfViewport(m_valueInSpecifiedUnits / 100.0f, m_context, extractMode(m_unit));
+ case LengthTypeEMS:
+ case LengthTypeEXS:
+ {
+ RenderStyle* style = 0;
+ if (m_context && m_context->renderer())
+ style = m_context->renderer()->style();
+ if (style) {
+ float useSize = style->fontSize();
+ ASSERT(useSize > 0);
+ if (type == LengthTypeEMS)
+ return m_valueInSpecifiedUnits * useSize;
+ else {
+ float xHeight = style->font().xHeight();
+ // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg
+ // if this causes problems in real world cases maybe it would be best to remove this
+ return m_valueInSpecifiedUnits * ceilf(xHeight);
+ }
+ }
+ return 0.0f;
+ }
+ case LengthTypePX:
+ return m_valueInSpecifiedUnits;
+ case LengthTypeCM:
+ return m_valueInSpecifiedUnits / 2.54f * cssPixelsPerInch;
+ case LengthTypeMM:
+ return m_valueInSpecifiedUnits / 25.4f * cssPixelsPerInch;
+ case LengthTypeIN:
+ return m_valueInSpecifiedUnits * cssPixelsPerInch;
+ case LengthTypePT:
+ return m_valueInSpecifiedUnits / 72.0f * cssPixelsPerInch;
+ case LengthTypePC:
+ return m_valueInSpecifiedUnits / 6.0f * cssPixelsPerInch;
+ default:
+ break;
+ }
+
+ ASSERT_NOT_REACHED();
+ return 0.0f;
+}
+
+void SVGLength::setValue(float value)
+{
+ SVGLengthType type = extractType(m_unit);
+ ASSERT(type != LengthTypeUnknown);
+
+ switch (type) {
+ case LengthTypeNumber:
+ m_valueInSpecifiedUnits = value;
+ break;
+ case LengthTypePercentage:
+ case LengthTypeEMS:
+ case LengthTypeEXS:
+ ASSERT_NOT_REACHED();
+ break;
+ case LengthTypePX:
+ m_valueInSpecifiedUnits = value;
+ break;
+ case LengthTypeCM:
+ m_valueInSpecifiedUnits = value * 2.54f / cssPixelsPerInch;
+ break;
+ case LengthTypeMM:
+ m_valueInSpecifiedUnits = value * 25.4f / cssPixelsPerInch;
+ break;
+ case LengthTypeIN:
+ m_valueInSpecifiedUnits = value / cssPixelsPerInch;
+ break;
+ case LengthTypePT:
+ m_valueInSpecifiedUnits = value * 72.0f / cssPixelsPerInch;
+ break;
+ case LengthTypePC:
+ m_valueInSpecifiedUnits = value / 6.0f * cssPixelsPerInch;
+ break;
+ default:
+ break;
+ }
+}
+
+void SVGLength::setValueInSpecifiedUnits(float value)
+{
+ m_valueInSpecifiedUnits = value;
+}
+
+float SVGLength::valueInSpecifiedUnits() const
+{
+ return m_valueInSpecifiedUnits;
+}
+
+float SVGLength::valueAsPercentage() const
+{
+ // 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed
+ if (extractType(m_unit) == LengthTypePercentage)
+ return valueInSpecifiedUnits() / 100.0f;
+
+ return valueInSpecifiedUnits();
+}
+
+bool SVGLength::setValueAsString(const String& s)
+{
+ if (s.isEmpty())
+ return false;
+
+ float convertedNumber = 0.0f;
+ const UChar* ptr = s.characters();
+ const UChar* end = ptr + s.length();
+
+ if (!parseNumber(ptr, end, convertedNumber, false))
+ return false;
+
+ SVGLengthType type = stringToLengthType(s);
+ if (ptr != end && type == LengthTypeNumber)
+ return false;
+
+ m_unit = storeUnit(extractMode(m_unit), type);
+ m_valueInSpecifiedUnits = convertedNumber;
+ return true;
+}
+
+String SVGLength::valueAsString() const
+{
+ return String::number(m_valueInSpecifiedUnits) + lengthTypeToString(extractType(m_unit));
+}
+
+void SVGLength::newValueSpecifiedUnits(unsigned short type, float value)
+{
+ ASSERT(type <= LengthTypePC);
+
+ m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type);
+ m_valueInSpecifiedUnits = value;
+}
+
+void SVGLength::convertToSpecifiedUnits(unsigned short type)
+{
+ ASSERT(type <= LengthTypePC);
+
+ float valueInUserUnits = value();
+ m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type);
+ setValue(valueInUserUnits);
+}
+
+float SVGLength::PercentageOfViewport(float value, const SVGStyledElement* context, SVGLengthMode mode)
+{
+ ASSERT(context);
+
+ float width = 0.0f, height = 0.0f;
+ SVGElement* viewportElement = context->viewportElement();
+
+ Document* doc = context->document();
+ if (doc->documentElement() == context) {
+ // We have to ask the canvas for the full "canvas size"...
+ RenderView* view = static_cast<RenderView*>(doc->renderer());
+ if (view && view->frameView()) {
+ width = view->frameView()->visibleWidth(); // TODO: recheck!
+ height = view->frameView()->visibleHeight(); // TODO: recheck!
+ }
+ } else if (viewportElement && viewportElement->isSVG()) {
+ const SVGSVGElement* svg = static_cast<const SVGSVGElement*>(viewportElement);
+ if (svg->hasAttribute(SVGNames::viewBoxAttr)) {
+ width = svg->viewBox().width();
+ height = svg->viewBox().height();
+ } else {
+ width = svg->width().value();
+ height = svg->height().value();
+ }
+ } else if (context->parent() && !context->parent()->isSVGElement()) {
+ if (RenderObject* renderer = context->renderer()) {
+ width = renderer->width();
+ height = renderer->height();
+ }
+ }
+
+ if (mode == LengthModeWidth)
+ return value * width;
+ else if (mode == LengthModeHeight)
+ return value * height;
+ else if (mode == LengthModeOther)
+ return value * sqrtf(powf(width, 2) + powf(height, 2)) / sqrtf(2.0f);
+
+ return 0.0f;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGLength.h b/WebCore/svg/SVGLength.h
new file mode 100644
index 0000000..543221f
--- /dev/null
+++ b/WebCore/svg/SVGLength.h
@@ -0,0 +1,111 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGLength_h
+#define SVGLength_h
+
+#if ENABLE(SVG)
+
+#include "PlatformString.h"
+
+namespace WebCore {
+
+ class SVGStyledElement;
+
+ enum SVGLengthType {
+ LengthTypeUnknown = 0,
+ LengthTypeNumber = 1,
+ LengthTypePercentage = 2,
+ LengthTypeEMS = 3,
+ LengthTypeEXS = 4,
+ LengthTypePX = 5,
+ LengthTypeCM = 6,
+ LengthTypeMM = 7,
+ LengthTypeIN = 8,
+ LengthTypePT = 9,
+ LengthTypePC = 10
+ };
+
+ enum SVGLengthMode {
+ LengthModeWidth = 0,
+ LengthModeHeight,
+ LengthModeOther
+ };
+
+ class SVGLength {
+ public:
+ // Forward declare these enums in the w3c naming scheme, for IDL generation
+ enum {
+ SVG_LENGTHTYPE_UNKNOWN = LengthTypeUnknown,
+ SVG_LENGTHTYPE_NUMBER = LengthTypeNumber,
+ SVG_LENGTHTYPE_PERCENTAGE = LengthTypePercentage,
+ SVG_LENGTHTYPE_EMS = LengthTypeEMS,
+ SVG_LENGTHTYPE_EXS = LengthTypeEXS,
+ SVG_LENGTHTYPE_PX = LengthTypePX,
+ SVG_LENGTHTYPE_CM = LengthTypeCM,
+ SVG_LENGTHTYPE_MM = LengthTypeMM,
+ SVG_LENGTHTYPE_IN = LengthTypeIN,
+ SVG_LENGTHTYPE_PT = LengthTypePT,
+ SVG_LENGTHTYPE_PC = LengthTypePC
+ };
+
+ SVGLength(const SVGStyledElement* context = 0, SVGLengthMode mode = LengthModeOther, const String& valueAsString = String());
+
+ // 'SVGLength' functions
+ SVGLengthType unitType() const;
+
+ float value() const;
+ void setValue(float);
+
+ float valueInSpecifiedUnits() const;
+ void setValueInSpecifiedUnits(float);
+
+ float valueAsPercentage() const;
+
+ String valueAsString() const;
+ bool setValueAsString(const String&);
+
+ void newValueSpecifiedUnits(unsigned short, float valueInSpecifiedUnits);
+ void convertToSpecifiedUnits(unsigned short);
+
+ // Helper functions
+ static float PercentageOfViewport(float value, const SVGStyledElement*, SVGLengthMode);
+
+ inline bool isRelative() const
+ {
+ SVGLengthType type = unitType();
+ return (type == LengthTypePercentage || type == LengthTypeEMS || type == LengthTypeEXS);
+ }
+
+ private:
+ float m_valueInSpecifiedUnits;
+ unsigned int m_unit;
+
+ const SVGStyledElement* m_context;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGLength_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGLength.idl b/WebCore/svg/SVGLength.idl
new file mode 100644
index 0000000..707469e
--- /dev/null
+++ b/WebCore/svg/SVGLength.idl
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor, PODType=SVGLength] SVGLength {
+ // Length Unit Types
+ const unsigned short SVG_LENGTHTYPE_UNKNOWN = 0;
+ const unsigned short SVG_LENGTHTYPE_NUMBER = 1;
+ const unsigned short SVG_LENGTHTYPE_PERCENTAGE = 2;
+ const unsigned short SVG_LENGTHTYPE_EMS = 3;
+ const unsigned short SVG_LENGTHTYPE_EXS = 4;
+ const unsigned short SVG_LENGTHTYPE_PX = 5;
+ const unsigned short SVG_LENGTHTYPE_CM = 6;
+ const unsigned short SVG_LENGTHTYPE_MM = 7;
+ const unsigned short SVG_LENGTHTYPE_IN = 8;
+ const unsigned short SVG_LENGTHTYPE_PT = 9;
+ const unsigned short SVG_LENGTHTYPE_PC = 10;
+
+ readonly attribute unsigned short unitType;
+ attribute float value;
+ attribute float valueInSpecifiedUnits;
+ attribute [ConvertNullToNullString] DOMString valueAsString;
+
+ void newValueSpecifiedUnits(in unsigned short unitType,
+ in float valueInSpecifiedUnits);
+ void convertToSpecifiedUnits(in unsigned short unitType);
+ };
+
+}
diff --git a/WebCore/svg/SVGLengthList.cpp b/WebCore/svg/SVGLengthList.cpp
new file mode 100644
index 0000000..c2d8160
--- /dev/null
+++ b/WebCore/svg/SVGLengthList.cpp
@@ -0,0 +1,64 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGLengthList.h"
+
+#include "SVGParserUtilities.h"
+
+namespace WebCore {
+
+SVGLengthList::SVGLengthList(const QualifiedName& attributeName)
+ : SVGPODList<SVGLength>(attributeName)
+{
+}
+
+SVGLengthList::~SVGLengthList()
+{
+}
+
+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;
+ SVGLength length(context, mode);
+ if (!length.setValueAsString(String(start, ptr - start)))
+ return;
+ appendItem(length, ec);
+ skipOptionalSpacesOrDelimiter(ptr, end);
+ }
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGLengthList.h b/WebCore/svg/SVGLengthList.h
new file mode 100644
index 0000000..a2c615d
--- /dev/null
+++ b/WebCore/svg/SVGLengthList.h
@@ -0,0 +1,46 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGLengthList_h
+#define SVGLengthList_h
+
+#if ENABLE(SVG)
+#include "SVGLength.h"
+#include "SVGList.h"
+
+namespace WebCore {
+
+ class SVGLengthList : public SVGPODList<SVGLength> {
+ public:
+ static PassRefPtr<SVGLengthList> create(const QualifiedName& attributeName) { return adoptRef(new SVGLengthList(attributeName)); }
+ virtual ~SVGLengthList();
+
+ void parse(const String& value, const SVGStyledElement* context, SVGLengthMode mode);
+
+ private:
+ SVGLengthList(const QualifiedName&);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGLengthList.idl b/WebCore/svg/SVGLengthList.idl
new file mode 100644
index 0000000..b11811b
--- /dev/null
+++ b/WebCore/svg/SVGLengthList.idl
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGLengthList {
+ readonly attribute unsigned long numberOfItems;
+
+ void clear()
+ raises(DOMException);
+ SVGLength initialize(in SVGLength item)
+ raises(DOMException, SVGException);
+ SVGLength getItem(in unsigned long index)
+ raises(DOMException);
+ SVGLength insertItemBefore(in SVGLength item, in unsigned long index)
+ raises(DOMException, SVGException);
+ SVGLength replaceItem(in SVGLength item, in unsigned long index)
+ raises(DOMException, SVGException);
+ SVGLength removeItem(in unsigned long index)
+ raises(DOMException);
+ SVGLength appendItem(in SVGLength item)
+ raises(DOMException, SVGException);
+ };
+
+}
diff --git a/WebCore/svg/SVGLineElement.cpp b/WebCore/svg/SVGLineElement.cpp
new file mode 100644
index 0000000..3b664d1
--- /dev/null
+++ b/WebCore/svg/SVGLineElement.cpp
@@ -0,0 +1,108 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGLineElement.h"
+
+#include "FloatPoint.h"
+#include "RenderPath.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+SVGLineElement::SVGLineElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_x1(this, LengthModeWidth)
+ , m_y1(this, LengthModeHeight)
+ , m_x2(this, LengthModeWidth)
+ , m_y2(this, LengthModeHeight)
+{
+}
+
+SVGLineElement::~SVGLineElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, X1, x1, SVGNames::x1Attr, m_x1)
+ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, Y1, y1, SVGNames::y1Attr, m_y1)
+ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, X2, x2, SVGNames::x2Attr, m_x2)
+ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, Y2, y2, SVGNames::y2Attr, m_y2)
+
+void SVGLineElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::x1Attr)
+ setX1BaseValue(SVGLength(this, LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::y1Attr)
+ setY1BaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::x2Attr)
+ setX2BaseValue(SVGLength(this, LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::y2Attr)
+ setY2BaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ else
+ {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ SVGStyledTransformableElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGLineElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledTransformableElement::svgAttributeChanged(attrName);
+
+ if (!renderer())
+ return;
+
+ if (attrName == SVGNames::x1Attr || attrName == SVGNames::y1Attr ||
+ attrName == SVGNames::x2Attr || attrName == SVGNames::y2Attr ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledTransformableElement::isKnownAttribute(attrName))
+ renderer()->setNeedsLayout(true);
+}
+
+Path SVGLineElement::toPathData() const
+{
+ return Path::createLine(FloatPoint(x1().value(), y1().value()),
+ FloatPoint(x2().value(), y2().value()));
+}
+
+bool SVGLineElement::hasRelativeValues() const
+{
+ return (x1().isRelative() || y1().isRelative() ||
+ x2().isRelative() || y2().isRelative());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGLineElement.h b/WebCore/svg/SVGLineElement.h
new file mode 100644
index 0000000..c6dbc08
--- /dev/null
+++ b/WebCore/svg/SVGLineElement.h
@@ -0,0 +1,69 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGLineElement_h
+#define SVGLineElement_h
+
+#if ENABLE(SVG)
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTests.h"
+
+namespace WebCore {
+
+ class SVGLength;
+
+ class SVGLineElement : public SVGStyledTransformableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired {
+ public:
+ SVGLineElement(const QualifiedName&, Document*);
+ virtual ~SVGLineElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ virtual Path toPathData() const;
+
+ virtual bool supportsMarkers() const { return true; }
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+ virtual bool hasRelativeValues() const;
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLineElement, SVGLength, SVGLength, X1, x1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLineElement, SVGLength, SVGLength, Y1, y1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLineElement, SVGLength, SVGLength, X2, x2)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLineElement, SVGLength, SVGLength, Y2, y2)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGLineElement.idl b/WebCore/svg/SVGLineElement.idl
new file mode 100644
index 0000000..28ed228
--- /dev/null
+++ b/WebCore/svg/SVGLineElement.idl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGLineElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable {
+ readonly attribute SVGAnimatedLength x1;
+ readonly attribute SVGAnimatedLength y1;
+ readonly attribute SVGAnimatedLength x2;
+ readonly attribute SVGAnimatedLength y2;
+ };
+
+}
diff --git a/WebCore/svg/SVGLinearGradientElement.cpp b/WebCore/svg/SVGLinearGradientElement.cpp
new file mode 100644
index 0000000..6cddf07
--- /dev/null
+++ b/WebCore/svg/SVGLinearGradientElement.cpp
@@ -0,0 +1,164 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGLinearGradientElement.h"
+
+#include "FloatPoint.h"
+#include "LinearGradientAttributes.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+#include "SVGPaintServerLinearGradient.h"
+#include "SVGTransform.h"
+#include "SVGTransformList.h"
+#include "SVGUnitTypes.h"
+
+namespace WebCore {
+
+SVGLinearGradientElement::SVGLinearGradientElement(const QualifiedName& tagName, Document* doc)
+ : SVGGradientElement(tagName, doc)
+ , m_x1(this, LengthModeWidth)
+ , m_y1(this, LengthModeHeight)
+ , m_x2(this, LengthModeWidth)
+ , m_y2(this, LengthModeHeight)
+{
+ // Spec: If the attribute is not specified, the effect is as if a value of "100%" were specified.
+ setX2BaseValue(SVGLength(this, LengthModeWidth, "100%"));
+}
+
+SVGLinearGradientElement::~SVGLinearGradientElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGLinearGradientElement, SVGLength, Length, length, X1, x1, SVGNames::x1Attr, m_x1)
+ANIMATED_PROPERTY_DEFINITIONS(SVGLinearGradientElement, SVGLength, Length, length, Y1, y1, SVGNames::y1Attr, m_y1)
+ANIMATED_PROPERTY_DEFINITIONS(SVGLinearGradientElement, SVGLength, Length, length, X2, x2, SVGNames::x2Attr, m_x2)
+ANIMATED_PROPERTY_DEFINITIONS(SVGLinearGradientElement, SVGLength, Length, length, Y2, y2, SVGNames::y2Attr, m_y2)
+
+void SVGLinearGradientElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::x1Attr)
+ setX1BaseValue(SVGLength(this, LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::y1Attr)
+ setY1BaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::x2Attr)
+ setX2BaseValue(SVGLength(this, LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::y2Attr)
+ setY2BaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ else
+ SVGGradientElement::parseMappedAttribute(attr);
+}
+
+void SVGLinearGradientElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGGradientElement::svgAttributeChanged(attrName);
+
+ if (!m_resource)
+ return;
+
+ if (attrName == SVGNames::x1Attr || attrName == SVGNames::y1Attr ||
+ attrName == SVGNames::x2Attr || attrName == SVGNames::y2Attr)
+ m_resource->invalidate();
+}
+
+void SVGLinearGradientElement::buildGradient() const
+{
+ LinearGradientAttributes attributes = collectGradientProperties();
+
+ // If we didn't find any gradient containing stop elements, ignore the request.
+ if (attributes.stops().isEmpty())
+ return;
+
+ RefPtr<SVGPaintServerLinearGradient> linearGradient = WTF::static_pointer_cast<SVGPaintServerLinearGradient>(m_resource);
+
+ linearGradient->setGradientStops(attributes.stops());
+ linearGradient->setBoundingBoxMode(attributes.boundingBoxMode());
+ linearGradient->setGradientSpreadMethod(attributes.spreadMethod());
+ linearGradient->setGradientTransform(attributes.gradientTransform());
+ linearGradient->setGradientStart(FloatPoint::narrowPrecision(attributes.x1(), attributes.y1()));
+ linearGradient->setGradientEnd(FloatPoint::narrowPrecision(attributes.x2(), attributes.y2()));
+}
+
+LinearGradientAttributes SVGLinearGradientElement::collectGradientProperties() const
+{
+ LinearGradientAttributes attributes;
+ HashSet<const SVGGradientElement*> processedGradients;
+
+ bool isLinear = true;
+ const SVGGradientElement* current = this;
+
+ while (current) {
+ if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spreadMethodAttr))
+ attributes.setSpreadMethod((SVGGradientSpreadMethod) current->spreadMethod());
+
+ if (!attributes.hasBoundingBoxMode() && current->hasAttribute(SVGNames::gradientUnitsAttr))
+ attributes.setBoundingBoxMode(current->getAttribute(SVGNames::gradientUnitsAttr) == "objectBoundingBox");
+
+ if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames::gradientTransformAttr))
+ attributes.setGradientTransform(current->gradientTransform()->consolidate().matrix());
+
+ if (!attributes.hasStops()) {
+ const Vector<SVGGradientStop>& stops(current->buildStops());
+ if (!stops.isEmpty())
+ attributes.setStops(stops);
+ }
+
+ if (isLinear) {
+ const SVGLinearGradientElement* linear = static_cast<const SVGLinearGradientElement*>(current);
+
+ if (!attributes.hasX1() && current->hasAttribute(SVGNames::x1Attr))
+ attributes.setX1(linear->x1().valueAsPercentage());
+
+ if (!attributes.hasY1() && current->hasAttribute(SVGNames::y1Attr))
+ attributes.setY1(linear->y1().valueAsPercentage());
+
+ if (!attributes.hasX2() && current->hasAttribute(SVGNames::x2Attr))
+ attributes.setX2(linear->x2().valueAsPercentage());
+
+ if (!attributes.hasY2() && current->hasAttribute(SVGNames::y2Attr))
+ attributes.setY2(linear->y2().valueAsPercentage());
+ }
+
+ processedGradients.add(current);
+
+ // Respect xlink:href, take attributes from referenced element
+ Node* refNode = ownerDocument()->getElementById(SVGURIReference::getTarget(current->href()));
+ if (refNode && (refNode->hasTagName(SVGNames::linearGradientTag) || refNode->hasTagName(SVGNames::radialGradientTag))) {
+ current = static_cast<const SVGGradientElement*>(const_cast<const Node*>(refNode));
+
+ // Cycle detection
+ if (processedGradients.contains(current))
+ return LinearGradientAttributes();
+
+ isLinear = current->gradientType() == LinearGradientPaintServer;
+ } else
+ current = 0;
+ }
+
+ return attributes;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGLinearGradientElement.h b/WebCore/svg/SVGLinearGradientElement.h
new file mode 100644
index 0000000..496585e
--- /dev/null
+++ b/WebCore/svg/SVGLinearGradientElement.h
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGLinearGradientElement_h
+#define SVGLinearGradientElement_h
+
+#if ENABLE(SVG)
+#include "SVGGradientElement.h"
+
+namespace WebCore {
+
+ struct LinearGradientAttributes;
+ class SVGLength;
+
+ class SVGLinearGradientElement : public SVGGradientElement {
+ public:
+ SVGLinearGradientElement(const QualifiedName&, Document*);
+ virtual ~SVGLinearGradientElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ protected:
+ virtual void buildGradient() const;
+ virtual SVGPaintServerType gradientType() const { return LinearGradientPaintServer; }
+
+ LinearGradientAttributes collectGradientProperties() const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLinearGradientElement, SVGLength, SVGLength, X1, x1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLinearGradientElement, SVGLength, SVGLength, Y1, y1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLinearGradientElement, SVGLength, SVGLength, X2, x2)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLinearGradientElement, SVGLength, SVGLength, Y2, y2)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGLinearGradientElement.idl b/WebCore/svg/SVGLinearGradientElement.idl
new file mode 100644
index 0000000..eb3eac1
--- /dev/null
+++ b/WebCore/svg/SVGLinearGradientElement.idl
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGLinearGradientElement : SVGGradientElement {
+ readonly attribute SVGAnimatedLength x1;
+ readonly attribute SVGAnimatedLength y1;
+ readonly attribute SVGAnimatedLength x2;
+ readonly attribute SVGAnimatedLength y2;
+ };
+
+}
diff --git a/WebCore/svg/SVGList.h b/WebCore/svg/SVGList.h
new file mode 100644
index 0000000..d4f7641
--- /dev/null
+++ b/WebCore/svg/SVGList.h
@@ -0,0 +1,256 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGList_h
+#define SVGList_h
+
+#if ENABLE(SVG)
+#include "ExceptionCode.h"
+#include "SVGListTraits.h"
+
+#include <wtf/RefCounted.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+ class QualifiedName;
+
+ template<typename Item>
+ struct SVGListTypeOperations {
+ static Item nullItem()
+ {
+ return SVGListTraits<UsesDefaultInitializer<Item>::value, Item>::nullItem();
+ }
+ };
+
+ template<typename Item>
+ class SVGList : public RefCounted<SVGList<Item> > {
+ private:
+ typedef SVGListTypeOperations<Item> TypeOperations;
+
+ public:
+ virtual ~SVGList() { }
+
+ const QualifiedName& associatedAttributeName() const { return m_associatedAttributeName; }
+
+ unsigned int numberOfItems() const { return m_vector.size(); }
+ void clear(ExceptionCode &) { m_vector.clear(); }
+
+ Item initialize(Item newItem, ExceptionCode& ec)
+ {
+ clear(ec);
+ return appendItem(newItem, ec);
+ }
+
+ Item getFirst() const
+ {
+ ExceptionCode ec = 0;
+ return getItem(0, ec);
+ }
+
+ Item getLast() const
+ {
+ ExceptionCode ec = 0;
+ return getItem(m_vector.size() - 1, ec);
+ }
+
+ Item getItem(unsigned int index, ExceptionCode& ec)
+ {
+ if (index >= m_vector.size()) {
+ ec = INDEX_SIZE_ERR;
+ return TypeOperations::nullItem();
+ }
+
+ return m_vector.at(index);
+ }
+
+ const Item getItem(unsigned int index, ExceptionCode& ec) const
+ {
+ if (index >= m_vector.size()) {
+ ec = INDEX_SIZE_ERR;
+ return TypeOperations::nullItem();
+ }
+
+ return m_vector[index];
+ }
+
+ Item insertItemBefore(Item newItem, unsigned int index, ExceptionCode&)
+ {
+ m_vector.insert(index, newItem);
+ return newItem;
+ }
+
+ Item replaceItem(Item newItem, unsigned int index, ExceptionCode& ec)
+ {
+ if (index >= m_vector.size()) {
+ ec = INDEX_SIZE_ERR;
+ return TypeOperations::nullItem();
+ }
+
+ m_vector[index] = newItem;
+ return newItem;
+ }
+
+ Item removeItem(unsigned int index, ExceptionCode& ec)
+ {
+ if (index >= m_vector.size()) {
+ ec = INDEX_SIZE_ERR;
+ return TypeOperations::nullItem();
+ }
+
+ Item item = m_vector[index];
+ m_vector.remove(index);
+ return item;
+ }
+
+ Item appendItem(Item newItem, ExceptionCode&)
+ {
+ m_vector.append(newItem);
+ return newItem;
+ }
+
+ protected:
+ SVGList(const QualifiedName& attributeName)
+ : m_associatedAttributeName(attributeName)
+ {
+ }
+
+ private:
+ Vector<Item> m_vector;
+ const QualifiedName& m_associatedAttributeName;
+ };
+
+ template<typename Item>
+ class SVGPODListItem : public RefCounted<SVGPODListItem<Item> > {
+ public:
+ static PassRefPtr<SVGPODListItem> create() { return adoptRef(new SVGPODListItem); }
+ static PassRefPtr<SVGPODListItem> copy(const Item& item) { return adoptRef(new SVGPODListItem(item)); }
+
+ operator Item&() { return m_item; }
+ operator const Item&() const { return m_item; }
+
+ // Updating facilities, used by JSSVGPODTypeWrapperCreatorForList
+ Item value() const { return m_item; }
+ void setValue(Item newItem) { m_item = newItem; }
+
+ private:
+ SVGPODListItem() : m_item() { }
+ SVGPODListItem(const Item& item) : RefCounted<SVGPODListItem<Item> >(), m_item(item) { }
+
+ Item m_item;
+ };
+
+ template<typename Item>
+ class SVGPODList : public SVGList<RefPtr<SVGPODListItem<Item> > >
+ {
+ public:
+ Item initialize(Item newItem, ExceptionCode& ec)
+ {
+ SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::initialize(SVGPODListItem<Item>::copy(newItem), ec).get());
+ if (!ptr)
+ return Item();
+
+ return static_cast<const Item&>(*ptr);
+ }
+
+ Item getFirst() const
+ {
+ SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::getFirst().get());
+ if (!ptr)
+ return Item();
+
+ return static_cast<const Item&>(*ptr);
+ }
+
+ Item getLast() const
+ {
+ SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::getLast().get());
+ if (!ptr)
+ return Item();
+
+ return static_cast<const Item&>(*ptr);
+ }
+
+ Item getItem(unsigned int index, ExceptionCode& ec)
+ {
+ SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::getItem(index, ec).get());
+ if (!ptr)
+ return Item();
+
+ return static_cast<const Item&>(*ptr);
+ }
+
+ const Item getItem(unsigned int index, ExceptionCode& ec) const
+ {
+ SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::getItem(index, ec).get());
+ if (!ptr)
+ return Item();
+
+ return static_cast<const Item&>(*ptr);
+ }
+
+ Item insertItemBefore(Item newItem, unsigned int index, ExceptionCode& ec)
+ {
+ SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::insertItemBefore(SVGPODListItem<Item>::copy(newItem), index, ec).get());
+ if (!ptr)
+ return Item();
+
+ return static_cast<const Item&>(*ptr);
+ }
+
+ Item replaceItem(Item newItem, unsigned int index, ExceptionCode& ec)
+ {
+ SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::replaceItem(SVGPODListItem<Item>::copy(newItem), index, ec).get());
+ if (!ptr)
+ return Item();
+
+ return static_cast<const Item&>(*ptr);
+ }
+
+ Item removeItem(unsigned int index, ExceptionCode& ec)
+ {
+ SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::removeItem(index, ec).get());
+ if (!ptr)
+ return Item();
+
+ return static_cast<const Item&>(*ptr);
+ }
+
+ Item appendItem(Item newItem, ExceptionCode& ec)
+ {
+ SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::appendItem(SVGPODListItem<Item>::copy(newItem), ec).get());
+ if (!ptr)
+ return Item();
+
+ return static_cast<const Item&>(*ptr);
+ }
+
+ protected:
+ SVGPODList(const QualifiedName& attributeName)
+ : SVGList<RefPtr<SVGPODListItem<Item> > >(attributeName) { }
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGList_h
diff --git a/WebCore/svg/SVGListTraits.h b/WebCore/svg/SVGListTraits.h
new file mode 100644
index 0000000..b028ad5
--- /dev/null
+++ b/WebCore/svg/SVGListTraits.h
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+ 2006 Apple Computer Inc.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGListTraits_h
+#define SVGListTraits_h
+
+#if ENABLE(SVG)
+
+namespace WebCore {
+
+ template<typename Item> struct UsesDefaultInitializer { static const bool value = true; };
+ template<> struct UsesDefaultInitializer<double> { static const bool value = false; };
+
+ template<bool usesDefaultInitializer, typename Item>
+ struct SVGListTraits { };
+
+ template<typename Item>
+ struct SVGListTraits<true, Item>
+ {
+ static Item nullItem() { return Item(); }
+ };
+
+ template<>
+ struct SVGListTraits<false, double>
+ {
+ static double nullItem() { return 0.0; }
+ };
+
+} // namespace WebCore
+
+#endif // SVG_SUPPORT
+#endif // SVGListTraits_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGLocatable.cpp b/WebCore/svg/SVGLocatable.cpp
new file mode 100644
index 0000000..91564a5
--- /dev/null
+++ b/WebCore/svg/SVGLocatable.cpp
@@ -0,0 +1,158 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+
+#include "SVGLocatable.h"
+
+#include "AffineTransform.h"
+#include "RenderPath.h"
+#include "SVGException.h"
+#include "SVGSVGElement.h"
+
+namespace WebCore {
+
+SVGLocatable::SVGLocatable()
+{
+}
+
+SVGLocatable::~SVGLocatable()
+{
+}
+
+SVGElement* SVGLocatable::nearestViewportElement(const SVGStyledElement* e)
+{
+ Node* n = e->parentNode();
+ while (n && !n->isDocumentNode()) {
+ if (n->hasTagName(SVGNames::svgTag) || n->hasTagName(SVGNames::symbolTag) ||
+ n->hasTagName(SVGNames::imageTag))
+ return static_cast<SVGElement*>(n);
+#if ENABLE(SVG_FOREIGN_OBJECT)
+ if (n->hasTagName(SVGNames::foreignObjectTag))
+ return static_cast<SVGElement*>(n);
+#endif
+
+ n = n->parentNode();
+ }
+
+ return 0;
+}
+
+SVGElement* SVGLocatable::farthestViewportElement(const SVGStyledElement* e)
+{
+ // FIXME : likely this will be always the <svg> farthest away.
+ // If we have a different implementation of documentElement(), one
+ // that give the documentElement() of the svg fragment, it could be
+ // used instead. This depends on cdf demands though(Rob.)
+ SVGElement* farthest = 0;
+ Node* n = e->parentNode();
+ while (n && !n->isDocumentNode()) {
+ if (n->hasTagName(SVGNames::svgTag) || n->hasTagName(SVGNames::symbolTag) ||
+ n->hasTagName(SVGNames::imageTag))
+ farthest = static_cast<SVGElement*>(n);
+#if ENABLE(SVG_FOREIGN_OBJECT)
+ if (n->hasTagName(SVGNames::foreignObjectTag))
+ farthest = static_cast<SVGElement*>(n);
+#endif
+
+ n = n->parentNode();
+ }
+
+ return farthest;
+}
+
+// Spec:
+// http://www.w3.org/TR/2005/WD-SVGMobile12-20050413/svgudom.html#svg::SVGLocatable
+FloatRect SVGLocatable::getBBox(const SVGStyledElement* e)
+{
+ FloatRect bboxRect;
+
+ if (e && e->renderer()) {
+ // Need this to make sure we have render object dimensions.
+ // See bug 11686.
+ e->document()->updateLayoutIgnorePendingStylesheets();
+ bboxRect = e->renderer()->relativeBBox(false);
+ }
+
+ return bboxRect;
+}
+
+AffineTransform SVGLocatable::getCTM(const SVGElement* element)
+{
+ if (!element)
+ return AffineTransform();
+
+ AffineTransform ctm;
+
+ Node* parent = element->parentNode();
+ if (parent && parent->isSVGElement()) {
+ SVGElement* parentElement = static_cast<SVGElement*>(parent);
+ if (parentElement && parentElement->isStyledLocatable()) {
+ AffineTransform parentCTM = static_cast<SVGStyledLocatableElement*>(parentElement)->getCTM();
+ ctm = parentCTM * ctm;
+ }
+ }
+
+ return ctm;
+}
+
+AffineTransform SVGLocatable::getScreenCTM(const SVGElement* element)
+{
+ if (!element)
+ return AffineTransform();
+
+ AffineTransform ctm;
+
+ Node* parent = element->parentNode();
+ if (parent && parent->isSVGElement()) {
+ SVGElement* parentElement = static_cast<SVGElement*>(parent);
+ if (parentElement && parentElement->isStyledLocatable()) {
+ AffineTransform parentCTM = static_cast<SVGStyledLocatableElement*>(parentElement)->getScreenCTM();
+ ctm = parentCTM * ctm;
+ }
+ }
+
+ return ctm;
+}
+
+AffineTransform SVGLocatable::getTransformToElement(SVGElement* target, ExceptionCode& ec) const
+{
+ AffineTransform ctm = getCTM();
+
+ if (target && target->isStyledLocatable()) {
+ AffineTransform targetCTM = static_cast<SVGStyledLocatableElement*>(target)->getCTM();
+ if (!targetCTM.isInvertible()) {
+ ec = SVGException::SVG_MATRIX_NOT_INVERTABLE;
+ return ctm;
+ }
+ ctm *= targetCTM.inverse();
+ }
+
+ return ctm;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGLocatable.h b/WebCore/svg/SVGLocatable.h
new file mode 100644
index 0000000..d9cf685
--- /dev/null
+++ b/WebCore/svg/SVGLocatable.h
@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGLocatable_h
+#define SVGLocatable_h
+
+#if ENABLE(SVG)
+
+#include "ExceptionCode.h"
+
+namespace WebCore {
+
+ class AffineTransform;
+ class FloatRect;
+ class SVGElement;
+ class SVGStyledElement;
+
+ class SVGLocatable {
+ public:
+ SVGLocatable();
+ virtual ~SVGLocatable();
+
+ // 'SVGLocatable' functions
+ virtual SVGElement* nearestViewportElement() const = 0;
+ virtual SVGElement* farthestViewportElement() const = 0;
+
+ virtual FloatRect getBBox() const = 0;
+ virtual AffineTransform getCTM() const = 0;
+ virtual AffineTransform getScreenCTM() const = 0;
+ AffineTransform getTransformToElement(SVGElement*, ExceptionCode&) const;
+
+ static SVGElement* nearestViewportElement(const SVGStyledElement*);
+ static SVGElement* farthestViewportElement(const SVGStyledElement*);
+
+ protected:
+ static FloatRect getBBox(const SVGStyledElement*);
+ static AffineTransform getCTM(const SVGElement*);
+ static AffineTransform getScreenCTM(const SVGElement*);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGLocatable_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGLocatable.idl b/WebCore/svg/SVGLocatable.idl
new file mode 100644
index 0000000..b051286
--- /dev/null
+++ b/WebCore/svg/SVGLocatable.idl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, ObjCProtocol] SVGLocatable {
+ readonly attribute SVGElement nearestViewportElement;
+ readonly attribute SVGElement farthestViewportElement;
+
+ SVGRect getBBox();
+ SVGMatrix getCTM();
+ SVGMatrix getScreenCTM();
+ SVGMatrix getTransformToElement(in SVGElement element)
+ raises(SVGException);
+ };
+
+}
diff --git a/WebCore/svg/SVGMPathElement.cpp b/WebCore/svg/SVGMPathElement.cpp
new file mode 100644
index 0000000..61bf633
--- /dev/null
+++ b/WebCore/svg/SVGMPathElement.cpp
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGMPathElement.h"
+#include "SVGPathElement.h"
+
+namespace WebCore {
+
+SVGMPathElement::SVGMPathElement(const QualifiedName& qname, Document* doc)
+ : SVGElement(qname, doc)
+{
+}
+
+SVGMPathElement::~SVGMPathElement()
+{
+}
+
+void SVGMPathElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (SVGURIReference::parseMappedAttribute(attr))
+ return;
+ SVGElement::parseMappedAttribute(attr);
+}
+
+SVGPathElement* SVGMPathElement::pathElement()
+{
+ Element* target = document()->getElementById(getTarget(SVGURIReference::href()));
+ if (target && target->hasTagName(SVGNames::pathTag))
+ return static_cast<SVGPathElement*>(target);
+ return 0;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGMPathElement.h b/WebCore/svg/SVGMPathElement.h
new file mode 100644
index 0000000..1e84cc7
--- /dev/null
+++ b/WebCore/svg/SVGMPathElement.h
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGMPathElement_h
+#define SVGMPathElement_h
+#if ENABLE(SVG)
+
+#include "SVGURIReference.h"
+#include "SVGExternalResourcesRequired.h"
+
+namespace WebCore {
+
+ class SVGPathElement;
+
+ class SVGMPathElement : public SVGElement,
+ SVGURIReference,
+ SVGExternalResourcesRequired
+ {
+ public:
+ SVGMPathElement(const QualifiedName&, Document*);
+ virtual ~SVGMPathElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ SVGPathElement* pathElement();
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGMPathElement_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGMarkerElement.cpp b/WebCore/svg/SVGMarkerElement.cpp
new file mode 100644
index 0000000..60d6a51
--- /dev/null
+++ b/WebCore/svg/SVGMarkerElement.cpp
@@ -0,0 +1,177 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGMarkerElement.h"
+
+#include "PlatformString.h"
+#include "RenderSVGViewportContainer.h"
+#include "SVGAngle.h"
+#include "SVGFitToViewBox.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+#include "SVGPreserveAspectRatio.h"
+#include "SVGSVGElement.h"
+
+namespace WebCore {
+
+SVGMarkerElement::SVGMarkerElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , SVGFitToViewBox()
+ , m_refX(this, LengthModeWidth)
+ , m_refY(this, LengthModeHeight)
+ , m_markerWidth(this, LengthModeWidth)
+ , m_markerHeight(this, LengthModeHeight)
+ , m_markerUnits(SVG_MARKERUNITS_STROKEWIDTH)
+ , m_orientType(0)
+ , m_orientAngle(new SVGAngle())
+{
+ // Spec: If the attribute is not specified, the effect is as if a value of "3" were specified.
+ setMarkerWidthBaseValue(SVGLength(this, LengthModeWidth, "3"));
+ setMarkerHeightBaseValue(SVGLength(this, LengthModeHeight, "3"));
+}
+
+SVGMarkerElement::~SVGMarkerElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement, SVGLength, Length, length, RefX, refX, SVGNames::refXAttr, m_refX)
+ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement, SVGLength, Length, length, RefY, refY, SVGNames::refYAttr, m_refY)
+ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement, int, Enumeration, enumeration, MarkerUnits, markerUnits, SVGNames::markerUnitsAttr, m_markerUnits)
+ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement, SVGLength, Length, length, MarkerWidth, markerWidth, SVGNames::markerWidthAttr, m_markerWidth)
+ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement, SVGLength, Length, length, MarkerHeight, markerHeight, SVGNames::markerHeightAttr, m_markerHeight)
+ANIMATED_PROPERTY_DEFINITIONS_WITH_CUSTOM_IDENTIFIER(SVGMarkerElement, int, Enumeration, enumeration, OrientType, orientType, SVGNames::orientAttr, "orientType", m_orientType)
+ANIMATED_PROPERTY_DEFINITIONS_WITH_CUSTOM_IDENTIFIER(SVGMarkerElement, SVGAngle*, Angle, angle, OrientAngle, orientAngle, SVGNames::orientAttr, "orientAngle", m_orientAngle.get())
+
+void SVGMarkerElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::markerUnitsAttr) {
+ if (attr->value() == "userSpaceOnUse")
+ setMarkerUnitsBaseValue(SVG_MARKERUNITS_USERSPACEONUSE);
+ } else if (attr->name() == SVGNames::refXAttr)
+ setRefXBaseValue(SVGLength(this, LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::refYAttr)
+ setRefYBaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::markerWidthAttr)
+ setMarkerWidthBaseValue(SVGLength(this, LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::markerHeightAttr)
+ setMarkerHeightBaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::orientAttr) {
+ if (attr->value() == "auto")
+ setOrientToAuto();
+ else {
+ SVGAngle* angle = new SVGAngle();
+ angle->setValueAsString(attr->value());
+ setOrientToAngle(angle);
+ }
+ } else {
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ if (SVGFitToViewBox::parseMappedAttribute(attr))
+ return;
+
+ SVGStyledElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGMarkerElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledElement::svgAttributeChanged(attrName);
+
+ if (!m_marker)
+ return;
+
+ if (attrName == SVGNames::markerUnitsAttr || attrName == SVGNames::refXAttr ||
+ attrName == SVGNames::refYAttr || attrName == SVGNames::markerWidthAttr ||
+ attrName == SVGNames::markerHeightAttr || attrName == SVGNames::orientAttr ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGFitToViewBox::isKnownAttribute(attrName) ||
+ SVGStyledElement::isKnownAttribute(attrName)) {
+ if (renderer())
+ renderer()->setNeedsLayout(true);
+
+ m_marker->invalidate();
+ }
+}
+
+void SVGMarkerElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+
+ if (renderer())
+ renderer()->setNeedsLayout(true);
+
+ if (m_marker)
+ m_marker->invalidate();
+}
+
+void SVGMarkerElement::setOrientToAuto()
+{
+ setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO);
+}
+
+void SVGMarkerElement::setOrientToAngle(SVGAngle* angle)
+{
+ setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE);
+ setOrientAngleBaseValue(angle);
+}
+
+SVGResource* SVGMarkerElement::canvasResource()
+{
+ if (!m_marker)
+ m_marker = SVGResourceMarker::create();
+
+ m_marker->setMarker(static_cast<RenderSVGViewportContainer*>(renderer()));
+
+ // Spec: If the attribute is not specified, the effect is as if a
+ // value of "0" were specified.
+ if (!m_orientType)
+ setOrientToAngle(SVGSVGElement::createSVGAngle());
+
+ if (orientType() == SVG_MARKER_ORIENT_ANGLE)
+ m_marker->setAngle(orientAngle()->value());
+ else
+ m_marker->setAutoAngle();
+
+ m_marker->setRef(refX().value(), refY().value());
+ m_marker->setUseStrokeWidth(markerUnits() == SVG_MARKERUNITS_STROKEWIDTH);
+
+ return m_marker.get();
+}
+
+RenderObject* SVGMarkerElement::createRenderer(RenderArena* arena, RenderStyle* style)
+{
+ RenderSVGViewportContainer* markerContainer = new (arena) RenderSVGViewportContainer(this);
+ markerContainer->setDrawsContents(false); // Marker contents will be explicitly drawn.
+ return markerContainer;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGMarkerElement.h b/WebCore/svg/SVGMarkerElement.h
new file mode 100644
index 0000000..3e6cf25
--- /dev/null
+++ b/WebCore/svg/SVGMarkerElement.h
@@ -0,0 +1,90 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGMarkerElement_h
+#define SVGMarkerElement_h
+
+#if ENABLE(SVG)
+#include "SVGResourceMarker.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGFitToViewBox.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+ class Document;
+ class SVGAngle;
+
+ class SVGMarkerElement : public SVGStyledElement,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired,
+ public SVGFitToViewBox {
+ public:
+ enum SVGMarkerUnitsType {
+ SVG_MARKERUNITS_UNKNOWN = 0,
+ SVG_MARKERUNITS_USERSPACEONUSE = 1,
+ SVG_MARKERUNITS_STROKEWIDTH = 2
+ };
+
+ enum SVGMarkerOrientType {
+ SVG_MARKER_ORIENT_UNKNOWN = 0,
+ SVG_MARKER_ORIENT_AUTO = 1,
+ SVG_MARKER_ORIENT_ANGLE = 2
+ };
+
+ SVGMarkerElement(const QualifiedName&, Document*);
+ virtual ~SVGMarkerElement();
+
+ void setOrientToAuto();
+ void setOrientToAngle(SVGAngle*);
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+ virtual SVGResource* canvasResource();
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, FloatRect, ViewBox, viewBox)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, SVGPreserveAspectRatio*, PreserveAspectRatio, preserveAspectRatio)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGLength, SVGLength, RefX, refX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGLength, SVGLength, RefY, refY)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGLength, SVGLength, MarkerWidth, markerWidth)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGLength, SVGLength, MarkerHeight, markerHeight)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, int, int, MarkerUnits, markerUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, int, int, OrientType, orientType)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGAngle*, RefPtr<SVGAngle>, OrientAngle, orientAngle)
+
+ RefPtr<SVGResourceMarker> m_marker;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGMarkerElement.idl b/WebCore/svg/SVGMarkerElement.idl
new file mode 100644
index 0000000..2f6c45e
--- /dev/null
+++ b/WebCore/svg/SVGMarkerElement.idl
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor] SVGMarkerElement : SVGElement,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGFitToViewBox {
+ // Marker Unit Types
+ const unsigned short SVG_MARKERUNITS_UNKNOWN = 0;
+ const unsigned short SVG_MARKERUNITS_USERSPACEONUSE = 1;
+ const unsigned short SVG_MARKERUNITS_STROKEWIDTH = 2;
+
+ // Marker Orientation Types
+ const unsigned short SVG_MARKER_ORIENT_UNKNOWN = 0;
+ const unsigned short SVG_MARKER_ORIENT_AUTO = 1;
+ const unsigned short SVG_MARKER_ORIENT_ANGLE = 2;
+
+ readonly attribute SVGAnimatedLength refX;
+ readonly attribute SVGAnimatedLength refY;
+ readonly attribute SVGAnimatedEnumeration markerUnits;
+ readonly attribute SVGAnimatedLength markerWidth;
+ readonly attribute SVGAnimatedLength markerHeight;
+ readonly attribute SVGAnimatedEnumeration orientType;
+ readonly attribute SVGAnimatedAngle orientAngle;
+
+ void setOrientToAuto();
+ void setOrientToAngle(in SVGAngle angle);
+ };
+
+}
diff --git a/WebCore/svg/SVGMaskElement.cpp b/WebCore/svg/SVGMaskElement.cpp
new file mode 100644
index 0000000..723fefa
--- /dev/null
+++ b/WebCore/svg/SVGMaskElement.cpp
@@ -0,0 +1,226 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+ 2005 Alexander Kellett <lypanov@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGMaskElement.h"
+
+#include "CSSStyleSelector.h"
+#include "GraphicsContext.h"
+#include "ImageBuffer.h"
+#include "RenderSVGContainer.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+#include "SVGRenderSupport.h"
+#include "SVGUnitTypes.h"
+#include <math.h>
+#include <wtf/MathExtras.h>
+#include <wtf/OwnPtr.h>
+
+using namespace std;
+
+namespace WebCore {
+
+SVGMaskElement::SVGMaskElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledLocatableElement(tagName, doc)
+ , SVGURIReference()
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_maskUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
+ , m_maskContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
+ , m_x(this, LengthModeWidth)
+ , m_y(this, LengthModeHeight)
+ , m_width(this, LengthModeWidth)
+ , m_height(this, LengthModeHeight)
+{
+ // Spec: If the attribute is not specified, the effect is as if a value of "-10%" were specified.
+ setXBaseValue(SVGLength(this, LengthModeWidth, "-10%"));
+ setYBaseValue(SVGLength(this, LengthModeHeight, "-10%"));
+
+ // Spec: If the attribute is not specified, the effect is as if a value of "120%" were specified.
+ setWidthBaseValue(SVGLength(this, LengthModeWidth, "120%"));
+ setHeightBaseValue(SVGLength(this, LengthModeHeight, "120%"));
+}
+
+SVGMaskElement::~SVGMaskElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGMaskElement, int, Enumeration, enumeration, MaskUnits, maskUnits, SVGNames::maskUnitsAttr, m_maskUnits)
+ANIMATED_PROPERTY_DEFINITIONS(SVGMaskElement, int, Enumeration, enumeration, MaskContentUnits, maskContentUnits, SVGNames::maskContentUnitsAttr, m_maskContentUnits)
+ANIMATED_PROPERTY_DEFINITIONS(SVGMaskElement, SVGLength, Length, length, X, x, SVGNames::xAttr, m_x)
+ANIMATED_PROPERTY_DEFINITIONS(SVGMaskElement, SVGLength, Length, length, Y, y, SVGNames::yAttr, m_y)
+ANIMATED_PROPERTY_DEFINITIONS(SVGMaskElement, SVGLength, Length, length, Width, width, SVGNames::widthAttr, m_width)
+ANIMATED_PROPERTY_DEFINITIONS(SVGMaskElement, SVGLength, Length, length, Height, height, SVGNames::heightAttr, m_height)
+
+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(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()));
+ else if (attr->name() == SVGNames::heightAttr)
+ setHeightBaseValue(SVGLength(this, 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 SVGMaskElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledElement::svgAttributeChanged(attrName);
+
+ if (!m_masker)
+ return;
+
+ if (attrName == SVGNames::maskUnitsAttr || attrName == SVGNames::maskContentUnitsAttr ||
+ attrName == SVGNames::xAttr || attrName == SVGNames::yAttr ||
+ attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr ||
+ SVGURIReference::isKnownAttribute(attrName) ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledElement::isKnownAttribute(attrName))
+ m_masker->invalidate();
+}
+
+void SVGMaskElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+
+ if (!m_masker)
+ return;
+
+ m_masker->invalidate();
+}
+
+auto_ptr<ImageBuffer> SVGMaskElement::drawMaskerContent(const FloatRect& targetRect, FloatRect& maskDestRect) const
+{
+ // Determine specified mask size
+ float xValue;
+ float yValue;
+ float widthValue;
+ float heightValue;
+
+ if (maskUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
+ xValue = x().valueAsPercentage() * targetRect.width();
+ yValue = y().valueAsPercentage() * targetRect.height();
+ widthValue = width().valueAsPercentage() * targetRect.width();
+ heightValue = height().valueAsPercentage() * targetRect.height();
+ } else {
+ xValue = x().value();
+ yValue = y().value();
+ widthValue = width().value();
+ heightValue = height().value();
+ }
+
+ IntSize imageSize(lroundf(widthValue), lroundf(heightValue));
+ clampImageBufferSizeToViewport(document()->renderer(), imageSize);
+
+ if (imageSize.width() < static_cast<int>(widthValue))
+ widthValue = imageSize.width();
+
+ if (imageSize.height() < static_cast<int>(heightValue))
+ heightValue = imageSize.height();
+
+ auto_ptr<ImageBuffer> maskImage = ImageBuffer::create(imageSize, false);
+ if (!maskImage.get())
+ return maskImage;
+
+ maskDestRect = FloatRect(xValue, yValue, widthValue, heightValue);
+ if (maskUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
+ maskDestRect.move(targetRect.x(), targetRect.y());
+
+ GraphicsContext* maskImageContext = maskImage->context();
+ ASSERT(maskImageContext);
+
+ maskImageContext->save();
+ maskImageContext->translate(-xValue, -yValue);
+
+ if (maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
+ maskImageContext->save();
+ maskImageContext->scale(FloatSize(targetRect.width(), targetRect.height()));
+ }
+
+ // Render subtree into ImageBuffer
+ for (Node* n = firstChild(); n; n = n->nextSibling()) {
+ SVGElement* elem = 0;
+ if (n->isSVGElement())
+ elem = static_cast<SVGElement*>(n);
+ if (!elem || !elem->isStyled())
+ continue;
+
+ SVGStyledElement* e = static_cast<SVGStyledElement*>(elem);
+ RenderObject* item = e->renderer();
+ if (!item)
+ continue;
+
+ renderSubtreeToImage(maskImage.get(), item);
+ }
+
+ if (maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
+ maskImageContext->restore();
+
+ maskImageContext->restore();
+ return maskImage;
+}
+
+RenderObject* SVGMaskElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+ RenderSVGContainer* maskContainer = new (arena) RenderSVGContainer(this);
+ maskContainer->setDrawsContents(false);
+ return maskContainer;
+}
+
+SVGResource* SVGMaskElement::canvasResource()
+{
+ if (!m_masker)
+ m_masker = SVGResourceMasker::create(this);
+ return m_masker.get();
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGMaskElement.h b/WebCore/svg/SVGMaskElement.h
new file mode 100644
index 0000000..cd44baf
--- /dev/null
+++ b/WebCore/svg/SVGMaskElement.h
@@ -0,0 +1,77 @@
+/*
+ Copyright (C) 2005 Alexander Kellett <lypanov@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGMaskElement_h
+#define SVGMaskElement_h
+
+#if ENABLE(SVG)
+#include "SVGResourceMasker.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledLocatableElement.h"
+#include "SVGTests.h"
+#include "SVGURIReference.h"
+
+namespace WebCore {
+
+ class SVGLength;
+
+ class SVGMaskElement : public SVGStyledLocatableElement,
+ public SVGURIReference,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired {
+ public:
+ SVGMaskElement(const QualifiedName&, Document*);
+ virtual ~SVGMaskElement();
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+ virtual SVGResource* canvasResource();
+
+ std::auto_ptr<ImageBuffer> drawMaskerContent(const FloatRect& targetRect, FloatRect& maskRect) const;
+
+ protected:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, int, int, MaskUnits, maskUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, int, int, MaskContentUnits, maskContentUnits)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGLength, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGLength, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGLength, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGLength, SVGLength, Height, height)
+
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ RefPtr<SVGResourceMasker> m_masker;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGMaskElement.idl b/WebCore/svg/SVGMaskElement.idl
new file mode 100644
index 0000000..19bdc14
--- /dev/null
+++ b/WebCore/svg/SVGMaskElement.idl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGMaskElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable {
+ readonly attribute SVGAnimatedEnumeration maskUnits;
+ readonly attribute SVGAnimatedEnumeration maskContentUnits;
+
+ readonly attribute SVGAnimatedLength x;
+ readonly attribute SVGAnimatedLength y;
+ readonly attribute SVGAnimatedLength width;
+ readonly attribute SVGAnimatedLength height;
+ };
+
+}
diff --git a/WebCore/svg/SVGMatrix.idl b/WebCore/svg/SVGMatrix.idl
new file mode 100644
index 0000000..efc5459
--- /dev/null
+++ b/WebCore/svg/SVGMatrix.idl
@@ -0,0 +1,52 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+module svg {
+
+ interface [Conditional=SVG, PODType=AffineTransform] SVGMatrix {
+ // FIXME: these attributes should all be floats but since we implement
+ // AffineTransform with doubles setting these as doubles makes more sense.
+ attribute double a;
+ attribute double b;
+ attribute double c;
+ attribute double d;
+ attribute double e;
+ attribute double f;
+
+ [Custom] SVGMatrix multiply(in SVGMatrix secondMatrix);
+ [Custom] SVGMatrix inverse()
+ raises(SVGException);
+ [Custom] SVGMatrix translate(in float x, in float y);
+ [Custom] SVGMatrix scale(in float scaleFactor);
+ [Custom] SVGMatrix scaleNonUniform(in float scaleFactorX, in float scaleFactorY);
+ [Custom] SVGMatrix rotate(in float angle);
+ [Custom] SVGMatrix rotateFromVector(in float x, in float y)
+ raises(SVGException);
+ [Custom] SVGMatrix flipX();
+ [Custom] SVGMatrix flipY();
+ [Custom] SVGMatrix skewX(in float angle);
+ [Custom] SVGMatrix skewY(in float angle);
+ };
+
+}
diff --git a/WebCore/svg/SVGMetadataElement.cpp b/WebCore/svg/SVGMetadataElement.cpp
new file mode 100644
index 0000000..a18f73a
--- /dev/null
+++ b/WebCore/svg/SVGMetadataElement.cpp
@@ -0,0 +1,38 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGMetadataElement.h"
+
+using namespace WebCore;
+
+SVGMetadataElement::SVGMetadataElement(const QualifiedName& tagName, Document *doc)
+: SVGElement(tagName, doc)
+{
+}
+
+SVGMetadataElement::~SVGMetadataElement()
+{
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGMetadataElement.h b/WebCore/svg/SVGMetadataElement.h
new file mode 100644
index 0000000..4bd87d6
--- /dev/null
+++ b/WebCore/svg/SVGMetadataElement.h
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGMetadataElement_h
+#define SVGMetadataElement_h
+#if ENABLE(SVG)
+
+#include "SVGElement.h"
+
+namespace WebCore
+{
+ class SVGMetadataElement : public SVGElement
+ {
+ public:
+ SVGMetadataElement(const QualifiedName&, Document*);
+ virtual ~SVGMetadataElement();
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGMetadataElement.idl b/WebCore/svg/SVGMetadataElement.idl
new file mode 100644
index 0000000..ce65b5e
--- /dev/null
+++ b/WebCore/svg/SVGMetadataElement.idl
@@ -0,0 +1,29 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+module svg {
+
+ interface [Conditional=SVG] SVGMetadataElement : SVGElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGMissingGlyphElement.cpp b/WebCore/svg/SVGMissingGlyphElement.cpp
new file mode 100644
index 0000000..5d31e82
--- /dev/null
+++ b/WebCore/svg/SVGMissingGlyphElement.cpp
@@ -0,0 +1,34 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG_FONTS)
+#include "SVGMissingGlyphElement.h"
+
+namespace WebCore {
+
+SVGMissingGlyphElement::SVGMissingGlyphElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+{
+}
+
+}
+
+#endif // ENABLE(SVG_FONTS)
diff --git a/WebCore/svg/SVGMissingGlyphElement.h b/WebCore/svg/SVGMissingGlyphElement.h
new file mode 100644
index 0000000..468ad9d
--- /dev/null
+++ b/WebCore/svg/SVGMissingGlyphElement.h
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGMissingGlyphElement_h
+#define SVGMissingGlyphElement_h
+
+#if ENABLE(SVG_FONTS)
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+ class SVGMissingGlyphElement : public SVGStyledElement {
+ public:
+ SVGMissingGlyphElement(const QualifiedName&, Document*);
+
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_FONTS)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGMissingGlyphElement.idl b/WebCore/svg/SVGMissingGlyphElement.idl
new file mode 100644
index 0000000..232c6b9
--- /dev/null
+++ b/WebCore/svg/SVGMissingGlyphElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG&SVG_FONTS] SVGMissingGlyphElement : SVGElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGNumber.idl b/WebCore/svg/SVGNumber.idl
new file mode 100644
index 0000000..7e4c8bd
--- /dev/null
+++ b/WebCore/svg/SVGNumber.idl
@@ -0,0 +1,32 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+module svg {
+
+ interface [Conditional=SVG, PODType=float] SVGNumber {
+ attribute float value
+ setter raises(DOMException);
+ };
+
+}
diff --git a/WebCore/svg/SVGNumberList.cpp b/WebCore/svg/SVGNumberList.cpp
new file mode 100644
index 0000000..7931eca
--- /dev/null
+++ b/WebCore/svg/SVGNumberList.cpp
@@ -0,0 +1,59 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGNumberList.h"
+
+#include "SVGParserUtilities.h"
+
+namespace WebCore {
+
+SVGNumberList::SVGNumberList(const QualifiedName& attributeName)
+ : SVGList<float>(attributeName)
+{
+}
+
+SVGNumberList::~SVGNumberList()
+{
+}
+
+void SVGNumberList::parse(const String& value)
+{
+ ExceptionCode ec = 0;
+
+ float number = 0.0f;
+
+ const UChar* ptr = value.characters();
+ const UChar* end = ptr + value.length();
+ // The spec strangely doesn't allow leading whitespace. We might choose to violate that intentionally. (section 4.1)
+ while (ptr < end) {
+ if (!parseNumber(ptr, end, number))
+ return;
+ appendItem(number, ec);
+ }
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGNumberList.h b/WebCore/svg/SVGNumberList.h
new file mode 100644
index 0000000..cd5957b
--- /dev/null
+++ b/WebCore/svg/SVGNumberList.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGNumberList_h
+#define SVGNumberList_h
+
+#if ENABLE(SVG)
+#include "SVGList.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+ class String;
+
+ class SVGNumberList : public SVGList<float> {
+ public:
+ static PassRefPtr<SVGNumberList> create(const QualifiedName& attributeName) { return adoptRef(new SVGNumberList(attributeName)); }
+ virtual ~SVGNumberList();
+
+ void parse(const String& value);
+
+ private:
+ SVGNumberList(const QualifiedName&);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGNumberList.idl b/WebCore/svg/SVGNumberList.idl
new file mode 100644
index 0000000..427a249
--- /dev/null
+++ b/WebCore/svg/SVGNumberList.idl
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGNumberList {
+ readonly attribute unsigned long numberOfItems;
+
+ void clear()
+ raises(DOMException);
+ SVGNumber initialize(in SVGNumber item)
+ raises(DOMException, SVGException);
+ SVGNumber getItem(in unsigned long index)
+ raises(DOMException);
+ SVGNumber insertItemBefore(in SVGNumber item, in unsigned long index)
+ raises(DOMException, SVGException);
+ SVGNumber replaceItem(in SVGNumber item, in unsigned long index)
+ raises(DOMException, SVGException);
+ SVGNumber removeItem(in unsigned long index)
+ raises(DOMException);
+ SVGNumber appendItem(in SVGNumber item)
+ raises(DOMException, SVGException);
+ };
+
+}
diff --git a/WebCore/svg/SVGPaint.cpp b/WebCore/svg/SVGPaint.cpp
new file mode 100644
index 0000000..bd27a57
--- /dev/null
+++ b/WebCore/svg/SVGPaint.cpp
@@ -0,0 +1,120 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGPaint.h"
+
+namespace WebCore {
+
+SVGPaint::SVGPaint()
+ : SVGColor()
+ , m_paintType(SVG_PAINTTYPE_UNKNOWN)
+{
+}
+
+SVGPaint::SVGPaint(const String& uri)
+ : SVGColor()
+ , m_paintType(SVG_PAINTTYPE_URI_RGBCOLOR)
+{
+ setUri(uri);
+}
+
+SVGPaint::SVGPaint(SVGPaintType paintType)
+ : SVGColor()
+ , m_paintType(paintType)
+{
+}
+
+SVGPaint::SVGPaint(SVGPaintType paintType, const String& uri, const String& rgbPaint, const String&)
+ : SVGColor(rgbPaint)
+ , m_paintType(paintType)
+{
+ setUri(uri);
+}
+
+SVGPaint::SVGPaint(const Color& c)
+ : SVGColor(c)
+ , m_paintType(SVG_PAINTTYPE_RGBCOLOR)
+{
+}
+
+SVGPaint::SVGPaint(const String& uri, const Color& c)
+ : SVGColor(c)
+ , m_paintType(SVG_PAINTTYPE_URI_RGBCOLOR)
+{
+ setUri(uri);
+}
+
+SVGPaint::~SVGPaint()
+{
+}
+
+SVGPaint* SVGPaint::defaultFill()
+{
+ static SVGPaint* _defaultFill = new SVGPaint(Color::black);
+ return _defaultFill;
+}
+
+SVGPaint* SVGPaint::defaultStroke()
+{
+ static SVGPaint* _defaultStroke = new SVGPaint(SVG_PAINTTYPE_NONE);
+ return _defaultStroke;
+}
+
+String SVGPaint::uri() const
+{
+ return m_uri;
+}
+
+void SVGPaint::setUri(const String& uri)
+{
+ m_uri = uri;
+}
+
+void SVGPaint::setPaint(SVGPaintType paintType, const String& uri, const String& rgbPaint, const String&, ExceptionCode&)
+{
+ m_paintType = paintType;
+
+ if (m_paintType == SVG_PAINTTYPE_URI)
+ setUri(uri);
+ else if (m_paintType == SVG_PAINTTYPE_RGBCOLOR)
+ setRGBColor(rgbPaint);
+}
+
+String SVGPaint::cssText() const
+{
+ if (m_paintType == SVG_PAINTTYPE_NONE)
+ return "none";
+ else if (m_paintType == SVG_PAINTTYPE_CURRENTCOLOR)
+ return "currentColor";
+ else if (m_paintType == SVG_PAINTTYPE_URI)
+ return "url(" + m_uri + ")";
+
+ return SVGColor::cssText();
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGPaint.h b/WebCore/svg/SVGPaint.h
new file mode 100644
index 0000000..e434eae
--- /dev/null
+++ b/WebCore/svg/SVGPaint.h
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Samuel Weinig (sam.weinig@gmial.com)
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPaint_h
+#define SVGPaint_h
+#if ENABLE(SVG)
+
+#include "SVGColor.h"
+
+namespace WebCore {
+
+ class SVGPaint : public SVGColor {
+ public:
+ enum SVGPaintType {
+ SVG_PAINTTYPE_UNKNOWN = 0,
+ SVG_PAINTTYPE_RGBCOLOR = 1,
+ SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2,
+ SVG_PAINTTYPE_NONE = 101,
+ SVG_PAINTTYPE_CURRENTCOLOR = 102,
+ SVG_PAINTTYPE_URI_NONE = 103,
+ SVG_PAINTTYPE_URI_CURRENTCOLOR = 104,
+ SVG_PAINTTYPE_URI_RGBCOLOR = 105,
+ SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106,
+ SVG_PAINTTYPE_URI = 107
+ };
+
+ SVGPaint();
+ SVGPaint(const String& uri);
+ SVGPaint(SVGPaintType);
+ SVGPaint(SVGPaintType, const String& uri, const String& rgbPaint = String(), const String& iccPaint = String());
+ SVGPaint(const Color& c);
+ SVGPaint(const String& uri, const Color& c);
+ virtual ~SVGPaint();
+
+ // 'SVGPaint' functions
+ SVGPaintType paintType() const { return m_paintType; }
+ String uri() const;
+
+ void setUri(const String&);
+ void setPaint(SVGPaintType, const String& uri, const String& rgbPaint, const String& iccPaint, ExceptionCode&);
+
+ virtual String cssText() const;
+
+ static SVGPaint* defaultFill();
+ static SVGPaint* defaultStroke();
+
+ virtual bool isSVGPaint() const { return true; }
+ private:
+ SVGPaintType m_paintType;
+ String m_uri;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGPaint_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPaint.idl b/WebCore/svg/SVGPaint.idl
new file mode 100644
index 0000000..7799aa3
--- /dev/null
+++ b/WebCore/svg/SVGPaint.idl
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor] SVGPaint : SVGColor {
+ // SVGPaintType
+ const unsigned short SVG_PAINTTYPE_UNKNOWN = 0;
+ const unsigned short SVG_PAINTTYPE_RGBCOLOR = 1;
+ const unsigned short SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2;
+ const unsigned short SVG_PAINTTYPE_NONE = 101;
+ const unsigned short SVG_PAINTTYPE_CURRENTCOLOR = 102;
+ const unsigned short SVG_PAINTTYPE_URI_NONE = 103;
+ const unsigned short SVG_PAINTTYPE_URI_CURRENTCOLOR = 104;
+ const unsigned short SVG_PAINTTYPE_URI_RGBCOLOR = 105;
+ const unsigned short SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106;
+ const unsigned short SVG_PAINTTYPE_URI = 107;
+
+ readonly attribute SVGPaintType paintType;
+ readonly attribute DOMString uri;
+
+ void setUri(in DOMString uri);
+ void setPaint(in SVGPaintType paintType,
+ in DOMString uri,
+ in DOMString rgbColor,
+ in DOMString iccColor)
+ raises(SVGException);
+ };
+
+}
diff --git a/WebCore/svg/SVGParserUtilities.cpp b/WebCore/svg/SVGParserUtilities.cpp
new file mode 100644
index 0000000..894af80
--- /dev/null
+++ b/WebCore/svg/SVGParserUtilities.cpp
@@ -0,0 +1,873 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002, 2003 The Karbon Developers
+ 2006 Alexander Kellett <lypanov@kde.org>
+ 2006, 2007 Rob Buis <buis@kde.org>
+ 2007 Apple, Inc. All rights reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGParserUtilities.h"
+
+#include "ExceptionCode.h"
+#include "FloatConversion.h"
+#include "FloatPoint.h"
+#include "Path.h"
+#include "PlatformString.h"
+#include "SVGPathSegList.h"
+#include "SVGPathSegArc.h"
+#include "SVGPathSegClosePath.h"
+#include "SVGPathSegCurvetoCubic.h"
+#include "SVGPathSegCurvetoCubicSmooth.h"
+#include "SVGPathSegCurvetoQuadratic.h"
+#include "SVGPathSegCurvetoQuadraticSmooth.h"
+#include "SVGPathSegLineto.h"
+#include "SVGPathSegLinetoHorizontal.h"
+#include "SVGPathSegLinetoVertical.h"
+#include "SVGPathSegList.h"
+#include "SVGPathSegMoveto.h"
+#include "SVGPointList.h"
+#include "SVGPathElement.h"
+#include <math.h>
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+/* We use this generic _parseNumber function to allow the Path parsing code to work
+ * at a higher precision internally, without any unnecessary runtime cost or code
+ * complexity
+ */
+template <typename FloatType> static bool _parseNumber(const UChar*& ptr, const UChar* end, FloatType& number, bool skip)
+{
+ int integer, exponent;
+ FloatType decimal, frac;
+ int sign, expsign;
+ const UChar* start = ptr;
+
+ exponent = 0;
+ integer = 0;
+ frac = 1;
+ decimal = 0;
+ sign = 1;
+ expsign = 1;
+
+ // read the sign
+ if (ptr < end && *ptr == '+')
+ ptr++;
+ else if (ptr < end && *ptr == '-') {
+ ptr++;
+ sign = -1;
+ }
+
+ if (ptr == end || ((*ptr < '0' || *ptr > '9') && *ptr != '.'))
+ // The first character of a number must be one of [0-9+-.]
+ return false;
+
+ // read the integer part
+ while (ptr < end && *ptr >= '0' && *ptr <= '9')
+ integer = (integer * 10) + *(ptr++) - '0';
+
+ if (ptr < end && *ptr == '.') { // read the decimals
+ ptr++;
+
+ // There must be a least one digit following the .
+ if (ptr >= end || *ptr < '0' || *ptr > '9')
+ return false;
+
+ while (ptr < end && *ptr >= '0' && *ptr <= '9')
+ decimal += (*(ptr++) - '0') * (frac *= static_cast<FloatType>(0.1));
+ }
+
+ // read the exponent part
+ if (ptr != start && ptr + 1 < end && (*ptr == 'e' || *ptr == 'E')
+ && (ptr[1] != 'x' && ptr[1] != 'm')) {
+ ptr++;
+
+ // read the sign of the exponent
+ if (*ptr == '+')
+ ptr++;
+ else if (*ptr == '-') {
+ ptr++;
+ expsign = -1;
+ }
+
+ // There must be an exponent
+ if (ptr >= end || *ptr < '0' || *ptr > '9')
+ return false;
+
+ while (ptr < end && *ptr >= '0' && *ptr <= '9') {
+ exponent *= 10;
+ exponent += *ptr - '0';
+ ptr++;
+ }
+ }
+
+ number = integer + decimal;
+ number *= sign * static_cast<FloatType>(pow(10.0, expsign * exponent));
+
+ if (start == ptr)
+ return false;
+
+ if (skip)
+ skipOptionalSpacesOrDelimiter(ptr, end);
+
+ return true;
+}
+
+bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip)
+{
+ return _parseNumber(ptr, end, number, skip);
+}
+
+// Only used for parsing Paths
+static bool parseNumber(const UChar*& ptr, const UChar* end, double& number, bool skip = true)
+{
+ return _parseNumber(ptr, end, number, skip);
+}
+
+bool parseNumberOptionalNumber(const String& s, float& x, float& y)
+{
+ if (s.isEmpty())
+ return false;
+ const UChar* cur = s.characters();
+ const UChar* end = cur + s.length();
+
+ if (!parseNumber(cur, end, x))
+ return false;
+
+ if (cur == end)
+ y = x;
+ else if (!parseNumber(cur, end, y, false))
+ return false;
+
+ return cur == end;
+}
+
+bool pointsListFromSVGData(SVGPointList* pointsList, const String& points)
+{
+ if (points.isEmpty())
+ return true;
+ const UChar* cur = points.characters();
+ const UChar* end = cur + points.length();
+
+ skipOptionalSpaces(cur, end);
+
+ bool delimParsed = false;
+ while (cur < end) {
+ delimParsed = false;
+ float xPos = 0.0f;
+ if (!parseNumber(cur, end, xPos))
+ return false;
+
+ float yPos = 0.0f;
+ if (!parseNumber(cur, end, yPos, false))
+ return false;
+
+ skipOptionalSpaces(cur, end);
+
+ if (cur < end && *cur == ',') {
+ delimParsed = true;
+ cur++;
+ }
+ skipOptionalSpaces(cur, end);
+
+ ExceptionCode ec = 0;
+ pointsList->appendItem(FloatPoint(xPos, yPos), ec);
+ }
+ return cur == end && !delimParsed;
+}
+
+ /**
+ * Parser for svg path data, contained in the d attribute.
+ *
+ * The parser delivers encountered commands and parameters by calling
+ * methods that correspond to those commands. Clients have to derive
+ * from this class and implement the abstract command methods.
+ *
+ * There are two operating modes. By default the parser just delivers unaltered
+ * svg path data commands and parameters. In the second mode, it will convert all
+ * relative coordinates to absolute ones, and convert all curves to cubic beziers.
+ */
+ class SVGPathParser
+ {
+ public:
+ virtual ~SVGPathParser() { }
+ bool parseSVG(const String& d, bool process = false);
+
+ protected:
+ virtual void svgMoveTo(double x1, double y1, bool closed, bool abs = true) = 0;
+ virtual void svgLineTo(double x1, double y1, bool abs = true) = 0;
+ virtual void svgLineToHorizontal(double x, bool abs = true) {}
+ virtual void svgLineToVertical(double y, bool abs = true) {}
+ virtual void svgCurveToCubic(double x1, double y1, double x2, double y2, double x, double y, bool abs = true) = 0;
+ virtual void svgCurveToCubicSmooth(double x, double y, double x2, double y2, bool abs = true) {}
+ virtual void svgCurveToQuadratic(double x, double y, double x1, double y1, bool abs = true) {}
+ virtual void svgCurveToQuadraticSmooth(double x, double y, bool abs = true) {}
+ virtual void svgArcTo(double x, double y, double r1, double r2, double angle, bool largeArcFlag, bool sweepFlag, bool abs = true) {}
+ virtual void svgClosePath() = 0;
+ private:
+ void calculateArc(bool relative, double& curx, double& cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag);
+ };
+
+bool SVGPathParser::parseSVG(const String& s, bool process)
+{
+ if (s.isEmpty())
+ return false;
+
+ const UChar* ptr = s.characters();
+ const UChar* end = ptr + s.length();
+
+ double contrlx, contrly, curx, cury, subpathx, subpathy, tox, toy, x1, y1, x2, y2, xc, yc;
+ double px1, py1, px2, py2, px3, py3;
+ bool closed = true;
+
+ if (!skipOptionalSpaces(ptr, end)) // skip any leading spaces
+ return false;
+
+ char command = *(ptr++), lastCommand = ' ';
+ if (command != 'm' && command != 'M') // path must start with moveto
+ return false;
+
+ subpathx = subpathy = curx = cury = contrlx = contrly = 0.0;
+ while (1) {
+ skipOptionalSpaces(ptr, end); // skip spaces between command and first coord
+
+ bool relative = false;
+
+ switch(command)
+ {
+ case 'm':
+ relative = true;
+ case 'M':
+ {
+ if (!parseNumber(ptr, end, tox) || !parseNumber(ptr, end, toy))
+ return false;
+
+ if (process) {
+ subpathx = curx = relative ? curx + tox : tox;
+ subpathy = cury = relative ? cury + toy : toy;
+
+ svgMoveTo(narrowPrecisionToFloat(curx), narrowPrecisionToFloat(cury), closed);
+ } else
+ svgMoveTo(narrowPrecisionToFloat(tox), narrowPrecisionToFloat(toy), closed, !relative);
+ closed = false;
+ break;
+ }
+ case 'l':
+ relative = true;
+ case 'L':
+ {
+ if (!parseNumber(ptr, end, tox) || !parseNumber(ptr, end, toy))
+ return false;
+
+ if (process) {
+ curx = relative ? curx + tox : tox;
+ cury = relative ? cury + toy : toy;
+
+ svgLineTo(narrowPrecisionToFloat(curx), narrowPrecisionToFloat(cury));
+ }
+ else
+ svgLineTo(narrowPrecisionToFloat(tox), narrowPrecisionToFloat(toy), !relative);
+ break;
+ }
+ case 'h':
+ {
+ if (!parseNumber(ptr, end, tox))
+ return false;
+ if (process) {
+ curx = curx + tox;
+ svgLineTo(narrowPrecisionToFloat(curx), narrowPrecisionToFloat(cury));
+ }
+ else
+ svgLineToHorizontal(narrowPrecisionToFloat(tox), false);
+ break;
+ }
+ case 'H':
+ {
+ if (!parseNumber(ptr, end, tox))
+ return false;
+ if (process) {
+ curx = tox;
+ svgLineTo(narrowPrecisionToFloat(curx), narrowPrecisionToFloat(cury));
+ }
+ else
+ svgLineToHorizontal(narrowPrecisionToFloat(tox));
+ break;
+ }
+ case 'v':
+ {
+ if (!parseNumber(ptr, end, toy))
+ return false;
+ if (process) {
+ cury = cury + toy;
+ svgLineTo(narrowPrecisionToFloat(curx), narrowPrecisionToFloat(cury));
+ }
+ else
+ svgLineToVertical(narrowPrecisionToFloat(toy), false);
+ break;
+ }
+ case 'V':
+ {
+ if (!parseNumber(ptr, end, toy))
+ return false;
+ if (process) {
+ cury = toy;
+ svgLineTo(narrowPrecisionToFloat(curx), narrowPrecisionToFloat(cury));
+ }
+ else
+ svgLineToVertical(narrowPrecisionToFloat(toy));
+ break;
+ }
+ case 'z':
+ case 'Z':
+ {
+ // reset curx, cury for next path
+ if (process) {
+ curx = subpathx;
+ cury = subpathy;
+ }
+ closed = true;
+ svgClosePath();
+ break;
+ }
+ case 'c':
+ relative = true;
+ case 'C':
+ {
+ if (!parseNumber(ptr, end, x1) || !parseNumber(ptr, end, y1) ||
+ !parseNumber(ptr, end, x2) || !parseNumber(ptr, end, y2) ||
+ !parseNumber(ptr, end, tox) || !parseNumber(ptr, end, toy))
+ return false;
+
+ if (process) {
+ px1 = relative ? curx + x1 : x1;
+ py1 = relative ? cury + y1 : y1;
+ px2 = relative ? curx + x2 : x2;
+ py2 = relative ? cury + y2 : y2;
+ px3 = relative ? curx + tox : tox;
+ py3 = relative ? cury + toy : toy;
+
+ svgCurveToCubic(narrowPrecisionToFloat(px1), narrowPrecisionToFloat(py1), narrowPrecisionToFloat(px2),
+ narrowPrecisionToFloat(py2), narrowPrecisionToFloat(px3), narrowPrecisionToFloat(py3));
+
+ contrlx = relative ? curx + x2 : x2;
+ contrly = relative ? cury + y2 : y2;
+ curx = relative ? curx + tox : tox;
+ cury = relative ? cury + toy : toy;
+ }
+ else
+ svgCurveToCubic(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1), narrowPrecisionToFloat(x2),
+ narrowPrecisionToFloat(y2), narrowPrecisionToFloat(tox), narrowPrecisionToFloat(toy), !relative);
+
+ break;
+ }
+ case 's':
+ relative = true;
+ case 'S':
+ {
+ if (!parseNumber(ptr, end, x2) || !parseNumber(ptr, end, y2) ||
+ !parseNumber(ptr, end, tox) || !parseNumber(ptr, end, toy))
+ return false;
+
+ if (!(lastCommand == 'c' || lastCommand == 'C' ||
+ lastCommand == 's' || lastCommand == 'S')) {
+ contrlx = curx;
+ contrly = cury;
+ }
+
+ if (process) {
+ px1 = 2 * curx - contrlx;
+ py1 = 2 * cury - contrly;
+ px2 = relative ? curx + x2 : x2;
+ py2 = relative ? cury + y2 : y2;
+ px3 = relative ? curx + tox : tox;
+ py3 = relative ? cury + toy : toy;
+
+ svgCurveToCubic(narrowPrecisionToFloat(px1), narrowPrecisionToFloat(py1), narrowPrecisionToFloat(px2),
+ narrowPrecisionToFloat(py2), narrowPrecisionToFloat(px3), narrowPrecisionToFloat(py3));
+
+ contrlx = relative ? curx + x2 : x2;
+ contrly = relative ? cury + y2 : y2;
+ curx = relative ? curx + tox : tox;
+ cury = relative ? cury + toy : toy;
+ }
+ else
+ svgCurveToCubicSmooth(narrowPrecisionToFloat(x2), narrowPrecisionToFloat(y2),
+ narrowPrecisionToFloat(tox), narrowPrecisionToFloat(toy), !relative);
+ break;
+ }
+ case 'q':
+ relative = true;
+ case 'Q':
+ {
+ if (!parseNumber(ptr, end, x1) || !parseNumber(ptr, end, y1) ||
+ !parseNumber(ptr, end, tox) || !parseNumber(ptr, end, toy))
+ return false;
+
+ if (process) {
+ px1 = relative ? (curx + 2 * (x1 + curx)) * (1.0 / 3.0) : (curx + 2 * x1) * (1.0 / 3.0);
+ py1 = relative ? (cury + 2 * (y1 + cury)) * (1.0 / 3.0) : (cury + 2 * y1) * (1.0 / 3.0);
+ px2 = relative ? ((curx + tox) + 2 * (x1 + curx)) * (1.0 / 3.0) : (tox + 2 * x1) * (1.0 / 3.0);
+ py2 = relative ? ((cury + toy) + 2 * (y1 + cury)) * (1.0 / 3.0) : (toy + 2 * y1) * (1.0 / 3.0);
+ px3 = relative ? curx + tox : tox;
+ py3 = relative ? cury + toy : toy;
+
+ svgCurveToCubic(narrowPrecisionToFloat(px1), narrowPrecisionToFloat(py1), narrowPrecisionToFloat(px2),
+ narrowPrecisionToFloat(py2), narrowPrecisionToFloat(px3), narrowPrecisionToFloat(py3));
+
+ contrlx = relative ? curx + x1 : x1;
+ contrly = relative ? cury + y1 : y1;
+ curx = relative ? curx + tox : tox;
+ cury = relative ? cury + toy : toy;
+ }
+ else
+ svgCurveToQuadratic(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1),
+ narrowPrecisionToFloat(tox), narrowPrecisionToFloat(toy), !relative);
+ break;
+ }
+ case 't':
+ relative = true;
+ case 'T':
+ {
+ if (!parseNumber(ptr, end, tox) || !parseNumber(ptr, end, toy))
+ return false;
+ if (!(lastCommand == 'q' || lastCommand == 'Q' ||
+ lastCommand == 't' || lastCommand == 'T')) {
+ contrlx = curx;
+ contrly = cury;
+ }
+
+ if (process) {
+ xc = 2 * curx - contrlx;
+ yc = 2 * cury - contrly;
+
+ px1 = relative ? (curx + 2 * xc) * (1.0 / 3.0) : (curx + 2 * xc) * (1.0 / 3.0);
+ py1 = relative ? (cury + 2 * yc) * (1.0 / 3.0) : (cury + 2 * yc) * (1.0 / 3.0);
+ px2 = relative ? ((curx + tox) + 2 * xc) * (1.0 / 3.0) : (tox + 2 * xc) * (1.0 / 3.0);
+ py2 = relative ? ((cury + toy) + 2 * yc) * (1.0 / 3.0) : (toy + 2 * yc) * (1.0 / 3.0);
+ px3 = relative ? curx + tox : tox;
+ py3 = relative ? cury + toy : toy;
+
+ svgCurveToCubic(narrowPrecisionToFloat(px1), narrowPrecisionToFloat(py1), narrowPrecisionToFloat(px2),
+ narrowPrecisionToFloat(py2), narrowPrecisionToFloat(px3), narrowPrecisionToFloat(py3));
+
+ contrlx = xc;
+ contrly = yc;
+ curx = relative ? curx + tox : tox;
+ cury = relative ? cury + toy : toy;
+ }
+ else
+ svgCurveToQuadraticSmooth(narrowPrecisionToFloat(tox), narrowPrecisionToFloat(toy), !relative);
+ break;
+ }
+ case 'a':
+ relative = true;
+ case 'A':
+ {
+ bool largeArc, sweep;
+ double angle, rx, ry;
+ if (!parseNumber(ptr, end, rx) || !parseNumber(ptr, end, ry) ||
+ !parseNumber(ptr, end, angle) || !parseNumber(ptr, end, tox))
+ return false;
+ largeArc = tox == 1;
+ if (!parseNumber(ptr, end, tox))
+ return false;
+ sweep = tox == 1;
+ if (!parseNumber(ptr, end, tox) || !parseNumber(ptr, end, toy))
+ return false;
+
+ // Spec: radii are nonnegative numbers
+ rx = fabs(rx);
+ ry = fabs(ry);
+
+ if (process)
+ calculateArc(relative, curx, cury, angle, tox, toy, rx, ry, largeArc, sweep);
+ else
+ svgArcTo(narrowPrecisionToFloat(tox), narrowPrecisionToFloat(toy), narrowPrecisionToFloat(rx), narrowPrecisionToFloat(ry),
+ narrowPrecisionToFloat(angle), largeArc, sweep, !relative);
+ break;
+ }
+ default:
+ // FIXME: An error should go to the JavaScript console, or the like.
+ return false;
+ }
+ lastCommand = command;
+
+ if (ptr >= end)
+ return true;
+
+ // Check for remaining coordinates in the current command.
+ if ((*ptr == '+' || *ptr == '-' || (*ptr >= '0' && *ptr <= '9')) &&
+ (command != 'z' && command != 'Z')) {
+ if (command == 'M')
+ command = 'L';
+ else if (command == 'm')
+ command = 'l';
+ } else
+ command = *(ptr++);
+
+ if (lastCommand != 'C' && lastCommand != 'c' &&
+ lastCommand != 'S' && lastCommand != 's' &&
+ lastCommand != 'Q' && lastCommand != 'q' &&
+ lastCommand != 'T' && lastCommand != 't') {
+ contrlx = curx;
+ contrly = cury;
+ }
+ }
+
+ return false;
+}
+
+// This works by converting the SVG arc to "simple" beziers.
+// For each bezier found a svgToCurve call is done.
+// Adapted from Niko's code in kdelibs/kdecore/svgicons.
+// Maybe this can serve in some shared lib? (Rob)
+void SVGPathParser::calculateArc(bool relative, double& curx, double& cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag)
+{
+ double sin_th, cos_th;
+ double a00, a01, a10, a11;
+ double x0, y0, x1, y1, xc, yc;
+ double d, sfactor, sfactor_sq;
+ double th0, th1, th_arc;
+ int i, n_segs;
+
+ sin_th = sin(angle * (piDouble / 180.0));
+ cos_th = cos(angle * (piDouble / 180.0));
+
+ double dx;
+
+ if (!relative)
+ dx = (curx - x) / 2.0;
+ else
+ dx = -x / 2.0;
+
+ double dy;
+
+ if (!relative)
+ dy = (cury - y) / 2.0;
+ else
+ dy = -y / 2.0;
+
+ double _x1 = cos_th * dx + sin_th * dy;
+ double _y1 = -sin_th * dx + cos_th * dy;
+ double Pr1 = r1 * r1;
+ double Pr2 = r2 * r2;
+ double Px = _x1 * _x1;
+ double Py = _y1 * _y1;
+
+ // Spec : check if radii are large enough
+ double check = Px / Pr1 + Py / Pr2;
+ if (check > 1) {
+ r1 = r1 * sqrt(check);
+ r2 = r2 * sqrt(check);
+ }
+
+ a00 = cos_th / r1;
+ a01 = sin_th / r1;
+ a10 = -sin_th / r2;
+ a11 = cos_th / r2;
+
+ x0 = a00 * curx + a01 * cury;
+ y0 = a10 * curx + a11 * cury;
+
+ if (!relative)
+ x1 = a00 * x + a01 * y;
+ else
+ x1 = a00 * (curx + x) + a01 * (cury + y);
+
+ if (!relative)
+ y1 = a10 * x + a11 * y;
+ else
+ y1 = a10 * (curx + x) + a11 * (cury + y);
+
+ /* (x0, y0) is current point in transformed coordinate space.
+ (x1, y1) is new point in transformed coordinate space.
+
+ The arc fits a unit-radius circle in this space.
+ */
+
+ d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);
+
+ sfactor_sq = 1.0 / d - 0.25;
+
+ if (sfactor_sq < 0)
+ sfactor_sq = 0;
+
+ sfactor = sqrt(sfactor_sq);
+
+ if (sweepFlag == largeArcFlag)
+ sfactor = -sfactor;
+
+ xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0);
+ yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0);
+
+ /* (xc, yc) is center of the circle. */
+ th0 = atan2(y0 - yc, x0 - xc);
+ th1 = atan2(y1 - yc, x1 - xc);
+
+ th_arc = th1 - th0;
+ if (th_arc < 0 && sweepFlag)
+ th_arc += 2 * piDouble;
+ else if (th_arc > 0 && !sweepFlag)
+ th_arc -= 2 * piDouble;
+
+ n_segs = (int) (int) ceil(fabs(th_arc / (piDouble * 0.5 + 0.001)));
+
+ for(i = 0; i < n_segs; i++) {
+ double sin_th, cos_th;
+ double a00, a01, a10, a11;
+ double x1, y1, x2, y2, x3, y3;
+ double t;
+ double th_half;
+
+ double _th0 = th0 + i * th_arc / n_segs;
+ double _th1 = th0 + (i + 1) * th_arc / n_segs;
+
+ sin_th = sin(angle * (piDouble / 180.0));
+ cos_th = cos(angle * (piDouble / 180.0));
+
+ /* inverse transform compared with rsvg_path_arc */
+ a00 = cos_th * r1;
+ a01 = -sin_th * r2;
+ a10 = sin_th * r1;
+ a11 = cos_th * r2;
+
+ th_half = 0.5 * (_th1 - _th0);
+ t = (8.0 / 3.0) * sin(th_half * 0.5) * sin(th_half * 0.5) / sin(th_half);
+ x1 = xc + cos(_th0) - t * sin(_th0);
+ y1 = yc + sin(_th0) + t * cos(_th0);
+ x3 = xc + cos(_th1);
+ y3 = yc + sin(_th1);
+ x2 = x3 + t * sin(_th1);
+ y2 = y3 - t * cos(_th1);
+
+ svgCurveToCubic(narrowPrecisionToFloat(a00 * x1 + a01 * y1), narrowPrecisionToFloat(a10 * x1 + a11 * y1),
+ narrowPrecisionToFloat(a00 * x2 + a01 * y2), narrowPrecisionToFloat(a10 * x2 + a11 * y2),
+ narrowPrecisionToFloat(a00 * x3 + a01 * y3), narrowPrecisionToFloat(a10 * x3 + a11 * y3));
+ }
+
+ if (!relative)
+ curx = x;
+ else
+ curx += x;
+
+ if (!relative)
+ cury = y;
+ else
+ cury += y;
+}
+
+class PathBuilder : public SVGPathParser
+{
+public:
+ bool build(Path* path, const String& d)
+ {
+ m_path = path;
+ return parseSVG(d, true);
+ }
+
+private:
+ virtual void svgMoveTo(double x1, double y1, bool closed, bool abs = true)
+ {
+ current.setX(narrowPrecisionToFloat(abs ? x1 : current.x() + x1));
+ current.setY(narrowPrecisionToFloat(abs ? y1 : current.y() + y1));
+ if (closed)
+ m_path->closeSubpath();
+ m_path->moveTo(current);
+ }
+ virtual void svgLineTo(double x1, double y1, bool abs = true)
+ {
+ current.setX(narrowPrecisionToFloat(abs ? x1 : current.x() + x1));
+ current.setY(narrowPrecisionToFloat(abs ? y1 : current.y() + y1));
+ m_path->addLineTo(current);
+ }
+ virtual void svgCurveToCubic(double x1, double y1, double x2, double y2, double x, double y, bool abs = true)
+ {
+ if (!abs) {
+ x1 += current.x();
+ y1 += current.y();
+ x2 += current.x();
+ y2 += current.y();
+ }
+ current.setX(narrowPrecisionToFloat(abs ? x : current.x() + x));
+ current.setY(narrowPrecisionToFloat(abs ? y : current.y() + y));
+ m_path->addBezierCurveTo(FloatPoint::narrowPrecision(x1, y1), FloatPoint::narrowPrecision(x2, y2), current);
+ }
+ virtual void svgClosePath()
+ {
+ m_path->closeSubpath();
+ }
+ Path* m_path;
+ FloatPoint current;
+};
+
+bool pathFromSVGData(Path& path, const String& d)
+{
+ PathBuilder builder;
+ return builder.build(&path, d);
+}
+
+class SVGPathSegListBuilder : public SVGPathParser
+{
+public:
+ bool build(SVGPathSegList* segList, const String& d, bool process)
+ {
+ m_pathSegList = segList;
+ return parseSVG(d, process);
+ }
+
+private:
+ virtual void svgMoveTo(double x1, double y1, bool, bool abs = true)
+ {
+ ExceptionCode ec = 0;
+
+ if (abs)
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegMovetoAbs(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1)), ec);
+ else
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegMovetoRel(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1)), ec);
+ }
+ virtual void svgLineTo(double x1, double y1, bool abs = true)
+ {
+ ExceptionCode ec = 0;
+
+ if (abs)
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoAbs(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1)), ec);
+ else
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoRel(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1)), ec);
+ }
+ virtual void svgLineToHorizontal(double x, bool abs)
+ {
+ ExceptionCode ec = 0;
+
+ if (abs)
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoHorizontalAbs(narrowPrecisionToFloat(x)), ec);
+ else
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoHorizontalRel(narrowPrecisionToFloat(x)), ec);
+ }
+ virtual void svgLineToVertical(double y, bool abs)
+ {
+ ExceptionCode ec = 0;
+
+ if (abs)
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoVerticalAbs(narrowPrecisionToFloat(y)), ec);
+ else
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoVerticalRel(narrowPrecisionToFloat(y)), ec);
+ }
+ virtual void svgCurveToCubic(double x1, double y1, double x2, double y2, double x, double y, bool abs = true)
+ {
+ ExceptionCode ec = 0;
+
+ if (abs)
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoCubicAbs(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y),
+ narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1),
+ narrowPrecisionToFloat(x2), narrowPrecisionToFloat(y2)), ec);
+ else
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoCubicRel(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y),
+ narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1),
+ narrowPrecisionToFloat(x2), narrowPrecisionToFloat(y2)), ec);
+ }
+ virtual void svgCurveToCubicSmooth(double x, double y, double x2, double y2, bool abs)
+ {
+ ExceptionCode ec = 0;
+
+ if (abs)
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoCubicSmoothAbs(narrowPrecisionToFloat(x2), narrowPrecisionToFloat(y2),
+ narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)), ec);
+ else
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoCubicSmoothRel(narrowPrecisionToFloat(x2), narrowPrecisionToFloat(y2),
+ narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)), ec);
+ }
+ virtual void svgCurveToQuadratic(double x, double y, double x1, double y1, bool abs)
+ {
+ ExceptionCode ec = 0;
+
+ if (abs)
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoQuadraticAbs(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1),
+ narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)), ec);
+ else
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoQuadraticRel(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1),
+ narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)), ec);
+ }
+ virtual void svgCurveToQuadraticSmooth(double x, double y, bool abs)
+ {
+ ExceptionCode ec = 0;
+
+ if (abs)
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothAbs(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)), ec);
+ else
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothRel(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)), ec);
+ }
+ virtual void svgArcTo(double x, double y, double r1, double r2, double angle, bool largeArcFlag, bool sweepFlag, bool abs)
+ {
+ ExceptionCode ec = 0;
+
+ if (abs)
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegArcAbs(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y),
+ narrowPrecisionToFloat(r1), narrowPrecisionToFloat(r2),
+ narrowPrecisionToFloat(angle), largeArcFlag, sweepFlag), ec);
+ else
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegArcRel(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y),
+ narrowPrecisionToFloat(r1), narrowPrecisionToFloat(r2),
+ narrowPrecisionToFloat(angle), largeArcFlag, sweepFlag), ec);
+ }
+ virtual void svgClosePath()
+ {
+ ExceptionCode ec = 0;
+ m_pathSegList->appendItem(SVGPathElement::createSVGPathSegClosePath(), ec);
+ }
+ SVGPathSegList* m_pathSegList;
+};
+
+bool pathSegListFromSVGData(SVGPathSegList* path , const String& d, bool process)
+{
+ SVGPathSegListBuilder builder;
+ return builder.build(path, d, process);
+}
+
+Vector<String> parseDelimitedString(const String& input, const char seperator)
+{
+ Vector<String> values;
+
+ const UChar* ptr = input.characters();
+ const UChar* end = ptr + input.length();
+ skipOptionalSpaces(ptr, end);
+
+ while (ptr < end) {
+ // Leading and trailing white space, and white space before and after semicolon separators, will be ignored.
+ const UChar* inputStart = ptr;
+ while (ptr < end && *ptr != seperator) // careful not to ignore whitespace inside inputs
+ ptr++;
+
+ if (ptr == inputStart)
+ break;
+
+ // walk backwards from the ; to ignore any whitespace
+ const UChar* inputEnd = ptr - 1;
+ while (inputStart < inputEnd && isWhitespace(*inputEnd))
+ inputEnd--;
+
+ values.append(String(inputStart, inputEnd - inputStart + 1));
+ skipOptionalSpacesOrDelimiter(ptr, end, seperator);
+ }
+
+ return values;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGParserUtilities.h b/WebCore/svg/SVGParserUtilities.h
new file mode 100644
index 0000000..17c8b1b
--- /dev/null
+++ b/WebCore/svg/SVGParserUtilities.h
@@ -0,0 +1,92 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002, 2003 The Karbon Developers
+ 2006, 2007 Rob Buis <buis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGParserUtilities_h
+#define SVGParserUtilities_h
+#if ENABLE(SVG)
+
+#include <PlatformString.h>
+
+namespace WebCore
+{
+ class Path;
+ class SVGPointList;
+ class SVGPathSegList;
+
+ bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip = true);
+ bool parseNumberOptionalNumber(const String& s, float& h, float& v);
+
+ // SVG allows several different whitespace characters:
+ // http://www.w3.org/TR/SVG/paths.html#PathDataBNF
+ static inline bool isWhitespace(const UChar& c) {
+ return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
+ }
+
+ static inline bool skipOptionalSpaces(const UChar*& ptr, const UChar* end)
+ {
+ while (ptr < end && isWhitespace(*ptr))
+ ptr++;
+ return ptr < end;
+ }
+
+ static inline bool skipOptionalSpacesOrDelimiter(const UChar*& ptr, const UChar *end, UChar delimiter = ',')
+ {
+ if (ptr < end && !isWhitespace(*ptr) && *ptr != delimiter)
+ return false;
+ if (skipOptionalSpaces(ptr, end)) {
+ if (ptr < end && *ptr == delimiter) {
+ ptr++;
+ skipOptionalSpaces(ptr, end);
+ }
+ }
+ return ptr < end;
+ }
+
+ static inline bool skipString(const UChar*& ptr, const UChar* end, const UChar* name, int length)
+ {
+ if (end - ptr < length)
+ return false;
+ if (memcmp(name, ptr, sizeof(UChar) * length))
+ return false;
+ ptr += length;
+ return true;
+ }
+
+ static inline bool skipString(const UChar*& ptr, const UChar* end, const char* str)
+ {
+ int length = strlen(str);
+ if (end - ptr < length)
+ return false;
+ for (int i = 0; i < length; ++i)
+ if (ptr[i] != str[i])
+ return false;
+ ptr += length;
+ return true;
+ }
+
+ bool pointsListFromSVGData(SVGPointList* pointsList, const String& points);
+ bool pathFromSVGData(Path& path, const String& d);
+ bool pathSegListFromSVGData(SVGPathSegList* pathSegList, const String& d, bool process = false);
+ Vector<String> parseDelimitedString(const String& input, const char seperator);
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGPathElement.cpp b/WebCore/svg/SVGPathElement.cpp
new file mode 100644
index 0000000..2375735
--- /dev/null
+++ b/WebCore/svg/SVGPathElement.cpp
@@ -0,0 +1,244 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathElement.h"
+
+#include "RenderPath.h"
+#include "SVGNames.h"
+#include "SVGParserUtilities.h"
+#include "SVGPathSegArc.h"
+#include "SVGPathSegClosePath.h"
+#include "SVGPathSegCurvetoCubic.h"
+#include "SVGPathSegCurvetoCubicSmooth.h"
+#include "SVGPathSegCurvetoQuadratic.h"
+#include "SVGPathSegCurvetoQuadraticSmooth.h"
+#include "SVGPathSegLineto.h"
+#include "SVGPathSegLinetoHorizontal.h"
+#include "SVGPathSegLinetoVertical.h"
+#include "SVGPathSegList.h"
+#include "SVGPathSegMoveto.h"
+#include "SVGSVGElement.h"
+
+namespace WebCore {
+
+SVGPathElement::SVGPathElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_pathLength(0.0f)
+{
+}
+
+SVGPathElement::~SVGPathElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGPathElement, float, Number, number, PathLength, pathLength, SVGNames::pathLengthAttr, m_pathLength)
+
+float SVGPathElement::getTotalLength()
+{
+ // FIXME: this may wish to use the pathSegList instead of the pathdata if that's cheaper to build (or cached)
+ return toPathData().length();
+}
+
+FloatPoint SVGPathElement::getPointAtLength(float length)
+{
+ // FIXME: this may wish to use the pathSegList instead of the pathdata if that's cheaper to build (or cached)
+ bool ok = false;
+ return toPathData().pointAtLength(length, ok);
+}
+
+unsigned long SVGPathElement::getPathSegAtLength(float length)
+{
+ return pathSegList()->getPathSegAtLength(length);
+}
+
+PassRefPtr<SVGPathSegClosePath> SVGPathElement::createSVGPathSegClosePath()
+{
+ return SVGPathSegClosePath::create();
+}
+
+PassRefPtr<SVGPathSegMovetoAbs> SVGPathElement::createSVGPathSegMovetoAbs(float x, float y)
+{
+ return SVGPathSegMovetoAbs::create(x, y);
+}
+
+PassRefPtr<SVGPathSegMovetoRel> SVGPathElement::createSVGPathSegMovetoRel(float x, float y)
+{
+ return SVGPathSegMovetoRel::create(x, y);
+}
+
+PassRefPtr<SVGPathSegLinetoAbs> SVGPathElement::createSVGPathSegLinetoAbs(float x, float y)
+{
+ return SVGPathSegLinetoAbs::create(x, y);
+}
+
+PassRefPtr<SVGPathSegLinetoRel> SVGPathElement::createSVGPathSegLinetoRel(float x, float y)
+{
+ return SVGPathSegLinetoRel::create(x, y);
+}
+
+PassRefPtr<SVGPathSegCurvetoCubicAbs> SVGPathElement::createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2)
+{
+ return SVGPathSegCurvetoCubicAbs::create(x, y, x1, y1, x2, y2);
+}
+
+PassRefPtr<SVGPathSegCurvetoCubicRel> SVGPathElement::createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2)
+{
+ return SVGPathSegCurvetoCubicRel::create(x, y, x1, y1, x2, y2);
+}
+
+PassRefPtr<SVGPathSegCurvetoQuadraticAbs> SVGPathElement::createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1)
+{
+ return SVGPathSegCurvetoQuadraticAbs::create(x, y, x1, y1);
+}
+
+PassRefPtr<SVGPathSegCurvetoQuadraticRel> SVGPathElement::createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1)
+{
+ return SVGPathSegCurvetoQuadraticRel::create(x, y, x1, y1);
+}
+
+PassRefPtr<SVGPathSegArcAbs> SVGPathElement::createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
+{
+ return SVGPathSegArcAbs::create(x, y, r1, r2, angle, largeArcFlag, sweepFlag);
+}
+
+PassRefPtr<SVGPathSegArcRel> SVGPathElement::createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
+{
+ return SVGPathSegArcRel::create(x, y, r1, r2, angle, largeArcFlag, sweepFlag);
+}
+
+PassRefPtr<SVGPathSegLinetoHorizontalAbs> SVGPathElement::createSVGPathSegLinetoHorizontalAbs(float x)
+{
+ return SVGPathSegLinetoHorizontalAbs::create(x);
+}
+
+PassRefPtr<SVGPathSegLinetoHorizontalRel> SVGPathElement::createSVGPathSegLinetoHorizontalRel(float x)
+{
+ return SVGPathSegLinetoHorizontalRel::create(x);
+}
+
+PassRefPtr<SVGPathSegLinetoVerticalAbs> SVGPathElement::createSVGPathSegLinetoVerticalAbs(float y)
+{
+ return SVGPathSegLinetoVerticalAbs::create(y);
+}
+
+PassRefPtr<SVGPathSegLinetoVerticalRel> SVGPathElement::createSVGPathSegLinetoVerticalRel(float y)
+{
+ return SVGPathSegLinetoVerticalRel::create(y);
+}
+
+PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> SVGPathElement::createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2)
+{
+ return SVGPathSegCurvetoCubicSmoothAbs::create(x, y, x2, y2);
+}
+
+PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> SVGPathElement::createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2)
+{
+ return SVGPathSegCurvetoCubicSmoothRel::create(x, y, x2, y2);
+}
+
+PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y)
+{
+ return SVGPathSegCurvetoQuadraticSmoothAbs::create(x, y);
+}
+
+PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y)
+{
+ return SVGPathSegCurvetoQuadraticSmoothRel::create(x, y);
+}
+
+void SVGPathElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::dAttr) {
+ ExceptionCode ec;
+ pathSegList()->clear(ec);
+ if (!pathSegListFromSVGData(pathSegList(), attr->value(), true))
+ document()->accessSVGExtensions()->reportError("Problem parsing d=\"" + attr->value() + "\"");
+ } else if (attr->name() == SVGNames::pathLengthAttr) {
+ m_pathLength = attr->value().toFloat();
+ if (m_pathLength < 0.0f)
+ document()->accessSVGExtensions()->reportError("A negative value for path attribute <pathLength> is not allowed");
+ } else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ SVGStyledTransformableElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledTransformableElement::svgAttributeChanged(attrName);
+
+ if (!renderer())
+ return;
+
+ if (attrName == SVGNames::dAttr || attrName == SVGNames::pathLengthAttr ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledTransformableElement::isKnownAttribute(attrName))
+ renderer()->setNeedsLayout(true);
+}
+
+SVGPathSegList* SVGPathElement::pathSegList() const
+{
+ if (!m_pathSegList)
+ m_pathSegList = SVGPathSegList::create(SVGNames::dAttr);
+
+ return m_pathSegList.get();
+}
+
+SVGPathSegList* SVGPathElement::normalizedPathSegList() const
+{
+ // TODO
+ return 0;
+}
+
+SVGPathSegList* SVGPathElement::animatedPathSegList() const
+{
+ // TODO
+ return 0;
+}
+
+SVGPathSegList* SVGPathElement::animatedNormalizedPathSegList() const
+{
+ // TODO
+ return 0;
+}
+
+Path SVGPathElement::toPathData() const
+{
+ return pathSegList()->toPathData();
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPathElement.h b/WebCore/svg/SVGPathElement.h
new file mode 100644
index 0000000..140e8b1
--- /dev/null
+++ b/WebCore/svg/SVGPathElement.h
@@ -0,0 +1,117 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPathElement_h
+#define SVGPathElement_h
+
+#if ENABLE(SVG)
+#include "SVGAnimatedPathData.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTests.h"
+
+namespace WebCore {
+
+ class SVGPathSeg;
+ class SVGPathSegArcAbs;
+ class SVGPathSegArcRel;
+ class SVGPathSegClosePath;
+ class SVGPathSegLinetoAbs;
+ class SVGPathSegLinetoRel;
+ class SVGPathSegMovetoAbs;
+ class SVGPathSegMovetoRel;
+ class SVGPathSegCurvetoCubicAbs;
+ class SVGPathSegCurvetoCubicRel;
+ class SVGPathSegLinetoVerticalAbs;
+ class SVGPathSegLinetoVerticalRel;
+ class SVGPathSegLinetoHorizontalAbs;
+ class SVGPathSegLinetoHorizontalRel;
+ class SVGPathSegCurvetoQuadraticAbs;
+ class SVGPathSegCurvetoQuadraticRel;
+ class SVGPathSegCurvetoCubicSmoothAbs;
+ class SVGPathSegCurvetoCubicSmoothRel;
+ class SVGPathSegCurvetoQuadraticSmoothAbs;
+ class SVGPathSegCurvetoQuadraticSmoothRel;
+ class SVGPathElement : public SVGStyledTransformableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired,
+ public SVGAnimatedPathData
+ {
+ public:
+ SVGPathElement(const QualifiedName&, Document*);
+ virtual ~SVGPathElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+ float getTotalLength();
+ FloatPoint getPointAtLength(float distance);
+ unsigned long getPathSegAtLength(float distance);
+
+ static PassRefPtr<SVGPathSegClosePath> createSVGPathSegClosePath();
+ static PassRefPtr<SVGPathSegMovetoAbs> createSVGPathSegMovetoAbs(float x, float y);
+ static PassRefPtr<SVGPathSegMovetoRel> createSVGPathSegMovetoRel(float x, float y);
+ static PassRefPtr<SVGPathSegLinetoAbs> createSVGPathSegLinetoAbs(float x, float y);
+ static PassRefPtr<SVGPathSegLinetoRel> createSVGPathSegLinetoRel(float x, float y);
+ static PassRefPtr<SVGPathSegCurvetoCubicAbs> createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2);
+ static PassRefPtr<SVGPathSegCurvetoCubicRel> createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2);
+ static PassRefPtr<SVGPathSegCurvetoQuadraticAbs> createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1);
+ static PassRefPtr<SVGPathSegCurvetoQuadraticRel> createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1);
+ static PassRefPtr<SVGPathSegArcAbs> createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
+ static PassRefPtr<SVGPathSegArcRel> createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
+ static PassRefPtr<SVGPathSegLinetoHorizontalAbs> createSVGPathSegLinetoHorizontalAbs(float x);
+ static PassRefPtr<SVGPathSegLinetoHorizontalRel> createSVGPathSegLinetoHorizontalRel(float x);
+ static PassRefPtr<SVGPathSegLinetoVerticalAbs> createSVGPathSegLinetoVerticalAbs(float y);
+ static PassRefPtr<SVGPathSegLinetoVerticalRel> createSVGPathSegLinetoVerticalRel(float y);
+ static PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2);
+ static PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2);
+ static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y);
+ static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y);
+
+ // Derived from: 'SVGAnimatedPathData'
+ virtual SVGPathSegList* pathSegList() const;
+ virtual SVGPathSegList* normalizedPathSegList() const;
+ virtual SVGPathSegList* animatedPathSegList() const;
+ virtual SVGPathSegList* animatedNormalizedPathSegList() const;
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ virtual Path toPathData() const;
+
+ virtual bool supportsMarkers() const { return true; }
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ mutable RefPtr<SVGPathSegList> m_pathSegList;
+
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPathElement, float, float, PathLength, pathLength)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGPathElement.idl b/WebCore/svg/SVGPathElement.idl
new file mode 100644
index 0000000..d66df1d
--- /dev/null
+++ b/WebCore/svg/SVGPathElement.idl
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable,
+ SVGAnimatedPathData {
+ readonly attribute SVGAnimatedNumber pathLength;
+
+ float getTotalLength();
+ SVGPoint getPointAtLength(in float distance);
+ unsigned long getPathSegAtLength(in float distance);
+
+ SVGPathSegClosePath createSVGPathSegClosePath();
+
+ SVGPathSegMovetoAbs createSVGPathSegMovetoAbs(in float x,
+ in float y);
+ SVGPathSegMovetoRel createSVGPathSegMovetoRel(in float x,
+ in float y);
+
+ SVGPathSegLinetoAbs createSVGPathSegLinetoAbs(in float x,
+ in float y);
+ SVGPathSegLinetoRel createSVGPathSegLinetoRel(in float x,
+ in float y);
+
+ SVGPathSegCurvetoCubicAbs createSVGPathSegCurvetoCubicAbs(in float x,
+ in float y,
+ in float x1,
+ in float y1,
+ in float x2,
+ in float y2);
+ SVGPathSegCurvetoCubicRel createSVGPathSegCurvetoCubicRel(in float x,
+ in float y,
+ in float x1,
+ in float y1,
+ in float x2,
+ in float y2);
+
+ SVGPathSegCurvetoQuadraticAbs createSVGPathSegCurvetoQuadraticAbs(in float x,
+ in float y,
+ in float x1,
+ in float y1);
+ SVGPathSegCurvetoQuadraticRel createSVGPathSegCurvetoQuadraticRel(in float x,
+ in float y,
+ in float x1,
+ in float y1);
+
+ SVGPathSegArcAbs createSVGPathSegArcAbs(in float x,
+ in float y,
+ in float r1,
+ in float r2,
+ in float angle,
+ in boolean largeArcFlag,
+ in boolean sweepFlag);
+ SVGPathSegArcRel createSVGPathSegArcRel(in float x,
+ in float y,
+ in float r1,
+ in float r2,
+ in float angle,
+ in boolean largeArcFlag,
+ in boolean sweepFlag);
+
+ SVGPathSegLinetoHorizontalAbs createSVGPathSegLinetoHorizontalAbs(in float x);
+ SVGPathSegLinetoHorizontalRel createSVGPathSegLinetoHorizontalRel(in float x);
+
+ SVGPathSegLinetoVerticalAbs createSVGPathSegLinetoVerticalAbs(in float y);
+ SVGPathSegLinetoVerticalRel createSVGPathSegLinetoVerticalRel(in float y);
+
+ SVGPathSegCurvetoCubicSmoothAbs createSVGPathSegCurvetoCubicSmoothAbs(in float x,
+ in float y,
+ in float x2,
+ in float y2);
+ SVGPathSegCurvetoCubicSmoothRel createSVGPathSegCurvetoCubicSmoothRel(in float x,
+ in float y,
+ in float x2,
+ in float y2);
+
+ SVGPathSegCurvetoQuadraticSmoothAbs createSVGPathSegCurvetoQuadraticSmoothAbs(in float x,
+ in float y);
+ SVGPathSegCurvetoQuadraticSmoothRel createSVGPathSegCurvetoQuadraticSmoothRel(in float x,
+ in float y);
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSeg.h b/WebCore/svg/SVGPathSeg.h
new file mode 100644
index 0000000..ed8ead4
--- /dev/null
+++ b/WebCore/svg/SVGPathSeg.h
@@ -0,0 +1,76 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPathSeg_h
+#define SVGPathSeg_h
+
+#if ENABLE(SVG)
+#include "PlatformString.h"
+#include "SVGNames.h"
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+ class SVGPathElement;
+ class SVGStyledElement;
+
+ class SVGPathSeg : public RefCounted<SVGPathSeg> {
+ public:
+ virtual ~SVGPathSeg() { }
+
+ enum SVGPathSegType {
+ PATHSEG_UNKNOWN = 0,
+ PATHSEG_CLOSEPATH = 1,
+ PATHSEG_MOVETO_ABS = 2,
+ PATHSEG_MOVETO_REL = 3,
+ PATHSEG_LINETO_ABS = 4,
+ PATHSEG_LINETO_REL = 5,
+ PATHSEG_CURVETO_CUBIC_ABS = 6,
+ PATHSEG_CURVETO_CUBIC_REL = 7,
+ PATHSEG_CURVETO_QUADRATIC_ABS = 8,
+ PATHSEG_CURVETO_QUADRATIC_REL = 9,
+ PATHSEG_ARC_ABS = 10,
+ PATHSEG_ARC_REL = 11,
+ PATHSEG_LINETO_HORIZONTAL_ABS = 12,
+ PATHSEG_LINETO_HORIZONTAL_REL = 13,
+ PATHSEG_LINETO_VERTICAL_ABS = 14,
+ PATHSEG_LINETO_VERTICAL_REL = 15,
+ PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16,
+ PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17,
+ PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18,
+ PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19
+ };
+
+ virtual unsigned short pathSegType() const { return PATHSEG_UNKNOWN; }
+ virtual String pathSegTypeAsLetter() const { return ""; }
+ virtual String toString() const { return ""; }
+
+ const QualifiedName& associatedAttributeName() const { return SVGNames::dAttr; }
+
+ protected:
+ SVGPathSeg() { }
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGPathSeg.idl b/WebCore/svg/SVGPathSeg.idl
new file mode 100644
index 0000000..3076750
--- /dev/null
+++ b/WebCore/svg/SVGPathSeg.idl
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor, ObjCCustomInternalImpl] SVGPathSeg {
+ // Path Segment Types
+ const unsigned short PATHSEG_UNKNOWN = 0;
+ const unsigned short PATHSEG_CLOSEPATH = 1;
+ const unsigned short PATHSEG_MOVETO_ABS = 2;
+ const unsigned short PATHSEG_MOVETO_REL = 3;
+ const unsigned short PATHSEG_LINETO_ABS = 4;
+ const unsigned short PATHSEG_LINETO_REL = 5;
+ const unsigned short PATHSEG_CURVETO_CUBIC_ABS = 6;
+ const unsigned short PATHSEG_CURVETO_CUBIC_REL = 7;
+ const unsigned short PATHSEG_CURVETO_QUADRATIC_ABS = 8;
+ const unsigned short PATHSEG_CURVETO_QUADRATIC_REL = 9;
+ const unsigned short PATHSEG_ARC_ABS = 10;
+ const unsigned short PATHSEG_ARC_REL = 11;
+ const unsigned short PATHSEG_LINETO_HORIZONTAL_ABS = 12;
+ const unsigned short PATHSEG_LINETO_HORIZONTAL_REL = 13;
+ const unsigned short PATHSEG_LINETO_VERTICAL_ABS = 14;
+ const unsigned short PATHSEG_LINETO_VERTICAL_REL = 15;
+ const unsigned short PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16;
+ const unsigned short PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17;
+ const unsigned short PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18;
+ const unsigned short PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19;
+
+ readonly attribute unsigned short pathSegType;
+ readonly attribute DOMString pathSegTypeAsLetter;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegArc.cpp b/WebCore/svg/SVGPathSegArc.cpp
new file mode 100644
index 0000000..605f7fc
--- /dev/null
+++ b/WebCore/svg/SVGPathSegArc.cpp
@@ -0,0 +1,210 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathSegArc.h"
+
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+SVGPathSegArcAbs::SVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+ , m_r1(r1)
+ , m_r2(r2)
+ , m_angle(angle)
+ , m_largeArcFlag(largeArcFlag)
+ , m_sweepFlag(sweepFlag)
+{
+}
+
+SVGPathSegArcAbs::~SVGPathSegArcAbs()
+{
+}
+
+void SVGPathSegArcAbs::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegArcAbs::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegArcAbs::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegArcAbs::y() const
+{
+ return m_y;
+}
+
+void SVGPathSegArcAbs::setR1(float r1)
+{
+ m_r1 = r1;
+}
+
+float SVGPathSegArcAbs::r1() const
+{
+ return m_r1;
+}
+
+void SVGPathSegArcAbs::setR2(float r2)
+{
+ m_r2 = r2;
+}
+
+float SVGPathSegArcAbs::r2() const
+{
+ return m_r2;
+}
+
+void SVGPathSegArcAbs::setAngle(float angle)
+{
+ m_angle = angle;
+}
+
+float SVGPathSegArcAbs::angle() const
+{
+ return m_angle;
+}
+
+void SVGPathSegArcAbs::setLargeArcFlag(bool largeArcFlag)
+{
+ m_largeArcFlag = largeArcFlag;
+}
+
+bool SVGPathSegArcAbs::largeArcFlag() const
+{
+ return m_largeArcFlag;
+}
+
+void SVGPathSegArcAbs::setSweepFlag(bool sweepFlag)
+{
+ m_sweepFlag = sweepFlag;
+}
+
+bool SVGPathSegArcAbs::sweepFlag() const
+{
+ return m_sweepFlag;
+}
+
+
+
+SVGPathSegArcRel::SVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+ , m_r1(r1)
+ , m_r2(r2)
+ , m_angle(angle)
+ , m_largeArcFlag(largeArcFlag)
+ , m_sweepFlag(sweepFlag)
+{
+}
+
+SVGPathSegArcRel::~SVGPathSegArcRel()
+{
+}
+
+void SVGPathSegArcRel::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegArcRel::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegArcRel::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegArcRel::y() const
+{
+ return m_y;
+}
+
+void SVGPathSegArcRel::setR1(float r1)
+{
+ m_r1 = r1;
+}
+
+float SVGPathSegArcRel::r1() const
+{
+ return m_r1;
+}
+
+void SVGPathSegArcRel::setR2(float r2)
+{
+ m_r2 = r2;
+}
+
+float SVGPathSegArcRel::r2() const
+{
+ return m_r2;
+}
+
+void SVGPathSegArcRel::setAngle(float angle)
+{
+ m_angle = angle;
+}
+
+float SVGPathSegArcRel::angle() const
+{
+ return m_angle;
+}
+
+void SVGPathSegArcRel::setLargeArcFlag(bool largeArcFlag)
+{
+ m_largeArcFlag = largeArcFlag;
+}
+
+bool SVGPathSegArcRel::largeArcFlag() const
+{
+ return m_largeArcFlag;
+}
+
+void SVGPathSegArcRel::setSweepFlag(bool sweepFlag)
+{
+ m_sweepFlag = sweepFlag;
+}
+
+bool SVGPathSegArcRel::sweepFlag() const
+{
+ return m_sweepFlag;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegArc.h b/WebCore/svg/SVGPathSegArc.h
new file mode 100644
index 0000000..06f08f5
--- /dev/null
+++ b/WebCore/svg/SVGPathSegArc.h
@@ -0,0 +1,130 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPathSegArc_h
+#define SVGPathSegArc_h
+
+#if ENABLE(SVG)
+
+#include "SVGPathSeg.h"
+
+namespace WebCore {
+
+ class SVGPathSegArcAbs : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegArcAbs> create(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
+ {
+ return adoptRef(new SVGPathSegArcAbs(x, y, r1, r2, angle, largeArcFlag, sweepFlag));
+ }
+
+ virtual ~SVGPathSegArcAbs();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_ARC_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "A"; }
+ virtual String toString() const { return String::format("A %.6lg %.6lg %.6lg %d %d %.6lg %.6lg", m_r1, m_r2, m_angle, m_largeArcFlag, m_sweepFlag, m_x, m_y); }
+
+ void setX(float x);
+ float x() const;
+
+ void setY(float y);
+ float y() const;
+
+ void setR1(float r1);
+ float r1() const;
+
+ void setR2(float r2);
+ float r2() const;
+
+ void setAngle(float angle);
+ float angle() const;
+
+ void setLargeArcFlag(bool largeArcFlag);
+ bool largeArcFlag() const;
+
+ void setSweepFlag(bool sweepFlag);
+ bool sweepFlag() const;
+
+ private:
+ SVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
+
+ float m_x;
+ float m_y;
+ float m_r1;
+ float m_r2;
+ float m_angle;
+
+ bool m_largeArcFlag : 1;
+ bool m_sweepFlag : 1;
+ };
+
+ class SVGPathSegArcRel : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegArcRel> create(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
+ {
+ return adoptRef(new SVGPathSegArcRel(x, y, r1, r2, angle, largeArcFlag, sweepFlag));
+ }
+ virtual ~SVGPathSegArcRel();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_ARC_REL; }
+ virtual String pathSegTypeAsLetter() const { return "a"; }
+ virtual String toString() const { return String::format("a %.6lg %.6lg %.6lg %d %d %.6lg %.6lg", m_r1, m_r2, m_angle, m_largeArcFlag, m_sweepFlag, m_x, m_y); }
+
+ void setX(float x);
+ float x() const;
+
+ void setY(float y);
+ float y() const;
+
+ void setR1(float r1);
+ float r1() const;
+
+ void setR2(float r2);
+ float r2() const;
+
+ void setAngle(float angle);
+ float angle() const;
+
+ void setLargeArcFlag(bool largeArcFlag);
+ bool largeArcFlag() const;
+
+ void setSweepFlag(bool sweepFlag);
+ bool sweepFlag() const;
+
+ private:
+ SVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
+
+ float m_x;
+ float m_y;
+ float m_r1;
+ float m_r2;
+ float m_angle;
+
+ bool m_largeArcFlag : 1;
+ bool m_sweepFlag : 1;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegArcAbs.idl b/WebCore/svg/SVGPathSegArcAbs.idl
new file mode 100644
index 0000000..5d9cf7c
--- /dev/null
+++ b/WebCore/svg/SVGPathSegArcAbs.idl
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegArcAbs : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ attribute float r1
+ /*setter raises(DOMException)*/;
+ attribute float r2
+ /*setter raises(DOMException)*/;
+ attribute float angle
+ /*setter raises(DOMException)*/;
+ attribute boolean largeArcFlag
+ /*setter raises(DOMException)*/;
+ attribute boolean sweepFlag
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegArcRel.idl b/WebCore/svg/SVGPathSegArcRel.idl
new file mode 100644
index 0000000..b4b66ab
--- /dev/null
+++ b/WebCore/svg/SVGPathSegArcRel.idl
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegArcRel : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ attribute float r1
+ /*setter raises(DOMException)*/;
+ attribute float r2
+ /*setter raises(DOMException)*/;
+ attribute float angle
+ /*setter raises(DOMException)*/;
+ attribute boolean largeArcFlag
+ /*setter raises(DOMException)*/;
+ attribute boolean sweepFlag
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegClosePath.cpp b/WebCore/svg/SVGPathSegClosePath.cpp
new file mode 100644
index 0000000..04b711c
--- /dev/null
+++ b/WebCore/svg/SVGPathSegClosePath.cpp
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathSegClosePath.h"
+
+namespace WebCore {
+
+SVGPathSegClosePath::SVGPathSegClosePath()
+ : SVGPathSeg()
+{
+}
+
+SVGPathSegClosePath::~SVGPathSegClosePath()
+{
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegClosePath.h b/WebCore/svg/SVGPathSegClosePath.h
new file mode 100644
index 0000000..eb74dea
--- /dev/null
+++ b/WebCore/svg/SVGPathSegClosePath.h
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPathSegClosePath_h
+#define SVGPathSegClosePath_h
+
+#if ENABLE(SVG)
+
+#include "SVGPathSeg.h"
+
+namespace WebCore
+{
+ class SVGPathSegClosePath : public SVGPathSeg
+ {
+ public:
+ static PassRefPtr<SVGPathSegClosePath> create() { return adoptRef(new SVGPathSegClosePath); }
+ virtual ~SVGPathSegClosePath();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CLOSEPATH; }
+ virtual String pathSegTypeAsLetter() const { return "Z"; }
+ virtual String toString() const { return "Z"; }
+
+ private:
+ SVGPathSegClosePath();
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegClosePath.idl b/WebCore/svg/SVGPathSegClosePath.idl
new file mode 100644
index 0000000..4061a13
--- /dev/null
+++ b/WebCore/svg/SVGPathSegClosePath.idl
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegClosePath : SVGPathSeg {
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegCurvetoCubic.cpp b/WebCore/svg/SVGPathSegCurvetoCubic.cpp
new file mode 100644
index 0000000..304d9c27
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoCubic.cpp
@@ -0,0 +1,189 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathSegCurvetoCubic.h"
+
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+SVGPathSegCurvetoCubicAbs::SVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+ , m_x1(x1)
+ , m_y1(y1)
+ , m_x2(x2)
+ , m_y2(y2)
+{
+}
+
+SVGPathSegCurvetoCubicAbs::~SVGPathSegCurvetoCubicAbs()
+{
+}
+
+void SVGPathSegCurvetoCubicAbs::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegCurvetoCubicAbs::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegCurvetoCubicAbs::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegCurvetoCubicAbs::y() const
+{
+ return m_y;
+}
+
+void SVGPathSegCurvetoCubicAbs::setX1(float x1)
+{
+ m_x1 = x1;
+}
+
+float SVGPathSegCurvetoCubicAbs::x1() const
+{
+ return m_x1;
+}
+
+void SVGPathSegCurvetoCubicAbs::setY1(float y1)
+{
+ m_y1 = y1;
+}
+
+float SVGPathSegCurvetoCubicAbs::y1() const
+{
+ return m_y1;
+}
+
+void SVGPathSegCurvetoCubicAbs::setX2(float x2)
+{
+ m_x2 = x2;
+}
+
+float SVGPathSegCurvetoCubicAbs::x2() const
+{
+ return m_x2;
+}
+
+void SVGPathSegCurvetoCubicAbs::setY2(float y2)
+{
+ m_y2 = y2;
+}
+
+float SVGPathSegCurvetoCubicAbs::y2() const
+{
+ return m_y2;
+}
+
+
+
+
+SVGPathSegCurvetoCubicRel::SVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+ , m_x1(x1)
+ , m_y1(y1)
+ , m_x2(x2)
+ , m_y2(y2)
+{
+}
+
+SVGPathSegCurvetoCubicRel::~SVGPathSegCurvetoCubicRel()
+{
+}
+
+void SVGPathSegCurvetoCubicRel::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegCurvetoCubicRel::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegCurvetoCubicRel::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegCurvetoCubicRel::y() const
+{
+ return m_y;
+}
+
+void SVGPathSegCurvetoCubicRel::setX1(float x1)
+{
+ m_x1 = x1;
+}
+
+float SVGPathSegCurvetoCubicRel::x1() const
+{
+ return m_x1;
+}
+
+void SVGPathSegCurvetoCubicRel::setY1(float y1)
+{
+ m_y1 = y1;
+}
+
+float SVGPathSegCurvetoCubicRel::y1() const
+{
+ return m_y1;
+}
+
+void SVGPathSegCurvetoCubicRel::setX2(float x2)
+{
+ m_x2 = x2;
+}
+
+float SVGPathSegCurvetoCubicRel::x2() const
+{
+ return m_x2;
+}
+
+void SVGPathSegCurvetoCubicRel::setY2(float y2)
+{
+ m_y2 = y2;
+}
+
+float SVGPathSegCurvetoCubicRel::y2() const
+{
+ return m_y2;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegCurvetoCubic.h b/WebCore/svg/SVGPathSegCurvetoCubic.h
new file mode 100644
index 0000000..b30d860
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoCubic.h
@@ -0,0 +1,119 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPathSegCurvetoCubic_h
+#define SVGPathSegCurvetoCubic_h
+
+#if ENABLE(SVG)
+
+#include "SVGPathSeg.h"
+
+namespace WebCore {
+ class SVGPathSegCurvetoCubicAbs : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoCubicAbs> create(float x, float y, float x1, float y1, float x2, float y2)
+ {
+ return adoptRef(new SVGPathSegCurvetoCubicAbs(x, y, x1, y1, x2, y2));
+ }
+
+ virtual ~SVGPathSegCurvetoCubicAbs();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "C"; }
+ virtual String toString() const { return String::format("C %.6lg %.6lg %.6lg %.6lg %.6lg %.6lg", m_x1, m_y1, m_x2, m_y2, m_x, m_y); }
+
+ void setX(float);
+ float x() const;
+
+ void setY(float);
+ float y() const;
+
+ void setX1(float);
+ float x1() const;
+
+ void setY1(float);
+ float y1() const;
+
+ void setX2(float);
+ float x2() const;
+
+ void setY2(float);
+ float y2() const;
+
+ private:
+ SVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2);
+
+ float m_x;
+ float m_y;
+ float m_x1;
+ float m_y1;
+ float m_x2;
+ float m_y2;
+ };
+
+ class SVGPathSegCurvetoCubicRel : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoCubicRel> create(float x, float y, float x1, float y1, float x2, float y2)
+ {
+ return adoptRef(new SVGPathSegCurvetoCubicRel(x, y, x1, y1, x2, y2));
+ }
+ virtual ~SVGPathSegCurvetoCubicRel();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_REL; }
+ virtual String pathSegTypeAsLetter() const { return "c"; }
+ virtual String toString() const { return String::format("c %.6lg %.6lg %.6lg %.6lg %.6lg %.6lg", m_x1, m_y1, m_x2, m_y2, m_x, m_y); }
+
+ void setX(float);
+ float x() const;
+
+ void setY(float);
+ float y() const;
+
+ void setX1(float);
+ float x1() const;
+
+ void setY1(float);
+ float y1() const;
+
+ void setX2(float);
+ float x2() const;
+
+ void setY2(float);
+ float y2() const;
+
+ private:
+ SVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2);
+
+ float m_x;
+ float m_y;
+ float m_x1;
+ float m_y1;
+ float m_x2;
+ float m_y2;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegCurvetoCubicAbs.idl b/WebCore/svg/SVGPathSegCurvetoCubicAbs.idl
new file mode 100644
index 0000000..79188ff
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoCubicAbs.idl
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegCurvetoCubicAbs : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ attribute float x1
+ /*setter raises(DOMException)*/;
+ attribute float y1
+ /*setter raises(DOMException)*/;
+ attribute float x2
+ /*setter raises(DOMException)*/;
+ attribute float y2
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegCurvetoCubicRel.idl b/WebCore/svg/SVGPathSegCurvetoCubicRel.idl
new file mode 100644
index 0000000..89677db
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoCubicRel.idl
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegCurvetoCubicRel : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ attribute float x1
+ /*setter raises(DOMException)*/;
+ attribute float y1
+ /*setter raises(DOMException)*/;
+ attribute float x2
+ /*setter raises(DOMException)*/;
+ attribute float y2
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.cpp b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.cpp
new file mode 100644
index 0000000..3a7ecef
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.cpp
@@ -0,0 +1,143 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGPathSegCurvetoCubicSmooth.h"
+
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+SVGPathSegCurvetoCubicSmoothAbs::SVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+ , m_x2(x2)
+ , m_y2(y2)
+{
+}
+
+SVGPathSegCurvetoCubicSmoothAbs::~SVGPathSegCurvetoCubicSmoothAbs()
+{
+}
+
+void SVGPathSegCurvetoCubicSmoothAbs::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegCurvetoCubicSmoothAbs::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegCurvetoCubicSmoothAbs::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegCurvetoCubicSmoothAbs::y() const
+{
+ return m_y;
+}
+
+void SVGPathSegCurvetoCubicSmoothAbs::setX2(float x2)
+{
+ m_x2 = x2;
+}
+
+float SVGPathSegCurvetoCubicSmoothAbs::x2() const
+{
+ return m_x2;
+}
+
+void SVGPathSegCurvetoCubicSmoothAbs::setY2(float y2)
+{
+ m_y2 = y2;
+}
+
+float SVGPathSegCurvetoCubicSmoothAbs::y2() const
+{
+ return m_y2;
+}
+
+
+
+SVGPathSegCurvetoCubicSmoothRel::SVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+ , m_x2(x2)
+ , m_y2(y2)
+{
+}
+
+SVGPathSegCurvetoCubicSmoothRel::~SVGPathSegCurvetoCubicSmoothRel()
+{
+}
+
+void SVGPathSegCurvetoCubicSmoothRel::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegCurvetoCubicSmoothRel::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegCurvetoCubicSmoothRel::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegCurvetoCubicSmoothRel::y() const
+{
+ return m_y;
+}
+
+void SVGPathSegCurvetoCubicSmoothRel::setX2(float x2)
+{
+ m_x2 = x2;
+}
+
+float SVGPathSegCurvetoCubicSmoothRel::x2() const
+{
+ return m_x2;
+}
+
+void SVGPathSegCurvetoCubicSmoothRel::setY2(float y2)
+{
+ m_y2 = y2;
+}
+
+float SVGPathSegCurvetoCubicSmoothRel::y2() const
+{
+ return m_y2;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h
new file mode 100644
index 0000000..c99c107
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h
@@ -0,0 +1,97 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPathSegCurvetoCubicSmooth_h
+#define SVGPathSegCurvetoCubicSmooth_h
+
+#if ENABLE(SVG)
+
+#include "SVGPathSeg.h"
+
+namespace WebCore {
+
+ class SVGPathSegCurvetoCubicSmoothAbs : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> create(float x, float y, float x2, float y2) { return adoptRef(new SVGPathSegCurvetoCubicSmoothAbs(x, y, x2, y2)); }
+ virtual ~SVGPathSegCurvetoCubicSmoothAbs();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "S"; }
+ virtual String toString() const { return String::format("S %.6lg %.6lg %.6lg %.6lg", m_x2, m_y2, m_x, m_y); }
+
+ void setX(float);
+ float x() const;
+
+ void setY(float);
+ float y() const;
+
+ void setX2(float);
+ float x2() const;
+
+ void setY2(float);
+ float y2() const;
+
+ private:
+ SVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2);
+
+ float m_x;
+ float m_y;
+ float m_x2;
+ float m_y2;
+ };
+
+ class SVGPathSegCurvetoCubicSmoothRel : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> create(float x, float y, float x2, float y2) { return adoptRef(new SVGPathSegCurvetoCubicSmoothRel(x, y, x2, y2)); }
+ virtual ~SVGPathSegCurvetoCubicSmoothRel();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_SMOOTH_REL; }
+ virtual String pathSegTypeAsLetter() const { return "s"; }
+ virtual String toString() const { return String::format("s %.6lg %.6lg %.6lg %.6lg", m_x2, m_y2, m_x, m_y); }
+
+ void setX(float);
+ float x() const;
+
+ void setY(float);
+ float y() const;
+
+ void setX2(float);
+ float x2() const;
+
+ void setY2(float);
+ float y2() const;
+
+ private:
+ SVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2);
+
+ float m_x;
+ float m_y;
+ float m_x2;
+ float m_y2;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegCurvetoCubicSmoothAbs.idl b/WebCore/svg/SVGPathSegCurvetoCubicSmoothAbs.idl
new file mode 100644
index 0000000..4768271
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoCubicSmoothAbs.idl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegCurvetoCubicSmoothAbs : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ attribute float x2
+ /*setter raises(DOMException)*/;
+ attribute float y2
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegCurvetoCubicSmoothRel.idl b/WebCore/svg/SVGPathSegCurvetoCubicSmoothRel.idl
new file mode 100644
index 0000000..c807621
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoCubicSmoothRel.idl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegCurvetoCubicSmoothRel : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ attribute float x2
+ /*setter raises(DOMException)*/;
+ attribute float y2
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegCurvetoQuadratic.cpp b/WebCore/svg/SVGPathSegCurvetoQuadratic.cpp
new file mode 100644
index 0000000..9402f02
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoQuadratic.cpp
@@ -0,0 +1,145 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathSegCurvetoQuadratic.h"
+
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+SVGPathSegCurvetoQuadraticAbs::SVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+ , m_x1(x1)
+ , m_y1(y1)
+{
+}
+
+SVGPathSegCurvetoQuadraticAbs::~SVGPathSegCurvetoQuadraticAbs()
+{
+}
+
+void SVGPathSegCurvetoQuadraticAbs::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegCurvetoQuadraticAbs::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegCurvetoQuadraticAbs::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegCurvetoQuadraticAbs::y() const
+{
+ return m_y;
+}
+
+void SVGPathSegCurvetoQuadraticAbs::setX1(float x1)
+{
+ m_x1 = x1;
+}
+
+float SVGPathSegCurvetoQuadraticAbs::x1() const
+{
+ return m_x1;
+}
+
+void SVGPathSegCurvetoQuadraticAbs::setY1(float y1)
+{
+ m_y1 = y1;
+}
+
+float SVGPathSegCurvetoQuadraticAbs::y1() const
+{
+ return m_y1;
+}
+
+
+
+
+SVGPathSegCurvetoQuadraticRel::SVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+ , m_x1(x1)
+ , m_y1(y1)
+{
+}
+
+SVGPathSegCurvetoQuadraticRel::~SVGPathSegCurvetoQuadraticRel()
+{
+}
+
+void SVGPathSegCurvetoQuadraticRel::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegCurvetoQuadraticRel::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegCurvetoQuadraticRel::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegCurvetoQuadraticRel::y() const
+{
+ return m_y;
+}
+
+void SVGPathSegCurvetoQuadraticRel::setX1(float x1)
+{
+ m_x1 = x1;
+}
+
+float SVGPathSegCurvetoQuadraticRel::x1() const
+{
+ return m_x1;
+}
+
+void SVGPathSegCurvetoQuadraticRel::setY1(float y1)
+{
+ m_y1 = y1;
+}
+
+float SVGPathSegCurvetoQuadraticRel::y1() const
+{
+ return m_y1;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegCurvetoQuadratic.h b/WebCore/svg/SVGPathSegCurvetoQuadratic.h
new file mode 100644
index 0000000..357ddc4
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoQuadratic.h
@@ -0,0 +1,97 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPathSegCurvetoQuadratic_h
+#define SVGPathSegCurvetoQuadratic_h
+
+#if ENABLE(SVG)
+
+#include "SVGPathSeg.h"
+
+namespace WebCore {
+
+ class SVGPathSegCurvetoQuadraticAbs : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoQuadraticAbs> create(float x, float y, float x1, float y1) { return adoptRef(new SVGPathSegCurvetoQuadraticAbs(x, y, x1, y1)); }
+ virtual ~SVGPathSegCurvetoQuadraticAbs();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "Q"; }
+ virtual String toString() const { return String::format("Q %.6lg %.6lg %.6lg %.6lg", m_x1, m_y1, m_x, m_y); }
+
+ void setX(float);
+ float x() const;
+
+ void setY(float);
+ float y() const;
+
+ void setX1(float);
+ float x1() const;
+
+ void setY1(float);
+ float y1() const;
+
+ private:
+ SVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1);
+
+ float m_x;
+ float m_y;
+ float m_x1;
+ float m_y1;
+ };
+
+ class SVGPathSegCurvetoQuadraticRel : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoQuadraticRel> create(float x, float y, float x1, float y1) { return adoptRef(new SVGPathSegCurvetoQuadraticRel(x, y, x1, y1)); }
+ virtual ~SVGPathSegCurvetoQuadraticRel();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_REL; }
+ virtual String pathSegTypeAsLetter() const { return "q"; }
+ virtual String toString() const { return String::format("q %.6lg %.6lg %.6lg %.6lg", m_x1, m_y1, m_x, m_y); }
+
+ void setX(float);
+ float x() const;
+
+ void setY(float);
+ float y() const;
+
+ void setX1(float);
+ float x1() const;
+
+ void setY1(float);
+ float y1() const;
+
+ private:
+ SVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1);
+
+ float m_x;
+ float m_y;
+ float m_x1;
+ float m_y1;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticAbs.idl b/WebCore/svg/SVGPathSegCurvetoQuadraticAbs.idl
new file mode 100644
index 0000000..b6da170
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoQuadraticAbs.idl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegCurvetoQuadraticAbs : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ attribute float x1
+ /*setter raises(DOMException)*/;
+ attribute float y1
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticRel.idl b/WebCore/svg/SVGPathSegCurvetoQuadraticRel.idl
new file mode 100644
index 0000000..2404b67
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoQuadraticRel.idl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegCurvetoQuadraticRel : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ attribute float x1
+ /*setter raises(DOMException)*/;
+ attribute float y1
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.cpp b/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.cpp
new file mode 100644
index 0000000..7026e1d
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.cpp
@@ -0,0 +1,100 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathSegCurvetoQuadraticSmooth.h"
+
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+SVGPathSegCurvetoQuadraticSmoothAbs::SVGPathSegCurvetoQuadraticSmoothAbs(float x, float y)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+{
+}
+
+SVGPathSegCurvetoQuadraticSmoothAbs::~SVGPathSegCurvetoQuadraticSmoothAbs()
+{
+}
+
+void SVGPathSegCurvetoQuadraticSmoothAbs::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegCurvetoQuadraticSmoothAbs::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegCurvetoQuadraticSmoothAbs::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegCurvetoQuadraticSmoothAbs::y() const
+{
+ return m_y;
+}
+
+
+
+SVGPathSegCurvetoQuadraticSmoothRel::SVGPathSegCurvetoQuadraticSmoothRel(float x, float y)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+{
+}
+
+SVGPathSegCurvetoQuadraticSmoothRel::~SVGPathSegCurvetoQuadraticSmoothRel()
+{
+}
+
+void SVGPathSegCurvetoQuadraticSmoothRel::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegCurvetoQuadraticSmoothRel::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegCurvetoQuadraticSmoothRel::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegCurvetoQuadraticSmoothRel::y() const
+{
+ return m_y;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h b/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h
new file mode 100644
index 0000000..86193fa
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h
@@ -0,0 +1,81 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPathSegCurvetoQuadraticSmooth_h
+#define SVGPathSegCurvetoQuadraticSmooth_h
+
+#if ENABLE(SVG)
+
+#include "SVGPathSeg.h"
+
+namespace WebCore {
+
+ class SVGPathSegCurvetoQuadraticSmoothAbs : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> create(float x, float y) { return adoptRef(new SVGPathSegCurvetoQuadraticSmoothAbs(x, y)); }
+ virtual ~SVGPathSegCurvetoQuadraticSmoothAbs();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "T"; }
+ virtual String toString() const { return String::format("T %.6lg %.6lg", m_x, m_y); }
+
+ void setX(float);
+ float x() const;
+
+ void setY(float);
+ float y() const;
+
+ private:
+ SVGPathSegCurvetoQuadraticSmoothAbs(float x, float y);
+
+ float m_x;
+ float m_y;
+ };
+
+ class SVGPathSegCurvetoQuadraticSmoothRel : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> create(float x, float y) { return adoptRef(new SVGPathSegCurvetoQuadraticSmoothRel(x, y)); }
+ virtual ~SVGPathSegCurvetoQuadraticSmoothRel();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; }
+ virtual String pathSegTypeAsLetter() const { return "t"; }
+ virtual String toString() const { return String::format("t %.6lg %.6lg", m_x, m_y); }
+
+ void setX(float);
+ float x() const;
+
+ void setY(float);
+ float y() const;
+
+ private:
+ SVGPathSegCurvetoQuadraticSmoothRel(float x, float y);
+
+ float m_x;
+ float m_y;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothAbs.idl b/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothAbs.idl
new file mode 100644
index 0000000..c47450b
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothAbs.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegCurvetoQuadraticSmoothAbs : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothRel.idl b/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothRel.idl
new file mode 100644
index 0000000..0cdff0e
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothRel.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegCurvetoQuadraticSmoothRel : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegLineto.cpp b/WebCore/svg/SVGPathSegLineto.cpp
new file mode 100644
index 0000000..bf94119
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLineto.cpp
@@ -0,0 +1,98 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathSegLineto.h"
+
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+SVGPathSegLinetoAbs::SVGPathSegLinetoAbs(float x, float y)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+{
+}
+
+SVGPathSegLinetoAbs::~SVGPathSegLinetoAbs()
+{
+}
+
+void SVGPathSegLinetoAbs::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegLinetoAbs::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegLinetoAbs::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegLinetoAbs::y() const
+{
+ return m_y;
+}
+
+SVGPathSegLinetoRel::SVGPathSegLinetoRel(float x, float y)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+{
+}
+
+SVGPathSegLinetoRel::~SVGPathSegLinetoRel()
+{
+}
+
+void SVGPathSegLinetoRel::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegLinetoRel::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegLinetoRel::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegLinetoRel::y() const
+{
+ return m_y;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegLineto.h b/WebCore/svg/SVGPathSegLineto.h
new file mode 100644
index 0000000..0110891
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLineto.h
@@ -0,0 +1,80 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPathSegLineto_h
+#define SVGPathSegLineto_h
+
+#if ENABLE(SVG)
+
+#include "SVGPathSeg.h"
+
+namespace WebCore {
+ class SVGPathSegLinetoAbs : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegLinetoAbs> create(float x, float y) { return adoptRef(new SVGPathSegLinetoAbs(x, y)); }
+ virtual ~SVGPathSegLinetoAbs();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_LINETO_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "L"; }
+ virtual String toString() const { return String::format("L %.6lg %.6lg", m_x, m_y); }
+
+ void setX(float);
+ float x() const;
+
+ void setY(float);
+ float y() const;
+
+ private:
+ SVGPathSegLinetoAbs(float x, float y);
+
+ float m_x;
+ float m_y;
+ };
+
+ class SVGPathSegLinetoRel : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegLinetoRel> create(float x, float y) { return adoptRef(new SVGPathSegLinetoRel(x, y)); }
+ virtual ~SVGPathSegLinetoRel();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_LINETO_REL; }
+ virtual String pathSegTypeAsLetter() const { return "l"; }
+ virtual String toString() const { return String::format("l %.6lg %.6lg", m_x, m_y); }
+
+ void setX(float);
+ float x() const;
+
+ void setY(float);
+ float y() const;
+
+ private:
+ SVGPathSegLinetoRel(float x, float y);
+
+ float m_x;
+ float m_y;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegLinetoAbs.idl b/WebCore/svg/SVGPathSegLinetoAbs.idl
new file mode 100644
index 0000000..3cb4e35
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoAbs.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegLinetoAbs : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegLinetoHorizontal.cpp b/WebCore/svg/SVGPathSegLinetoHorizontal.cpp
new file mode 100644
index 0000000..5629695
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoHorizontal.cpp
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathSegLinetoHorizontal.h"
+
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+SVGPathSegLinetoHorizontalAbs::SVGPathSegLinetoHorizontalAbs(float x)
+ : SVGPathSeg()
+ , m_x(x)
+{
+}
+
+SVGPathSegLinetoHorizontalAbs::~SVGPathSegLinetoHorizontalAbs()
+{
+}
+
+void SVGPathSegLinetoHorizontalAbs::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegLinetoHorizontalAbs::x() const
+{
+ return m_x;
+}
+
+
+
+SVGPathSegLinetoHorizontalRel::SVGPathSegLinetoHorizontalRel(float x)
+ : SVGPathSeg()
+ , m_x(x)
+{
+}
+
+SVGPathSegLinetoHorizontalRel::~SVGPathSegLinetoHorizontalRel()
+{
+}
+
+void SVGPathSegLinetoHorizontalRel::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegLinetoHorizontalRel::x() const
+{
+ return m_x;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegLinetoHorizontal.h b/WebCore/svg/SVGPathSegLinetoHorizontal.h
new file mode 100644
index 0000000..504f40d
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoHorizontal.h
@@ -0,0 +1,72 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPathSegLinetoHorizontal_h
+#define SVGPathSegLinetoHorizontal_h
+
+#if ENABLE(SVG)
+
+#include "SVGPathSeg.h"
+
+namespace WebCore {
+
+ class SVGPathSegLinetoHorizontalAbs : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegLinetoHorizontalAbs> create(float x) { return adoptRef(new SVGPathSegLinetoHorizontalAbs(x)); }
+ virtual ~SVGPathSegLinetoHorizontalAbs();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_LINETO_HORIZONTAL_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "H"; }
+ virtual String toString() const { return String::format("H %.6lg", m_x); }
+
+ void setX(float);
+ float x() const;
+
+ private:
+ SVGPathSegLinetoHorizontalAbs(float x);
+ float m_x;
+ };
+
+ class SVGPathSegLinetoHorizontalRel : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegLinetoHorizontalRel> create(float x) { return adoptRef(new SVGPathSegLinetoHorizontalRel(x)); }
+ virtual ~SVGPathSegLinetoHorizontalRel();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_LINETO_HORIZONTAL_REL; }
+ virtual String pathSegTypeAsLetter() const { return "h"; }
+ virtual String toString() const { return String::format("h %.6lg", m_x); }
+
+ void setX(float);
+ float x() const;
+
+ private:
+ SVGPathSegLinetoHorizontalRel(float x);
+
+ float m_x;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegLinetoHorizontalAbs.idl b/WebCore/svg/SVGPathSegLinetoHorizontalAbs.idl
new file mode 100644
index 0000000..2a0aff5
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoHorizontalAbs.idl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegLinetoHorizontalAbs : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegLinetoHorizontalRel.idl b/WebCore/svg/SVGPathSegLinetoHorizontalRel.idl
new file mode 100644
index 0000000..4fa03b4
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoHorizontalRel.idl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegLinetoHorizontalRel : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegLinetoRel.idl b/WebCore/svg/SVGPathSegLinetoRel.idl
new file mode 100644
index 0000000..94f129d
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoRel.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegLinetoRel : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegLinetoVertical.cpp b/WebCore/svg/SVGPathSegLinetoVertical.cpp
new file mode 100644
index 0000000..6f32c04
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoVertical.cpp
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathSegLinetoVertical.h"
+
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+SVGPathSegLinetoVerticalAbs::SVGPathSegLinetoVerticalAbs(float y)
+ : SVGPathSeg()
+ , m_y(y)
+{
+}
+
+SVGPathSegLinetoVerticalAbs::~SVGPathSegLinetoVerticalAbs()
+{
+}
+
+void SVGPathSegLinetoVerticalAbs::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegLinetoVerticalAbs::y() const
+{
+ return m_y;
+}
+
+
+
+
+SVGPathSegLinetoVerticalRel::SVGPathSegLinetoVerticalRel(float y)
+ : SVGPathSeg()
+ , m_y(y)
+{
+}
+
+SVGPathSegLinetoVerticalRel::~SVGPathSegLinetoVerticalRel()
+{
+}
+
+void SVGPathSegLinetoVerticalRel::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegLinetoVerticalRel::y() const
+{
+ return m_y;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegLinetoVertical.h b/WebCore/svg/SVGPathSegLinetoVertical.h
new file mode 100644
index 0000000..d3bf067
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoVertical.h
@@ -0,0 +1,73 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPathSegLinetoVertical_h
+#define SVGPathSegLinetoVertical_h
+
+#if ENABLE(SVG)
+
+#include "SVGPathSeg.h"
+
+namespace WebCore {
+
+ class SVGPathSegLinetoVerticalAbs : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegLinetoVerticalAbs> create(float y) { return adoptRef(new SVGPathSegLinetoVerticalAbs(y)); }
+ virtual~SVGPathSegLinetoVerticalAbs();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_LINETO_VERTICAL_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "V"; }
+ virtual String toString() const { return String::format("V %.6lg", m_y); }
+
+ void setY(float);
+ float y() const;
+
+ private:
+ SVGPathSegLinetoVerticalAbs(float y);
+
+ float m_y;
+ };
+
+ class SVGPathSegLinetoVerticalRel : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegLinetoVerticalRel> create(float y) { return adoptRef(new SVGPathSegLinetoVerticalRel(y)); }
+ virtual ~SVGPathSegLinetoVerticalRel();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_LINETO_VERTICAL_REL; }
+ virtual String pathSegTypeAsLetter() const { return "v"; }
+ virtual String toString() const { return String::format("v %.6lg", m_y); }
+
+ void setY(float);
+ float y() const;
+
+ private:
+ SVGPathSegLinetoVerticalRel(float y);
+
+ float m_y;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegLinetoVerticalAbs.idl b/WebCore/svg/SVGPathSegLinetoVerticalAbs.idl
new file mode 100644
index 0000000..c2c59a5
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoVerticalAbs.idl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegLinetoVerticalAbs : SVGPathSeg {
+ attribute float y
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegLinetoVerticalRel.idl b/WebCore/svg/SVGPathSegLinetoVerticalRel.idl
new file mode 100644
index 0000000..bb8c3af
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoVerticalRel.idl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegLinetoVerticalRel : SVGPathSeg {
+ attribute float y
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegList.cpp b/WebCore/svg/SVGPathSegList.cpp
new file mode 100644
index 0000000..9a4f21e
--- /dev/null
+++ b/WebCore/svg/SVGPathSegList.cpp
@@ -0,0 +1,140 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathSegList.h"
+
+#include "FloatPoint.h"
+#include "Path.h"
+#include "PathTraversalState.h"
+#include "SVGPathSegMoveto.h"
+#include "SVGPathSegLineto.h"
+#include "SVGPathSegCurvetoCubic.h"
+
+namespace WebCore {
+
+SVGPathSegList::SVGPathSegList(const QualifiedName& attributeName)
+ : SVGList<RefPtr<SVGPathSeg> >(attributeName)
+{
+}
+
+SVGPathSegList::~SVGPathSegList()
+{
+}
+
+unsigned SVGPathSegList::getPathSegAtLength(double)
+{
+ // FIXME : to be useful this will need to support non-normalized SVGPathSegLists
+ ExceptionCode ec = 0;
+ int len = numberOfItems();
+ // FIXME: Eventually this will likely move to a "path applier"-like model, until then PathTraversalState is less useful as we could just use locals
+ PathTraversalState traversalState(PathTraversalState::TraversalSegmentAtLength);
+ for (int i = 0; i < len; ++i) {
+ SVGPathSeg* segment = getItem(i, ec).get();
+ float segmentLength = 0;
+ switch (segment->pathSegType()) {
+ case SVGPathSeg::PATHSEG_MOVETO_ABS:
+ {
+ SVGPathSegMovetoAbs* moveTo = static_cast<SVGPathSegMovetoAbs*>(segment);
+ segmentLength = traversalState.moveTo(FloatPoint(moveTo->x(), moveTo->y()));
+ break;
+ }
+ case SVGPathSeg::PATHSEG_LINETO_ABS:
+ {
+ SVGPathSegLinetoAbs* lineTo = static_cast<SVGPathSegLinetoAbs*>(segment);
+ segmentLength = traversalState.lineTo(FloatPoint(lineTo->x(), lineTo->y()));
+ break;
+ }
+ case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS:
+ {
+ SVGPathSegCurvetoCubicAbs* curveTo = static_cast<SVGPathSegCurvetoCubicAbs*>(segment);
+ segmentLength = traversalState.cubicBezierTo(FloatPoint(curveTo->x1(), curveTo->y1()),
+ FloatPoint(curveTo->x2(), curveTo->y2()),
+ FloatPoint(curveTo->x(), curveTo->y()));
+ break;
+ }
+ case SVGPathSeg::PATHSEG_CLOSEPATH:
+ segmentLength = traversalState.closeSubpath();
+ break;
+ default:
+ ASSERT(false); // FIXME: This only works with normalized/processed path data.
+ break;
+ }
+ traversalState.m_totalLength += segmentLength;
+ if ((traversalState.m_action == PathTraversalState::TraversalSegmentAtLength)
+ && (traversalState.m_totalLength > traversalState.m_desiredLength)) {
+ return traversalState.m_segmentIndex;
+ }
+ traversalState.m_segmentIndex++;
+ }
+
+ return 0; // The SVG spec is unclear as to what to return when the distance is not on the path
+}
+
+Path SVGPathSegList::toPathData()
+{
+ // FIXME : This should also support non-normalized PathSegLists
+ Path pathData;
+ ExceptionCode ec = 0;
+ int len = numberOfItems();
+ for (int i = 0; i < len; ++i) {
+ SVGPathSeg* segment = getItem(i, ec).get();;
+ switch (segment->pathSegType())
+ {
+ case SVGPathSeg::PATHSEG_MOVETO_ABS:
+ {
+ SVGPathSegMovetoAbs* moveTo = static_cast<SVGPathSegMovetoAbs*>(segment);
+ pathData.moveTo(FloatPoint(moveTo->x(), moveTo->y()));
+ break;
+ }
+ case SVGPathSeg::PATHSEG_LINETO_ABS:
+ {
+ SVGPathSegLinetoAbs* lineTo = static_cast<SVGPathSegLinetoAbs*>(segment);
+ pathData.addLineTo(FloatPoint(lineTo->x(), lineTo->y()));
+ break;
+ }
+ case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS:
+ {
+ SVGPathSegCurvetoCubicAbs* curveTo = static_cast<SVGPathSegCurvetoCubicAbs*>(segment);
+ pathData.addBezierCurveTo(FloatPoint(curveTo->x1(), curveTo->y1()),
+ FloatPoint(curveTo->x2(), curveTo->y2()),
+ FloatPoint(curveTo->x(), curveTo->y()));
+ break;
+ }
+ case SVGPathSeg::PATHSEG_CLOSEPATH:
+ pathData.closeSubpath();
+ break;
+ default:
+ ASSERT(false); // FIXME: This only works with normalized/processed path data.
+ break;
+ }
+ }
+
+ return pathData;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPathSegList.h b/WebCore/svg/SVGPathSegList.h
new file mode 100644
index 0000000..880d54c
--- /dev/null
+++ b/WebCore/svg/SVGPathSegList.h
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPathSegList_h
+#define SVGPathSegList_h
+
+#if ENABLE(SVG)
+#include "SVGList.h"
+#include "SVGPathSeg.h"
+
+namespace WebCore {
+
+ class Path;
+ class SVGElement;
+
+ class SVGPathSegList : public SVGList<RefPtr<SVGPathSeg> > {
+ public:
+ static PassRefPtr<SVGPathSegList> create(const QualifiedName& attributeName) { return adoptRef(new SVGPathSegList(attributeName)); }
+ virtual ~SVGPathSegList();
+
+ unsigned getPathSegAtLength(double);
+ Path toPathData();
+
+ private:
+ SVGPathSegList(const QualifiedName&);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGPathSegList.idl b/WebCore/svg/SVGPathSegList.idl
new file mode 100644
index 0000000..f55167e
--- /dev/null
+++ b/WebCore/svg/SVGPathSegList.idl
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegList {
+ readonly attribute unsigned long numberOfItems;
+
+ [Custom] void clear()
+ raises(DOMException);
+ [Custom] SVGPathSeg initialize(in SVGPathSeg newItem)
+ raises(DOMException, SVGException);
+ [Custom] SVGPathSeg getItem(in unsigned long index)
+ raises(DOMException);
+ [Custom] SVGPathSeg insertItemBefore(in SVGPathSeg newItem, in unsigned long index)
+ raises(DOMException, SVGException);
+ [Custom] SVGPathSeg replaceItem(in SVGPathSeg newItem, in unsigned long index)
+ raises(DOMException, SVGException);
+ [Custom] SVGPathSeg removeItem(in unsigned long index)
+ raises(DOMException);
+ [Custom] SVGPathSeg appendItem(in SVGPathSeg newItem)
+ raises(DOMException, SVGException);
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegMoveto.cpp b/WebCore/svg/SVGPathSegMoveto.cpp
new file mode 100644
index 0000000..2b6ca56
--- /dev/null
+++ b/WebCore/svg/SVGPathSegMoveto.cpp
@@ -0,0 +1,101 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathSegMoveto.h"
+
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+SVGPathSegMovetoAbs::SVGPathSegMovetoAbs(float x, float y)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+{
+}
+
+SVGPathSegMovetoAbs::~SVGPathSegMovetoAbs()
+{
+}
+
+void SVGPathSegMovetoAbs::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegMovetoAbs::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegMovetoAbs::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegMovetoAbs::y() const
+{
+ return m_y;
+}
+
+
+
+
+SVGPathSegMovetoRel::SVGPathSegMovetoRel(float x, float y)
+ : SVGPathSeg()
+ , m_x(x)
+ , m_y(y)
+{
+}
+
+SVGPathSegMovetoRel::~SVGPathSegMovetoRel()
+{
+}
+
+void SVGPathSegMovetoRel::setX(float x)
+{
+ m_x = x;
+}
+
+float SVGPathSegMovetoRel::x() const
+{
+ return m_x;
+}
+
+void SVGPathSegMovetoRel::setY(float y)
+{
+ m_y = y;
+}
+
+float SVGPathSegMovetoRel::y() const
+{
+ return m_y;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegMoveto.h b/WebCore/svg/SVGPathSegMoveto.h
new file mode 100644
index 0000000..f97b340
--- /dev/null
+++ b/WebCore/svg/SVGPathSegMoveto.h
@@ -0,0 +1,80 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPathSegMoveto_h
+#define SVGPathSegMoveto_h
+
+#if ENABLE(SVG)
+
+#include "SVGPathSeg.h"
+
+namespace WebCore {
+ class SVGPathSegMovetoAbs : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegMovetoAbs> create(float x, float y) { return adoptRef(new SVGPathSegMovetoAbs(x, y)); }
+ virtual ~SVGPathSegMovetoAbs();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_MOVETO_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "M"; }
+ virtual String toString() const { return String::format("M %.6lg %.6lg", m_x, m_y); }
+
+ void setX(float);
+ float x() const;
+
+ void setY(float);
+ float y() const;
+
+ private:
+ SVGPathSegMovetoAbs(float x, float y);
+
+ float m_x;
+ float m_y;
+ };
+
+ class SVGPathSegMovetoRel : public SVGPathSeg {
+ public:
+ static PassRefPtr<SVGPathSegMovetoRel> create(float x, float y) { return adoptRef(new SVGPathSegMovetoRel(x, y)); }
+ virtual ~SVGPathSegMovetoRel();
+
+ virtual unsigned short pathSegType() const { return PATHSEG_MOVETO_REL; }
+ virtual String pathSegTypeAsLetter() const { return "m"; }
+ virtual String toString() const { return String::format("m %.6lg %.6lg", m_x, m_y); }
+
+ void setX(float);
+ float x() const;
+
+ void setY(float);
+ float y() const;
+
+ private:
+ SVGPathSegMovetoRel(float x, float y);
+
+ float m_x;
+ float m_y;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGPathSegMovetoAbs.idl b/WebCore/svg/SVGPathSegMovetoAbs.idl
new file mode 100644
index 0000000..13ffde4
--- /dev/null
+++ b/WebCore/svg/SVGPathSegMovetoAbs.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegMovetoAbs : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPathSegMovetoRel.idl b/WebCore/svg/SVGPathSegMovetoRel.idl
new file mode 100644
index 0000000..3393d9e
--- /dev/null
+++ b/WebCore/svg/SVGPathSegMovetoRel.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPathSegMovetoRel : SVGPathSeg {
+ attribute float x
+ /*setter raises(DOMException)*/;
+ attribute float y
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGPatternElement.cpp b/WebCore/svg/SVGPatternElement.cpp
new file mode 100644
index 0000000..dda42d7
--- /dev/null
+++ b/WebCore/svg/SVGPatternElement.cpp
@@ -0,0 +1,330 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPatternElement.h"
+
+#include "AffineTransform.h"
+#include "Document.h"
+#include "FloatConversion.h"
+#include "GraphicsContext.h"
+#include "ImageBuffer.h"
+#include "PatternAttributes.h"
+#include "RenderSVGContainer.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+#include "SVGPaintServerPattern.h"
+#include "SVGRenderSupport.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGSVGElement.h"
+#include "SVGTransformList.h"
+#include "SVGTransformable.h"
+#include "SVGUnitTypes.h"
+
+#include <math.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/MathExtras.h>
+
+using namespace std;
+
+namespace WebCore {
+
+SVGPatternElement::SVGPatternElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , SVGURIReference()
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , SVGFitToViewBox()
+ , m_x(this, LengthModeWidth)
+ , m_y(this, LengthModeHeight)
+ , m_width(this, LengthModeWidth)
+ , m_height(this, LengthModeHeight)
+ , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
+ , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
+ , m_patternTransform(SVGTransformList::create(SVGNames::patternTransformAttr))
+{
+}
+
+SVGPatternElement::~SVGPatternElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGPatternElement, int, Enumeration, enumeration, PatternUnits, patternUnits, SVGNames::patternUnitsAttr, m_patternUnits)
+ANIMATED_PROPERTY_DEFINITIONS(SVGPatternElement, int, Enumeration, enumeration, PatternContentUnits, patternContentUnits, SVGNames::patternContentUnitsAttr, m_patternContentUnits)
+ANIMATED_PROPERTY_DEFINITIONS(SVGPatternElement, SVGLength, Length, length, X, x, SVGNames::xAttr, m_x)
+ANIMATED_PROPERTY_DEFINITIONS(SVGPatternElement, SVGLength, Length, length, Y, y, SVGNames::yAttr, m_y)
+ANIMATED_PROPERTY_DEFINITIONS(SVGPatternElement, SVGLength, Length, length, Width, width, SVGNames::widthAttr, m_width)
+ANIMATED_PROPERTY_DEFINITIONS(SVGPatternElement, SVGLength, Length, length, Height, height, SVGNames::heightAttr, m_height)
+ANIMATED_PROPERTY_DEFINITIONS(SVGPatternElement, SVGTransformList*, TransformList, transformList, PatternTransform, patternTransform, SVGNames::patternTransformAttr, m_patternTransform.get())
+
+void SVGPatternElement::parseMappedAttribute(MappedAttribute* 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* patternTransforms = patternTransformBaseValue();
+ if (!SVGTransformable::parseTransformAttribute(patternTransforms, attr->value())) {
+ ExceptionCode ec = 0;
+ patternTransforms->clear(ec);
+ }
+ } else 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()));
+ if (width().value() < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for pattern attribute <width> is not allowed");
+ } else if (attr->name() == SVGNames::heightAttr) {
+ setHeightBaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ if (width().value() < 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(attr))
+ return;
+
+ SVGStyledElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGPatternElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledElement::svgAttributeChanged(attrName);
+
+ if (!m_resource)
+ return;
+
+ if (attrName == SVGNames::patternUnitsAttr || attrName == SVGNames::patternContentUnitsAttr ||
+ attrName == SVGNames::patternTransformAttr || attrName == SVGNames::xAttr || attrName == SVGNames::yAttr ||
+ attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr ||
+ SVGURIReference::isKnownAttribute(attrName) ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGFitToViewBox::isKnownAttribute(attrName) ||
+ SVGStyledElement::isKnownAttribute(attrName))
+ m_resource->invalidate();
+}
+
+void SVGPatternElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+
+ if (!m_resource)
+ return;
+
+ m_resource->invalidate();
+}
+
+void SVGPatternElement::buildPattern(const FloatRect& targetRect) const
+{
+ PatternAttributes attributes = collectPatternProperties();
+
+ // If we didn't find any pattern content, ignore the request.
+ if (!attributes.patternContentElement() || !renderer() || !renderer()->style())
+ return;
+
+ FloatRect patternBoundaries;
+ FloatRect patternContentBoundaries;
+
+ // Determine specified pattern size
+ if (attributes.boundingBoxMode())
+ patternBoundaries = FloatRect(attributes.x().valueAsPercentage() * targetRect.width(),
+ attributes.y().valueAsPercentage() * targetRect.height(),
+ attributes.width().valueAsPercentage() * targetRect.width(),
+ attributes.height().valueAsPercentage() * targetRect.height());
+ else
+ patternBoundaries = FloatRect(attributes.x().value(),
+ attributes.y().value(),
+ attributes.width().value(),
+ attributes.height().value());
+
+ // Clip pattern boundaries to target boundaries
+ if (patternBoundaries.width() > targetRect.width())
+ patternBoundaries.setWidth(targetRect.width());
+
+ if (patternBoundaries.height() > targetRect.height())
+ patternBoundaries.setHeight(targetRect.height());
+
+ IntSize patternSize(patternBoundaries.width(), patternBoundaries.height());
+ clampImageBufferSizeToViewport(document()->renderer(), patternSize);
+
+ if (patternSize.width() < static_cast<int>(patternBoundaries.width()))
+ patternBoundaries.setWidth(patternSize.width());
+
+ if (patternSize.height() < static_cast<int>(patternBoundaries.height()))
+ patternBoundaries.setHeight(patternSize.height());
+
+ // Eventually calculate the pattern content boundaries (only needed with overflow="visible").
+ RenderStyle* style = renderer()->style();
+ if (style->overflowX() == OVISIBLE && style->overflowY() == OVISIBLE) {
+ for (Node* n = attributes.patternContentElement()->firstChild(); n; n = n->nextSibling()) {
+ if (!n->isSVGElement() || !static_cast<SVGElement*>(n)->isStyledTransformable() || !n->renderer())
+ continue;
+ patternContentBoundaries.unite(n->renderer()->relativeBBox(true));
+ }
+ }
+
+ AffineTransform viewBoxCTM = viewBoxToViewTransform(patternBoundaries.width(), patternBoundaries.height());
+ FloatRect patternBoundariesIncludingOverflow = patternBoundaries;
+
+ // Apply objectBoundingBoxMode fixup for patternContentUnits, if viewBox is not set.
+ if (!patternContentBoundaries.isEmpty()) {
+ if (!viewBoxCTM.isIdentity())
+ patternContentBoundaries = viewBoxCTM.mapRect(patternContentBoundaries);
+ else if (attributes.boundingBoxModeContent())
+ patternContentBoundaries = FloatRect(patternContentBoundaries.x() * targetRect.width(),
+ patternContentBoundaries.y() * targetRect.height(),
+ patternContentBoundaries.width() * targetRect.width(),
+ patternContentBoundaries.height() * targetRect.height());
+
+ patternBoundariesIncludingOverflow.unite(patternContentBoundaries);
+ }
+
+ IntSize imageSize(lroundf(patternBoundariesIncludingOverflow.width()), lroundf(patternBoundariesIncludingOverflow.height()));
+ clampImageBufferSizeToViewport(document()->renderer(), imageSize);
+
+ auto_ptr<ImageBuffer> patternImage = ImageBuffer::create(imageSize, false);
+
+ if (!patternImage.get())
+ return;
+
+ GraphicsContext* context = patternImage->context();
+ ASSERT(context);
+
+ context->save();
+
+ // Move to pattern start origin
+ if (patternBoundariesIncludingOverflow.location() != patternBoundaries.location()) {
+ context->translate(patternBoundaries.x() - patternBoundariesIncludingOverflow.x(),
+ patternBoundaries.y() - patternBoundariesIncludingOverflow.y());
+
+ patternBoundaries.setLocation(patternBoundariesIncludingOverflow.location());
+ }
+
+ // Process viewBox or boundingBoxModeContent correction
+ if (!viewBoxCTM.isIdentity())
+ context->concatCTM(viewBoxCTM);
+ else if (attributes.boundingBoxModeContent()) {
+ context->translate(targetRect.x(), targetRect.y());
+ context->scale(FloatSize(targetRect.width(), targetRect.height()));
+ }
+
+ // Render subtree into ImageBuffer
+ for (Node* n = attributes.patternContentElement()->firstChild(); n; n = n->nextSibling()) {
+ if (!n->isSVGElement() || !static_cast<SVGElement*>(n)->isStyled() || !n->renderer())
+ continue;
+ renderSubtreeToImage(patternImage.get(), n->renderer());
+ }
+
+ context->restore();
+
+ m_resource->setPatternTransform(attributes.patternTransform());
+ m_resource->setPatternBoundaries(patternBoundaries);
+ m_resource->setTile(patternImage);
+}
+
+RenderObject* SVGPatternElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+ RenderSVGContainer* patternContainer = new (arena) RenderSVGContainer(this);
+ patternContainer->setDrawsContents(false);
+ return patternContainer;
+}
+
+SVGResource* SVGPatternElement::canvasResource()
+{
+ if (!m_resource)
+ m_resource = SVGPaintServerPattern::create(this);
+
+ return m_resource.get();
+}
+
+PatternAttributes SVGPatternElement::collectPatternProperties() const
+{
+ PatternAttributes attributes;
+ HashSet<const SVGPatternElement*> processedPatterns;
+
+ const SVGPatternElement* current = this;
+ while (current) {
+ if (!attributes.hasX() && current->hasAttribute(SVGNames::xAttr))
+ attributes.setX(current->x());
+
+ if (!attributes.hasY() && current->hasAttribute(SVGNames::yAttr))
+ attributes.setY(current->y());
+
+ if (!attributes.hasWidth() && current->hasAttribute(SVGNames::widthAttr))
+ attributes.setWidth(current->width());
+
+ if (!attributes.hasHeight() && current->hasAttribute(SVGNames::heightAttr))
+ attributes.setHeight(current->height());
+
+ if (!attributes.hasBoundingBoxMode() && current->hasAttribute(SVGNames::patternUnitsAttr))
+ attributes.setBoundingBoxMode(current->getAttribute(SVGNames::patternUnitsAttr) == "objectBoundingBox");
+
+ if (!attributes.hasBoundingBoxModeContent() && current->hasAttribute(SVGNames::patternContentUnitsAttr))
+ attributes.setBoundingBoxModeContent(current->getAttribute(SVGNames::patternContentUnitsAttr) == "objectBoundingBox");
+
+ if (!attributes.hasPatternTransform() && current->hasAttribute(SVGNames::patternTransformAttr))
+ attributes.setPatternTransform(current->patternTransform()->consolidate().matrix());
+
+ if (!attributes.hasPatternContentElement() && current->hasChildNodes())
+ attributes.setPatternContentElement(current);
+
+ processedPatterns.add(current);
+
+ // Respect xlink:href, take attributes from referenced element
+ Node* refNode = ownerDocument()->getElementById(SVGURIReference::getTarget(current->href()));
+ if (refNode && refNode->hasTagName(SVGNames::patternTag)) {
+ current = static_cast<const SVGPatternElement*>(const_cast<const Node*>(refNode));
+
+ // Cycle detection
+ if (processedPatterns.contains(current))
+ return PatternAttributes();
+ } else
+ current = 0;
+ }
+
+ return attributes;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPatternElement.h b/WebCore/svg/SVGPatternElement.h
new file mode 100644
index 0000000..6b00a62
--- /dev/null
+++ b/WebCore/svg/SVGPatternElement.h
@@ -0,0 +1,90 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPatternElement_h
+#define SVGPatternElement_h
+
+#if ENABLE(SVG)
+#include "SVGPaintServerPattern.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGFitToViewBox.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledElement.h"
+#include "SVGTests.h"
+#include "SVGURIReference.h"
+
+
+namespace WebCore {
+
+ struct PatternAttributes;
+
+ class SVGLength;
+ class SVGTransformList;
+
+ class SVGPatternElement : public SVGStyledElement,
+ public SVGURIReference,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired,
+ public SVGFitToViewBox {
+ public:
+ SVGPatternElement(const QualifiedName&, Document*);
+ virtual ~SVGPatternElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+ virtual SVGResource* canvasResource();
+
+ protected:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, FloatRect, ViewBox, viewBox)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, SVGPreserveAspectRatio*, PreserveAspectRatio, preserveAspectRatio)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGLength, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGLength, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGLength, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGLength, SVGLength, Height, height)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, int, int, PatternUnits, patternUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, int, int, PatternContentUnits, patternContentUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGTransformList*, RefPtr<SVGTransformList>, PatternTransform, patternTransform)
+
+ mutable RefPtr<SVGPaintServerPattern> m_resource;
+
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ friend class SVGPaintServerPattern;
+ void buildPattern(const FloatRect& targetRect) const;
+
+ PatternAttributes collectPatternProperties() const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGPatternElement.idl b/WebCore/svg/SVGPatternElement.idl
new file mode 100644
index 0000000..8b380fb
--- /dev/null
+++ b/WebCore/svg/SVGPatternElement.idl
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPatternElement : SVGElement,
+ SVGURIReference,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGFitToViewBox
+ /* SVGUnitTypes */ {
+ readonly attribute SVGAnimatedEnumeration patternUnits;
+ readonly attribute SVGAnimatedEnumeration patternContentUnits;
+ readonly attribute SVGAnimatedTransformList patternTransform;
+ readonly attribute SVGAnimatedLength x;
+ readonly attribute SVGAnimatedLength y;
+ readonly attribute SVGAnimatedLength width;
+ readonly attribute SVGAnimatedLength height;
+ };
+
+}
diff --git a/WebCore/svg/SVGPoint.idl b/WebCore/svg/SVGPoint.idl
new file mode 100644
index 0000000..1a0d227
--- /dev/null
+++ b/WebCore/svg/SVGPoint.idl
@@ -0,0 +1,36 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+module svg {
+
+ interface [Conditional=SVG, PODType=FloatPoint] SVGPoint {
+ attribute float x
+ setter raises(DOMException);
+ attribute float y
+ setter raises(DOMException);
+
+ SVGPoint matrixTransform(in SVGMatrix matrix);
+ };
+
+}
diff --git a/WebCore/svg/SVGPointList.cpp b/WebCore/svg/SVGPointList.cpp
new file mode 100644
index 0000000..25160bb
--- /dev/null
+++ b/WebCore/svg/SVGPointList.cpp
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+
+#include "SVGPointList.h"
+
+namespace WebCore {
+
+SVGPointList::SVGPointList(const QualifiedName& attributeName)
+ : SVGPODList<FloatPoint>(attributeName)
+{
+}
+
+SVGPointList::~SVGPointList()
+{
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPointList.h b/WebCore/svg/SVGPointList.h
new file mode 100644
index 0000000..77d4edd
--- /dev/null
+++ b/WebCore/svg/SVGPointList.h
@@ -0,0 +1,46 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPointList_h
+#define SVGPointList_h
+
+#if ENABLE(SVG)
+#include "SVGList.h"
+#include "FloatPoint.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+ class SVGPointList : public SVGPODList<FloatPoint> {
+ public:
+ static PassRefPtr<SVGPointList> create(const QualifiedName& attributeName) { return adoptRef(new SVGPointList(attributeName)); }
+
+ virtual ~SVGPointList();
+
+ private:
+ SVGPointList(const QualifiedName&);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGPointList.idl b/WebCore/svg/SVGPointList.idl
new file mode 100644
index 0000000..3ac8b1a
--- /dev/null
+++ b/WebCore/svg/SVGPointList.idl
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPointList {
+ readonly attribute unsigned long numberOfItems;
+
+ [Custom] void clear()
+ raises(DOMException);
+ [Custom] SVGPoint initialize(in SVGPoint item)
+ raises(DOMException, SVGException);
+ [Custom] SVGPoint getItem(in unsigned long index)
+ raises(DOMException);
+ [Custom] SVGPoint insertItemBefore(in SVGPoint item, in unsigned long index)
+ raises(DOMException, SVGException);
+ [Custom] SVGPoint replaceItem(in SVGPoint item, in unsigned long index)
+ raises(DOMException, SVGException);
+ [Custom] SVGPoint removeItem(in unsigned long index)
+ raises(DOMException);
+ [Custom] SVGPoint appendItem(in SVGPoint item)
+ raises(DOMException, SVGException);
+ };
+
+}
diff --git a/WebCore/svg/SVGPolyElement.cpp b/WebCore/svg/SVGPolyElement.cpp
new file mode 100644
index 0000000..6c3416f
--- /dev/null
+++ b/WebCore/svg/SVGPolyElement.cpp
@@ -0,0 +1,131 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPolyElement.h"
+
+#include "Document.h"
+#include "FloatPoint.h"
+#include "RenderPath.h"
+#include "SVGNames.h"
+#include "SVGParserUtilities.h"
+#include "SVGPointList.h"
+
+namespace WebCore {
+
+SVGPolyElement::SVGPolyElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , SVGAnimatedPoints()
+ , m_ignoreAttributeChanges(false)
+{
+}
+
+SVGPolyElement::~SVGPolyElement()
+{
+}
+
+SVGPointList* SVGPolyElement::points() const
+{
+ if (!m_points)
+ m_points = SVGPointList::create(SVGNames::pointsAttr);
+
+ return m_points.get();
+}
+
+SVGPointList* SVGPolyElement::animatedPoints() const
+{
+ // FIXME!
+ return 0;
+}
+
+void SVGPolyElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const AtomicString& value = attr->value();
+ if (attr->name() == SVGNames::pointsAttr) {
+ ExceptionCode ec = 0;
+ points()->clear(ec);
+
+ if (!pointsListFromSVGData(points(), value)) {
+ points()->clear(ec);
+ document()->accessSVGExtensions()->reportError("Problem parsing points=\"" + value + "\"");
+ }
+ } else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ SVGStyledTransformableElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGPolyElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ if (m_ignoreAttributeChanges)
+ return;
+
+ SVGStyledTransformableElement::svgAttributeChanged(attrName);
+
+ if (!renderer())
+ return;
+
+ if (attrName == SVGNames::pointsAttr) {
+ m_ignoreAttributeChanges = true;
+ renderer()->setNeedsLayout(true);
+
+ ExceptionCode ec = 0;
+
+ // Spec: Additionally, the 'points' attribute on the original element
+ // accessed via the XML DOM (e.g., using the getAttribute() method call)
+ // will reflect any changes made to points.
+ String _points;
+ int len = points()->numberOfItems();
+ for (int i = 0; i < len; ++i) {
+ FloatPoint p = points()->getItem(i, ec);
+ _points += String::format("%.6lg %.6lg ", p.x(), p.y());
+ }
+
+ if (RefPtr<Attr> attr = const_cast<SVGPolyElement*>(this)->getAttributeNode(SVGNames::pointsAttr.localName())) {
+ ExceptionCode ec = 0;
+ attr->setValue(_points, ec);
+ }
+
+ m_ignoreAttributeChanges = false;
+ return;
+ }
+
+ if (SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledTransformableElement::isKnownAttribute(attrName))
+ renderer()->setNeedsLayout(true);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPolyElement.h b/WebCore/svg/SVGPolyElement.h
new file mode 100644
index 0000000..09ce1df
--- /dev/null
+++ b/WebCore/svg/SVGPolyElement.h
@@ -0,0 +1,68 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPolyElement_h
+#define SVGPolyElement_h
+
+#if ENABLE(SVG)
+#include "SVGAnimatedPoints.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTests.h"
+
+namespace WebCore {
+
+ class SVGPolyElement : public SVGStyledTransformableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired,
+ public SVGAnimatedPoints {
+ public:
+ SVGPolyElement(const QualifiedName&, Document*);
+ virtual ~SVGPolyElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ virtual SVGPointList* points() const;
+ virtual SVGPointList* animatedPoints() const;
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ virtual bool rendererIsNeeded(RenderStyle* style) { return StyledElement::rendererIsNeeded(style); }
+ virtual bool supportsMarkers() const { return true; }
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ bool m_ignoreAttributeChanges : 1;
+ mutable RefPtr<SVGPointList> m_points;
+
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGPolygonElement.cpp b/WebCore/svg/SVGPolygonElement.cpp
new file mode 100644
index 0000000..95513e4
--- /dev/null
+++ b/WebCore/svg/SVGPolygonElement.cpp
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPolygonElement.h"
+
+#include "SVGPointList.h"
+
+namespace WebCore {
+
+SVGPolygonElement::SVGPolygonElement(const QualifiedName& tagName, Document* doc)
+ : SVGPolyElement(tagName, doc)
+{
+}
+
+SVGPolygonElement::~SVGPolygonElement()
+{
+}
+
+Path SVGPolygonElement::toPathData() const
+{
+ Path polyData;
+
+ int len = points()->numberOfItems();
+ if (len < 1)
+ return polyData;
+
+ ExceptionCode ec = 0;
+ polyData.moveTo(points()->getItem(0, ec));
+
+ for (int i = 1; i < len; ++i)
+ polyData.addLineTo(points()->getItem(i, ec));
+
+ polyData.closeSubpath();
+ return polyData;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPolygonElement.h b/WebCore/svg/SVGPolygonElement.h
new file mode 100644
index 0000000..7afb553
--- /dev/null
+++ b/WebCore/svg/SVGPolygonElement.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPolygonElement_h
+#define SVGPolygonElement_h
+
+#if ENABLE(SVG)
+#include "SVGPolyElement.h"
+
+namespace WebCore {
+
+ class SVGPolygonElement : public SVGPolyElement {
+ public:
+ SVGPolygonElement(const QualifiedName&, Document*);
+ virtual ~SVGPolygonElement();
+
+ virtual Path toPathData() const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGPolygonElement.idl b/WebCore/svg/SVGPolygonElement.idl
new file mode 100644
index 0000000..1bb7806
--- /dev/null
+++ b/WebCore/svg/SVGPolygonElement.idl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPolygonElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable,
+ SVGAnimatedPoints {
+ };
+
+}
diff --git a/WebCore/svg/SVGPolylineElement.cpp b/WebCore/svg/SVGPolylineElement.cpp
new file mode 100644
index 0000000..9ea136e
--- /dev/null
+++ b/WebCore/svg/SVGPolylineElement.cpp
@@ -0,0 +1,60 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPolylineElement.h"
+
+#include "SVGPointList.h"
+
+namespace WebCore {
+
+SVGPolylineElement::SVGPolylineElement(const QualifiedName& tagName, Document* doc)
+ : SVGPolyElement(tagName, doc)
+{
+}
+
+SVGPolylineElement::~SVGPolylineElement()
+{
+}
+
+Path SVGPolylineElement::toPathData() const
+{
+ Path polyData;
+
+ int len = points()->numberOfItems();
+ if (len < 1)
+ return polyData;
+
+ ExceptionCode ec = 0;
+ polyData.moveTo(points()->getItem(0, ec));
+
+ for (int i = 1; i < len; ++i)
+ polyData.addLineTo(points()->getItem(i, ec));
+
+ return polyData;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPolylineElement.h b/WebCore/svg/SVGPolylineElement.h
new file mode 100644
index 0000000..d43dbbe
--- /dev/null
+++ b/WebCore/svg/SVGPolylineElement.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPolylineElement_h
+#define SVGPolylineElement_h
+
+#if ENABLE(SVG)
+#include "SVGPolyElement.h"
+
+namespace WebCore {
+
+ class SVGPolylineElement : public SVGPolyElement {
+ public:
+ SVGPolylineElement(const QualifiedName&, Document*);
+ virtual ~SVGPolylineElement();
+
+ virtual Path toPathData() const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGPolylineElement.idl b/WebCore/svg/SVGPolylineElement.idl
new file mode 100644
index 0000000..a77ef6d
--- /dev/null
+++ b/WebCore/svg/SVGPolylineElement.idl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGPolylineElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable,
+ SVGAnimatedPoints {
+ };
+
+}
diff --git a/WebCore/svg/SVGPreserveAspectRatio.cpp b/WebCore/svg/SVGPreserveAspectRatio.cpp
new file mode 100644
index 0000000..0709b9d
--- /dev/null
+++ b/WebCore/svg/SVGPreserveAspectRatio.cpp
@@ -0,0 +1,207 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPreserveAspectRatio.h"
+
+#include "SVGParserUtilities.h"
+#include "SVGSVGElement.h"
+
+namespace WebCore {
+
+SVGPreserveAspectRatio::SVGPreserveAspectRatio()
+ : m_align(SVG_PRESERVEASPECTRATIO_XMIDYMID)
+ , m_meetOrSlice(SVG_MEETORSLICE_MEET)
+{
+ // FIXME: Should the two values default to UNKNOWN instead?
+}
+
+SVGPreserveAspectRatio::~SVGPreserveAspectRatio()
+{
+}
+
+void SVGPreserveAspectRatio::setAlign(unsigned short align)
+{
+ m_align = align;
+}
+
+unsigned short SVGPreserveAspectRatio::align() const
+{
+ return m_align;
+}
+
+void SVGPreserveAspectRatio::setMeetOrSlice(unsigned short meetOrSlice)
+{
+ m_meetOrSlice = meetOrSlice;
+}
+
+unsigned short SVGPreserveAspectRatio::meetOrSlice() const
+{
+ return m_meetOrSlice;
+}
+
+bool SVGPreserveAspectRatio::parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate)
+{
+ SVGPreserveAspectRatioType align = SVG_PRESERVEASPECTRATIO_NONE;
+ SVGMeetOrSliceType meetOrSlice = SVG_MEETORSLICE_MEET;
+ bool ret = false;
+
+ if (!skipOptionalSpaces(currParam, end))
+ goto bail_out;
+
+ if (*currParam == 'd') {
+ if (!skipString(currParam, end, "defer"))
+ goto bail_out;
+ // FIXME: We just ignore the "defer" here.
+ if (!skipOptionalSpaces(currParam, end))
+ goto bail_out;
+ }
+
+ if (*currParam == 'n') {
+ if (!skipString(currParam, end, "none"))
+ goto bail_out;
+ skipOptionalSpaces(currParam, end);
+ } else if (*currParam == 'x') {
+ if ((end - currParam) < 8)
+ goto bail_out;
+ if (currParam[1] != 'M' || currParam[4] != 'Y' || currParam[5] != 'M')
+ goto bail_out;
+ if (currParam[2] == 'i') {
+ if (currParam[3] == 'n') {
+ if (currParam[6] == 'i') {
+ if (currParam[7] == 'n')
+ align = SVG_PRESERVEASPECTRATIO_XMINYMIN;
+ else if (currParam[7] == 'd')
+ align = SVG_PRESERVEASPECTRATIO_XMINYMID;
+ else
+ goto bail_out;
+ } else if (currParam[6] == 'a' && currParam[7] == 'x')
+ align = SVG_PRESERVEASPECTRATIO_XMINYMAX;
+ else
+ goto bail_out;
+ } else if (currParam[3] == 'd') {
+ if (currParam[6] == 'i') {
+ if (currParam[7] == 'n')
+ align = SVG_PRESERVEASPECTRATIO_XMIDYMIN;
+ else if (currParam[7] == 'd')
+ align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
+ else
+ goto bail_out;
+ } else if (currParam[6] == 'a' && currParam[7] == 'x')
+ align = SVG_PRESERVEASPECTRATIO_XMIDYMAX;
+ else
+ goto bail_out;
+ } else
+ goto bail_out;
+ } else if (currParam[2] == 'a' && currParam[3] == 'x') {
+ if (currParam[6] == 'i') {
+ if (currParam[7] == 'n')
+ align = SVG_PRESERVEASPECTRATIO_XMAXYMIN;
+ else if (currParam[7] == 'd')
+ align = SVG_PRESERVEASPECTRATIO_XMAXYMID;
+ else
+ goto bail_out;
+ } else if (currParam[6] == 'a' && currParam[7] == 'x')
+ align = SVG_PRESERVEASPECTRATIO_XMAXYMAX;
+ else
+ goto bail_out;
+ } else
+ goto bail_out;
+ currParam += 8;
+ skipOptionalSpaces(currParam, end);
+ } else
+ goto bail_out;
+
+ if (currParam < end) {
+ if (*currParam == 'm') {
+ if (!skipString(currParam, end, "meet"))
+ goto bail_out;
+ skipOptionalSpaces(currParam, end);
+ } else if (*currParam == 's') {
+ if (!skipString(currParam, end, "slice"))
+ goto bail_out;
+ skipOptionalSpaces(currParam, end);
+ if (align != SVG_PRESERVEASPECTRATIO_NONE)
+ meetOrSlice = SVG_MEETORSLICE_SLICE;
+ }
+ }
+
+ if (end != currParam && validate) {
+bail_out:
+ // FIXME: Should the two values be set to UNKNOWN instead?
+ align = SVG_PRESERVEASPECTRATIO_NONE;
+ meetOrSlice = SVG_MEETORSLICE_MEET;
+ } else
+ ret = true;
+
+ if (m_align == align && m_meetOrSlice == meetOrSlice)
+ return ret;
+
+ m_align = align;
+ m_meetOrSlice = meetOrSlice;
+ return ret;
+}
+
+AffineTransform SVGPreserveAspectRatio::getCTM(double logicX, double logicY,
+ double logicWidth, double logicHeight,
+ double /*physX*/, double /*physY*/,
+ double physWidth, double physHeight)
+{
+ AffineTransform temp;
+
+ if (align() == SVG_PRESERVEASPECTRATIO_UNKNOWN)
+ return temp;
+
+ double vpar = logicWidth / logicHeight;
+ double svgar = physWidth / physHeight;
+
+ if (align() == SVG_PRESERVEASPECTRATIO_NONE) {
+ temp.scale(physWidth / logicWidth, physHeight / logicHeight);
+ temp.translate(-logicX, -logicY);
+ } else if (vpar < svgar && (meetOrSlice() == SVG_MEETORSLICE_MEET) || vpar >= svgar && (meetOrSlice() == SVG_MEETORSLICE_SLICE)) {
+ temp.scale(physHeight / logicHeight, physHeight / logicHeight);
+
+ if (align() == SVG_PRESERVEASPECTRATIO_XMINYMIN || align() == SVG_PRESERVEASPECTRATIO_XMINYMID || align() == SVG_PRESERVEASPECTRATIO_XMINYMAX)
+ temp.translate(-logicX, -logicY);
+ else if (align() == SVG_PRESERVEASPECTRATIO_XMIDYMIN || align() == SVG_PRESERVEASPECTRATIO_XMIDYMID || align() == SVG_PRESERVEASPECTRATIO_XMIDYMAX)
+ temp.translate(-logicX - (logicWidth - physWidth * logicHeight / physHeight) / 2, -logicY);
+ else
+ temp.translate(-logicX - (logicWidth - physWidth * logicHeight / physHeight), -logicY);
+ } else {
+ temp.scale(physWidth / logicWidth, physWidth / logicWidth);
+
+ if (align() == SVG_PRESERVEASPECTRATIO_XMINYMIN || align() == SVG_PRESERVEASPECTRATIO_XMIDYMIN || align() == SVG_PRESERVEASPECTRATIO_XMAXYMIN)
+ temp.translate(-logicX, -logicY);
+ else if (align() == SVG_PRESERVEASPECTRATIO_XMINYMID || align() == SVG_PRESERVEASPECTRATIO_XMIDYMID || align() == SVG_PRESERVEASPECTRATIO_XMAXYMID)
+ temp.translate(-logicX, -logicY - (logicHeight - physHeight * logicWidth / physWidth) / 2);
+ else
+ temp.translate(-logicX, -logicY - (logicHeight - physHeight * logicWidth / physWidth));
+ }
+
+ return temp;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPreserveAspectRatio.h b/WebCore/svg/SVGPreserveAspectRatio.h
new file mode 100644
index 0000000..a1bed65
--- /dev/null
+++ b/WebCore/svg/SVGPreserveAspectRatio.h
@@ -0,0 +1,91 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPreserveAspectRatio_h
+#define SVGPreserveAspectRatio_h
+
+#if ENABLE(SVG)
+#include "PlatformString.h"
+#include "SVGNames.h"
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class String;
+ class AffineTransform;
+ class SVGStyledElement;
+
+ class SVGPreserveAspectRatio : public RefCounted<SVGPreserveAspectRatio> {
+ public:
+ static PassRefPtr<SVGPreserveAspectRatio> create() { return adoptRef(new SVGPreserveAspectRatio); }
+
+ enum SVGPreserveAspectRatioType {
+ SVG_PRESERVEASPECTRATIO_UNKNOWN = 0,
+ SVG_PRESERVEASPECTRATIO_NONE = 1,
+ SVG_PRESERVEASPECTRATIO_XMINYMIN = 2,
+ SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3,
+ SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4,
+ SVG_PRESERVEASPECTRATIO_XMINYMID = 5,
+ SVG_PRESERVEASPECTRATIO_XMIDYMID = 6,
+ SVG_PRESERVEASPECTRATIO_XMAXYMID = 7,
+ SVG_PRESERVEASPECTRATIO_XMINYMAX = 8,
+ SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9,
+ SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10
+ };
+
+ enum SVGMeetOrSliceType {
+ SVG_MEETORSLICE_UNKNOWN = 0,
+ SVG_MEETORSLICE_MEET = 1,
+ SVG_MEETORSLICE_SLICE = 2
+ };
+
+ virtual ~SVGPreserveAspectRatio();
+
+ void setAlign(unsigned short);
+ unsigned short align() const;
+
+ void setMeetOrSlice(unsigned short);
+ unsigned short meetOrSlice() const;
+
+ AffineTransform getCTM(double logicX, double logicY,
+ double logicWidth, double logicHeight,
+ double physX, double physY,
+ double physWidth, double physHeight);
+
+ // Helper
+ bool parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate = true);
+
+ const QualifiedName& associatedAttributeName() const { return SVGNames::preserveAspectRatioAttr; }
+
+ private:
+ SVGPreserveAspectRatio();
+
+ unsigned short m_align;
+ unsigned short m_meetOrSlice;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGPreserveAspectRatio_h
+
diff --git a/WebCore/svg/SVGPreserveAspectRatio.idl b/WebCore/svg/SVGPreserveAspectRatio.idl
new file mode 100644
index 0000000..066353e
--- /dev/null
+++ b/WebCore/svg/SVGPreserveAspectRatio.idl
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor] SVGPreserveAspectRatio {
+ // Alignment Types
+ const unsigned short SVG_PRESERVEASPECTRATIO_UNKNOWN = 0;
+ const unsigned short SVG_PRESERVEASPECTRATIO_NONE = 1;
+ const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMIN = 2;
+ const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3;
+ const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4;
+ const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMID = 5;
+ const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMID = 6;
+ const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMID = 7;
+ const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMAX = 8;
+ const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9;
+ const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10;
+ // Meet-or-slice Types
+ const unsigned short SVG_MEETORSLICE_UNKNOWN = 0;
+ const unsigned short SVG_MEETORSLICE_MEET = 1;
+ const unsigned short SVG_MEETORSLICE_SLICE = 2;
+
+ attribute unsigned short align
+ /*setter raises(DOMException)*/;
+ attribute unsigned short meetOrSlice
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGRadialGradientElement.cpp b/WebCore/svg/SVGRadialGradientElement.cpp
new file mode 100644
index 0000000..9ec5eb8
--- /dev/null
+++ b/WebCore/svg/SVGRadialGradientElement.cpp
@@ -0,0 +1,186 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGRadialGradientElement.h"
+
+#include "FloatConversion.h"
+#include "FloatPoint.h"
+#include "RadialGradientAttributes.h"
+#include "RenderObject.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+#include "SVGPaintServerRadialGradient.h"
+#include "SVGStopElement.h"
+#include "SVGTransform.h"
+#include "SVGTransformList.h"
+#include "SVGUnitTypes.h"
+
+namespace WebCore {
+
+SVGRadialGradientElement::SVGRadialGradientElement(const QualifiedName& tagName, Document* doc)
+ : SVGGradientElement(tagName, doc)
+ , m_cx(this, LengthModeWidth)
+ , m_cy(this, LengthModeHeight)
+ , m_r(this, LengthModeOther)
+ , m_fx(this, LengthModeWidth)
+ , m_fy(this, LengthModeHeight)
+{
+ // Spec: If the attribute is not specified, the effect is as if a value of "50%" were specified.
+ setCxBaseValue(SVGLength(this, LengthModeWidth, "50%"));
+ setCyBaseValue(SVGLength(this, LengthModeHeight, "50%"));
+ setRBaseValue(SVGLength(this, LengthModeOther, "50%"));
+}
+
+SVGRadialGradientElement::~SVGRadialGradientElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGRadialGradientElement, SVGLength, Length, length, Cx, cx, SVGNames::cxAttr, m_cx)
+ANIMATED_PROPERTY_DEFINITIONS(SVGRadialGradientElement, SVGLength, Length, length, Cy, cy, SVGNames::cyAttr, m_cy)
+ANIMATED_PROPERTY_DEFINITIONS(SVGRadialGradientElement, SVGLength, Length, length, Fx, fx, SVGNames::fxAttr, m_fx)
+ANIMATED_PROPERTY_DEFINITIONS(SVGRadialGradientElement, SVGLength, Length, length, Fy, fy, SVGNames::fyAttr, m_fy)
+ANIMATED_PROPERTY_DEFINITIONS(SVGRadialGradientElement, SVGLength, Length, length, R, r, SVGNames::rAttr, m_r)
+
+void SVGRadialGradientElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::cxAttr)
+ setCxBaseValue(SVGLength(this, LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::cyAttr)
+ setCyBaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::rAttr) {
+ setRBaseValue(SVGLength(this, LengthModeOther, attr->value()));
+ if (r().value() < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for radial gradient radius <r> is not allowed");
+ } else if (attr->name() == SVGNames::fxAttr)
+ setFxBaseValue(SVGLength(this, LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::fyAttr)
+ setFyBaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ else
+ SVGGradientElement::parseMappedAttribute(attr);
+}
+
+void SVGRadialGradientElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGGradientElement::svgAttributeChanged(attrName);
+
+ if (!m_resource)
+ return;
+
+ if (attrName == SVGNames::cxAttr || attrName == SVGNames::cyAttr ||
+ attrName == SVGNames::fyAttr || attrName == SVGNames::fyAttr ||
+ attrName == SVGNames::rAttr)
+ m_resource->invalidate();
+}
+
+void SVGRadialGradientElement::buildGradient() const
+{
+ RadialGradientAttributes attributes = collectGradientProperties();
+
+ // If we didn't find any gradient containing stop elements, ignore the request.
+ if (attributes.stops().isEmpty())
+ return;
+
+ RefPtr<SVGPaintServerRadialGradient> radialGradient = WTF::static_pointer_cast<SVGPaintServerRadialGradient>(m_resource);
+
+ radialGradient->setGradientStops(attributes.stops());
+ radialGradient->setBoundingBoxMode(attributes.boundingBoxMode());
+ radialGradient->setGradientSpreadMethod(attributes.spreadMethod());
+ radialGradient->setGradientTransform(attributes.gradientTransform());
+ radialGradient->setGradientCenter(FloatPoint::narrowPrecision(attributes.cx(), attributes.cy()));
+ radialGradient->setGradientFocal(FloatPoint::narrowPrecision(attributes.fx(), attributes.fy()));
+ radialGradient->setGradientRadius(narrowPrecisionToFloat(attributes.r()));
+}
+
+RadialGradientAttributes SVGRadialGradientElement::collectGradientProperties() const
+{
+ RadialGradientAttributes attributes;
+ HashSet<const SVGGradientElement*> processedGradients;
+
+ bool isRadial = true;
+ const SVGGradientElement* current = this;
+
+ while (current) {
+ if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spreadMethodAttr))
+ attributes.setSpreadMethod((SVGGradientSpreadMethod) current->spreadMethod());
+
+ if (!attributes.hasBoundingBoxMode() && current->hasAttribute(SVGNames::gradientUnitsAttr))
+ attributes.setBoundingBoxMode(current->getAttribute(SVGNames::gradientUnitsAttr) == "objectBoundingBox");
+
+ if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames::gradientTransformAttr))
+ attributes.setGradientTransform(current->gradientTransform()->consolidate().matrix());
+
+ if (!attributes.hasStops()) {
+ const Vector<SVGGradientStop>& stops(current->buildStops());
+ if (!stops.isEmpty())
+ attributes.setStops(stops);
+ }
+
+ if (isRadial) {
+ const SVGRadialGradientElement* radial = static_cast<const SVGRadialGradientElement*>(current);
+
+ if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAttr))
+ attributes.setCx(radial->cx().valueAsPercentage());
+
+ if (!attributes.hasCy() && current->hasAttribute(SVGNames::cyAttr))
+ attributes.setCy(radial->cy().valueAsPercentage());
+
+ if (!attributes.hasR() && current->hasAttribute(SVGNames::rAttr))
+ attributes.setR(radial->r().valueAsPercentage());
+
+ if (!attributes.hasFx() && current->hasAttribute(SVGNames::fxAttr))
+ attributes.setFx(radial->fx().valueAsPercentage());
+
+ if (!attributes.hasFy() && current->hasAttribute(SVGNames::fyAttr))
+ attributes.setFy(radial->fy().valueAsPercentage());
+ }
+
+ processedGradients.add(current);
+
+ // Respect xlink:href, take attributes from referenced element
+ Node* refNode = ownerDocument()->getElementById(SVGURIReference::getTarget(current->href()));
+ if (refNode && (refNode->hasTagName(SVGNames::radialGradientTag) || refNode->hasTagName(SVGNames::linearGradientTag))) {
+ current = static_cast<const SVGGradientElement*>(const_cast<const Node*>(refNode));
+
+ // Cycle detection
+ if (processedGradients.contains(current))
+ return RadialGradientAttributes();
+
+ isRadial = current->gradientType() == RadialGradientPaintServer;
+ } else
+ current = 0;
+ }
+
+ // Handle default values for fx/fy
+ if (!attributes.hasFx())
+ attributes.setFx(attributes.cx());
+
+ if (!attributes.hasFy())
+ attributes.setFy(attributes.cy());
+
+ return attributes;
+}
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGRadialGradientElement.h b/WebCore/svg/SVGRadialGradientElement.h
new file mode 100644
index 0000000..7007ea5
--- /dev/null
+++ b/WebCore/svg/SVGRadialGradientElement.h
@@ -0,0 +1,62 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGRadialGradientElement_h
+#define SVGRadialGradientElement_h
+
+#if ENABLE(SVG)
+#include "SVGGradientElement.h"
+
+namespace WebCore {
+
+ struct RadialGradientAttributes;
+ class SVGLength;
+
+ class SVGRadialGradientElement : public SVGGradientElement {
+ public:
+ SVGRadialGradientElement(const QualifiedName&, Document*);
+ virtual ~SVGRadialGradientElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ protected:
+ virtual void buildGradient() const;
+ virtual SVGPaintServerType gradientType() const { return RadialGradientPaintServer; }
+
+ RadialGradientAttributes collectGradientProperties() const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRadialGradientElement, SVGLength, SVGLength, Cx, cx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRadialGradientElement, SVGLength, SVGLength, Cy, cy)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRadialGradientElement, SVGLength, SVGLength, R, r)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRadialGradientElement, SVGLength, SVGLength, Fx, fx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRadialGradientElement, SVGLength, SVGLength, Fy, fy)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGRadialGradientElement.idl b/WebCore/svg/SVGRadialGradientElement.idl
new file mode 100644
index 0000000..032dda5
--- /dev/null
+++ b/WebCore/svg/SVGRadialGradientElement.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGRadialGradientElement : SVGGradientElement {
+ readonly attribute SVGAnimatedLength cx;
+ readonly attribute SVGAnimatedLength cy;
+ readonly attribute SVGAnimatedLength r;
+ readonly attribute SVGAnimatedLength fx;
+ readonly attribute SVGAnimatedLength fy;
+ };
+
+}
diff --git a/WebCore/svg/SVGRect.idl b/WebCore/svg/SVGRect.idl
new file mode 100644
index 0000000..7fdce65
--- /dev/null
+++ b/WebCore/svg/SVGRect.idl
@@ -0,0 +1,38 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+module svg {
+
+ interface [Conditional=SVG, PODType=FloatRect] SVGRect {
+ attribute float x
+ setter raises(DOMException);
+ attribute float y
+ setter raises(DOMException);
+ attribute float width
+ setter raises(DOMException);
+ attribute float height
+ setter raises(DOMException);
+ };
+
+}
diff --git a/WebCore/svg/SVGRectElement.cpp b/WebCore/svg/SVGRectElement.cpp
new file mode 100644
index 0000000..6820b9d
--- /dev/null
+++ b/WebCore/svg/SVGRectElement.cpp
@@ -0,0 +1,131 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGRectElement.h"
+
+#include "RenderPath.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+SVGRectElement::SVGRectElement(const QualifiedName& tagName, Document *doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_x(this, LengthModeWidth)
+ , m_y(this, LengthModeHeight)
+ , m_width(this, LengthModeWidth)
+ , m_height(this, LengthModeHeight)
+ , m_rx(this, LengthModeWidth)
+ , m_ry(this, LengthModeHeight)
+{
+}
+
+SVGRectElement::~SVGRectElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGRectElement, SVGLength, Length, length, X, x, SVGNames::xAttr, m_x)
+ANIMATED_PROPERTY_DEFINITIONS(SVGRectElement, SVGLength, Length, length, Y, y, SVGNames::yAttr, m_y)
+ANIMATED_PROPERTY_DEFINITIONS(SVGRectElement, SVGLength, Length, length, Width, width, SVGNames::widthAttr, m_width)
+ANIMATED_PROPERTY_DEFINITIONS(SVGRectElement, SVGLength, Length, length, Height, height, SVGNames::heightAttr, m_height)
+ANIMATED_PROPERTY_DEFINITIONS(SVGRectElement, SVGLength, Length, length, Rx, rx, SVGNames::rxAttr, m_rx)
+ANIMATED_PROPERTY_DEFINITIONS(SVGRectElement, SVGLength, Length, length, Ry, ry, SVGNames::ryAttr, m_ry)
+
+void SVGRectElement::parseMappedAttribute(MappedAttribute* 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::rxAttr) {
+ setRxBaseValue(SVGLength(this, LengthModeWidth, attr->value()));
+ if (rx().value() < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for rect <rx> is not allowed");
+ } else if (attr->name() == SVGNames::ryAttr) {
+ setRyBaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ if (ry().value() < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for rect <ry> is not allowed");
+ } else if (attr->name() == SVGNames::widthAttr) {
+ setWidthBaseValue(SVGLength(this, LengthModeWidth, attr->value()));
+ if (width().value() < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for rect <width> is not allowed");
+ } else if (attr->name() == SVGNames::heightAttr) {
+ setHeightBaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ if (height().value() < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for rect <height> is not allowed");
+ } else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ SVGStyledTransformableElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGRectElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledTransformableElement::svgAttributeChanged(attrName);
+
+ if (!renderer())
+ return;
+
+ if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr ||
+ attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledTransformableElement::isKnownAttribute(attrName))
+ renderer()->setNeedsLayout(true);
+}
+
+Path SVGRectElement::toPathData() const
+{
+ FloatRect rect(x().value(), y().value(), width().value(), height().value());
+
+ bool hasRx = hasAttribute(SVGNames::rxAttr);
+ bool hasRy = hasAttribute(SVGNames::ryAttr);
+ if (hasRx || hasRy) {
+ float _rx = hasRx ? rx().value() : ry().value();
+ float _ry = hasRy ? ry().value() : rx().value();
+ return Path::createRoundedRectangle(rect, FloatSize(_rx, _ry));
+ }
+
+ return Path::createRectangle(rect);
+}
+
+bool SVGRectElement::hasRelativeValues() const
+{
+ return (x().isRelative() || width().isRelative() ||
+ y().isRelative() || height().isRelative());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGRectElement.h b/WebCore/svg/SVGRectElement.h
new file mode 100644
index 0000000..244a6ef
--- /dev/null
+++ b/WebCore/svg/SVGRectElement.h
@@ -0,0 +1,67 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGRectElement_h
+#define SVGRectElement_h
+
+#if ENABLE(SVG)
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTests.h"
+
+namespace WebCore {
+
+ class SVGRectElement : public SVGStyledTransformableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired {
+ public:
+ SVGRectElement(const QualifiedName&, Document*);
+ virtual ~SVGRectElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ virtual Path toPathData() const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+ virtual bool hasRelativeValues() const;
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGLength, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGLength, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGLength, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGLength, SVGLength, Height, height)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGLength, SVGLength, Rx, rx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGLength, SVGLength, Ry, ry)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGRectElement.idl b/WebCore/svg/SVGRectElement.idl
new file mode 100644
index 0000000..540ceb3
--- /dev/null
+++ b/WebCore/svg/SVGRectElement.idl
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGRectElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable {
+ readonly attribute SVGAnimatedLength x;
+ readonly attribute SVGAnimatedLength y;
+ readonly attribute SVGAnimatedLength width;
+ readonly attribute SVGAnimatedLength height;
+ readonly attribute SVGAnimatedLength rx;
+ readonly attribute SVGAnimatedLength ry;
+ };
+
+}
diff --git a/WebCore/svg/SVGRenderingIntent.h b/WebCore/svg/SVGRenderingIntent.h
new file mode 100644
index 0000000..699f228
--- /dev/null
+++ b/WebCore/svg/SVGRenderingIntent.h
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGRenderingIntent_h
+#define SVGRenderingIntent_h
+
+#if ENABLE(SVG)
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class SVGRenderingIntent : public RefCounted<SVGRenderingIntent> {
+public:
+ enum SVGRenderingIntentType {
+ RENDERING_INTENT_UNKNOWN = 0,
+ RENDERING_INTENT_AUTO = 1,
+ RENDERING_INTENT_PERCEPTUAL = 2,
+ RENDERING_INTENT_RELATIVE_COLORIMETRIC = 3,
+ RENDERING_INTENT_SATURATION = 4,
+ RENDERING_INTENT_ABSOLUTE_COLORIMETRIC = 5
+ };
+
+private:
+ SVGRenderingIntent() { }
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGRenderingIntent_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGRenderingIntent.idl b/WebCore/svg/SVGRenderingIntent.idl
new file mode 100644
index 0000000..fc21549
--- /dev/null
+++ b/WebCore/svg/SVGRenderingIntent.idl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor] SVGRenderingIntent {
+ // Rendering Intent Types
+ const unsigned short RENDERING_INTENT_UNKNOWN = 0;
+ const unsigned short RENDERING_INTENT_AUTO = 1;
+ const unsigned short RENDERING_INTENT_PERCEPTUAL = 2;
+ const unsigned short RENDERING_INTENT_RELATIVE_COLORIMETRIC = 3;
+ const unsigned short RENDERING_INTENT_SATURATION = 4;
+ const unsigned short RENDERING_INTENT_ABSOLUTE_COLORIMETRIC = 5;
+ };
+
+}
diff --git a/WebCore/svg/SVGSVGElement.cpp b/WebCore/svg/SVGSVGElement.cpp
new file mode 100644
index 0000000..33d8867
--- /dev/null
+++ b/WebCore/svg/SVGSVGElement.cpp
@@ -0,0 +1,538 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+ 2007 Apple Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGSVGElement.h"
+
+#include "AffineTransform.h"
+#include "CSSHelper.h"
+#include "CSSPropertyNames.h"
+#include "Document.h"
+#include "EventListener.h"
+#include "EventNames.h"
+#include "FloatConversion.h"
+#include "FloatRect.h"
+#include "Frame.h"
+#include "HTMLNames.h"
+#include "RenderSVGViewportContainer.h"
+#include "RenderSVGRoot.h"
+#include "SVGAngle.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+#include "SVGPreserveAspectRatio.h"
+#include "SVGTransform.h"
+#include "SVGTransformList.h"
+#include "SVGViewElement.h"
+#include "SVGViewSpec.h"
+#include "SVGZoomEvent.h"
+#include "SelectionController.h"
+#include "TimeScheduler.h"
+
+namespace WebCore {
+
+using namespace HTMLNames;
+using namespace EventNames;
+using namespace SVGNames;
+
+SVGSVGElement::SVGSVGElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledLocatableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , SVGFitToViewBox()
+ , SVGZoomAndPan()
+ , m_x(this, LengthModeWidth)
+ , m_y(this, LengthModeHeight)
+ , m_width(this, LengthModeWidth)
+ , m_height(this, LengthModeHeight)
+ , m_useCurrentView(false)
+ , m_timeScheduler(new TimeScheduler(doc))
+ , m_viewSpec(0)
+ , m_containerSize(300, 150)
+ , m_hasSetContainerSize(false)
+{
+ setWidthBaseValue(SVGLength(this, LengthModeWidth, "100%"));
+ setHeightBaseValue(SVGLength(this, LengthModeHeight, "100%"));
+}
+
+SVGSVGElement::~SVGSVGElement()
+{
+ delete m_timeScheduler;
+ m_timeScheduler = 0;
+
+ // There are cases where removedFromDocument() is not called.
+ // see ContainerNode::removeAllChildren, called by it's destructor.
+ document()->accessSVGExtensions()->removeTimeContainer(this);
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGSVGElement, SVGLength, Length, length, X, x, SVGNames::xAttr, m_x)
+ANIMATED_PROPERTY_DEFINITIONS(SVGSVGElement, SVGLength, Length, length, Y, y, SVGNames::yAttr, m_y)
+ANIMATED_PROPERTY_DEFINITIONS(SVGSVGElement, SVGLength, Length, length, Width, width, SVGNames::widthAttr, m_width)
+ANIMATED_PROPERTY_DEFINITIONS(SVGSVGElement, SVGLength, Length, length, Height, height, SVGNames::heightAttr, m_height)
+
+const AtomicString& SVGSVGElement::contentScriptType() const
+{
+ static const AtomicString defaultValue("text/ecmascript");
+ const AtomicString& n = getAttribute(contentScriptTypeAttr);
+ return n.isNull() ? defaultValue : n;
+}
+
+void SVGSVGElement::setContentScriptType(const AtomicString& type)
+{
+ setAttribute(SVGNames::contentScriptTypeAttr, type);
+}
+
+const AtomicString& SVGSVGElement::contentStyleType() const
+{
+ static const AtomicString defaultValue("text/css");
+ const AtomicString& n = getAttribute(contentStyleTypeAttr);
+ return n.isNull() ? defaultValue : n;
+}
+
+void SVGSVGElement::setContentStyleType(const AtomicString& type)
+{
+ setAttribute(SVGNames::contentStyleTypeAttr, type);
+}
+
+FloatRect SVGSVGElement::viewport() const
+{
+ double _x = 0.0;
+ double _y = 0.0;
+ if (!isOutermostSVG()) {
+ _x = x().value();
+ _y = y().value();
+ }
+ float w = width().value();
+ float h = height().value();
+ AffineTransform viewBox = viewBoxToViewTransform(w, h);
+ double wDouble = w;
+ double hDouble = h;
+ viewBox.map(_x, _y, &_x, &_y);
+ viewBox.map(w, h, &wDouble, &hDouble);
+ return FloatRect::narrowPrecision(_x, _y, wDouble, hDouble);
+}
+
+int SVGSVGElement::relativeWidthValue() const
+{
+ SVGLength w = width();
+ if (w.unitType() != LengthTypePercentage)
+ return 0;
+
+ return static_cast<int>(w.valueAsPercentage() * m_containerSize.width());
+}
+
+int SVGSVGElement::relativeHeightValue() const
+{
+ SVGLength h = height();
+ if (h.unitType() != LengthTypePercentage)
+ return 0;
+
+ return static_cast<int>(h.valueAsPercentage() * m_containerSize.height());
+}
+
+float SVGSVGElement::pixelUnitToMillimeterX() const
+{
+ // 2.54 / cssPixelsPerInch gives CM.
+ return (2.54f / cssPixelsPerInch) * 10.0f;
+}
+
+float SVGSVGElement::pixelUnitToMillimeterY() const
+{
+ // 2.54 / cssPixelsPerInch gives CM.
+ return (2.54f / cssPixelsPerInch) * 10.0f;
+}
+
+float SVGSVGElement::screenPixelToMillimeterX() const
+{
+ return pixelUnitToMillimeterX();
+}
+
+float SVGSVGElement::screenPixelToMillimeterY() const
+{
+ return pixelUnitToMillimeterY();
+}
+
+bool SVGSVGElement::useCurrentView() const
+{
+ return m_useCurrentView;
+}
+
+void SVGSVGElement::setUseCurrentView(bool currentView)
+{
+ m_useCurrentView = currentView;
+}
+
+SVGViewSpec* SVGSVGElement::currentView() const
+{
+ if (!m_viewSpec)
+ m_viewSpec.set(new SVGViewSpec(this));
+
+ return m_viewSpec.get();
+}
+
+float SVGSVGElement::currentScale() const
+{
+ if (document() && document()->frame())
+ return document()->frame()->zoomFactor() / 100.0f;
+ return 1.0f;
+}
+
+void SVGSVGElement::setCurrentScale(float scale)
+{
+ if (document() && document()->frame())
+ document()->frame()->setZoomFactor(static_cast<int>(scale / 100.0f));
+}
+
+FloatPoint SVGSVGElement::currentTranslate() const
+{
+ return m_translation;
+}
+
+void SVGSVGElement::setCurrentTranslate(const FloatPoint &translation)
+{
+ m_translation = translation;
+ if (parentNode() == document() && document()->renderer())
+ document()->renderer()->repaint();
+}
+
+void SVGSVGElement::addSVGWindowEventListener(const AtomicString& eventType, const Attribute* attr)
+{
+ // FIXME: None of these should be window events long term.
+ // Once we propertly support SVGLoad, etc.
+ RefPtr<EventListener> listener = document()->accessSVGExtensions()->
+ createSVGEventListener(attr->localName().string(), attr->value(), this);
+ document()->setHTMLWindowEventListener(eventType, listener.release());
+}
+
+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))
+ return;
+ if (SVGZoomAndPan::parseMappedAttribute(attr))
+ return;
+
+ SVGStyledLocatableElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledElement::svgAttributeChanged(attrName);
+
+ if (!renderer())
+ return;
+
+ if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr ||
+ attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGFitToViewBox::isKnownAttribute(attrName) ||
+ SVGZoomAndPan::isKnownAttribute(attrName) ||
+ SVGStyledLocatableElement::isKnownAttribute(attrName))
+ renderer()->setNeedsLayout(true);
+}
+
+unsigned long SVGSVGElement::suspendRedraw(unsigned long /* max_wait_milliseconds */)
+{
+ // FIXME: Implement me (see bug 11275)
+ return 0;
+}
+
+void SVGSVGElement::unsuspendRedraw(unsigned long /* suspend_handle_id */, ExceptionCode& ec)
+{
+ // if suspend_handle_id is not found, throw exception
+ // FIXME: Implement me (see bug 11275)
+}
+
+void SVGSVGElement::unsuspendRedrawAll()
+{
+ // FIXME: Implement me (see bug 11275)
+}
+
+void SVGSVGElement::forceRedraw()
+{
+ // FIXME: Implement me (see bug 11275)
+}
+
+NodeList* SVGSVGElement::getIntersectionList(const FloatRect& rect, SVGElement*)
+{
+ // FIXME: Implement me (see bug 11274)
+ return 0;
+}
+
+NodeList* SVGSVGElement::getEnclosureList(const FloatRect& rect, SVGElement*)
+{
+ // FIXME: Implement me (see bug 11274)
+ return 0;
+}
+
+bool SVGSVGElement::checkIntersection(SVGElement* element, const FloatRect& rect)
+{
+ // TODO : take into account pointer-events?
+ // FIXME: Why is element ignored??
+ // FIXME: Implement me (see bug 11274)
+ return rect.intersects(getBBox());
+}
+
+bool SVGSVGElement::checkEnclosure(SVGElement* element, const FloatRect& rect)
+{
+ // TODO : take into account pointer-events?
+ // FIXME: Why is element ignored??
+ // FIXME: Implement me (see bug 11274)
+ return rect.contains(getBBox());
+}
+
+void SVGSVGElement::deselectAll()
+{
+ document()->frame()->selectionController()->clear();
+}
+
+float SVGSVGElement::createSVGNumber()
+{
+ return 0.0f;
+}
+
+SVGLength SVGSVGElement::createSVGLength()
+{
+ return SVGLength();
+}
+
+SVGAngle* SVGSVGElement::createSVGAngle()
+{
+ return new SVGAngle();
+}
+
+FloatPoint SVGSVGElement::createSVGPoint()
+{
+ return FloatPoint();
+}
+
+AffineTransform SVGSVGElement::createSVGMatrix()
+{
+ return AffineTransform();
+}
+
+FloatRect SVGSVGElement::createSVGRect()
+{
+ return FloatRect();
+}
+
+SVGTransform SVGSVGElement::createSVGTransform()
+{
+ return SVGTransform();
+}
+
+SVGTransform SVGSVGElement::createSVGTransformFromMatrix(const AffineTransform& matrix)
+{
+ return SVGTransform(matrix);
+}
+
+AffineTransform SVGSVGElement::getCTM() const
+{
+ AffineTransform mat;
+ if (!isOutermostSVG())
+ mat.translate(x().value(), y().value());
+
+ if (attributes()->getNamedItem(SVGNames::viewBoxAttr)) {
+ AffineTransform viewBox = viewBoxToViewTransform(width().value(), height().value());
+ mat = viewBox * mat;
+ }
+
+ return mat;
+}
+
+AffineTransform SVGSVGElement::getScreenCTM() const
+{
+ document()->updateLayoutIgnorePendingStylesheets();
+ float rootX = 0.0f;
+ float rootY = 0.0f;
+
+ if (RenderObject* renderer = this->renderer()) {
+ renderer = renderer->parent();
+ if (isOutermostSVG()) {
+ int tx = 0;
+ int ty = 0;
+ if (renderer)
+ renderer->absolutePosition(tx, ty, true);
+ rootX += tx;
+ rootY += ty;
+ } else {
+ rootX += x().value();
+ rootY += y().value();
+ }
+ }
+
+ AffineTransform mat = SVGStyledLocatableElement::getScreenCTM();
+ mat.translate(rootX, rootY);
+
+ if (attributes()->getNamedItem(SVGNames::viewBoxAttr)) {
+ AffineTransform viewBox = viewBoxToViewTransform(width().value(), height().value());
+ mat = viewBox * mat;
+ }
+
+ return mat;
+}
+
+RenderObject* SVGSVGElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+ if (isOutermostSVG())
+ return new (arena) RenderSVGRoot(this);
+ else
+ return new (arena) RenderSVGViewportContainer(this);
+}
+
+void SVGSVGElement::insertedIntoDocument()
+{
+ document()->accessSVGExtensions()->addTimeContainer(this);
+ SVGStyledLocatableElement::insertedIntoDocument();
+}
+
+void SVGSVGElement::removedFromDocument()
+{
+ document()->accessSVGExtensions()->removeTimeContainer(this);
+ SVGStyledLocatableElement::removedFromDocument();
+}
+
+void SVGSVGElement::pauseAnimations()
+{
+ if (!m_timeScheduler->animationsPaused())
+ m_timeScheduler->toggleAnimations();
+}
+
+void SVGSVGElement::unpauseAnimations()
+{
+ if (m_timeScheduler->animationsPaused())
+ m_timeScheduler->toggleAnimations();
+}
+
+bool SVGSVGElement::animationsPaused() const
+{
+ return m_timeScheduler->animationsPaused();
+}
+
+float SVGSVGElement::getCurrentTime() const
+{
+ return narrowPrecisionToFloat(m_timeScheduler->elapsed());
+}
+
+void SVGSVGElement::setCurrentTime(float /* seconds */)
+{
+ // FIXME: Implement me, bug 12073
+}
+
+bool SVGSVGElement::hasRelativeValues() const
+{
+ return (x().isRelative() || width().isRelative() ||
+ y().isRelative() || height().isRelative());
+}
+
+bool SVGSVGElement::isOutermostSVG() const
+{
+ // This is true whenever this is the outermost SVG, even if there are HTML elements outside it
+ return !parentNode()->isSVGElement();
+}
+
+AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float viewHeight) const
+{
+ FloatRect viewBoxRect;
+ if (useCurrentView()) {
+ if (currentView()) // what if we should use it but it is not set?
+ viewBoxRect = currentView()->viewBox();
+ } else
+ viewBoxRect = viewBox();
+ if (!viewBoxRect.width() || !viewBoxRect.height())
+ return AffineTransform();
+
+ AffineTransform ctm = preserveAspectRatio()->getCTM(viewBoxRect.x(),
+ viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(),
+ 0, 0, viewWidth, viewHeight);
+
+ if (useCurrentView() && currentView())
+ return currentView()->transform()->concatenate().matrix() * ctm;
+
+ return ctm;
+}
+
+void SVGSVGElement::inheritViewAttributes(SVGViewElement* viewElement)
+{
+ setUseCurrentView(true);
+ if (viewElement->hasAttribute(SVGNames::viewBoxAttr))
+ currentView()->setViewBox(viewElement->viewBox());
+ else
+ currentView()->setViewBox(viewBox());
+ if (viewElement->hasAttribute(SVGNames::preserveAspectRatioAttr)) {
+ currentView()->preserveAspectRatio()->setAlign(viewElement->preserveAspectRatio()->align());
+ currentView()->preserveAspectRatio()->setMeetOrSlice(viewElement->preserveAspectRatio()->meetOrSlice());
+ } else {
+ currentView()->preserveAspectRatio()->setAlign(preserveAspectRatio()->align());
+ currentView()->preserveAspectRatio()->setMeetOrSlice(preserveAspectRatio()->meetOrSlice());
+ }
+ if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr))
+ currentView()->setZoomAndPan(viewElement->zoomAndPan());
+ renderer()->setNeedsLayout(true);
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGSVGElement.h b/WebCore/svg/SVGSVGElement.h
new file mode 100644
index 0000000..4296938
--- /dev/null
+++ b/WebCore/svg/SVGSVGElement.h
@@ -0,0 +1,172 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGSVGElement_h
+#define SVGSVGElement_h
+
+#if ENABLE(SVG)
+
+#include "IntSize.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGFitToViewBox.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledLocatableElement.h"
+#include "SVGTests.h"
+#include "SVGZoomAndPan.h"
+
+namespace WebCore
+{
+ class SVGAngle;
+ class SVGLength;
+ class SVGTransform;
+ class SVGViewSpec;
+ class SVGViewElement;
+ class TimeScheduler;
+ class SVGSVGElement : public SVGStyledLocatableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired,
+ public SVGFitToViewBox,
+ public SVGZoomAndPan
+ {
+ public:
+ SVGSVGElement(const QualifiedName&, Document*);
+ virtual ~SVGSVGElement();
+
+ virtual bool isSVG() const { return true; }
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ // 'SVGSVGElement' functions
+ const AtomicString& contentScriptType() const;
+ void setContentScriptType(const AtomicString& type);
+
+ const AtomicString& contentStyleType() const;
+ void setContentStyleType(const AtomicString& type);
+
+ FloatRect viewport() const;
+
+ void setContainerSize(const IntSize& containerSize) { m_containerSize = containerSize; m_hasSetContainerSize = true; }
+ IntSize containerSize() const { return m_containerSize; }
+ bool hasSetContainerSize() const { return m_hasSetContainerSize; }
+ int relativeWidthValue() const;
+ int relativeHeightValue() const;
+
+ float pixelUnitToMillimeterX() const;
+ float pixelUnitToMillimeterY() const;
+ float screenPixelToMillimeterX() const;
+ float screenPixelToMillimeterY() const;
+
+ bool useCurrentView() const;
+ void setUseCurrentView(bool currentView);
+
+ SVGViewSpec* currentView() const;
+
+ float currentScale() const;
+ void setCurrentScale(float scale);
+
+ FloatPoint currentTranslate() const;
+ void setCurrentTranslate(const FloatPoint&);
+
+ TimeScheduler* timeScheduler() { return m_timeScheduler; }
+
+ void pauseAnimations();
+ void unpauseAnimations();
+ bool animationsPaused() const;
+
+ float getCurrentTime() const;
+ void setCurrentTime(float seconds);
+
+ unsigned long suspendRedraw(unsigned long max_wait_milliseconds);
+ void unsuspendRedraw(unsigned long suspend_handle_id, ExceptionCode&);
+ void unsuspendRedrawAll();
+ void forceRedraw();
+
+ NodeList* getIntersectionList(const FloatRect&, SVGElement* referenceElement);
+ NodeList* getEnclosureList(const FloatRect&, SVGElement* referenceElement);
+ bool checkIntersection(SVGElement*, const FloatRect&);
+ bool checkEnclosure(SVGElement*, const FloatRect&);
+ void deselectAll();
+
+ static float createSVGNumber();
+ static SVGLength createSVGLength();
+ static SVGAngle* createSVGAngle();
+ static FloatPoint createSVGPoint();
+ static AffineTransform createSVGMatrix();
+ static FloatRect createSVGRect();
+ static SVGTransform createSVGTransform();
+ static SVGTransform createSVGTransformFromMatrix(const AffineTransform&);
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ // 'virtual SVGLocatable' functions
+ virtual AffineTransform getCTM() const;
+ virtual AffineTransform getScreenCTM() const;
+
+ virtual bool rendererIsNeeded(RenderStyle* style) { return StyledElement::rendererIsNeeded(style); }
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
+
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ virtual AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) const;
+
+ void inheritViewAttributes(SVGViewElement*);
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ friend class RenderSVGRoot;
+ friend class RenderSVGViewportContainer;
+
+ virtual bool hasRelativeValues() const;
+
+ bool isOutermostSVG() const;
+
+ private:
+ void addSVGWindowEventListener(const AtomicString& eventType, const Attribute* attr);
+
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, FloatRect, ViewBox, viewBox)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, SVGPreserveAspectRatio*, PreserveAspectRatio, preserveAspectRatio)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGLength, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGLength, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGLength, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGLength, SVGLength, Height, height)
+
+ bool m_useCurrentView;
+ TimeScheduler* m_timeScheduler;
+ FloatPoint m_translation;
+ mutable OwnPtr<SVGViewSpec> m_viewSpec;
+ IntSize m_containerSize;
+ bool m_hasSetContainerSize;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGSVGElement.idl b/WebCore/svg/SVGSVGElement.idl
new file mode 100644
index 0000000..4c3f512
--- /dev/null
+++ b/WebCore/svg/SVGSVGElement.idl
@@ -0,0 +1,88 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+module svg {
+
+ // TODO: no css::ViewCSS available!
+ // TODO: Fix SVGSVGElement inheritance (css::DocumentCSS)!
+ // TODO: no events::DocumentEvent available!
+ interface [Conditional=SVG] SVGSVGElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGLocatable,
+ SVGFitToViewBox,
+ SVGZoomAndPan {
+ readonly attribute SVGAnimatedLength x;
+ readonly attribute SVGAnimatedLength y;
+ readonly attribute SVGAnimatedLength width;
+ readonly attribute SVGAnimatedLength height;
+ attribute core::DOMString contentScriptType
+ /*setter raises(DOMException)*/;
+ attribute core::DOMString contentStyleType
+ /*setter raises(DOMException)*/;
+ readonly attribute SVGRect viewport;
+ readonly attribute float pixelUnitToMillimeterX;
+ readonly attribute float pixelUnitToMillimeterY;
+ readonly attribute float screenPixelToMillimeterX;
+ readonly attribute float screenPixelToMillimeterY;
+ attribute boolean useCurrentView
+ /*setter raises(DOMException)*/;
+ // TODO readonly attribute SVGViewSpec currentView;
+ attribute float currentScale
+ /*setter raises(DOMException)*/;
+ readonly attribute SVGPoint currentTranslate;
+
+ unsigned long suspendRedraw(in unsigned long maxWaitMilliseconds);
+ void unsuspendRedraw(in unsigned long suspendHandleId)
+ setter raises(DOMException);
+ void unsuspendRedrawAll();
+ void forceRedraw();
+ void pauseAnimations();
+ void unpauseAnimations();
+ boolean animationsPaused();
+ float getCurrentTime();
+ void setCurrentTime(in float seconds);
+ core::NodeList getIntersectionList(in SVGRect rect,
+ in SVGElement referenceElement);
+ core::NodeList getEnclosureList(in SVGRect rect,
+ in SVGElement referenceElement);
+ boolean checkIntersection(in SVGElement element,
+ in SVGRect rect);
+ boolean checkEnclosure(in SVGElement element,
+ in SVGRect rect);
+ void deselectAll();
+
+ SVGNumber createSVGNumber();
+ SVGLength createSVGLength();
+ SVGAngle createSVGAngle();
+ SVGPoint createSVGPoint();
+ SVGMatrix createSVGMatrix();
+ SVGRect createSVGRect();
+ SVGTransform createSVGTransform();
+ SVGTransform createSVGTransformFromMatrix(in SVGMatrix matrix);
+ };
+
+}
diff --git a/WebCore/svg/SVGScriptElement.cpp b/WebCore/svg/SVGScriptElement.cpp
new file mode 100644
index 0000000..1278972
--- /dev/null
+++ b/WebCore/svg/SVGScriptElement.cpp
@@ -0,0 +1,70 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGScriptElement.h"
+
+#include "SVGNames.h"
+
+namespace WebCore {
+
+SVGScriptElement::SVGScriptElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+ , SVGURIReference()
+ , SVGExternalResourcesRequired()
+{
+}
+
+SVGScriptElement::~SVGScriptElement()
+{
+}
+
+String SVGScriptElement::type() const
+{
+ return m_type;
+}
+
+void SVGScriptElement::setType(const String& type)
+{
+ m_type = type;
+}
+
+void SVGScriptElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::typeAttr)
+ setType(attr->value());
+ else {
+ if (SVGURIReference::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+
+ SVGElement::parseMappedAttribute(attr);
+ }
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGScriptElement.h b/WebCore/svg/SVGScriptElement.h
new file mode 100644
index 0000000..c2c92bb
--- /dev/null
+++ b/WebCore/svg/SVGScriptElement.h
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGScriptElement_h
+#define SVGScriptElement_h
+#if ENABLE(SVG)
+
+#include "SVGElement.h"
+#include "SVGURIReference.h"
+#include "SVGExternalResourcesRequired.h"
+
+namespace WebCore
+{
+ class SVGScriptElement : public SVGElement,
+ public SVGURIReference,
+ public SVGExternalResourcesRequired
+ {
+ public:
+ SVGScriptElement(const QualifiedName&, Document*);
+ virtual ~SVGScriptElement();
+
+ // 'SVGScriptElement' functions
+ String type() const;
+ void setType(const String&);
+
+ // Internal
+ virtual void parseMappedAttribute(MappedAttribute *attr);
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ String m_type;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGScriptElement.idl b/WebCore/svg/SVGScriptElement.idl
new file mode 100644
index 0000000..da2e034
--- /dev/null
+++ b/WebCore/svg/SVGScriptElement.idl
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGScriptElement : SVGElement,
+ SVGURIReference,
+ SVGExternalResourcesRequired {
+ attribute [ConvertNullToNullString] DOMString type
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGSetElement.cpp b/WebCore/svg/SVGSetElement.cpp
new file mode 100644
index 0000000..1d783e6
--- /dev/null
+++ b/WebCore/svg/SVGSetElement.cpp
@@ -0,0 +1,57 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGSetElement.h"
+#include "TimeScheduler.h"
+#include "Document.h"
+#include "SVGDocumentExtensions.h"
+#include "SVGSVGElement.h"
+
+namespace WebCore {
+
+SVGSetElement::SVGSetElement(const QualifiedName& tagName, Document *doc)
+ : SVGAnimationElement(tagName, doc)
+{
+}
+
+SVGSetElement::~SVGSetElement()
+{
+}
+
+bool SVGSetElement::updateAnimatedValue(EAnimationMode, float timePercentage, unsigned valueIndex, float percentagePast)
+{
+ m_animatedValue = m_to;
+ return true;
+}
+
+bool SVGSetElement::calculateFromAndToValues(EAnimationMode, unsigned valueIndex)
+{
+ return true;
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGSetElement.h b/WebCore/svg/SVGSetElement.h
new file mode 100644
index 0000000..91fc380
--- /dev/null
+++ b/WebCore/svg/SVGSetElement.h
@@ -0,0 +1,52 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGSetElement_h
+#define SVGSetElement_h
+#if ENABLE(SVG)
+
+#include "SVGAnimationElement.h"
+
+namespace WebCore
+{
+ class SVGSetElement : public SVGAnimationElement
+ {
+ public:
+ SVGSetElement(const QualifiedName&, Document*);
+ virtual ~SVGSetElement();
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ virtual bool updateAnimatedValue(EAnimationMode, float timePercentage, unsigned valueIndex, float percentagePast);
+ virtual bool calculateFromAndToValues(EAnimationMode, unsigned valueIndex);
+
+ private:
+ String m_savedTo;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGSetElement.idl b/WebCore/svg/SVGSetElement.idl
new file mode 100644
index 0000000..132f0ae
--- /dev/null
+++ b/WebCore/svg/SVGSetElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGSetElement : SVGAnimationElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGStopElement.cpp b/WebCore/svg/SVGStopElement.cpp
new file mode 100644
index 0000000..eb1657f
--- /dev/null
+++ b/WebCore/svg/SVGStopElement.cpp
@@ -0,0 +1,68 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGStopElement.h"
+
+#include "Document.h"
+#include "RenderSVGGradientStop.h"
+#include "SVGGradientElement.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+SVGStopElement::SVGStopElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , m_offset(0.0f)
+{
+}
+
+SVGStopElement::~SVGStopElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGStopElement, float, Number, number, Offset, offset, SVGNames::offsetAttr, m_offset)
+
+void SVGStopElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::offsetAttr) {
+ const String& value = attr->value();
+ if (value.endsWith("%"))
+ setOffsetBaseValue(value.left(value.length() - 1).toFloat() / 100.0f);
+ else
+ setOffsetBaseValue(value.toFloat());
+
+ setChanged();
+ } else
+ SVGStyledElement::parseMappedAttribute(attr);
+}
+
+RenderObject* SVGStopElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+ return new (arena) RenderSVGGradientStop(this);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGStopElement.h b/WebCore/svg/SVGStopElement.h
new file mode 100644
index 0000000..84ac4eb
--- /dev/null
+++ b/WebCore/svg/SVGStopElement.h
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGStopElement_h
+#define SVGStopElement_h
+
+#if ENABLE(SVG)
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+ class SVGStopElement : public SVGStyledElement {
+ public:
+ SVGStopElement(const QualifiedName&, Document*);
+ virtual ~SVGStopElement();
+
+ virtual bool isGradientStop() const { return true; }
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGStopElement, float, float, Offset, offset)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGStopElement.idl b/WebCore/svg/SVGStopElement.idl
new file mode 100644
index 0000000..2a16128
--- /dev/null
+++ b/WebCore/svg/SVGStopElement.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGStopElement : SVGElement,
+ SVGStylable {
+ readonly attribute SVGAnimatedNumber offset;
+ };
+
+}
diff --git a/WebCore/svg/SVGStringList.cpp b/WebCore/svg/SVGStringList.cpp
new file mode 100644
index 0000000..9a23a4a
--- /dev/null
+++ b/WebCore/svg/SVGStringList.cpp
@@ -0,0 +1,71 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGStringList.h"
+
+#include "SVGParserUtilities.h"
+
+namespace WebCore {
+
+SVGStringList::SVGStringList(const QualifiedName& attributeName)
+ : SVGList<String>(attributeName)
+{
+}
+
+SVGStringList::~SVGStringList()
+{
+}
+
+void SVGStringList::reset(const String& str)
+{
+ ExceptionCode ec = 0;
+
+ parse(str, ' ');
+ if (numberOfItems() == 0)
+ appendItem(String(""), ec); // Create empty string...
+}
+
+void SVGStringList::parse(const String& data, UChar delimiter)
+{
+ // TODO : more error checking/reporting
+ ExceptionCode ec = 0;
+ clear(ec);
+
+ const UChar* ptr = data.characters();
+ const UChar* end = ptr + data.length();
+ while (ptr < end) {
+ const UChar* start = ptr;
+ while (ptr < end && *ptr != delimiter && !isWhitespace(*ptr))
+ ptr++;
+ if (ptr == start)
+ break;
+ appendItem(String(start, ptr - start), ec);
+ skipOptionalSpacesOrDelimiter(ptr, end, delimiter);
+ }
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGStringList.h b/WebCore/svg/SVGStringList.h
new file mode 100644
index 0000000..1cbe9d2
--- /dev/null
+++ b/WebCore/svg/SVGStringList.h
@@ -0,0 +1,47 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGStringList_h
+#define SVGStringList_h
+
+#if ENABLE(SVG)
+#include "PlatformString.h"
+#include "SVGList.h"
+
+namespace WebCore {
+
+ class SVGStringList : public SVGList<String> {
+ public:
+ static PassRefPtr<SVGStringList> create(const QualifiedName& attributeName) { return adoptRef(new SVGStringList(attributeName)); }
+ virtual ~SVGStringList();
+
+ void reset(const String& str);
+ void parse(const String& data, UChar delimiter = ',');
+
+ private:
+ SVGStringList(const QualifiedName&);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGStringList_h
diff --git a/WebCore/svg/SVGStringList.idl b/WebCore/svg/SVGStringList.idl
new file mode 100644
index 0000000..7bdd5ed
--- /dev/null
+++ b/WebCore/svg/SVGStringList.idl
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGStringList {
+ readonly attribute unsigned long numberOfItems;
+
+ void clear()
+ raises(core::DOMException);
+ core::DOMString initialize(in core::DOMString item)
+ raises(core::DOMException, SVGException);
+ core::DOMString getItem(in unsigned long index)
+ raises(core::DOMException);
+ core::DOMString insertItemBefore(in core::DOMString item, in unsigned long index)
+ raises(core::DOMException, SVGException);
+ core::DOMString replaceItem(in core::DOMString item, in unsigned long index)
+ raises(core::DOMException, SVGException);
+ core::DOMString removeItem(in unsigned long index)
+ raises(core::DOMException);
+ core::DOMString appendItem(in core::DOMString item)
+ raises(core::DOMException, SVGException);
+ };
+
+}
diff --git a/WebCore/svg/SVGStylable.cpp b/WebCore/svg/SVGStylable.cpp
new file mode 100644
index 0000000..5d063c3
--- /dev/null
+++ b/WebCore/svg/SVGStylable.cpp
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGStylable.h"
+
+namespace WebCore {
+
+SVGStylable::SVGStylable()
+{
+}
+
+SVGStylable::~SVGStylable()
+{
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGStylable.h b/WebCore/svg/SVGStylable.h
new file mode 100644
index 0000000..ade5c2f
--- /dev/null
+++ b/WebCore/svg/SVGStylable.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGStylable_h
+#define SVGStylable_h
+
+#if ENABLE(SVG)
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+ class CSSValue;
+ class CSSStyleDeclaration;
+ class String;
+ class QualifiedName;
+
+ class SVGStylable {
+ public:
+ SVGStylable();
+ virtual ~SVGStylable();
+
+ virtual CSSStyleDeclaration* style() = 0;
+ virtual PassRefPtr<CSSValue> getPresentationAttribute(const String&) = 0;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGStylable_h
diff --git a/WebCore/svg/SVGStylable.idl b/WebCore/svg/SVGStylable.idl
new file mode 100644
index 0000000..731d818
--- /dev/null
+++ b/WebCore/svg/SVGStylable.idl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2007 Rob Buis <rwlbuis@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, ObjCProtocol] SVGStylable {
+ readonly attribute SVGAnimatedString className;
+ readonly attribute css::CSSStyleDeclaration style;
+
+ css::CSSValue getPresentationAttribute(in core::DOMString name);
+ };
+
+}
diff --git a/WebCore/svg/SVGStyleElement.cpp b/WebCore/svg/SVGStyleElement.cpp
new file mode 100644
index 0000000..c3dbd33
--- /dev/null
+++ b/WebCore/svg/SVGStyleElement.cpp
@@ -0,0 +1,137 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Apple Computer, Inc.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGStyleElement.h"
+
+#include "CSSStyleSheet.h"
+#include "Document.h"
+#include "ExceptionCode.h"
+#include "HTMLNames.h"
+#include "XMLNames.h"
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+SVGStyleElement::SVGStyleElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+ , m_createdByParser(false)
+{
+}
+
+const AtomicString& SVGStyleElement::xmlspace() const
+{
+ return getAttribute(XMLNames::spaceAttr);
+}
+
+void SVGStyleElement::setXmlspace(const AtomicString&, ExceptionCode& ec)
+{
+ ec = NO_MODIFICATION_ALLOWED_ERR;
+}
+
+const AtomicString& SVGStyleElement::type() const
+{
+ static const AtomicString defaultValue("text/css");
+ const AtomicString& n = getAttribute(typeAttr);
+ return n.isNull() ? defaultValue : n;
+}
+
+void SVGStyleElement::setType(const AtomicString&, ExceptionCode& ec)
+{
+ ec = NO_MODIFICATION_ALLOWED_ERR;
+}
+
+const AtomicString& SVGStyleElement::media() const
+{
+ static const AtomicString defaultValue("all");
+ const AtomicString& n = getAttribute(mediaAttr);
+ return n.isNull() ? defaultValue : n;
+}
+
+void SVGStyleElement::setMedia(const AtomicString&, ExceptionCode& ec)
+{
+ ec = NO_MODIFICATION_ALLOWED_ERR;
+}
+
+String SVGStyleElement::title() const
+{
+ return getAttribute(titleAttr);
+}
+
+void SVGStyleElement::setTitle(const AtomicString&, ExceptionCode& ec)
+{
+ ec = NO_MODIFICATION_ALLOWED_ERR;
+}
+
+void SVGStyleElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == titleAttr && m_sheet)
+ m_sheet->setTitle(attr->value());
+ else
+ SVGElement::parseMappedAttribute(attr);
+}
+
+void SVGStyleElement::finishParsingChildren()
+{
+ StyleElement::sheet(this);
+ m_createdByParser = false;
+ SVGElement::finishParsingChildren();
+}
+
+void SVGStyleElement::insertedIntoDocument()
+{
+ SVGElement::insertedIntoDocument();
+
+ if (!m_createdByParser)
+ StyleElement::insertedIntoDocument(document(), this);
+}
+
+void SVGStyleElement::removedFromDocument()
+{
+ SVGElement::removedFromDocument();
+ StyleElement::removedFromDocument(document());
+}
+
+void SVGStyleElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+ StyleElement::process(this);
+}
+
+StyleSheet* SVGStyleElement::sheet()
+{
+ return StyleElement::sheet(this);
+}
+
+bool SVGStyleElement::sheetLoaded()
+{
+ document()->removePendingSheet();
+ return true;
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGStyleElement.h b/WebCore/svg/SVGStyleElement.h
new file mode 100644
index 0000000..f0774aa
--- /dev/null
+++ b/WebCore/svg/SVGStyleElement.h
@@ -0,0 +1,71 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGStyleElement_h
+#define SVGStyleElement_h
+#if ENABLE(SVG)
+
+#include <SVGElement.h>
+#include "StyleElement.h"
+
+namespace WebCore {
+
+ class SVGStyleElement : public SVGElement, public StyleElement {
+ public:
+ SVGStyleElement(const QualifiedName&, Document*);
+
+ // Derived from: 'Element'
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+
+ void setCreatedByParser(bool createdByParser) { m_createdByParser = createdByParser; }
+ virtual void finishParsingChildren();
+
+ // 'SVGStyleElement' functions
+ const AtomicString& xmlspace() const;
+ void setXmlspace(const AtomicString&, ExceptionCode&);
+
+ virtual bool sheetLoaded();
+
+ virtual const AtomicString& type() const;
+ void setType(const AtomicString&, ExceptionCode&);
+
+ virtual const AtomicString& media() const;
+ void setMedia(const AtomicString&, ExceptionCode&);
+
+ virtual String title() const;
+ void setTitle(const AtomicString&, ExceptionCode&);
+
+ StyleSheet* sheet();
+
+ protected:
+ bool m_createdByParser;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGStyleElement_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGStyleElement.idl b/WebCore/svg/SVGStyleElement.idl
new file mode 100644
index 0000000..ba065d9
--- /dev/null
+++ b/WebCore/svg/SVGStyleElement.idl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGStyleElement : SVGElement {
+ attribute AtomicString xmlspace
+ setter raises(DOMException);
+ attribute core::DOMString type
+ setter raises(DOMException);
+ attribute core::DOMString media
+ setter raises(DOMException);
+ attribute core::DOMString title
+ setter raises(DOMException);
+ };
+
+}
diff --git a/WebCore/svg/SVGStyledElement.cpp b/WebCore/svg/SVGStyledElement.cpp
new file mode 100644
index 0000000..127f7e0
--- /dev/null
+++ b/WebCore/svg/SVGStyledElement.cpp
@@ -0,0 +1,290 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2007 Rob Buis <buis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGStyledElement.h"
+
+#include "Attr.h"
+#include "CSSParser.h"
+#include "CSSStyleSelector.h"
+#include "CString.h"
+#include "Document.h"
+#include "HTMLNames.h"
+#include "PlatformString.h"
+#include "SVGElement.h"
+#include "SVGElementInstance.h"
+#include "SVGNames.h"
+#include "RenderObject.h"
+#include "SVGRenderStyle.h"
+#include "SVGResource.h"
+#include "SVGSVGElement.h"
+#include <wtf/Assertions.h>
+
+namespace WebCore {
+
+using namespace SVGNames;
+
+SVGStyledElement::SVGStyledElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+{
+}
+
+SVGStyledElement::~SVGStyledElement()
+{
+ SVGResource::removeClient(this);
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGStyledElement, String, String, string, ClassName, className, HTMLNames::classAttr, m_className)
+
+bool SVGStyledElement::rendererIsNeeded(RenderStyle* style)
+{
+ // http://www.w3.org/TR/SVG/extend.html#PrivateData
+ // Prevent anything other than SVG renderers from appearing in our render tree
+ // Spec: SVG allows inclusion of elements from foreign namespaces anywhere
+ // with the SVG content. In general, the SVG user agent will include the unknown
+ // elements in the DOM but will otherwise ignore unknown elements.
+ if (!parentNode() || parentNode()->isSVGElement())
+ return StyledElement::rendererIsNeeded(style);
+
+ return false;
+}
+
+static void mapAttributeToCSSProperty(HashMap<AtomicStringImpl*, int>* propertyNameToIdMap, const QualifiedName& attrName)
+{
+ int propertyId = cssPropertyID(attrName.localName());
+ ASSERT(propertyId > 0);
+ propertyNameToIdMap->set(attrName.localName().impl(), propertyId);
+}
+
+int SVGStyledElement::cssPropertyIdForSVGAttributeName(const QualifiedName& attrName)
+{
+ if (!attrName.namespaceURI().isNull())
+ return 0;
+
+ static HashMap<AtomicStringImpl*, int>* propertyNameToIdMap = 0;
+ if (!propertyNameToIdMap) {
+ propertyNameToIdMap = new HashMap<AtomicStringImpl*, int>;
+ // This is a list of all base CSS and SVG CSS properties which are exposed as SVG XML attributes
+ mapAttributeToCSSProperty(propertyNameToIdMap, alignment_baselineAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, baseline_shiftAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, clipAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, clip_pathAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, clip_ruleAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, colorAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, color_interpolationAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, color_interpolation_filtersAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, color_profileAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, color_renderingAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, cursorAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, directionAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, displayAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, dominant_baselineAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, enable_backgroundAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, fillAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, fill_opacityAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, fill_ruleAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, filterAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, flood_colorAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, flood_opacityAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, font_familyAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, font_sizeAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, font_stretchAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, font_styleAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, font_variantAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, font_weightAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, glyph_orientation_horizontalAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, glyph_orientation_verticalAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, image_renderingAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, kerningAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, letter_spacingAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, lighting_colorAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, marker_endAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, marker_midAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, marker_startAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, maskAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, opacityAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, overflowAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, pointer_eventsAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, shape_renderingAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, stop_colorAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, stop_opacityAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, strokeAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, stroke_dasharrayAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, stroke_dashoffsetAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, stroke_linecapAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, stroke_linejoinAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, stroke_miterlimitAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, stroke_opacityAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, stroke_widthAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, text_anchorAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, text_decorationAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, text_renderingAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, unicode_bidiAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, visibilityAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, word_spacingAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, writing_modeAttr);
+ }
+
+ return propertyNameToIdMap->get(attrName.localName().impl());
+}
+
+bool SVGStyledElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
+{
+ if (SVGStyledElement::cssPropertyIdForSVGAttributeName(attrName) > 0) {
+ result = eSVG;
+ return false;
+ }
+ return SVGElement::mapToEntry(attrName, result);
+}
+
+void SVGStyledElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ // NOTE: Any subclass which overrides parseMappedAttribute for a property handled by
+ // cssPropertyIdForSVGAttributeName will also have to override mapToEntry to disable the default eSVG mapping
+ int propId = SVGStyledElement::cssPropertyIdForSVGAttributeName(attr->name());
+ if (propId > 0) {
+ addCSSProperty(attr, propId, attr->value());
+ setChanged();
+ return;
+ }
+
+ // id and class are handled by StyledElement
+ SVGElement::parseMappedAttribute(attr);
+}
+
+bool SVGStyledElement::isKnownAttribute(const QualifiedName& attrName)
+{
+ // Recognize all style related SVG CSS properties
+ int propId = SVGStyledElement::cssPropertyIdForSVGAttributeName(attrName);
+ if (propId > 0)
+ return true;
+
+ return (attrName == HTMLNames::idAttr || attrName == HTMLNames::styleAttr);
+}
+
+void SVGStyledElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGElement::svgAttributeChanged(attrName);
+
+ // If we're the child of a resource element, be sure to invalidate it.
+ invalidateResourcesInAncestorChain();
+
+ SVGDocumentExtensions* extensions = document()->accessSVGExtensions();
+ if (!extensions)
+ return;
+
+ // TODO: Fix bug http://bugs.webkit.org/show_bug.cgi?id=15430 (SVGElementInstances should rebuild themselves lazily)
+
+ // In case we're referenced by a <use> element, we have element instances registered
+ // to us in the SVGDocumentExtensions. If notifyAttributeChange() is called, we need
+ // to recursively update all children including ourselves.
+ updateElementInstance(extensions);
+}
+
+void SVGStyledElement::invalidateResourcesInAncestorChain() const
+{
+ Node* node = parentNode();
+ while (node) {
+ if (!node->isSVGElement())
+ break;
+
+ SVGElement* element = static_cast<SVGElement*>(node);
+ if (SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(element->isStyled() ? element : 0)) {
+ if (SVGResource* resource = styledElement->canvasResource())
+ resource->invalidate();
+ }
+
+ node = node->parentNode();
+ }
+}
+
+void SVGStyledElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+ if (document()->parsing())
+ return;
+
+ SVGDocumentExtensions* extensions = document()->accessSVGExtensions();
+ if (!extensions)
+ return;
+
+ // TODO: Fix bug http://bugs.webkit.org/show_bug.cgi?id=15430 (SVGElementInstances should rebuild themselves lazily)
+
+ // In case we're referenced by a <use> element, we have element instances registered
+ // to us in the SVGDocumentExtensions. If childrenChanged() is called, we need
+ // to recursively update all children including ourselves.
+ updateElementInstance(extensions);
+}
+
+void SVGStyledElement::updateElementInstance(SVGDocumentExtensions* extensions) const
+{
+ SVGStyledElement* nonConstThis = const_cast<SVGStyledElement*>(this);
+ HashSet<SVGElementInstance*>* set = extensions->instancesForElement(nonConstThis);
+ if (!set || set->isEmpty())
+ return;
+
+ // We need to be careful here, as the instancesForElement
+ // hash set may be modified after we call updateInstance!
+ HashSet<SVGElementInstance*> localCopy;
+
+ // First create a local copy of the hashset
+ HashSet<SVGElementInstance*>::const_iterator it1 = set->begin();
+ const HashSet<SVGElementInstance*>::const_iterator end1 = set->end();
+
+ for (; it1 != end1; ++it1)
+ localCopy.add(*it1);
+
+ // Actually nofify instances to update
+ HashSet<SVGElementInstance*>::const_iterator it2 = localCopy.begin();
+ const HashSet<SVGElementInstance*>::const_iterator end2 = localCopy.end();
+
+ for (; it2 != end2; ++it2)
+ (*it2)->updateInstance(nonConstThis);
+}
+
+RenderStyle* SVGStyledElement::resolveStyle(RenderStyle* parentStyle)
+{
+ if (renderer()) {
+ RenderStyle* renderStyle = renderer()->style();
+ renderStyle->ref();
+ return renderStyle;
+ }
+
+ return document()->styleSelector()->styleForElement(this, parentStyle);
+}
+
+PassRefPtr<CSSValue> SVGStyledElement::getPresentationAttribute(const String& name)
+{
+ MappedAttribute* cssSVGAttr = mappedAttributes()->getAttributeItem(name);
+ if (!cssSVGAttr || !cssSVGAttr->style())
+ return 0;
+ return cssSVGAttr->style()->getPropertyCSSValue(name);
+}
+
+void SVGStyledElement::detach()
+{
+ SVGResource::removeClient(this);
+ SVGElement::detach();
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGStyledElement.h b/WebCore/svg/SVGStyledElement.h
new file mode 100644
index 0000000..0d798ab
--- /dev/null
+++ b/WebCore/svg/SVGStyledElement.h
@@ -0,0 +1,80 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGStyledElement_h
+#define SVGStyledElement_h
+
+#if ENABLE(SVG)
+#include "AffineTransform.h"
+#include "Path.h"
+#include "SVGElement.h"
+#include "SVGLength.h"
+#include "SVGResource.h"
+#include "SVGStylable.h"
+
+namespace WebCore {
+
+ class SVGStyledElement : public SVGElement,
+ public SVGStylable {
+ public:
+ SVGStyledElement(const QualifiedName&, Document*);
+ virtual ~SVGStyledElement();
+
+ virtual bool isStyled() const { return true; }
+ virtual bool supportsMarkers() const { return false; }
+
+ virtual PassRefPtr<CSSValue> getPresentationAttribute(const String& name);
+ virtual CSSStyleDeclaration* style() { return StyledElement::style(); }
+
+ bool isKnownAttribute(const QualifiedName&);
+
+ virtual bool rendererIsNeeded(RenderStyle*);
+ virtual SVGResource* canvasResource() { return 0; }
+
+ virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+
+ // Centralized place to force a manual style resolution. Hacky but needed for now.
+ RenderStyle* resolveStyle(RenderStyle* parentStyle);
+
+ void invalidateResourcesInAncestorChain() const;
+ virtual void detach();
+
+ protected:
+ virtual bool hasRelativeValues() const { return true; }
+
+ static int cssPropertyIdForSVGAttributeName(const QualifiedName&);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGStyledElement, String, String, ClassName, className)
+
+ void updateElementInstance(SVGDocumentExtensions*) const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGStyledElement
diff --git a/WebCore/svg/SVGStyledLocatableElement.cpp b/WebCore/svg/SVGStyledLocatableElement.cpp
new file mode 100644
index 0000000..eaed36d
--- /dev/null
+++ b/WebCore/svg/SVGStyledLocatableElement.cpp
@@ -0,0 +1,72 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGStyledLocatableElement.h"
+
+#include "RenderPath.h"
+#include "SVGElement.h"
+#include "AffineTransform.h"
+#include "SVGSVGElement.h"
+
+namespace WebCore {
+
+SVGStyledLocatableElement::SVGStyledLocatableElement(const QualifiedName& tagName, Document* doc)
+ : SVGLocatable()
+ , SVGStyledElement(tagName, doc)
+{
+}
+
+SVGStyledLocatableElement::~SVGStyledLocatableElement()
+{
+}
+
+SVGElement* SVGStyledLocatableElement::nearestViewportElement() const
+{
+ return SVGLocatable::nearestViewportElement(this);
+}
+
+SVGElement* SVGStyledLocatableElement::farthestViewportElement() const
+{
+ return SVGLocatable::farthestViewportElement(this);
+}
+
+FloatRect SVGStyledLocatableElement::getBBox() const
+{
+ return SVGLocatable::getBBox(this);
+}
+
+AffineTransform SVGStyledLocatableElement::getCTM() const
+{
+ return SVGLocatable::getCTM(this);
+}
+
+AffineTransform SVGStyledLocatableElement::getScreenCTM() const
+{
+ return SVGLocatable::getScreenCTM(this);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGStyledLocatableElement.h b/WebCore/svg/SVGStyledLocatableElement.h
new file mode 100644
index 0000000..9af3337
--- /dev/null
+++ b/WebCore/svg/SVGStyledLocatableElement.h
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGStyledLocatableElement_h
+#define SVGStyledLocatableElement_h
+
+#if ENABLE(SVG)
+#include "SVGLocatable.h"
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+ class SVGElement;
+
+ class SVGStyledLocatableElement : public SVGStyledElement,
+ virtual public SVGLocatable {
+ public:
+ SVGStyledLocatableElement(const QualifiedName&, Document*);
+ virtual ~SVGStyledLocatableElement();
+
+ virtual bool isStyledLocatable() const { return true; }
+
+ virtual SVGElement* nearestViewportElement() const;
+ virtual SVGElement* farthestViewportElement() const;
+
+ virtual FloatRect getBBox() const;
+ virtual AffineTransform getCTM() const;
+ virtual AffineTransform getScreenCTM() const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGStyledLocatableElement_h
diff --git a/WebCore/svg/SVGStyledTransformableElement.cpp b/WebCore/svg/SVGStyledTransformableElement.cpp
new file mode 100644
index 0000000..28ce33c
--- /dev/null
+++ b/WebCore/svg/SVGStyledTransformableElement.cpp
@@ -0,0 +1,111 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGStyledTransformableElement.h"
+
+#include "Attr.h"
+#include "RegularExpression.h"
+#include "RenderPath.h"
+#include "SVGDocument.h"
+#include "AffineTransform.h"
+#include "SVGStyledElement.h"
+#include "SVGTransformList.h"
+
+namespace WebCore {
+
+SVGStyledTransformableElement::SVGStyledTransformableElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledLocatableElement(tagName, doc)
+ , SVGTransformable()
+ , m_transform(SVGTransformList::create(SVGNames::transformAttr))
+{
+}
+
+SVGStyledTransformableElement::~SVGStyledTransformableElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGStyledTransformableElement, SVGTransformList*, TransformList, transformList, Transform, transform, SVGNames::transformAttr, m_transform.get())
+
+AffineTransform SVGStyledTransformableElement::getCTM() const
+{
+ return SVGTransformable::getCTM(this);
+}
+
+AffineTransform SVGStyledTransformableElement::getScreenCTM() const
+{
+ return SVGTransformable::getScreenCTM(this);
+}
+
+AffineTransform SVGStyledTransformableElement::animatedLocalTransform() const
+{
+ return transform()->concatenate().matrix();
+}
+
+void SVGStyledTransformableElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::transformAttr) {
+ SVGTransformList* localTransforms = transformBaseValue();
+
+ ExceptionCode ec = 0;
+ localTransforms->clear(ec);
+
+ if (!SVGTransformable::parseTransformAttribute(localTransforms, attr->value()))
+ localTransforms->clear(ec);
+ else
+ setTransformBaseValue(localTransforms);
+ } else
+ SVGStyledLocatableElement::parseMappedAttribute(attr);
+}
+
+bool SVGStyledTransformableElement::isKnownAttribute(const QualifiedName& attrName)
+{
+ return SVGTransformable::isKnownAttribute(attrName) ||
+ SVGStyledLocatableElement::isKnownAttribute(attrName);
+}
+
+SVGElement* SVGStyledTransformableElement::nearestViewportElement() const
+{
+ return SVGTransformable::nearestViewportElement(this);
+}
+
+SVGElement* SVGStyledTransformableElement::farthestViewportElement() const
+{
+ return SVGTransformable::farthestViewportElement(this);
+}
+
+FloatRect SVGStyledTransformableElement::getBBox() const
+{
+ return SVGTransformable::getBBox(this);
+}
+
+RenderObject* SVGStyledTransformableElement::createRenderer(RenderArena* arena, RenderStyle* style)
+{
+ // By default, any subclass is expected to do path-based drawing
+ return new (arena) RenderPath(style, this);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGStyledTransformableElement.h b/WebCore/svg/SVGStyledTransformableElement.h
new file mode 100644
index 0000000..8e23a51
--- /dev/null
+++ b/WebCore/svg/SVGStyledTransformableElement.h
@@ -0,0 +1,67 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGStyledTransformableElement_h
+#define SVGStyledTransformableElement_h
+
+#if ENABLE(SVG)
+#include "SVGStyledLocatableElement.h"
+#include "SVGTransformable.h"
+
+namespace WebCore {
+
+ class AffineTransform;
+ class SVGTransformList;
+
+ class SVGStyledTransformableElement : public SVGStyledLocatableElement,
+ public SVGTransformable {
+ public:
+ SVGStyledTransformableElement(const QualifiedName&, Document*);
+ virtual ~SVGStyledTransformableElement();
+
+ virtual bool isStyledTransformable() const { return true; }
+
+ virtual AffineTransform getCTM() const;
+ virtual AffineTransform getScreenCTM() const;
+ virtual SVGElement* nearestViewportElement() const;
+ virtual SVGElement* farthestViewportElement() const;
+
+ virtual AffineTransform animatedLocalTransform() const;
+
+ virtual FloatRect getBBox() const;
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ bool isKnownAttribute(const QualifiedName&);
+
+ // "base class" methods for all the elements which render as paths
+ virtual Path toPathData() const { return Path(); }
+ virtual Path toClipPath() const { return toPathData(); }
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ protected:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGStyledTransformableElement, SVGTransformList*, RefPtr<SVGTransformList>, Transform, transform)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGStyledTransformableElement_h
diff --git a/WebCore/svg/SVGSwitchElement.cpp b/WebCore/svg/SVGSwitchElement.cpp
new file mode 100644
index 0000000..2867d00
--- /dev/null
+++ b/WebCore/svg/SVGSwitchElement.cpp
@@ -0,0 +1,66 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGSwitchElement.h"
+
+#include "RenderSVGTransformableContainer.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+SVGSwitchElement::SVGSwitchElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+{
+}
+
+SVGSwitchElement::~SVGSwitchElement()
+{
+}
+
+bool SVGSwitchElement::childShouldCreateRenderer(Node* child) const
+{
+ for (Node* n = firstChild(); n != 0; n = n->nextSibling()) {
+ if (n->isSVGElement()) {
+ SVGElement* element = static_cast<SVGElement*>(n);
+ if (element && element->isValid())
+ return (n == child); // Only allow this child if it's the first valid child
+ }
+ }
+
+ return false;
+}
+
+RenderObject* SVGSwitchElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+ return new (arena) RenderSVGTransformableContainer(this);
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGSwitchElement.h b/WebCore/svg/SVGSwitchElement.h
new file mode 100644
index 0000000..3bfc275
--- /dev/null
+++ b/WebCore/svg/SVGSwitchElement.h
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGSwitchElement_h
+#define SVGSwitchElement_h
+#if ENABLE(SVG)
+
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTests.h"
+
+namespace WebCore
+{
+ class SVGSwitchElement : public SVGStyledTransformableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired
+ {
+ public:
+ SVGSwitchElement(const QualifiedName&, Document*);
+ virtual ~SVGSwitchElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ virtual bool childShouldCreateRenderer(Node*) const;
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ mutable bool m_insideRenderSection;
+
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGSwitchElement.idl b/WebCore/svg/SVGSwitchElement.idl
new file mode 100644
index 0000000..18690a4
--- /dev/null
+++ b/WebCore/svg/SVGSwitchElement.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGSwitchElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable {
+ };
+
+}
diff --git a/WebCore/svg/SVGSymbolElement.cpp b/WebCore/svg/SVGSymbolElement.cpp
new file mode 100644
index 0000000..073a13d
--- /dev/null
+++ b/WebCore/svg/SVGSymbolElement.cpp
@@ -0,0 +1,60 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGSymbolElement.h"
+
+#include "PlatformString.h"
+#include "SVGFitToViewBox.h"
+
+namespace WebCore {
+
+SVGSymbolElement::SVGSymbolElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , SVGFitToViewBox()
+{
+}
+
+SVGSymbolElement::~SVGSymbolElement()
+{
+}
+
+void SVGSymbolElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ if (SVGFitToViewBox::parseMappedAttribute(attr))
+ return;
+
+ SVGStyledElement::parseMappedAttribute(attr);
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGSymbolElement.h b/WebCore/svg/SVGSymbolElement.h
new file mode 100644
index 0000000..eaa0b94
--- /dev/null
+++ b/WebCore/svg/SVGSymbolElement.h
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGSymbolElement_h
+#define SVGSymbolElement_h
+#if ENABLE(SVG)
+
+#include "SVGExternalResourcesRequired.h"
+#include "SVGFitToViewBox.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledElement.h"
+
+namespace WebCore
+{
+ class SVGSymbolElement : public SVGStyledElement,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired,
+ public SVGFitToViewBox
+ {
+ public:
+ SVGSymbolElement(const QualifiedName&, Document*);
+ virtual ~SVGSymbolElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual bool shouldAttachChild(Element*) const { return false; }
+
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, FloatRect, ViewBox, viewBox)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, SVGPreserveAspectRatio*, PreserveAspectRatio, preserveAspectRatio)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGSymbolElement.idl b/WebCore/svg/SVGSymbolElement.idl
new file mode 100644
index 0000000..3e591a3
--- /dev/null
+++ b/WebCore/svg/SVGSymbolElement.idl
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGSymbolElement : SVGElement,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGFitToViewBox {
+ };
+
+}
diff --git a/WebCore/svg/SVGTRefElement.cpp b/WebCore/svg/SVGTRefElement.cpp
new file mode 100644
index 0000000..872e7c8
--- /dev/null
+++ b/WebCore/svg/SVGTRefElement.cpp
@@ -0,0 +1,82 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGTRefElement.h"
+
+#include "RenderSVGInline.h"
+#include "SVGDocument.h"
+#include "SVGNames.h"
+#include "Text.h"
+#include "XLinkNames.h"
+
+namespace WebCore {
+
+SVGTRefElement::SVGTRefElement(const QualifiedName& tagName, Document* doc)
+ : SVGTextPositioningElement(tagName, doc)
+ , SVGURIReference()
+{
+}
+
+SVGTRefElement::~SVGTRefElement()
+{
+}
+
+void SVGTRefElement::updateReferencedText()
+{
+ Element* target = document()->getElementById(SVGURIReference::getTarget(href()));
+ String textContent;
+ if (target && target->isSVGElement())
+ textContent = static_cast<SVGElement*>(target)->textContent();
+ ExceptionCode ignore = 0;
+ setTextContent(textContent, ignore);
+}
+
+void SVGTRefElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (SVGURIReference::parseMappedAttribute(attr)) {
+ updateReferencedText();
+ return;
+ }
+
+ SVGTextPositioningElement::parseMappedAttribute(attr);
+}
+
+bool SVGTRefElement::childShouldCreateRenderer(Node* child) const
+{
+ if (child->isTextNode() || child->hasTagName(SVGNames::tspanTag) ||
+ child->hasTagName(SVGNames::trefTag))
+ return true;
+ return false;
+}
+
+RenderObject* SVGTRefElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+ return new (arena) RenderSVGInline(this);
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGTRefElement.h b/WebCore/svg/SVGTRefElement.h
new file mode 100644
index 0000000..16ea5c3
--- /dev/null
+++ b/WebCore/svg/SVGTRefElement.h
@@ -0,0 +1,57 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGTRefElement_h
+#define SVGTRefElement_h
+#if ENABLE(SVG)
+
+#include "SVGTextPositioningElement.h"
+#include "SVGURIReference.h"
+
+namespace WebCore
+{
+ class SVGTRefElement : public SVGTextPositioningElement, public SVGURIReference
+ {
+ public:
+ SVGTRefElement(const QualifiedName&, Document*);
+ virtual ~SVGTRefElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+ bool childShouldCreateRenderer(Node*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
+
+ void updateReferencedText();
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGTRefElement.idl b/WebCore/svg/SVGTRefElement.idl
new file mode 100644
index 0000000..60bd5b2
--- /dev/null
+++ b/WebCore/svg/SVGTRefElement.idl
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGTRefElement : SVGTextPositioningElement,
+ SVGURIReference {
+ };
+
+}
diff --git a/WebCore/svg/SVGTSpanElement.cpp b/WebCore/svg/SVGTSpanElement.cpp
new file mode 100644
index 0000000..45a7727
--- /dev/null
+++ b/WebCore/svg/SVGTSpanElement.cpp
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGTSpanElement.h"
+
+#include "RenderInline.h"
+#include "RenderSVGTSpan.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+SVGTSpanElement::SVGTSpanElement(const QualifiedName& tagName, Document* doc)
+ : SVGTextPositioningElement(tagName, doc)
+{
+}
+
+SVGTSpanElement::~SVGTSpanElement()
+{
+}
+
+bool SVGTSpanElement::childShouldCreateRenderer(Node* child) const
+{
+ if (child->isTextNode() || child->hasTagName(SVGNames::tspanTag) ||
+ child->hasTagName(SVGNames::trefTag) || child->hasTagName(SVGNames::textPathTag))
+ return true;
+
+ return false;
+}
+
+RenderObject* SVGTSpanElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+ return new (arena) RenderSVGTSpan(this);
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGTSpanElement.h b/WebCore/svg/SVGTSpanElement.h
new file mode 100644
index 0000000..f2d0303
--- /dev/null
+++ b/WebCore/svg/SVGTSpanElement.h
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGTSpanElement_h
+#define SVGTSpanElement_h
+#if ENABLE(SVG)
+
+#include "SVGTextPositioningElement.h"
+
+namespace WebCore
+{
+ class SVGTSpanElement : public SVGTextPositioningElement
+ {
+ public:
+ SVGTSpanElement(const QualifiedName&, Document*);
+ virtual ~SVGTSpanElement();
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+ bool childShouldCreateRenderer(Node*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGTSpanElement.idl b/WebCore/svg/SVGTSpanElement.idl
new file mode 100644
index 0000000..28728ec
--- /dev/null
+++ b/WebCore/svg/SVGTSpanElement.idl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGTSpanElement : SVGTextPositioningElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGTests.cpp b/WebCore/svg/SVGTests.cpp
new file mode 100644
index 0000000..1a3cf01
--- /dev/null
+++ b/WebCore/svg/SVGTests.cpp
@@ -0,0 +1,122 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGTests.h"
+
+#include "DOMImplementation.h"
+#include "Language.h"
+#include "SVGElement.h"
+#include "SVGNames.h"
+#include "SVGStringList.h"
+
+namespace WebCore {
+
+SVGTests::SVGTests()
+{
+}
+
+SVGTests::~SVGTests()
+{
+}
+
+SVGStringList* SVGTests::requiredFeatures() const
+{
+ if (!m_features)
+ m_features = SVGStringList::create(SVGNames::requiredFeaturesAttr);
+
+ return m_features.get();
+}
+
+SVGStringList* SVGTests::requiredExtensions() const
+{
+ if (!m_extensions)
+ m_extensions = SVGStringList::create(SVGNames::requiredExtensionsAttr);
+
+ return m_extensions.get();
+}
+
+SVGStringList* SVGTests::systemLanguage() const
+{
+ if (!m_systemLanguage)
+ m_systemLanguage = SVGStringList::create(SVGNames::systemLanguageAttr);
+
+ return m_systemLanguage.get();
+}
+
+bool SVGTests::hasExtension(const String&) const
+{
+ return false;
+}
+
+bool SVGTests::isValid() const
+{
+ ExceptionCode ec = 0;
+
+ if (m_features) {
+ for (unsigned long i = 0; i < m_features->numberOfItems(); i++) {
+ String value = m_features->getItem(i, ec);
+ if (value.isEmpty() || !DOMImplementation::instance()->hasFeature(value, String()))
+ return false;
+ }
+ }
+
+ if (m_systemLanguage) {
+ for (unsigned long i = 0; i < m_systemLanguage->numberOfItems(); i++)
+ if (m_systemLanguage->getItem(i, ec) != defaultLanguage().substring(0, 2))
+ return false;
+ }
+
+ if (m_extensions && m_extensions->numberOfItems() > 0)
+ return false;
+
+ return true;
+}
+
+bool SVGTests::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::requiredFeaturesAttr) {
+ requiredFeatures()->reset(attr->value());
+ return true;
+ } else if (attr->name() == SVGNames::requiredExtensionsAttr) {
+ requiredExtensions()->reset(attr->value());
+ return true;
+ } else if (attr->name() == SVGNames::systemLanguageAttr) {
+ systemLanguage()->reset(attr->value());
+ return true;
+ }
+
+ return false;
+}
+
+bool SVGTests::isKnownAttribute(const QualifiedName& attrName)
+{
+ return (attrName == SVGNames::requiredFeaturesAttr ||
+ attrName == SVGNames::requiredExtensionsAttr ||
+ attrName == SVGNames::systemLanguageAttr);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGTests.h b/WebCore/svg/SVGTests.h
new file mode 100644
index 0000000..2d82cb4
--- /dev/null
+++ b/WebCore/svg/SVGTests.h
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGTests_h
+#define SVGTests_h
+
+#if ENABLE(SVG)
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+ class MappedAttribute;
+ class String;
+ class SVGStringList;
+ class QualifiedName;
+
+ class SVGTests {
+ public:
+ SVGTests();
+ virtual ~SVGTests();
+
+ SVGStringList* requiredFeatures() const;
+ SVGStringList* requiredExtensions() const;
+ SVGStringList* systemLanguage() const;
+
+ bool hasExtension(const String&) const;
+
+ bool isValid() const;
+
+ bool parseMappedAttribute(MappedAttribute*);
+ bool isKnownAttribute(const QualifiedName&);
+
+ private:
+ mutable RefPtr<SVGStringList> m_features;
+ mutable RefPtr<SVGStringList> m_extensions;
+ mutable RefPtr<SVGStringList> m_systemLanguage;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGTests_h
diff --git a/WebCore/svg/SVGTests.idl b/WebCore/svg/SVGTests.idl
new file mode 100644
index 0000000..fe20a04
--- /dev/null
+++ b/WebCore/svg/SVGTests.idl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, ObjCProtocol] SVGTests {
+ readonly attribute SVGStringList requiredFeatures;
+ readonly attribute SVGStringList requiredExtensions;
+ readonly attribute SVGStringList systemLanguage;
+
+ boolean hasExtension(in core::DOMString extension);
+ };
+
+}
diff --git a/WebCore/svg/SVGTextContentElement.cpp b/WebCore/svg/SVGTextContentElement.cpp
new file mode 100644
index 0000000..03ed592
--- /dev/null
+++ b/WebCore/svg/SVGTextContentElement.cpp
@@ -0,0 +1,496 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGTextContentElement.h"
+
+#include "CSSPropertyNames.h"
+#include "CSSValueKeywords.h"
+#include "ExceptionCode.h"
+#include "FloatPoint.h"
+#include "FloatRect.h"
+#include "Frame.h"
+#include "Position.h"
+#include "RenderSVGText.h"
+#include "SelectionController.h"
+#include "SVGCharacterLayoutInfo.h"
+#include "SVGRootInlineBox.h"
+#include "SVGLength.h"
+#include "SVGInlineTextBox.h"
+#include "SVGNames.h"
+#include "XMLNames.h"
+
+namespace WebCore {
+
+SVGTextContentElement::SVGTextContentElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_textLength(this, LengthModeOther)
+ , m_lengthAdjust(LENGTHADJUST_SPACING)
+{
+}
+
+SVGTextContentElement::~SVGTextContentElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGTextContentElement, SVGLength, Length, length, TextLength, textLength, SVGNames::textLengthAttr, m_textLength)
+ANIMATED_PROPERTY_DEFINITIONS(SVGTextContentElement, int, Enumeration, enumeration, LengthAdjust, lengthAdjust, SVGNames::lengthAdjustAttr, m_lengthAdjust)
+
+static inline float cummulatedCharacterRangeLength(const Vector<SVGChar>::iterator& start, const Vector<SVGChar>::iterator& end, SVGInlineTextBox* textBox,
+ int startOffset, long startPosition, long length, bool isVerticalText, long& atCharacter)
+{
+ float textLength = 0.0f;
+ RenderStyle* style = textBox->textObject()->style();
+
+ bool usesFullRange = (startPosition == -1 && length == -1);
+
+ for (Vector<SVGChar>::iterator it = start; it != end; ++it) {
+ if (usesFullRange || (atCharacter >= startPosition && atCharacter <= startPosition + length)) {
+ unsigned int newOffset = textBox->start() + (it - start) + startOffset;
+
+ // Take RTL text into account and pick right glyph width/height.
+ if (textBox->m_reversed)
+ newOffset = textBox->start() + textBox->end() - newOffset;
+
+ if (isVerticalText)
+ textLength += textBox->calculateGlyphHeight(style, newOffset);
+ else
+ textLength += textBox->calculateGlyphWidth(style, newOffset);
+ }
+
+ if (!usesFullRange) {
+ if (atCharacter < startPosition + length)
+ atCharacter++;
+ else if (atCharacter == startPosition + length)
+ break;
+ }
+ }
+
+ return textLength;
+}
+
+// Helper class for querying certain glyph information
+struct SVGInlineTextBoxQueryWalker {
+ typedef enum {
+ NumberOfCharacters,
+ TextLength,
+ SubStringLength,
+ StartPosition,
+ EndPosition,
+ Extent,
+ Rotation,
+ CharacterNumberAtPosition
+ } QueryMode;
+
+ SVGInlineTextBoxQueryWalker(const SVGTextContentElement* reference, QueryMode mode)
+ : m_reference(reference)
+ , m_mode(mode)
+ , m_queryStartPosition(0)
+ , m_queryLength(0)
+ , m_queryPointInput()
+ , m_queryLongResult(0)
+ , m_queryFloatResult(0.0f)
+ , m_queryPointResult()
+ , m_queryRectResult()
+ , m_stopProcessing(true)
+ , m_atCharacter(0)
+ {
+ }
+
+ void chunkPortionCallback(SVGInlineTextBox* textBox, int startOffset, const AffineTransform& chunkCtm,
+ const Vector<SVGChar>::iterator& start, const Vector<SVGChar>::iterator& end)
+ {
+ RenderStyle* style = textBox->textObject()->style();
+ bool isVerticalText = style->svgStyle()->writingMode() == WM_TBRL || style->svgStyle()->writingMode() == WM_TB;
+
+ switch (m_mode) {
+ case NumberOfCharacters:
+ {
+ m_queryLongResult += (end - start);
+ m_stopProcessing = false;
+ return;
+ }
+ case TextLength:
+ {
+ float textLength = cummulatedCharacterRangeLength(start, end, textBox, startOffset, -1, -1, isVerticalText, m_atCharacter);
+
+ if (isVerticalText)
+ m_queryFloatResult += textLength;
+ else
+ m_queryFloatResult += textLength;
+
+ m_stopProcessing = false;
+ return;
+ }
+ case SubStringLength:
+ {
+ long startPosition = m_queryStartPosition;
+ long length = m_queryLength;
+
+ float textLength = cummulatedCharacterRangeLength(start, end, textBox, startOffset, startPosition, length, isVerticalText, m_atCharacter);
+
+ if (isVerticalText)
+ m_queryFloatResult += textLength;
+ else
+ m_queryFloatResult += textLength;
+
+ if (m_atCharacter == startPosition + length)
+ m_stopProcessing = true;
+ else
+ m_stopProcessing = false;
+
+ return;
+ }
+ case StartPosition:
+ {
+ for (Vector<SVGChar>::iterator it = start; it != end; ++it) {
+ if (m_atCharacter == m_queryStartPosition) {
+ m_queryPointResult = FloatPoint(it->x, it->y);
+ m_stopProcessing = true;
+ return;
+ }
+
+ m_atCharacter++;
+ }
+
+ m_stopProcessing = false;
+ return;
+ }
+ case EndPosition:
+ {
+ for (Vector<SVGChar>::iterator it = start; it != end; ++it) {
+ if (m_atCharacter == m_queryStartPosition) {
+ unsigned int newOffset = textBox->start() + (it - start) + startOffset;
+
+ // Take RTL text into account and pick right glyph width/height.
+ if (textBox->m_reversed)
+ newOffset = textBox->start() + textBox->end() - newOffset;
+
+ if (isVerticalText)
+ m_queryPointResult.move(it->x, it->y + textBox->calculateGlyphHeight(style, newOffset));
+ else
+ m_queryPointResult.move(it->x + textBox->calculateGlyphWidth(style, newOffset), it->y);
+
+ m_stopProcessing = true;
+ return;
+ }
+
+ m_atCharacter++;
+ }
+
+ m_stopProcessing = false;
+ return;
+ }
+ case Extent:
+ {
+ for (Vector<SVGChar>::iterator it = start; it != end; ++it) {
+ if (m_atCharacter == m_queryStartPosition) {
+ unsigned int newOffset = textBox->start() + (it - start) + startOffset;
+ m_queryRectResult = textBox->calculateGlyphBoundaries(style, newOffset, *it);
+ m_stopProcessing = true;
+ return;
+ }
+
+ m_atCharacter++;
+ }
+
+ m_stopProcessing = false;
+ return;
+ }
+ case Rotation:
+ {
+ for (Vector<SVGChar>::iterator it = start; it != end; ++it) {
+ if (m_atCharacter == m_queryStartPosition) {
+ m_queryFloatResult = it->angle;
+ m_stopProcessing = true;
+ return;
+ }
+
+ m_atCharacter++;
+ }
+
+ m_stopProcessing = false;
+ return;
+ }
+ case CharacterNumberAtPosition:
+ {
+ int offset = 0;
+ SVGChar* charAtPos = textBox->closestCharacterToPosition(m_queryPointInput.x(), m_queryPointInput.y(), offset);
+
+ offset += m_atCharacter;
+ if (charAtPos && offset > m_queryLongResult)
+ m_queryLongResult = offset;
+
+ m_atCharacter += end - start;
+ m_stopProcessing = false;
+ return;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ m_stopProcessing = true;
+ return;
+ }
+ }
+
+ void setQueryInputParameters(long startPosition, long length, FloatPoint referencePoint)
+ {
+ m_queryStartPosition = startPosition;
+ m_queryLength = length;
+ m_queryPointInput = referencePoint;
+ }
+
+ long longResult() const { return m_queryLongResult; }
+ float floatResult() const { return m_queryFloatResult; }
+ FloatPoint pointResult() const { return m_queryPointResult; }
+ FloatRect rectResult() const { return m_queryRectResult; }
+ bool stopProcessing() const { return m_stopProcessing; }
+
+private:
+ const SVGTextContentElement* m_reference;
+ QueryMode m_mode;
+
+ long m_queryStartPosition;
+ long m_queryLength;
+ FloatPoint m_queryPointInput;
+
+ long m_queryLongResult;
+ float m_queryFloatResult;
+ FloatPoint m_queryPointResult;
+ FloatRect m_queryRectResult;
+
+ bool m_stopProcessing;
+ long m_atCharacter;
+};
+
+static Vector<SVGInlineTextBox*> findInlineTextBoxInTextChunks(const SVGTextContentElement* element, const Vector<SVGTextChunk>& chunks)
+{
+ Vector<SVGTextChunk>::const_iterator it = chunks.begin();
+ const Vector<SVGTextChunk>::const_iterator end = chunks.end();
+
+ Vector<SVGInlineTextBox*> boxes;
+
+ for (; it != end; ++it) {
+ Vector<SVGInlineBoxCharacterRange>::const_iterator boxIt = it->boxes.begin();
+ const Vector<SVGInlineBoxCharacterRange>::const_iterator boxEnd = it->boxes.end();
+
+ for (; boxIt != boxEnd; ++boxIt) {
+ SVGInlineTextBox* textBox = static_cast<SVGInlineTextBox*>(boxIt->box);
+
+ Node* textElement = textBox->textObject()->parent()->element();
+ ASSERT(textElement);
+
+ if (textElement == element || textElement->parent() == element)
+ boxes.append(textBox);
+ }
+ }
+
+ return boxes;
+}
+
+static inline SVGRootInlineBox* rootInlineBoxForTextContentElement(const SVGTextContentElement* element)
+{
+ RenderObject* object = element->renderer();
+
+ if (!object || !object->isSVGText() || object->isText())
+ return 0;
+
+ RenderSVGText* svgText = static_cast<RenderSVGText*>(object);
+
+ // Find root inline box
+ SVGRootInlineBox* rootBox = static_cast<SVGRootInlineBox*>(svgText->firstRootBox());
+ if (!rootBox) {
+ // Layout is not sync yet!
+ element->document()->updateLayoutIgnorePendingStylesheets();
+ rootBox = static_cast<SVGRootInlineBox*>(svgText->firstRootBox());
+ }
+
+ ASSERT(rootBox);
+ return rootBox;
+}
+
+static inline SVGInlineTextBoxQueryWalker executeTextQuery(const SVGTextContentElement* element, SVGInlineTextBoxQueryWalker::QueryMode mode,
+ long startPosition = 0, long length = 0, FloatPoint referencePoint = FloatPoint())
+{
+ SVGRootInlineBox* rootBox = rootInlineBoxForTextContentElement(element);
+ if (!rootBox)
+ return SVGInlineTextBoxQueryWalker(0, mode);
+
+ // Find all inline text box associated with our renderer
+ Vector<SVGInlineTextBox*> textBoxes = findInlineTextBoxInTextChunks(element, rootBox->svgTextChunks());
+
+ // Walk text chunks to find chunks associated with our inline text box
+ SVGInlineTextBoxQueryWalker walkerCallback(element, mode);
+ walkerCallback.setQueryInputParameters(startPosition, length, referencePoint);
+
+ SVGTextChunkWalker<SVGInlineTextBoxQueryWalker> walker(&walkerCallback, &SVGInlineTextBoxQueryWalker::chunkPortionCallback);
+
+ Vector<SVGInlineTextBox*>::iterator it = textBoxes.begin();
+ Vector<SVGInlineTextBox*>::iterator end = textBoxes.end();
+
+ for (; it != end; ++it) {
+ rootBox->walkTextChunks(&walker, *it);
+
+ if (walkerCallback.stopProcessing())
+ break;
+ }
+
+ return walkerCallback;
+}
+
+long SVGTextContentElement::getNumberOfChars() const
+{
+ return executeTextQuery(this, SVGInlineTextBoxQueryWalker::NumberOfCharacters).longResult();
+}
+
+float SVGTextContentElement::getComputedTextLength() const
+{
+ return executeTextQuery(this, SVGInlineTextBoxQueryWalker::TextLength).floatResult();
+}
+
+float SVGTextContentElement::getSubStringLength(long charnum, unsigned long nchars, ExceptionCode& ec) const
+{
+ if (charnum < 0 || charnum > getNumberOfChars()) {
+ ec = INDEX_SIZE_ERR;
+ return 0.0f;
+ }
+
+ return executeTextQuery(this, SVGInlineTextBoxQueryWalker::SubStringLength, charnum, nchars).floatResult();
+}
+
+FloatPoint SVGTextContentElement::getStartPositionOfChar(long charnum, ExceptionCode& ec) const
+{
+ if (charnum < 0 || charnum > getNumberOfChars()) {
+ ec = INDEX_SIZE_ERR;
+ return FloatPoint();
+ }
+
+ return executeTextQuery(this, SVGInlineTextBoxQueryWalker::StartPosition, charnum).pointResult();
+}
+
+FloatPoint SVGTextContentElement::getEndPositionOfChar(long charnum, ExceptionCode& ec) const
+{
+ if (charnum < 0 || charnum > getNumberOfChars()) {
+ ec = INDEX_SIZE_ERR;
+ return FloatPoint();
+ }
+
+ return executeTextQuery(this, SVGInlineTextBoxQueryWalker::EndPosition, charnum).pointResult();
+}
+
+FloatRect SVGTextContentElement::getExtentOfChar(long charnum, ExceptionCode& ec) const
+{
+ if (charnum < 0 || charnum > getNumberOfChars()) {
+ ec = INDEX_SIZE_ERR;
+ return FloatRect();
+ }
+
+ return executeTextQuery(this, SVGInlineTextBoxQueryWalker::Extent, charnum).rectResult();
+}
+
+float SVGTextContentElement::getRotationOfChar(long charnum, ExceptionCode& ec) const
+{
+ if (charnum < 0 || charnum > getNumberOfChars()) {
+ ec = INDEX_SIZE_ERR;
+ return 0.0f;
+ }
+
+ return executeTextQuery(this, SVGInlineTextBoxQueryWalker::Rotation, charnum).floatResult();
+}
+
+long SVGTextContentElement::getCharNumAtPosition(const FloatPoint& point) const
+{
+ return executeTextQuery(this, SVGInlineTextBoxQueryWalker::CharacterNumberAtPosition, 0.0f, 0.0f, point).longResult();
+}
+
+void SVGTextContentElement::selectSubString(long charnum, long nchars, ExceptionCode& ec) const
+{
+ long numberOfChars = getNumberOfChars();
+ if (charnum < 0 || nchars < 0 || charnum > numberOfChars) {
+ ec = INDEX_SIZE_ERR;
+ return;
+ }
+
+ if (nchars > numberOfChars - charnum)
+ nchars = numberOfChars - charnum;
+
+ ASSERT(document());
+ ASSERT(document()->frame());
+
+ SelectionController* controller = document()->frame()->selectionController();
+ if (!controller)
+ return;
+
+ // Find selection start
+ VisiblePosition start(const_cast<SVGTextContentElement*>(this), 0, SEL_DEFAULT_AFFINITY);
+ for (long i = 0; i < charnum; ++i)
+ start = start.next();
+
+ // Find selection end
+ VisiblePosition end(start);
+ for (long i = 0; i < nchars; ++i)
+ end = end.next();
+
+ controller->setSelection(Selection(start, end));
+}
+
+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, CSS_PROP_WHITE_SPACE, CSS_VAL_PRE);
+ else
+ addCSSProperty(attr, CSS_PROP_WHITE_SPACE, CSS_VAL_NOWRAP);
+ }
+ return;
+ }
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+
+ SVGStyledElement::parseMappedAttribute(attr);
+ }
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGTextContentElement.h b/WebCore/svg/SVGTextContentElement.h
new file mode 100644
index 0000000..570ed6b
--- /dev/null
+++ b/WebCore/svg/SVGTextContentElement.h
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGTextContentElement_h
+#define SVGTextContentElement_h
+
+#if ENABLE(SVG)
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledElement.h"
+#include "SVGTests.h"
+
+namespace WebCore {
+ class SVGLength;
+
+ class SVGTextContentElement : public SVGStyledElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired
+ {
+ public:
+ enum SVGLengthAdjustType {
+ LENGTHADJUST_UNKNOWN = 0,
+ LENGTHADJUST_SPACING = 1,
+ LENGTHADJUST_SPACINGANDGLYPHS = 2
+ };
+
+ SVGTextContentElement(const QualifiedName&, Document*);
+ virtual ~SVGTextContentElement();
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+ virtual bool isTextContent() const { return true; }
+
+ // 'SVGTextContentElement' functions
+ long getNumberOfChars() const;
+ float getComputedTextLength() const;
+ float getSubStringLength(long charnum, unsigned long nchars, ExceptionCode&) const;
+ FloatPoint getStartPositionOfChar(long charnum, ExceptionCode&) const;
+ FloatPoint getEndPositionOfChar(long charnum, ExceptionCode&) const;
+ FloatRect getExtentOfChar(long charnum, ExceptionCode&) const;
+ float getRotationOfChar(long charnum, ExceptionCode&) const;
+ long getCharNumAtPosition(const FloatPoint&) const;
+ void selectSubString(long charnum, long nchars, ExceptionCode&) const;
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextContentElement, SVGLength, SVGLength, TextLength, textLength)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextContentElement, int, int, LengthAdjust, lengthAdjust)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGTextContentElement.idl b/WebCore/svg/SVGTextContentElement.idl
new file mode 100644
index 0000000..e4e0163
--- /dev/null
+++ b/WebCore/svg/SVGTextContentElement.idl
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor] SVGTextContentElement : SVGElement,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable {
+ // lengthAdjust Types
+ const unsigned short LENGTHADJUST_UNKNOWN = 0;
+ const unsigned short LENGTHADJUST_SPACING = 1;
+ const unsigned short LENGTHADJUST_SPACINGANDGLYPHS = 2;
+
+ readonly attribute SVGAnimatedLength textLength;
+ readonly attribute SVGAnimatedEnumeration lengthAdjust;
+
+ long getNumberOfChars();
+ float getComputedTextLength();
+ float getSubStringLength(in unsigned long offset,
+ in unsigned long length)
+ raises(DOMException);
+ SVGPoint getStartPositionOfChar(in unsigned long offset)
+ raises(DOMException);
+ SVGPoint getEndPositionOfChar(in unsigned long offset)
+ raises(DOMException);
+ SVGRect getExtentOfChar(in unsigned long offset)
+ raises(DOMException);
+ float getRotationOfChar(in unsigned long offset)
+ raises(DOMException);
+ long getCharNumAtPosition(in SVGPoint point);
+ void selectSubString(in unsigned long offset,
+ in unsigned long length)
+ raises(DOMException);
+ };
+
+}
diff --git a/WebCore/svg/SVGTextElement.cpp b/WebCore/svg/SVGTextElement.cpp
new file mode 100644
index 0000000..7b65fa2
--- /dev/null
+++ b/WebCore/svg/SVGTextElement.cpp
@@ -0,0 +1,115 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGTextElement.h"
+
+#include "AffineTransform.h"
+#include "FloatRect.h"
+#include "RenderSVGText.h"
+#include "SVGLengthList.h"
+#include "SVGRenderStyle.h"
+#include "SVGTSpanElement.h"
+#include "SVGTransformList.h"
+
+namespace WebCore {
+
+SVGTextElement::SVGTextElement(const QualifiedName& tagName, Document* doc)
+ : SVGTextPositioningElement(tagName, doc)
+ , SVGTransformable()
+ , m_transform(SVGTransformList::create(SVGNames::transformAttr))
+{
+}
+
+SVGTextElement::~SVGTextElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGTextElement, SVGTransformList*, TransformList, transformList, Transform, transform, SVGNames::transformAttr, m_transform.get())
+
+void SVGTextElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::transformAttr) {
+ SVGTransformList* localTransforms = transformBaseValue();
+
+ ExceptionCode ec = 0;
+ localTransforms->clear(ec);
+
+ if (!SVGTransformable::parseTransformAttribute(localTransforms, attr->value()))
+ localTransforms->clear(ec);
+ else {
+ setTransformBaseValue(localTransforms);
+ if (renderer())
+ renderer()->setNeedsLayout(true); // should be in setTransformBaseValue
+ }
+ } else
+ SVGTextPositioningElement::parseMappedAttribute(attr);
+}
+
+SVGElement* SVGTextElement::nearestViewportElement() const
+{
+ return SVGTransformable::nearestViewportElement(this);
+}
+
+SVGElement* SVGTextElement::farthestViewportElement() const
+{
+ return SVGTransformable::farthestViewportElement(this);
+}
+
+FloatRect SVGTextElement::getBBox() const
+{
+ return SVGTransformable::getBBox(this);
+}
+
+AffineTransform SVGTextElement::getScreenCTM() const
+{
+ return SVGTransformable::getScreenCTM(this);
+}
+
+AffineTransform SVGTextElement::getCTM() const
+{
+ return SVGTransformable::getCTM(this);
+}
+
+AffineTransform SVGTextElement::animatedLocalTransform() const
+{
+ return transform()->concatenate().matrix();
+}
+
+RenderObject* SVGTextElement::createRenderer(RenderArena* arena, RenderStyle* style)
+{
+ return new (arena) RenderSVGText(this);
+}
+
+bool SVGTextElement::childShouldCreateRenderer(Node* child) const
+{
+ if (child->isTextNode() || child->hasTagName(SVGNames::tspanTag) ||
+ child->hasTagName(SVGNames::trefTag) || child->hasTagName(SVGNames::aTag) || child->hasTagName(SVGNames::textPathTag))
+ return true;
+ return false;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGTextElement.h b/WebCore/svg/SVGTextElement.h
new file mode 100644
index 0000000..3e5c1e0
--- /dev/null
+++ b/WebCore/svg/SVGTextElement.h
@@ -0,0 +1,62 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGTextElement_h
+#define SVGTextElement_h
+
+#if ENABLE(SVG)
+#include "SVGTextPositioningElement.h"
+#include "SVGTransformable.h"
+
+namespace WebCore {
+
+ class SVGTextElement : public SVGTextPositioningElement,
+ public SVGTransformable {
+ public:
+ SVGTextElement(const QualifiedName&, Document*);
+ virtual ~SVGTextElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ virtual SVGElement* nearestViewportElement() const;
+ virtual SVGElement* farthestViewportElement() const;
+
+ virtual FloatRect getBBox() const;
+ virtual AffineTransform getCTM() const;
+ virtual AffineTransform getScreenCTM() const;
+ virtual AffineTransform animatedLocalTransform() const;
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+ virtual bool childShouldCreateRenderer(Node*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ mutable AffineTransform m_localMatrix;
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextElement, SVGTransformList*, RefPtr<SVGTransformList>, Transform, transform)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGTextElement.idl b/WebCore/svg/SVGTextElement.idl
new file mode 100644
index 0000000..046faa3
--- /dev/null
+++ b/WebCore/svg/SVGTextElement.idl
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGTextElement : SVGTextPositioningElement,
+ SVGTransformable {
+ };
+
+}
diff --git a/WebCore/svg/SVGTextPathElement.cpp b/WebCore/svg/SVGTextPathElement.cpp
new file mode 100644
index 0000000..47c08f5
--- /dev/null
+++ b/WebCore/svg/SVGTextPathElement.cpp
@@ -0,0 +1,108 @@
+/*
+ Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGTextPathElement.h"
+
+#include "AffineTransform.h"
+#include "FloatRect.h"
+#include "RenderSVGTextPath.h"
+#include "SVGLengthList.h"
+#include "SVGPathElement.h"
+#include "SVGRenderStyle.h"
+#include "SVGTextPathElement.h"
+#include "SVGTransformList.h"
+
+namespace WebCore {
+
+SVGTextPathElement::SVGTextPathElement(const QualifiedName& tagName, Document* doc)
+ : SVGTextContentElement(tagName, doc)
+ , SVGURIReference()
+ , m_startOffset(this, LengthModeOther)
+ , m_method(SVG_TEXTPATH_METHODTYPE_ALIGN)
+ , m_spacing(SVG_TEXTPATH_SPACINGTYPE_EXACT)
+{
+}
+
+SVGTextPathElement::~SVGTextPathElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGTextPathElement, SVGLength, Length, length, StartOffset, startOffset, SVGNames::startOffsetAttr, m_startOffset)
+ANIMATED_PROPERTY_DEFINITIONS(SVGTextPathElement, int, Enumeration, enumeration, Method, method, SVGNames::methodAttr, m_method)
+ANIMATED_PROPERTY_DEFINITIONS(SVGTextPathElement, int, Enumeration, enumeration, Spacing, spacing, SVGNames::spacingAttr, m_spacing)
+
+void SVGTextPathElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+
+ if (attr->name() == SVGNames::startOffsetAttr)
+ setStartOffsetBaseValue(SVGLength(this, 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);
+ }
+}
+
+RenderObject* SVGTextPathElement::createRenderer(RenderArena* arena, RenderStyle* style)
+{
+ return new (arena) RenderSVGTextPath(this);
+}
+
+bool SVGTextPathElement::childShouldCreateRenderer(Node* child) const
+{
+ if (child->isTextNode() || child->hasTagName(SVGNames::trefTag) ||
+ child->hasTagName(SVGNames::tspanTag) || child->hasTagName(SVGNames::textPathTag))
+ return true;
+
+ return false;
+}
+
+void SVGTextPathElement::insertedIntoDocument()
+{
+ SVGElement::insertedIntoDocument();
+
+ String id = SVGURIReference::getTarget(href());
+ Element* targetElement = ownerDocument()->getElementById(id);
+ if (!targetElement) {
+ document()->accessSVGExtensions()->addPendingResource(id, this);
+ return;
+ }
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGTextPathElement.h b/WebCore/svg/SVGTextPathElement.h
new file mode 100644
index 0000000..4db7a94
--- /dev/null
+++ b/WebCore/svg/SVGTextPathElement.h
@@ -0,0 +1,85 @@
+/*
+ Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGTextPathElement_h
+#define SVGTextPathElement_h
+
+#if ENABLE(SVG)
+#include "SVGTextContentElement.h"
+
+#include "SVGURIReference.h"
+
+namespace WebCore
+{
+ enum SVGTextPathMethodType {
+ SVG_TEXTPATH_METHODTYPE_UNKNOWN = 0,
+ SVG_TEXTPATH_METHODTYPE_ALIGN = 1,
+ SVG_TEXTPATH_METHODTYPE_STRETCH = 2
+ };
+
+ enum SVGTextPathSpacingType {
+ SVG_TEXTPATH_SPACINGTYPE_UNKNOWN = 0,
+ SVG_TEXTPATH_SPACINGTYPE_AUTO = 1,
+ SVG_TEXTPATH_SPACINGTYPE_EXACT = 2
+ };
+
+ class SVGTextPathElement : public SVGTextContentElement,
+ public SVGURIReference
+ {
+ public:
+ // Forward declare these enums in the w3c naming scheme, for IDL generation
+ enum {
+ TEXTPATH_METHODTYPE_UNKNOWN = SVG_TEXTPATH_METHODTYPE_UNKNOWN,
+ TEXTPATH_METHODTYPE_ALIGN = SVG_TEXTPATH_METHODTYPE_ALIGN,
+ TEXTPATH_METHODTYPE_STRETCH = SVG_TEXTPATH_METHODTYPE_STRETCH,
+ TEXTPATH_SPACINGTYPE_UNKNOWN = SVG_TEXTPATH_SPACINGTYPE_UNKNOWN,
+ TEXTPATH_SPACINGTYPE_AUTO = SVG_TEXTPATH_SPACINGTYPE_AUTO,
+ TEXTPATH_SPACINGTYPE_EXACT = SVG_TEXTPATH_SPACINGTYPE_EXACT
+ };
+
+ SVGTextPathElement(const QualifiedName&, Document*);
+ virtual ~SVGTextPathElement();
+
+ virtual void insertedIntoDocument();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual bool rendererIsNeeded(RenderStyle* style) { return StyledElement::rendererIsNeeded(style); }
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ bool childShouldCreateRenderer(Node*) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPathElement, SVGLength, SVGLength, StartOffset, startOffset)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPathElement, int, int, Method, method)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPathElement, int, int, Spacing, spacing)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGTextPathElement.idl b/WebCore/svg/SVGTextPathElement.idl
new file mode 100644
index 0000000..0183def
--- /dev/null
+++ b/WebCore/svg/SVGTextPathElement.idl
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor] SVGTextPathElement : SVGTextContentElement,
+ SVGURIReference {
+ // textPath Method Types
+ const unsigned short TEXTPATH_METHODTYPE_UNKNOWN = 0;
+ const unsigned short TEXTPATH_METHODTYPE_ALIGN = 1;
+ const unsigned short TEXTPATH_METHODTYPE_STRETCH = 2;
+
+ // textPath Spacing Types
+ const unsigned short TEXTPATH_SPACINGTYPE_UNKNOWN = 0;
+ const unsigned short TEXTPATH_SPACINGTYPE_AUTO = 1;
+ const unsigned short TEXTPATH_SPACINGTYPE_EXACT = 2;
+
+ readonly attribute SVGAnimatedLength startOffset;
+ readonly attribute SVGAnimatedEnumeration method;
+ readonly attribute SVGAnimatedEnumeration spacing;
+ };
+
+}
diff --git a/WebCore/svg/SVGTextPositioningElement.cpp b/WebCore/svg/SVGTextPositioningElement.cpp
new file mode 100644
index 0000000..2bfc33e
--- /dev/null
+++ b/WebCore/svg/SVGTextPositioningElement.cpp
@@ -0,0 +1,72 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGTextPositioningElement.h"
+
+#include "SVGLengthList.h"
+#include "SVGNames.h"
+#include "SVGNumberList.h"
+
+namespace WebCore {
+
+SVGTextPositioningElement::SVGTextPositioningElement(const QualifiedName& tagName, Document* doc)
+ : SVGTextContentElement(tagName, doc)
+ , m_x(SVGLengthList::create(SVGNames::xAttr))
+ , m_y(SVGLengthList::create(SVGNames::yAttr))
+ , m_dx(SVGLengthList::create(SVGNames::dxAttr))
+ , m_dy(SVGLengthList::create(SVGNames::dyAttr))
+ , m_rotate(SVGNumberList::create(SVGNames::rotateAttr))
+{
+}
+
+SVGTextPositioningElement::~SVGTextPositioningElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGTextPositioningElement, SVGLengthList*, LengthList, lengthList, X, x, SVGNames::xAttr, m_x.get())
+ANIMATED_PROPERTY_DEFINITIONS(SVGTextPositioningElement, SVGLengthList*, LengthList, lengthList, Y, y, SVGNames::yAttr, m_y.get())
+ANIMATED_PROPERTY_DEFINITIONS(SVGTextPositioningElement, SVGLengthList*, LengthList, lengthList, Dx, dx, SVGNames::dxAttr, m_dx.get())
+ANIMATED_PROPERTY_DEFINITIONS(SVGTextPositioningElement, SVGLengthList*, LengthList, lengthList, Dy, dy, SVGNames::dyAttr, m_dy.get())
+ANIMATED_PROPERTY_DEFINITIONS(SVGTextPositioningElement, SVGNumberList*, NumberList, numberList, Rotate, rotate, SVGNames::rotateAttr, m_rotate.get())
+
+void SVGTextPositioningElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::xAttr)
+ xBaseValue()->parse(attr->value(), this, LengthModeWidth);
+ else if (attr->name() == SVGNames::yAttr)
+ yBaseValue()->parse(attr->value(), this, LengthModeHeight);
+ else if (attr->name() == SVGNames::dxAttr)
+ dxBaseValue()->parse(attr->value(), this, LengthModeWidth);
+ else if (attr->name() == SVGNames::dyAttr)
+ dyBaseValue()->parse(attr->value(), this, LengthModeHeight);
+ else if (attr->name() == SVGNames::rotateAttr)
+ rotateBaseValue()->parse(attr->value());
+ else
+ SVGTextContentElement::parseMappedAttribute(attr);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGTextPositioningElement.h b/WebCore/svg/SVGTextPositioningElement.h
new file mode 100644
index 0000000..fc4251c
--- /dev/null
+++ b/WebCore/svg/SVGTextPositioningElement.h
@@ -0,0 +1,52 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGTextPositioningElement_h
+#define SVGTextPositioningElement_h
+
+#if ENABLE(SVG)
+#include "SVGTextContentElement.h"
+
+namespace WebCore {
+
+ class SVGLengthList;
+ class SVGNumberList;
+
+ class SVGTextPositioningElement : public SVGTextContentElement {
+ public:
+ SVGTextPositioningElement(const QualifiedName&, Document*);
+ virtual ~SVGTextPositioningElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPositioningElement, SVGLengthList*, RefPtr<SVGLengthList>, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPositioningElement, SVGLengthList*, RefPtr<SVGLengthList>, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPositioningElement, SVGLengthList*, RefPtr<SVGLengthList>, Dx, dx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPositioningElement, SVGLengthList*, RefPtr<SVGLengthList>, Dy, dy)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPositioningElement, SVGNumberList*, RefPtr<SVGNumberList>, Rotate, rotate)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGTextPositioningElement.idl b/WebCore/svg/SVGTextPositioningElement.idl
new file mode 100644
index 0000000..45ea2ec
--- /dev/null
+++ b/WebCore/svg/SVGTextPositioningElement.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGTextPositioningElement : SVGTextContentElement {
+ readonly attribute SVGAnimatedLengthList x;
+ readonly attribute SVGAnimatedLengthList y;
+ readonly attribute SVGAnimatedLengthList dx;
+ readonly attribute SVGAnimatedLengthList dy;
+ readonly attribute SVGAnimatedNumberList rotate;
+ };
+
+}
diff --git a/WebCore/svg/SVGTimer.cpp b/WebCore/svg/SVGTimer.cpp
new file mode 100644
index 0000000..270793b
--- /dev/null
+++ b/WebCore/svg/SVGTimer.cpp
@@ -0,0 +1,172 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Apple Computer, Inc.
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGTimer.h"
+
+#include <wtf/HashMap.h>
+#include "SVGAnimateTransformElement.h"
+#include "SVGAnimateMotionElement.h"
+#include "SVGTransformList.h"
+#include "SVGAnimateColorElement.h"
+#include "SVGStyledTransformableElement.h"
+
+namespace WebCore {
+
+SVGTimer::SVGTimer(TimeScheduler* scheduler, double interval, bool singleShot)
+ : Timer<TimeScheduler>(scheduler, &TimeScheduler::timerFired)
+ , m_scheduler(scheduler)
+ , m_interval(interval)
+ , m_singleShot(singleShot)
+{
+}
+
+void SVGTimer::start()
+{
+ if (m_singleShot)
+ startOneShot(m_interval);
+ else
+ startRepeating(m_interval);
+}
+
+SVGTimer::TargetAnimationMap SVGTimer::animationsByElement(double elapsedSeconds)
+{
+ // Build a list of all animations which apply to each element
+ // FIXME: This list should be sorted by animation priority
+ TargetAnimationMap targetMap;
+#if ENABLE(SVG_ANIMATION)
+ ExceptionCode ec = 0;
+ SVGNotifySet::const_iterator end = m_notifySet.end();
+ for (SVGNotifySet::const_iterator it = m_notifySet.begin(); it != end; ++it) {
+ SVGAnimationElement* animation = *it;
+
+ // If we're dealing with a disabled element with fill="freeze",
+ // we have to take it into account for further calculations.
+ if (!m_enabledNotifySet.contains(animation)) {
+ if (!animation->isFrozen())
+ continue;
+ if (elapsedSeconds <= (animation->getStartTime() + animation->getSimpleDuration(ec)))
+ continue;
+ }
+
+ SVGElement* target = const_cast<SVGElement*>(animation->targetElement());
+ TargetAnimationMap::iterator i = targetMap.find(target);
+ if (i != targetMap.end())
+ i->second.append(animation);
+ else {
+ Vector<SVGAnimationElement*> list;
+ list.append(animation);
+ targetMap.set(target, list);
+ }
+ }
+#endif
+ return targetMap;
+}
+
+// FIXME: This funtion will eventually become part of the AnimationCompositor
+void SVGTimer::applyAnimations(double elapsedSeconds, const SVGTimer::TargetAnimationMap& targetMap)
+{
+#if ENABLE(SVG_ANIMATION)
+ TargetAnimationMap::const_iterator targetIterator = targetMap.begin();
+ TargetAnimationMap::const_iterator tend = targetMap.end();
+ for (; targetIterator != tend; ++targetIterator) {
+ // FIXME: This is still not 100% correct. Correct would be:
+ // 1. Walk backwards through the priority list until a replace (!isAdditive()) is found
+ // -- This optimization is not possible without careful consideration for dependent values (such as cx and fx in SVGRadialGradient)
+ // 2. Set the initial value (or last replace) as the new animVal
+ // 3. Call each enabled animation in turn, to have it apply its changes
+ // 4. After building a new animVal, set it on the element.
+
+ // Currenly we use the actual animVal on the element as "temporary storage"
+ // and abstract the getting/setting of the attributes into the SVGAnimate* classes
+
+ unsigned count = targetIterator->second.size();
+ for (unsigned i = 0; i < count; ++i) {
+ SVGAnimationElement* animation = targetIterator->second[i];
+
+ if (!animation->isValidAnimation())
+ continue;
+
+ if (!animation->updateAnimationBaseValueFromElement())
+ continue;
+
+ if (!animation->updateAnimatedValueForElapsedSeconds(elapsedSeconds))
+ continue;
+
+ animation->applyAnimatedValueToElement();
+ }
+ }
+
+ // Make a second pass through the map to avoid multiple setChanged calls on the same element.
+ for (targetIterator = targetMap.begin(); targetIterator != tend; ++targetIterator) {
+ SVGElement* key = targetIterator->first;
+ if (key && key->isStyled())
+ static_cast<SVGStyledElement*>(key)->setChanged();
+ }
+#endif
+}
+
+void SVGTimer::notifyAll()
+{
+#if ENABLE(SVG_ANIMATION)
+ if (m_enabledNotifySet.isEmpty())
+ return;
+
+ // First build a list of animation elements per target element
+ double elapsedSeconds = m_scheduler->elapsed() * 1000.0; // Take time now.
+ TargetAnimationMap targetMap = animationsByElement(elapsedSeconds);
+
+ // Then composite those animations down to final values and apply
+ applyAnimations(elapsedSeconds, targetMap);
+#endif
+}
+
+void SVGTimer::addNotify(SVGAnimationElement* element, bool enabled)
+{
+#if ENABLE(SVG_ANIMATION)
+ m_notifySet.add(element);
+ if (enabled)
+ m_enabledNotifySet.add(element);
+ else
+ m_enabledNotifySet.remove(element);
+#endif
+}
+
+void SVGTimer::removeNotify(SVGAnimationElement *element)
+{
+#if ENABLE(SVG_ANIMATION)
+ // FIXME: Why do we keep a pointer to the element forever (marked disabled)?
+ // That can't be right!
+
+ m_enabledNotifySet.remove(element);
+ if (m_enabledNotifySet.isEmpty())
+ stop();
+#endif
+}
+
+} // namespace
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGTimer.h b/WebCore/svg/SVGTimer.h
new file mode 100644
index 0000000..19e164c
--- /dev/null
+++ b/WebCore/svg/SVGTimer.h
@@ -0,0 +1,70 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Apple Computer, Inc.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#if ENABLE(SVG)
+
+#include "TimeScheduler.h"
+#include "Timer.h"
+#include <wtf/HashSet.h>
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+
+class SVGElement;
+class SVGAnimationElement;
+
+typedef HashSet<SVGAnimationElement*> SVGNotifySet;
+
+class SVGTimer : private Timer<TimeScheduler>
+{
+public:
+ SVGTimer(TimeScheduler*, double interval, bool singleShot);
+
+ void start();
+ using Timer<TimeScheduler>::stop;
+ using Timer<TimeScheduler>::isActive;
+
+ void notifyAll();
+ void addNotify(SVGAnimationElement*, bool enabled = false);
+ void removeNotify(SVGAnimationElement*);
+
+ static SVGTimer* downcast(Timer<TimeScheduler>* t) { return static_cast<SVGTimer*>(t); }
+
+private:
+ typedef HashMap<SVGElement*, Vector<SVGAnimationElement*> > TargetAnimationMap;
+ TargetAnimationMap animationsByElement(double elapsedTime);
+ void applyAnimations(double elapsedSeconds, const SVGTimer::TargetAnimationMap& targetMap);
+
+ TimeScheduler* m_scheduler;
+ double m_interval;
+ bool m_singleShot;
+
+ SVGNotifySet m_notifySet;
+ SVGNotifySet m_enabledNotifySet;
+};
+
+} // namespace
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGTitleElement.cpp b/WebCore/svg/SVGTitleElement.cpp
new file mode 100644
index 0000000..3e23a1b
--- /dev/null
+++ b/WebCore/svg/SVGTitleElement.cpp
@@ -0,0 +1,59 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGTitleElement.h"
+
+#include "Document.h"
+
+namespace WebCore {
+
+SVGTitleElement::SVGTitleElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+{
+}
+
+void SVGTitleElement::insertedIntoDocument()
+{
+ SVGStyledElement::insertedIntoDocument();
+ if (firstChild())
+ document()->setTitle(textContent(), this);
+}
+
+void SVGTitleElement::removedFromDocument()
+{
+ SVGElement::removedFromDocument();
+ document()->removeTitle(this);
+}
+
+void SVGTitleElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+ if (inDocument())
+ document()->setTitle(textContent(), this);
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGTitleElement.h b/WebCore/svg/SVGTitleElement.h
new file mode 100644
index 0000000..cd4768c
--- /dev/null
+++ b/WebCore/svg/SVGTitleElement.h
@@ -0,0 +1,50 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGTitleElement_h
+#define SVGTitleElement_h
+#if ENABLE(SVG)
+
+#include "SVGLangSpace.h"
+#include "SVGStyledElement.h"
+
+namespace WebCore
+{
+ class SVGTitleElement : public SVGStyledElement,
+ public SVGLangSpace
+ {
+ public:
+ SVGTitleElement(const QualifiedName&, Document*);
+
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGTitleElement.idl b/WebCore/svg/SVGTitleElement.idl
new file mode 100644
index 0000000..f7a1182
--- /dev/null
+++ b/WebCore/svg/SVGTitleElement.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGTitleElement : SVGElement,
+ SVGLangSpace,
+ SVGStylable {
+ };
+
+}
diff --git a/WebCore/svg/SVGTransform.cpp b/WebCore/svg/SVGTransform.cpp
new file mode 100644
index 0000000..eab8868
--- /dev/null
+++ b/WebCore/svg/SVGTransform.cpp
@@ -0,0 +1,156 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+
+#include "FloatPoint.h"
+#include "FloatSize.h"
+#include "SVGAngle.h"
+#include "SVGSVGElement.h"
+#include "SVGTransform.h"
+
+#include <math.h>
+
+using namespace WebCore;
+
+SVGTransform::SVGTransform()
+ : m_type(SVG_TRANSFORM_UNKNOWN)
+ , m_angle(0)
+{
+}
+
+SVGTransform::SVGTransform(SVGTransformType type)
+ : m_type(type)
+ , m_angle(0)
+ , m_center(FloatPoint())
+ , m_matrix(AffineTransform())
+{
+}
+
+SVGTransform::SVGTransform(const AffineTransform& matrix)
+ : m_type(SVG_TRANSFORM_MATRIX)
+ , m_angle(0)
+ , m_matrix(matrix)
+{
+}
+
+SVGTransform::~SVGTransform()
+{
+}
+
+bool SVGTransform::isValid()
+{
+ return (m_type != SVG_TRANSFORM_UNKNOWN);
+}
+
+SVGTransform::SVGTransformType SVGTransform::type() const
+{
+ return m_type;
+}
+
+AffineTransform SVGTransform::matrix() const
+{
+ return m_matrix;
+}
+
+float SVGTransform::angle() const
+{
+ return m_angle;
+}
+
+FloatPoint SVGTransform::rotationCenter() const
+{
+ return m_center;
+}
+
+void SVGTransform::setMatrix(const AffineTransform& matrix)
+{
+ m_type = SVG_TRANSFORM_MATRIX;
+ m_angle = 0;
+
+ m_matrix = matrix;
+}
+
+void SVGTransform::setTranslate(float tx, float ty)
+{
+ m_type = SVG_TRANSFORM_TRANSLATE;
+ m_angle = 0;
+
+ m_matrix.reset();
+ m_matrix.translate(tx, ty);
+}
+
+FloatPoint SVGTransform::translate() const
+{
+ return FloatPoint::narrowPrecision(m_matrix.e(), m_matrix.f());
+}
+
+void SVGTransform::setScale(float sx, float sy)
+{
+ m_type = SVG_TRANSFORM_SCALE;
+ m_angle = 0;
+ m_center = FloatPoint();
+
+ m_matrix.reset();
+ m_matrix.scale(sx, sy);
+}
+
+FloatSize SVGTransform::scale() const
+{
+ return FloatSize::narrowPrecision(m_matrix.a(), m_matrix.d());
+}
+
+void SVGTransform::setRotate(float angle, float cx, float cy)
+{
+ m_type = SVG_TRANSFORM_ROTATE;
+ m_angle = angle;
+ m_center = FloatPoint(cx, cy);
+
+ // TODO: toString() implementation, which can show cx, cy (need to be stored?)
+ m_matrix.reset();
+ m_matrix.translate(cx, cy);
+ m_matrix.rotate(angle);
+ m_matrix.translate(-cx, -cy);
+}
+
+void SVGTransform::setSkewX(float angle)
+{
+ m_type = SVG_TRANSFORM_SKEWX;
+ m_angle = angle;
+
+ m_matrix.reset();
+ m_matrix.skewX(angle);
+}
+
+void SVGTransform::setSkewY(float angle)
+{
+ m_type = SVG_TRANSFORM_SKEWY;
+ m_angle = angle;
+
+ m_matrix.reset();
+ m_matrix.skewY(angle);
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/SVGTransform.h b/WebCore/svg/SVGTransform.h
new file mode 100644
index 0000000..a8bcb8e
--- /dev/null
+++ b/WebCore/svg/SVGTransform.h
@@ -0,0 +1,95 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGTransform_h
+#define SVGTransform_h
+#if ENABLE(SVG)
+
+#include "AffineTransform.h"
+#include "FloatPoint.h"
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+ class FloatSize;
+
+ class SVGTransform {
+ public:
+ enum SVGTransformType {
+ SVG_TRANSFORM_UNKNOWN = 0,
+ SVG_TRANSFORM_MATRIX = 1,
+ SVG_TRANSFORM_TRANSLATE = 2,
+ SVG_TRANSFORM_SCALE = 3,
+ SVG_TRANSFORM_ROTATE = 4,
+ SVG_TRANSFORM_SKEWX = 5,
+ SVG_TRANSFORM_SKEWY = 6
+ };
+
+ SVGTransform();
+ SVGTransform(SVGTransformType);
+ explicit SVGTransform(const AffineTransform&);
+ virtual ~SVGTransform();
+
+ SVGTransformType type() const;
+
+ AffineTransform matrix() const;
+
+ float angle() const;
+ FloatPoint rotationCenter() const;
+
+ void setMatrix(const AffineTransform&);
+ void setTranslate(float tx, float ty);
+ void setScale(float sx, float sy);
+ void setRotate(float angle, float cx, float cy);
+ void setSkewX(float angle);
+ void setSkewY(float angle);
+
+ // Internal use only (animation system)
+ FloatPoint translate() const;
+ FloatSize scale() const;
+
+ bool isValid();
+
+ private:
+ SVGTransformType m_type;
+ float m_angle;
+ FloatPoint m_center;
+ AffineTransform m_matrix;
+ };
+
+ inline bool operator==(const SVGTransform& a, const SVGTransform& b)
+ {
+ return a.type() == b.type() && a.angle() == b.angle() && a.matrix() == b.matrix();
+ }
+
+ inline bool operator!=(const SVGTransform& a, const SVGTransform& b)
+ {
+ return !(a == b);
+ }
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGTransform.idl b/WebCore/svg/SVGTransform.idl
new file mode 100644
index 0000000..3163cd6
--- /dev/null
+++ b/WebCore/svg/SVGTransform.idl
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor, PODType=SVGTransform] SVGTransform {
+ // Transform Types
+ const unsigned short SVG_TRANSFORM_UNKNOWN = 0;
+ const unsigned short SVG_TRANSFORM_MATRIX = 1;
+ const unsigned short SVG_TRANSFORM_TRANSLATE = 2;
+ const unsigned short SVG_TRANSFORM_SCALE = 3;
+ const unsigned short SVG_TRANSFORM_ROTATE = 4;
+ const unsigned short SVG_TRANSFORM_SKEWX = 5;
+ const unsigned short SVG_TRANSFORM_SKEWY = 6;
+
+ readonly attribute unsigned short type;
+ readonly attribute SVGMatrix matrix;
+ readonly attribute float angle;
+
+ void setMatrix(in SVGMatrix matrix);
+ void setTranslate(in float tx, in float ty);
+ void setScale(in float sx, in float sy);
+ void setRotate(in float angle, in float cx, in float cy);
+ void setSkewX(in float angle);
+ void setSkewY(in float angle);
+ };
+
+}
diff --git a/WebCore/svg/SVGTransformDistance.cpp b/WebCore/svg/SVGTransformDistance.cpp
new file mode 100644
index 0000000..df86b0f
--- /dev/null
+++ b/WebCore/svg/SVGTransformDistance.cpp
@@ -0,0 +1,278 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGTransformDistance.h"
+
+#include "FloatConversion.h"
+#include "FloatPoint.h"
+#include "FloatSize.h"
+#include "SVGTransform.h"
+
+#include <math.h>
+
+namespace WebCore {
+
+SVGTransformDistance::SVGTransformDistance()
+ : m_type(SVGTransform::SVG_TRANSFORM_UNKNOWN)
+ , m_angle(0)
+{
+}
+
+SVGTransformDistance::SVGTransformDistance(SVGTransform::SVGTransformType type, float angle, float cx, float cy, const AffineTransform& transform)
+ : m_type(type)
+ , m_angle(angle)
+ , m_cx(cx)
+ , m_cy(cy)
+ , m_transform(transform)
+{
+}
+
+SVGTransformDistance::SVGTransformDistance(const SVGTransform& fromSVGTransform, const SVGTransform& toSVGTransform)
+ : m_type(fromSVGTransform.type())
+ , m_angle(0)
+ , m_cx(0)
+ , m_cy(0)
+{
+ ASSERT(m_type == toSVGTransform.type());
+
+ switch (m_type) {
+ case SVGTransform::SVG_TRANSFORM_UNKNOWN:
+ return;
+ case SVGTransform::SVG_TRANSFORM_MATRIX:
+ // FIXME: need to be able to subtract to matrices
+ return;
+ case SVGTransform::SVG_TRANSFORM_ROTATE:
+ {
+ FloatSize centerDistance = toSVGTransform.rotationCenter() - fromSVGTransform.rotationCenter();
+ m_angle = toSVGTransform.angle() - fromSVGTransform.angle();
+ m_cx = centerDistance.width();
+ m_cy = centerDistance.height();
+ return;
+ }
+ case SVGTransform::SVG_TRANSFORM_TRANSLATE:
+ {
+ FloatSize translationDistance = toSVGTransform.translate() - fromSVGTransform.translate();
+ m_transform.translate(translationDistance.width(), translationDistance.height());
+ return;
+ }
+ case SVGTransform::SVG_TRANSFORM_SCALE:
+ {
+ float scaleX = fromSVGTransform.scale().width() != 0 ? toSVGTransform.scale().width() / fromSVGTransform.scale().width() : toSVGTransform.scale().width() / 0.00001f;
+ float scaleY = fromSVGTransform.scale().height() != 0 ? toSVGTransform.scale().height() / fromSVGTransform.scale().height() : toSVGTransform.scale().height() / 0.00001f;
+ m_transform.scale(scaleX, scaleY);
+ return;
+ }
+ case SVGTransform::SVG_TRANSFORM_SKEWX:
+ case SVGTransform::SVG_TRANSFORM_SKEWY:
+ m_angle = toSVGTransform.angle() - fromSVGTransform.angle();
+ return;
+ }
+}
+
+SVGTransformDistance SVGTransformDistance::scaledDistance(float scaleFactor) const
+{
+ switch (m_type) {
+ case SVGTransform::SVG_TRANSFORM_UNKNOWN:
+ return SVGTransformDistance();
+ case SVGTransform::SVG_TRANSFORM_ROTATE:
+ return SVGTransformDistance(m_type, m_angle * scaleFactor, m_cx * scaleFactor, m_cy * scaleFactor, AffineTransform());
+ case SVGTransform::SVG_TRANSFORM_SCALE:
+ case SVGTransform::SVG_TRANSFORM_MATRIX:
+ return SVGTransformDistance(m_type, m_angle * scaleFactor, m_cx * scaleFactor, m_cy * scaleFactor, AffineTransform(m_transform).scale(scaleFactor));
+ case SVGTransform::SVG_TRANSFORM_TRANSLATE:
+ {
+ AffineTransform newTransform(m_transform);
+ newTransform.setE(m_transform.e() * scaleFactor);
+ newTransform.setF(m_transform.f() * scaleFactor);
+ return SVGTransformDistance(m_type, 0, 0, 0, newTransform);
+ }
+ case SVGTransform::SVG_TRANSFORM_SKEWX:
+ case SVGTransform::SVG_TRANSFORM_SKEWY:
+ return SVGTransformDistance(m_type, m_angle * scaleFactor, m_cx * scaleFactor, m_cy * scaleFactor, AffineTransform());
+ }
+
+ ASSERT_NOT_REACHED();
+ return SVGTransformDistance();
+}
+
+SVGTransform SVGTransformDistance::addSVGTransforms(const SVGTransform& first, const SVGTransform& second)
+{
+ ASSERT(first.type() == second.type());
+
+ SVGTransform transform;
+
+ switch (first.type()) {
+ case SVGTransform::SVG_TRANSFORM_UNKNOWN:
+ return SVGTransform();
+ case SVGTransform::SVG_TRANSFORM_ROTATE:
+ {
+ transform.setRotate(first.angle() + second.angle(), first.rotationCenter().x() + second.rotationCenter().x(),
+ first.rotationCenter().y() + second.rotationCenter().y());
+ return transform;
+ }
+ case SVGTransform::SVG_TRANSFORM_MATRIX:
+ transform.setMatrix(first.matrix() * second.matrix());
+ return transform;
+ case SVGTransform::SVG_TRANSFORM_TRANSLATE:
+ {
+ float dx = first.translate().x() + second.translate().x();
+ float dy = first.translate().y() + second.translate().y();
+ transform.setTranslate(dx, dy);
+ return transform;
+ }
+ case SVGTransform::SVG_TRANSFORM_SCALE:
+ {
+ FloatSize scale = first.scale() + second.scale();
+ transform.setScale(scale.width(), scale.height());
+ return transform;
+ }
+ case SVGTransform::SVG_TRANSFORM_SKEWX:
+ transform.setSkewX(first.angle() + second.angle());
+ return transform;
+ case SVGTransform::SVG_TRANSFORM_SKEWY:
+ transform.setSkewY(first.angle() + second.angle());
+ return transform;
+ }
+
+ ASSERT_NOT_REACHED();
+ return SVGTransform();
+}
+
+void SVGTransformDistance::addSVGTransform(const SVGTransform& transform, bool absoluteValue)
+{
+ // If this is the first add, set the type for this SVGTransformDistance
+ if (m_type == SVGTransform::SVG_TRANSFORM_UNKNOWN)
+ m_type = transform.type();
+
+ ASSERT(m_type == transform.type());
+
+ switch (m_type) {
+ case SVGTransform::SVG_TRANSFORM_UNKNOWN:
+ return;
+ case SVGTransform::SVG_TRANSFORM_MATRIX:
+ m_transform *= transform.matrix(); // FIXME: what does 'distance' between two transforms mean? how should we respect 'absoluteValue' here?
+ return;
+ case SVGTransform::SVG_TRANSFORM_ROTATE:
+ m_angle += absoluteValue ? fabsf(transform.angle()) : transform.angle();
+ m_cx += absoluteValue ? fabsf(transform.rotationCenter().x()) : transform.rotationCenter().x();
+ m_cy += absoluteValue ? fabsf(transform.rotationCenter().y()) : transform.rotationCenter().y();
+ // fall through
+ case SVGTransform::SVG_TRANSFORM_TRANSLATE:
+ {
+ float dx = absoluteValue ? fabsf(transform.translate().x()) : transform.translate().x();
+ float dy = absoluteValue ? fabsf(transform.translate().y()) : transform.translate().y();
+ m_transform.translate(dx, dy);
+ return;
+ }
+ case SVGTransform::SVG_TRANSFORM_SCALE:
+ {
+ float scaleX = absoluteValue ? fabsf(transform.scale().width()) : transform.scale().width();
+ float scaleY = absoluteValue ? fabsf(transform.scale().height()) : transform.scale().height();
+ m_transform.scale(scaleX, scaleY);
+ return;
+ }
+ case SVGTransform::SVG_TRANSFORM_SKEWX:
+ case SVGTransform::SVG_TRANSFORM_SKEWY:
+ m_angle += absoluteValue ? fabsf(transform.angle()) : transform.angle();
+ return;
+ }
+
+ ASSERT_NOT_REACHED();
+ return;
+}
+
+SVGTransform SVGTransformDistance::addToSVGTransform(const SVGTransform& transform) const
+{
+ ASSERT(m_type == transform.type() || transform == SVGTransform());
+
+ SVGTransform newTransform(transform);
+
+ switch (m_type) {
+ case SVGTransform::SVG_TRANSFORM_UNKNOWN:
+ return SVGTransform();
+ case SVGTransform::SVG_TRANSFORM_MATRIX:
+ return SVGTransform(transform.matrix() * m_transform);
+ case SVGTransform::SVG_TRANSFORM_TRANSLATE:
+ {
+ FloatPoint translation = transform.translate();
+ translation += FloatSize::narrowPrecision(m_transform.e(), m_transform.f());
+ newTransform.setTranslate(translation.x(), translation.y());
+ return newTransform;
+ }
+ case SVGTransform::SVG_TRANSFORM_SCALE:
+ {
+ FloatSize scale = transform.scale();
+ scale += FloatSize::narrowPrecision(m_transform.a(), m_transform.d());
+ newTransform.setScale(scale.width(), scale.height());
+ return newTransform;
+ }
+ case SVGTransform::SVG_TRANSFORM_ROTATE:
+ {
+ // FIXME: I'm not certain the translation is calculated correctly here
+ FloatPoint center = transform.rotationCenter();
+ newTransform.setRotate(transform.angle() + m_angle,
+ center.x() + m_cx,
+ center.y() + m_cy);
+ return newTransform;
+ }
+ case SVGTransform::SVG_TRANSFORM_SKEWX:
+ newTransform.setSkewX(transform.angle() + m_angle);
+ return newTransform;
+ case SVGTransform::SVG_TRANSFORM_SKEWY:
+ newTransform.setSkewY(transform.angle() + m_angle);
+ return newTransform;
+ }
+
+ ASSERT_NOT_REACHED();
+ return SVGTransform();
+}
+
+bool SVGTransformDistance::isZero() const
+{
+ return (m_transform == AffineTransform() && m_angle == 0);
+}
+
+float SVGTransformDistance::distance() const
+{
+ switch (m_type) {
+ case SVGTransform::SVG_TRANSFORM_UNKNOWN:
+ return 0.0f;
+ case SVGTransform::SVG_TRANSFORM_ROTATE:
+ return sqrtf(m_angle * m_angle + m_cx * m_cx + m_cy * m_cy);
+ case SVGTransform::SVG_TRANSFORM_MATRIX:
+ return 0.0f; // I'm not quite sure yet what distance between two matrices means.
+ case SVGTransform::SVG_TRANSFORM_SCALE:
+ return static_cast<float>(sqrt(m_transform.a() * m_transform.a() + m_transform.d() * m_transform.d()));
+ case SVGTransform::SVG_TRANSFORM_TRANSLATE:
+ return static_cast<float>(sqrt(m_transform.e() * m_transform.e() + m_transform.f() * m_transform.f()));
+ case SVGTransform::SVG_TRANSFORM_SKEWX:
+ case SVGTransform::SVG_TRANSFORM_SKEWY:
+ return m_angle;
+ }
+ ASSERT_NOT_REACHED();
+ return 0.0f;
+}
+
+}
+
+#endif
diff --git a/WebCore/svg/SVGTransformDistance.h b/WebCore/svg/SVGTransformDistance.h
new file mode 100644
index 0000000..b3663ad
--- /dev/null
+++ b/WebCore/svg/SVGTransformDistance.h
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGTransformDistance_h
+#define SVGTransformDistance_h
+#if ENABLE(SVG)
+
+#include "SVGTransform.h"
+
+namespace WebCore {
+
+ class AffineTransform;
+
+ class SVGTransformDistance {
+ public:
+ SVGTransformDistance();
+ SVGTransformDistance(const SVGTransform& fromTransform, const SVGTransform& toTransform);
+
+ SVGTransformDistance scaledDistance(float scaleFactor) const;
+ SVGTransform addToSVGTransform(const SVGTransform&) const;
+ void addSVGTransform(const SVGTransform&, bool absoluteValue = false);
+
+ static SVGTransform addSVGTransforms(const SVGTransform&, const SVGTransform&);
+
+ bool isZero() const;
+
+ float distance() const;
+ private:
+ SVGTransformDistance(SVGTransform::SVGTransformType, float angle, float cx, float cy, const AffineTransform&);
+
+ SVGTransform::SVGTransformType m_type;
+ float m_angle;
+ float m_cx;
+ float m_cy;
+ AffineTransform m_transform; // for storing scale, translation or matrix transforms
+ };
+}
+
+#endif // ENABLE(SVG)
+#endif // SVGTransformDistance_h
diff --git a/WebCore/svg/SVGTransformList.cpp b/WebCore/svg/SVGTransformList.cpp
new file mode 100644
index 0000000..9b75848
--- /dev/null
+++ b/WebCore/svg/SVGTransformList.cpp
@@ -0,0 +1,85 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "AffineTransform.h"
+#include "SVGTransform.h"
+#include "SVGSVGElement.h"
+#include "SVGTransformDistance.h"
+#include "SVGTransformList.h"
+
+using namespace WebCore;
+
+SVGTransformList::SVGTransformList(const QualifiedName& attributeName)
+ : SVGPODList<SVGTransform>(attributeName)
+{
+}
+
+SVGTransformList::~SVGTransformList()
+{
+}
+
+SVGTransform SVGTransformList::createSVGTransformFromMatrix(const AffineTransform& matrix) const
+{
+ return SVGSVGElement::createSVGTransformFromMatrix(matrix);
+}
+
+SVGTransform SVGTransformList::consolidate()
+{
+ ExceptionCode ec = 0;
+ return initialize(concatenate(), ec);
+}
+
+SVGTransform SVGTransformList::concatenate() const
+{
+ unsigned int length = numberOfItems();
+ if (!length)
+ return SVGTransform();
+
+ AffineTransform matrix;
+ ExceptionCode ec = 0;
+ for (unsigned int i = 0; i < length; i++)
+ matrix = getItem(i, ec).matrix() * matrix;
+
+ return SVGTransform(matrix);
+}
+
+SVGTransform SVGTransformList::concatenateForType(SVGTransform::SVGTransformType type) const
+{
+ unsigned int length = numberOfItems();
+ if (!length)
+ return SVGTransform();
+
+ ExceptionCode ec = 0;
+ SVGTransformDistance totalTransform;
+ for (unsigned int i = 0; i < length; i++) {
+ const SVGTransform& transform = getItem(i, ec);
+ if (transform.type() == type)
+ totalTransform.addSVGTransform(transform);
+ }
+
+ return totalTransform.addToSVGTransform(SVGTransform());
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGTransformList.h b/WebCore/svg/SVGTransformList.h
new file mode 100644
index 0000000..be72f9d
--- /dev/null
+++ b/WebCore/svg/SVGTransformList.h
@@ -0,0 +1,52 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGTransformList_h
+#define SVGTransformList_h
+
+#if ENABLE(SVG)
+#include "SVGList.h"
+#include "SVGTransform.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+ class SVGTransformList : public SVGPODList<SVGTransform> {
+ public:
+ static PassRefPtr<SVGTransformList> create(const QualifiedName& attributeName) { return adoptRef(new SVGTransformList(attributeName)); }
+ virtual ~SVGTransformList();
+
+ SVGTransform createSVGTransformFromMatrix(const AffineTransform&) const;
+ SVGTransform consolidate();
+
+ // Internal use only
+ SVGTransform concatenate() const;
+ SVGTransform concatenateForType(SVGTransform::SVGTransformType) const;
+
+ private:
+ SVGTransformList(const QualifiedName&);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGTransformList_h
diff --git a/WebCore/svg/SVGTransformList.idl b/WebCore/svg/SVGTransformList.idl
new file mode 100644
index 0000000..67968ff
--- /dev/null
+++ b/WebCore/svg/SVGTransformList.idl
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGTransformList {
+ readonly attribute unsigned long numberOfItems;
+
+ [Custom] void clear()
+ raises(DOMException);
+ [Custom] SVGTransform initialize(in SVGTransform item)
+ raises(DOMException, SVGException);
+ [Custom] SVGTransform getItem(in unsigned long index)
+ raises(DOMException);
+ [Custom] SVGTransform insertItemBefore(in SVGTransform item, in unsigned long index)
+ raises(DOMException, SVGException);
+ [Custom] SVGTransform replaceItem(in SVGTransform item, in unsigned long index)
+ raises(DOMException, SVGException);
+ [Custom] SVGTransform removeItem(in unsigned long index)
+ raises(DOMException);
+ [Custom] SVGTransform appendItem(in SVGTransform item)
+ raises(DOMException, SVGException);
+ SVGTransform createSVGTransformFromMatrix(in SVGMatrix matrix);
+ SVGTransform consolidate();
+ };
+
+}
diff --git a/WebCore/svg/SVGTransformable.cpp b/WebCore/svg/SVGTransformable.cpp
new file mode 100644
index 0000000..8614d55
--- /dev/null
+++ b/WebCore/svg/SVGTransformable.cpp
@@ -0,0 +1,233 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+ 2007 Eric Seidel <eric@webkit.org>
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGTransformable.h"
+
+#include "AffineTransform.h"
+#include "FloatConversion.h"
+#include "RegularExpression.h"
+#include "SVGNames.h"
+#include "SVGParserUtilities.h"
+#include "SVGStyledElement.h"
+#include "SVGTransformList.h"
+
+namespace WebCore {
+
+SVGTransformable::SVGTransformable() : SVGLocatable()
+{
+}
+
+SVGTransformable::~SVGTransformable()
+{
+}
+
+AffineTransform SVGTransformable::getCTM(const SVGElement* element) const
+{
+ AffineTransform ctm = SVGLocatable::getCTM(element);
+ return animatedLocalTransform() * ctm;
+}
+
+AffineTransform SVGTransformable::getScreenCTM(const SVGElement* element) const
+{
+ AffineTransform ctm = SVGLocatable::getScreenCTM(element);
+ return animatedLocalTransform() * ctm;
+}
+
+int parseTransformParamList(const UChar*& ptr, const UChar* end, float* values, int required, int optional)
+{
+ int optionalParams = 0, requiredParams = 0;
+
+ if (!skipOptionalSpaces(ptr, end) || *ptr != '(')
+ return -1;
+
+ ptr++;
+
+ skipOptionalSpaces(ptr, end);
+
+ while (requiredParams < required) {
+ if (ptr >= end || !parseNumber(ptr, end, values[requiredParams], false))
+ return -1;
+ requiredParams++;
+ if (requiredParams < required)
+ skipOptionalSpacesOrDelimiter(ptr, end);
+ }
+ if (!skipOptionalSpaces(ptr, end))
+ return -1;
+
+ bool delimParsed = skipOptionalSpacesOrDelimiter(ptr, end);
+
+ if (ptr >= end)
+ return -1;
+
+ if (*ptr == ')') { // skip optionals
+ ptr++;
+ if (delimParsed)
+ return -1;
+ } else {
+ while (optionalParams < optional) {
+ if (ptr >= end || !parseNumber(ptr, end, values[requiredParams + optionalParams], false))
+ return -1;
+ optionalParams++;
+ if (optionalParams < optional)
+ skipOptionalSpacesOrDelimiter(ptr, end);
+ }
+
+ if (!skipOptionalSpaces(ptr, end))
+ return -1;
+
+ delimParsed = skipOptionalSpacesOrDelimiter(ptr, end);
+
+ if (ptr >= end || *ptr != ')' || delimParsed)
+ return -1;
+ ptr++;
+ }
+
+ return requiredParams + optionalParams;
+}
+
+// These should be kept in sync with enum SVGTransformType
+static const int requiredValuesForType[] = {0, 6, 1, 1, 1, 1, 1};
+static const int optionalValuesForType[] = {0, 0, 1, 1, 2, 0, 0};
+
+bool SVGTransformable::parseTransformValue(unsigned type, const UChar*& ptr, const UChar* end, SVGTransform& t)
+{
+ if (type == SVGTransform::SVG_TRANSFORM_UNKNOWN)
+ return false;
+
+ int valueCount = 0;
+ float values[] = {0, 0, 0, 0, 0, 0};
+ if ((valueCount = parseTransformParamList(ptr, end, values, requiredValuesForType[type], optionalValuesForType[type])) < 0)
+ return false;
+
+ switch (type) {
+ case SVGTransform::SVG_TRANSFORM_SKEWX:
+ t.setSkewX(values[0]);
+ break;
+ case SVGTransform::SVG_TRANSFORM_SKEWY:
+ t.setSkewY(values[0]);
+ break;
+ case SVGTransform::SVG_TRANSFORM_SCALE:
+ if (valueCount == 1) // Spec: if only one param given, assume uniform scaling
+ t.setScale(values[0], values[0]);
+ else
+ t.setScale(values[0], values[1]);
+ break;
+ case SVGTransform::SVG_TRANSFORM_TRANSLATE:
+ if (valueCount == 1) // Spec: if only one param given, assume 2nd param to be 0
+ t.setTranslate(values[0], 0);
+ else
+ t.setTranslate(values[0], values[1]);
+ break;
+ case SVGTransform::SVG_TRANSFORM_ROTATE:
+ if (valueCount == 1)
+ t.setRotate(values[0], 0, 0);
+ else
+ t.setRotate(values[0], values[1], values[2]);
+ break;
+ case SVGTransform::SVG_TRANSFORM_MATRIX:
+ t.setMatrix(AffineTransform(values[0], values[1], values[2], values[3], values[4], values[5]));
+ break;
+ }
+
+ return true;
+}
+
+static const UChar skewXDesc[] = {'s','k','e','w', 'X'};
+static const UChar skewYDesc[] = {'s','k','e','w', 'Y'};
+static const UChar scaleDesc[] = {'s','c','a','l', 'e'};
+static const UChar translateDesc[] = {'t','r','a','n', 's', 'l', 'a', 't', 'e'};
+static const UChar rotateDesc[] = {'r','o','t','a', 't', 'e'};
+static const UChar matrixDesc[] = {'m','a','t','r', 'i', 'x'};
+
+static inline bool parseAndSkipType(const UChar*& currTransform, const UChar* end, unsigned short& type)
+{
+ if (currTransform >= end)
+ return false;
+
+ if (*currTransform == 's') {
+ if (skipString(currTransform, end, skewXDesc, sizeof(skewXDesc) / sizeof(UChar)))
+ type = SVGTransform::SVG_TRANSFORM_SKEWX;
+ else if (skipString(currTransform, end, skewYDesc, sizeof(skewYDesc) / sizeof(UChar)))
+ type = SVGTransform::SVG_TRANSFORM_SKEWY;
+ else if (skipString(currTransform, end, scaleDesc, sizeof(scaleDesc) / sizeof(UChar)))
+ type = SVGTransform::SVG_TRANSFORM_SCALE;
+ else
+ return false;
+ } else if (skipString(currTransform, end, translateDesc, sizeof(translateDesc) / sizeof(UChar)))
+ type = SVGTransform::SVG_TRANSFORM_TRANSLATE;
+ else if (skipString(currTransform, end, rotateDesc, sizeof(rotateDesc) / sizeof(UChar)))
+ type = SVGTransform::SVG_TRANSFORM_ROTATE;
+ else if (skipString(currTransform, end, matrixDesc, sizeof(matrixDesc) / sizeof(UChar)))
+ type = SVGTransform::SVG_TRANSFORM_MATRIX;
+ else
+ return false;
+
+ return true;
+}
+
+bool SVGTransformable::parseTransformAttribute(SVGTransformList* list, const AtomicString& transform)
+{
+ const UChar* start = transform.characters();
+ const UChar* end = start + transform.length();
+ return parseTransformAttribute(list, start, end);
+}
+
+bool SVGTransformable::parseTransformAttribute(SVGTransformList* list, const UChar*& currTransform, const UChar* end)
+{
+ bool delimParsed = false;
+ while (currTransform < end) {
+ delimParsed = false;
+ unsigned short type = SVGTransform::SVG_TRANSFORM_UNKNOWN;
+ skipOptionalSpaces(currTransform, end);
+
+ if (!parseAndSkipType(currTransform, end, type))
+ return false;
+
+ SVGTransform t;
+ if (!parseTransformValue(type, currTransform, end, t))
+ return false;
+
+ ExceptionCode ec = 0;
+ list->appendItem(t, ec);
+ skipOptionalSpaces(currTransform, end);
+ if (currTransform < end && *currTransform == ',') {
+ delimParsed = true;
+ currTransform++;
+ }
+ skipOptionalSpaces(currTransform, end);
+ }
+
+ return !delimParsed;
+}
+
+bool SVGTransformable::isKnownAttribute(const QualifiedName& attrName)
+{
+ return attrName == SVGNames::transformAttr;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGTransformable.h b/WebCore/svg/SVGTransformable.h
new file mode 100644
index 0000000..1b1813f
--- /dev/null
+++ b/WebCore/svg/SVGTransformable.h
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGTransformable_h
+#define SVGTransformable_h
+
+#if ENABLE(SVG)
+#include "PlatformString.h"
+#include "SVGLocatable.h"
+
+namespace WebCore {
+
+ class AffineTransform;
+ class AtomicString;
+ class SVGTransform;
+ class SVGTransformList;
+ class QualifiedName;
+
+ class SVGTransformable : virtual public SVGLocatable {
+ public:
+ SVGTransformable();
+ virtual ~SVGTransformable();
+
+ static bool parseTransformAttribute(SVGTransformList*, const AtomicString& transform);
+ static bool parseTransformAttribute(SVGTransformList*, const UChar*& ptr, const UChar* end);
+ static bool parseTransformValue(unsigned type, const UChar*& ptr, const UChar* end, SVGTransform&);
+
+ AffineTransform getCTM(const SVGElement*) const;
+ AffineTransform getScreenCTM(const SVGElement*) const;
+
+ virtual AffineTransform animatedLocalTransform() const = 0;
+
+ bool isKnownAttribute(const QualifiedName&);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGTransformable_h
diff --git a/WebCore/svg/SVGTransformable.idl b/WebCore/svg/SVGTransformable.idl
new file mode 100644
index 0000000..02a4336
--- /dev/null
+++ b/WebCore/svg/SVGTransformable.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, ObjCProtocol] SVGTransformable : SVGLocatable {
+ readonly attribute SVGAnimatedTransformList transform;
+ };
+
+}
diff --git a/WebCore/svg/SVGURIReference.cpp b/WebCore/svg/SVGURIReference.cpp
new file mode 100644
index 0000000..5a2cabc
--- /dev/null
+++ b/WebCore/svg/SVGURIReference.cpp
@@ -0,0 +1,73 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGURIReference.h"
+
+#include "SVGNames.h"
+#include "SVGStyledElement.h"
+#include "XLinkNames.h"
+
+namespace WebCore {
+
+SVGURIReference::SVGURIReference()
+{
+}
+
+SVGURIReference::~SVGURIReference()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS_WITH_CONTEXT(SVGURIReference, String, String, string, Href, href, XLinkNames::hrefAttr, m_href)
+
+bool SVGURIReference::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name().matches(XLinkNames::hrefAttr)) {
+ setHrefBaseValue(attr->value());
+ return true;
+ }
+
+ return false;
+}
+
+bool SVGURIReference::isKnownAttribute(const QualifiedName& attrName)
+{
+ return attrName.matches(XLinkNames::hrefAttr);
+}
+
+String SVGURIReference::getTarget(const String& url)
+{
+ if (url.startsWith("url(")) { // URI References, ie. fill:url(#target)
+ unsigned int start = url.find('#') + 1;
+ unsigned int end = url.reverseFind(')');
+
+ return url.substring(start, end - start);
+ } else if (url.find('#') > -1) { // format is #target
+ unsigned int start = url.find('#') + 1;
+ return url.substring(start, url.length() - start);
+ } else // Normal Reference, ie. style="color-profile:changeColor"
+ return url;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGURIReference.h b/WebCore/svg/SVGURIReference.h
new file mode 100644
index 0000000..22f2f45
--- /dev/null
+++ b/WebCore/svg/SVGURIReference.h
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGURIReference_h
+#define SVGURIReference_h
+
+#if ENABLE(SVG)
+#include "SVGElement.h"
+
+namespace WebCore {
+
+ class MappedAttribute;
+
+ class SVGURIReference {
+ public:
+ SVGURIReference();
+ virtual ~SVGURIReference();
+
+ bool parseMappedAttribute(MappedAttribute*);
+ bool isKnownAttribute(const QualifiedName&);
+
+ static String getTarget(const String& url);
+
+ protected:
+ virtual const SVGElement* contextElement() const = 0;
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS_WITH_CONTEXT(SVGURIReference, String, String, Href, href)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGURIReference_h
diff --git a/WebCore/svg/SVGURIReference.idl b/WebCore/svg/SVGURIReference.idl
new file mode 100644
index 0000000..72bd9c8
--- /dev/null
+++ b/WebCore/svg/SVGURIReference.idl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, ObjCProtocol] SVGURIReference {
+ readonly attribute SVGAnimatedString href;
+ };
+
+}
diff --git a/WebCore/svg/SVGUnitTypes.h b/WebCore/svg/SVGUnitTypes.h
new file mode 100644
index 0000000..6be737f
--- /dev/null
+++ b/WebCore/svg/SVGUnitTypes.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGUnitTypes_h
+#define SVGUnitTypes_h
+
+#if ENABLE(SVG)
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class SVGUnitTypes : public RefCounted<SVGUnitTypes> {
+public:
+ enum SVGUnitType {
+ SVG_UNIT_TYPE_UNKNOWN = 0,
+ SVG_UNIT_TYPE_USERSPACEONUSE = 1,
+ SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2
+ };
+
+private:
+ SVGUnitTypes() { }
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGUnitTypes_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGUnitTypes.idl b/WebCore/svg/SVGUnitTypes.idl
new file mode 100644
index 0000000..0c3791e
--- /dev/null
+++ b/WebCore/svg/SVGUnitTypes.idl
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor] SVGUnitTypes {
+ // Unit Types
+ const unsigned short SVG_UNIT_TYPE_UNKNOWN = 0;
+ const unsigned short SVG_UNIT_TYPE_USERSPACEONUSE = 1;
+ const unsigned short SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2;
+ };
+
+}
diff --git a/WebCore/svg/SVGUseElement.cpp b/WebCore/svg/SVGUseElement.cpp
new file mode 100644
index 0000000..b2e8776
--- /dev/null
+++ b/WebCore/svg/SVGUseElement.cpp
@@ -0,0 +1,817 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+// Dump SVGElementInstance object tree - useful to debug instanceRoot problems
+// #define DUMP_INSTANCE_TREE
+
+// Dump the deep-expanded shadow tree (where the renderes are built from)
+// #define DUMP_SHADOW_TREE
+
+#if ENABLE(SVG)
+#include "SVGUseElement.h"
+
+#include "CSSStyleSelector.h"
+#include "CString.h"
+#include "Document.h"
+#include "Event.h"
+#include "HTMLNames.h"
+#include "RenderSVGTransformableContainer.h"
+#include "SVGElementInstance.h"
+#include "SVGElementInstanceList.h"
+#include "SVGGElement.h"
+#include "SVGLength.h"
+#include "SVGNames.h"
+#include "SVGPreserveAspectRatio.h"
+#include "SVGSVGElement.h"
+#include "SVGSymbolElement.h"
+#include "XLinkNames.h"
+#include "XMLSerializer.h"
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+SVGUseElement::SVGUseElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , SVGURIReference()
+ , m_x(this, LengthModeWidth)
+ , m_y(this, LengthModeHeight)
+ , m_width(this, LengthModeWidth)
+ , m_height(this, LengthModeHeight)
+{
+}
+
+SVGUseElement::~SVGUseElement()
+{
+}
+
+ANIMATED_PROPERTY_DEFINITIONS(SVGUseElement, SVGLength, Length, length, X, x, SVGNames::xAttr, m_x)
+ANIMATED_PROPERTY_DEFINITIONS(SVGUseElement, SVGLength, Length, length, Y, y, SVGNames::yAttr, m_y)
+ANIMATED_PROPERTY_DEFINITIONS(SVGUseElement, SVGLength, Length, length, Width, width, SVGNames::widthAttr, m_width)
+ANIMATED_PROPERTY_DEFINITIONS(SVGUseElement, SVGLength, Length, length, Height, height, SVGNames::heightAttr, m_height)
+
+SVGElementInstance* SVGUseElement::instanceRoot() const
+{
+ return m_targetElementInstance.get();
+}
+
+SVGElementInstance* SVGUseElement::animatedInstanceRoot() const
+{
+ // FIXME: Implement me.
+ return 0;
+}
+
+void SVGUseElement::parseMappedAttribute(MappedAttribute* 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()));
+ if (width().value() < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for use attribute <width> is not allowed");
+ } else if (attr->name() == SVGNames::heightAttr) {
+ setHeightBaseValue(SVGLength(this, LengthModeHeight, attr->value()));
+ if (height().value() < 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 SVGUseElement::insertedIntoDocument()
+{
+ SVGElement::insertedIntoDocument();
+ buildPendingResource();
+}
+
+void SVGUseElement::removedFromDocument()
+{
+ SVGElement::removedFromDocument();
+
+ m_targetElementInstance = 0;
+ m_shadowTreeRootElement = 0;
+}
+
+void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGStyledTransformableElement::svgAttributeChanged(attrName);
+
+ if (!attached())
+ return;
+
+ if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr ||
+ attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGURIReference::isKnownAttribute(attrName) ||
+ SVGStyledTransformableElement::isKnownAttribute(attrName)) {
+ // TODO: Now that we're aware of the attribute name, we can finally optimize
+ // updating <use> attributes - to not reclone every time.
+ buildPendingResource();
+
+ if (m_shadowTreeRootElement)
+ m_shadowTreeRootElement->setChanged();
+ }
+}
+
+void SVGUseElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+
+ if (!attached())
+ return;
+
+ buildPendingResource();
+
+ if (m_shadowTreeRootElement)
+ m_shadowTreeRootElement->setChanged();
+}
+
+void SVGUseElement::recalcStyle(StyleChange change)
+{
+ SVGStyledElement::recalcStyle(change);
+
+ // The shadow tree root element is NOT a direct child element of us.
+ // So we have to take care it receives style updates, manually.
+ if (!m_shadowTreeRootElement || !m_shadowTreeRootElement->attached())
+ return;
+
+ // Mimic Element::recalcStyle(). The main difference is that we don't call attach() on the
+ // shadow tree root element, but call attachShadowTree() here. Calling attach() will crash
+ // as the shadow tree root element has no (direct) parent node. Yes, shadow trees are tricky.
+ if (change >= Inherit || m_shadowTreeRootElement->changed()) {
+ RenderStyle* newStyle = document()->styleSelector()->styleForElement(m_shadowTreeRootElement.get());
+ StyleChange ch = m_shadowTreeRootElement->diff(m_shadowTreeRootElement->renderStyle(), newStyle);
+ if (ch == Detach) {
+ ASSERT(m_shadowTreeRootElement->attached());
+ m_shadowTreeRootElement->detach();
+ attachShadowTree();
+
+ // attach recalulates the style for all children. No need to do it twice.
+ m_shadowTreeRootElement->setChanged(NoStyleChange);
+ m_shadowTreeRootElement->setHasChangedChild(false);
+ newStyle->deref(document()->renderArena());
+ return;
+ }
+
+ newStyle->deref(document()->renderArena());
+ }
+
+ // Only change==Detach needs special treatment, for anything else recalcStyle() works.
+ m_shadowTreeRootElement->recalcStyle(change);
+}
+
+#ifdef DUMP_INSTANCE_TREE
+void dumpInstanceTree(unsigned int& depth, String& text, SVGElementInstance* targetInstance)
+{
+ SVGElement* element = targetInstance->correspondingElement();
+ ASSERT(element);
+
+ String elementId = element->getIDAttribute();
+ String elementNodeName = element->nodeName();
+ String parentNodeName = element->parentNode() ? element->parentNode()->nodeName() : "null";
+ String firstChildNodeName = element->firstChild() ? element->firstChild()->nodeName() : "null";
+
+ for (unsigned int i = 0; i < depth; ++i)
+ text += " ";
+
+ text += String::format("SVGElementInstance (parentNode=%s, firstChild=%s, correspondingElement=%s, id=%s)\n",
+ parentNodeName.latin1().data(), firstChildNodeName.latin1().data(), elementNodeName.latin1().data(), elementId.latin1().data());
+
+ depth++;
+
+ for (SVGElementInstance* instance = targetInstance->firstChild(); instance; instance = instance->nextSibling())
+ dumpInstanceTree(depth, text, instance);
+
+ depth--;
+}
+#endif
+
+static bool isDisallowedElement(Node* element)
+{
+#if ENABLE(SVG_FOREIGN_OBJECT)
+ // <foreignObject> should never be contained in a <use> tree. Too dangerous side effects possible.
+ if (element->hasTagName(SVGNames::foreignObjectTag))
+ return true;
+#endif
+
+ return false;
+}
+
+static bool subtreeContainsDisallowedElement(Node* start)
+{
+ if (isDisallowedElement(start))
+ return true;
+
+ for (Node* cur = start->firstChild(); cur; cur = cur->nextSibling()) {
+ if (subtreeContainsDisallowedElement(cur))
+ return true;
+ }
+
+ return false;
+}
+
+void SVGUseElement::buildPendingResource()
+{
+ String id = SVGURIReference::getTarget(href());
+ Element* targetElement = document()->getElementById(id);
+
+ if (!targetElement) {
+ // TODO: We want to deregister as pending resource, if our href() changed!
+ // TODO: Move to svgAttributeChanged, once we're fixing use & the new dynamic update concept.
+ document()->accessSVGExtensions()->addPendingResource(id, this);
+ return;
+ }
+
+ // Do not build the shadow/instance tree for <use> elements living in a shadow tree.
+ // The will be expanded soon anyway - see expandUseElementsInShadowTree().
+ Node* parent = parentNode();
+ while (parent) {
+ if (parent->isShadowNode())
+ return;
+
+ parent = parent->parentNode();
+ }
+
+ SVGElement* target = 0;
+ if (targetElement && targetElement->isSVGElement())
+ target = static_cast<SVGElement*>(targetElement);
+
+ // Do not allow self-referencing.
+ // 'target' may be null, if it's a non SVG namespaced element.
+ if (!target || target == this) {
+ m_targetElementInstance = 0;
+ m_shadowTreeRootElement = 0;
+ return;
+ }
+
+ // Why a seperated instance/shadow tree? SVG demands it:
+ // The instance tree is accesable from JavaScript, and has to
+ // expose a 1:1 copy of the referenced tree, whereas internally we need
+ // to alter the tree for correct "use-on-symbol", "use-on-svg" support.
+
+ // Build instance tree. Create root SVGElementInstance object for the first sub-tree node.
+ //
+ // Spec: If the 'use' element references a simple graphics element such as a 'rect', then there is only a
+ // single SVGElementInstance object, and the correspondingElement attribute on this SVGElementInstance object
+ // is the SVGRectElement that corresponds to the referenced 'rect' element.
+ m_targetElementInstance = new SVGElementInstance(this, target);
+
+ // Eventually enter recursion to build SVGElementInstance objects for the sub-tree children
+ bool foundProblem = false;
+ buildInstanceTree(target, m_targetElementInstance.get(), foundProblem);
+
+ // SVG specification does not say a word about <use> & cycles. My view on this is: just ignore it!
+ // Non-appearing <use> content is easier to debug, then half-appearing content.
+ if (foundProblem) {
+ m_targetElementInstance = 0;
+ m_shadowTreeRootElement = 0;
+ return;
+ }
+
+ // Assure instance tree building was successfull
+ ASSERT(m_targetElementInstance);
+ ASSERT(m_targetElementInstance->correspondingUseElement() == this);
+
+ // Setup shadow tree root node
+ m_shadowTreeRootElement = new SVGGElement(SVGNames::gTag, document());
+ m_shadowTreeRootElement->setInDocument();
+ m_shadowTreeRootElement->setShadowParentNode(this);
+
+ // Spec: An additional transformation translate(x,y) is appended to the end
+ // (i.e., right-side) of the transform attribute on the generated 'g', where x
+ // and y represent the values of the x and y attributes on the 'use' element.
+ if (x().value() != 0.0 || y().value() != 0.0) {
+ String transformString = String::format("translate(%f, %f)", x().value(), y().value());
+ m_shadowTreeRootElement->setAttribute(SVGNames::transformAttr, transformString);
+ }
+
+ // Build shadow tree from instance tree
+ // This also handles the special cases: <use> on <symbol>, <use> on <svg>.
+ buildShadowTree(target, m_targetElementInstance.get());
+
+#if ENABLE(SVG) && ENABLE(SVG_USE)
+ // Expand all <use> elements in the shadow tree.
+ // Expand means: replace the actual <use> element by what it references.
+ expandUseElementsInShadowTree(m_shadowTreeRootElement.get());
+
+ // Expand all <symbol> elements in the shadow tree.
+ // Expand means: replace the actual <symbol> element by the <svg> element.
+ expandSymbolElementsInShadowTree(m_shadowTreeRootElement.get());
+
+#endif
+
+ // Now that the shadow tree is completly expanded, we can associate
+ // shadow tree elements <-> instances in the instance tree.
+ associateInstancesWithShadowTreeElements(m_shadowTreeRootElement->firstChild(), m_targetElementInstance.get());
+
+ // Eventually dump instance tree
+#ifdef DUMP_INSTANCE_TREE
+ String text;
+ unsigned int depth = 0;
+
+ dumpInstanceTree(depth, text, m_targetElementInstance.get());
+ fprintf(stderr, "\nDumping <use> instance tree:\n%s\n", text.latin1().data());
+#endif
+
+ // Eventually dump shadow tree
+#ifdef DUMP_SHADOW_TREE
+ ExceptionCode ec = 0;
+ OwnPtr<XMLSerializer> serializer(new XMLSerializer());
+
+ String markup = serializer->serializeToString(m_shadowTreeRootElement.get(), ec);
+ ASSERT(ec == 0);
+
+ fprintf(stderr, "Dumping <use> shadow tree markup:\n%s\n", markup.latin1().data());
+#endif
+
+ // The DOM side is setup properly. Now we have to attach the root shadow
+ // tree element manually - using attach() won't work for "shadow nodes".
+ attachShadowTree();
+}
+
+RenderObject* SVGUseElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+ return new (arena) RenderSVGTransformableContainer(this);
+}
+
+void SVGUseElement::attach()
+{
+ SVGStyledTransformableElement::attach();
+
+ // If we're a pending resource, this doesn't have any effect.
+ attachShadowTree();
+}
+
+void SVGUseElement::detach()
+{
+ SVGStyledTransformableElement::detach();
+
+ if (m_shadowTreeRootElement)
+ m_shadowTreeRootElement->detach();
+}
+
+static bool isDirectReference(Node* n)
+{
+ return n->hasTagName(SVGNames::pathTag) ||
+ n->hasTagName(SVGNames::rectTag) ||
+ n->hasTagName(SVGNames::circleTag) ||
+ n->hasTagName(SVGNames::ellipseTag) ||
+ n->hasTagName(SVGNames::polygonTag) ||
+ n->hasTagName(SVGNames::polylineTag) ||
+ n->hasTagName(SVGNames::textTag);
+}
+
+Path SVGUseElement::toClipPath() const
+{
+ if (!m_shadowTreeRootElement)
+ const_cast<SVGUseElement*>(this)->buildPendingResource();
+
+ Node* n = m_shadowTreeRootElement->firstChild();
+ if (n->isSVGElement() && static_cast<SVGElement*>(n)->isStyledTransformable()) {
+ if (!isDirectReference(n))
+ // Spec: Indirect references are an error (14.3.5)
+ document()->accessSVGExtensions()->reportError("Not allowed to use indirect reference in <clip-path>");
+ else
+ return static_cast<SVGStyledTransformableElement*>(n)->toClipPath();
+ }
+
+ return Path();
+}
+
+void SVGUseElement::buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstance, bool& foundProblem)
+{
+ ASSERT(target);
+ ASSERT(targetInstance);
+
+ // A general description from the SVG spec, describing what buildInstanceTree() actually does.
+ //
+ // Spec: If the 'use' element references a 'g' which contains two 'rect' elements, then the instance tree
+ // contains three SVGElementInstance objects, a root SVGElementInstance object whose correspondingElement
+ // is the SVGGElement object for the 'g', and then two child SVGElementInstance objects, each of which has
+ // its correspondingElement that is an SVGRectElement object.
+
+ for (Node* node = target->firstChild(); node; node = node->nextSibling()) {
+ SVGElement* element = 0;
+ if (node->isSVGElement())
+ element = static_cast<SVGElement*>(node);
+
+ // Skip any non-svg nodes or any disallowed element.
+ if (!element || isDisallowedElement(element))
+ continue;
+
+ // Create SVGElementInstance object, for both container/non-container nodes.
+ SVGElementInstance* instancePtr = new SVGElementInstance(this, element);
+
+ RefPtr<SVGElementInstance> instance = instancePtr;
+ targetInstance->appendChild(instance.release());
+
+ // Enter recursion, appending new instance tree nodes to the "instance" object.
+ if (element->hasChildNodes())
+ buildInstanceTree(element, instancePtr, foundProblem);
+
+ // Spec: If the referenced object is itself a 'use', or if there are 'use' subelements within the referenced
+ // object, the instance tree will contain recursive expansion of the indirect references to form a complete tree.
+ if (element->hasTagName(SVGNames::useTag))
+ handleDeepUseReferencing(element, instancePtr, foundProblem);
+ }
+
+ // Spec: If the referenced object is itself a 'use', or if there are 'use' subelements within the referenced
+ // object, the instance tree will contain recursive expansion of the indirect references to form a complete tree.
+ if (target->hasTagName(SVGNames::useTag))
+ handleDeepUseReferencing(target, targetInstance, foundProblem);
+}
+
+void SVGUseElement::handleDeepUseReferencing(SVGElement* use, SVGElementInstance* targetInstance, bool& foundProblem)
+{
+ String id = SVGURIReference::getTarget(use->href());
+ Element* targetElement = document()->getElementById(id);
+ SVGElement* target = 0;
+ if (targetElement && targetElement->isSVGElement())
+ target = static_cast<SVGElement*>(targetElement);
+
+ if (!target)
+ return;
+
+ // Cycle detection first!
+ foundProblem = (target == this);
+
+ // Shortcut for self-references
+ if (foundProblem)
+ return;
+
+ SVGElementInstance* instance = targetInstance->parentNode();
+ while (instance) {
+ SVGElement* element = instance->correspondingElement();
+
+ if (element->getIDAttribute() == id) {
+ foundProblem = true;
+ return;
+ }
+
+ instance = instance->parentNode();
+ }
+
+ // Create an instance object, even if we're dealing with a cycle
+ SVGElementInstance* newInstance = new SVGElementInstance(this, target);
+ targetInstance->appendChild(newInstance);
+
+ // Eventually enter recursion to build SVGElementInstance objects for the sub-tree children
+ buildInstanceTree(target, newInstance, foundProblem);
+}
+
+void SVGUseElement::alterShadowTreeForSVGTag(SVGElement* target)
+{
+ String widthString = String::number(width().value());
+ String heightString = String::number(height().value());
+
+ if (hasAttribute(SVGNames::widthAttr))
+ target->setAttribute(SVGNames::widthAttr, widthString);
+
+ if (hasAttribute(SVGNames::heightAttr))
+ target->setAttribute(SVGNames::heightAttr, heightString);
+}
+
+void SVGUseElement::removeDisallowedElementsFromSubtree(Node* element)
+{
+ ExceptionCode ec = 0;
+
+ for (RefPtr<Node> child = element->firstChild(); child; child = child->nextSibling()) {
+ if (isDisallowedElement(child.get())) {
+ ASSERT(child->parent());
+ child->parent()->removeChild(child.get(), ec);
+ ASSERT(ec == 0);
+
+ continue;
+ }
+
+ if (child->hasChildNodes())
+ removeDisallowedElementsFromSubtree(child.get());
+ }
+}
+
+void SVGUseElement::buildShadowTree(SVGElement* target, SVGElementInstance* targetInstance)
+{
+ // For instance <use> on <foreignObject> (direct case).
+ if (isDisallowedElement(target))
+ return;
+
+ RefPtr<Node> newChild = targetInstance->correspondingElement()->cloneNode(true);
+
+ // We don't walk the target tree element-by-element, and clone each element,
+ // but instead use cloneNode(deep=true). This is an optimization for the common
+ // case where <use> doesn't contain disallowed elements (ie. <foreignObject>).
+ // Though if there are disallowed elements in the subtree, we have to remove them.
+ // For instance: <use> on <g> containing <foreignObject> (indirect case).
+ if (subtreeContainsDisallowedElement(newChild.get()))
+ removeDisallowedElementsFromSubtree(newChild.get());
+
+ SVGElement* newChildPtr = 0;
+ if (newChild->isSVGElement())
+ newChildPtr = static_cast<SVGElement*>(newChild.get());
+ ASSERT(newChildPtr);
+
+ ExceptionCode ec = 0;
+ m_shadowTreeRootElement->appendChild(newChild.release(), ec);
+ ASSERT(ec == 0);
+
+ // Handle use referencing <svg> special case
+ if (target->hasTagName(SVGNames::svgTag))
+ alterShadowTreeForSVGTag(newChildPtr);
+}
+
+#if ENABLE(SVG) && ENABLE(SVG_USE)
+void SVGUseElement::expandUseElementsInShadowTree(Node* element)
+{
+ // Why expand the <use> elements in the shadow tree here, and not just
+ // do this directly in buildShadowTree, if we encounter a <use> element?
+ //
+ // Short answer: Because we may miss to expand some elements. Ie. if a <symbol>
+ // contains <use> tags, we'd miss them. So once we're done with settin' up the
+ // actual shadow tree (after the special case modification for svg/symbol) we have
+ // to walk it completely and expand all <use> elements.
+ if (element->hasTagName(SVGNames::useTag)) {
+ SVGUseElement* use = static_cast<SVGUseElement*>(element);
+
+ String id = SVGURIReference::getTarget(use->href());
+ Element* targetElement = document()->getElementById(id);
+ SVGElement* target = 0;
+ if (targetElement && targetElement->isSVGElement())
+ target = static_cast<SVGElement*>(targetElement);
+
+ // Don't ASSERT(target) here, it may be "pending", too.
+ if (target) {
+ // Setup sub-shadow tree root node
+ RefPtr<SVGElement> cloneParent = new SVGGElement(SVGNames::gTag, document());
+
+ // Spec: In the generated content, the 'use' will be replaced by 'g', where all attributes from the
+ // 'use' element except for x, y, width, height and xlink:href are transferred to the generated 'g' element.
+ transferUseAttributesToReplacedElement(use, cloneParent.get());
+
+ // Spec: An additional transformation translate(x,y) is appended to the end
+ // (i.e., right-side) of the transform attribute on the generated 'g', where x
+ // and y represent the values of the x and y attributes on the 'use' element.
+ if (use->x().value() != 0.0 || use->y().value() != 0.0) {
+ if (!cloneParent->hasAttribute(SVGNames::transformAttr)) {
+ String transformString = String::format("translate(%f, %f)", use->x().value(), use->y().value());
+ cloneParent->setAttribute(SVGNames::transformAttr, transformString);
+ } else {
+ String transformString = String::format(" translate(%f, %f)", use->x().value(), use->y().value());
+ const AtomicString& transformAttribute = cloneParent->getAttribute(SVGNames::transformAttr);
+ cloneParent->setAttribute(SVGNames::transformAttr, transformAttribute + transformString);
+ }
+ }
+
+ ExceptionCode ec = 0;
+
+ // For instance <use> on <foreignObject> (direct case).
+ if (isDisallowedElement(target)) {
+ // We still have to setup the <use> replacment (<g>). Otherwhise
+ // associateInstancesWithShadowTreeElements() makes wrong assumptions.
+ // Replace <use> with referenced content.
+ ASSERT(use->parentNode());
+ use->parentNode()->replaceChild(cloneParent.release(), use, ec);
+ ASSERT(ec == 0);
+ return;
+ }
+
+ RefPtr<Node> newChild = target->cloneNode(true);
+
+ // We don't walk the target tree element-by-element, and clone each element,
+ // but instead use cloneNode(deep=true). This is an optimization for the common
+ // case where <use> doesn't contain disallowed elements (ie. <foreignObject>).
+ // Though if there are disallowed elements in the subtree, we have to remove them.
+ // For instance: <use> on <g> containing <foreignObject> (indirect case).
+ if (subtreeContainsDisallowedElement(newChild.get()))
+ removeDisallowedElementsFromSubtree(newChild.get());
+
+ SVGElement* newChildPtr = 0;
+ if (newChild->isSVGElement())
+ newChildPtr = static_cast<SVGElement*>(newChild.get());
+ ASSERT(newChildPtr);
+
+ cloneParent->appendChild(newChild.release(), ec);
+ ASSERT(ec == 0);
+
+ // Replace <use> with referenced content.
+ ASSERT(use->parentNode());
+ use->parentNode()->replaceChild(cloneParent.release(), use, ec);
+ ASSERT(ec == 0);
+
+ // Handle use referencing <svg> special case
+ if (target->hasTagName(SVGNames::svgTag))
+ alterShadowTreeForSVGTag(newChildPtr);
+
+ // Immediately stop here, and restart expanding.
+ expandUseElementsInShadowTree(m_shadowTreeRootElement.get());
+ return;
+ }
+ }
+
+ for (RefPtr<Node> child = element->firstChild(); child; child = child->nextSibling())
+ expandUseElementsInShadowTree(child.get());
+}
+
+void SVGUseElement::expandSymbolElementsInShadowTree(Node* element)
+{
+ if (element->hasTagName(SVGNames::symbolTag)) {
+ // Spec: The referenced 'symbol' and its contents are deep-cloned into the generated tree,
+ // with the exception that the 'symbol' is replaced by an 'svg'. This generated 'svg' will
+ // always have explicit values for attributes width and height. If attributes width and/or
+ // height are provided on the 'use' element, then these attributes will be transferred to
+ // the generated 'svg'. If attributes width and/or height are not specified, the generated
+ // 'svg' element will use values of 100% for these attributes.
+ RefPtr<SVGSVGElement> svgElement = new SVGSVGElement(SVGNames::svgTag, document());
+
+ // Transfer all attributes from <symbol> to the new <svg> element
+ *svgElement->attributes() = *element->attributes();
+
+ // Explicitly re-set width/height values
+ String widthString = String::number(width().value());
+ String heightString = String::number(height().value());
+
+ svgElement->setAttribute(SVGNames::widthAttr, hasAttribute(SVGNames::widthAttr) ? widthString : "100%");
+ svgElement->setAttribute(SVGNames::heightAttr, hasAttribute(SVGNames::heightAttr) ? heightString : "100%");
+
+ ExceptionCode ec = 0;
+
+ // Only clone symbol children, and add them to the new <svg> element
+ for (Node* child = element->firstChild(); child; child = child->nextSibling()) {
+ RefPtr<Node> newChild = child->cloneNode(true);
+ svgElement->appendChild(newChild.release(), ec);
+ ASSERT(ec == 0);
+ }
+
+ // We don't walk the target tree element-by-element, and clone each element,
+ // but instead use cloneNode(deep=true). This is an optimization for the common
+ // case where <use> doesn't contain disallowed elements (ie. <foreignObject>).
+ // Though if there are disallowed elements in the subtree, we have to remove them.
+ // For instance: <use> on <g> containing <foreignObject> (indirect case).
+ if (subtreeContainsDisallowedElement(svgElement.get()))
+ removeDisallowedElementsFromSubtree(svgElement.get());
+
+ // Replace <symbol> with <svg>.
+ ASSERT(element->parentNode());
+ element->parentNode()->replaceChild(svgElement.release(), element, ec);
+ ASSERT(ec == 0);
+
+ // Immediately stop here, and restart expanding.
+ expandSymbolElementsInShadowTree(m_shadowTreeRootElement.get());
+ return;
+ }
+
+ for (RefPtr<Node> child = element->firstChild(); child; child = child->nextSibling())
+ expandSymbolElementsInShadowTree(child.get());
+}
+
+#endif
+
+void SVGUseElement::attachShadowTree()
+{
+ if (!m_shadowTreeRootElement || m_shadowTreeRootElement->attached() || !document()->shouldCreateRenderers() || !attached() || !renderer())
+ return;
+
+ // Inspired by RenderTextControl::createSubtreeIfNeeded().
+ if (renderer()->canHaveChildren() && childShouldCreateRenderer(m_shadowTreeRootElement.get())) {
+ RenderStyle* style = m_shadowTreeRootElement->styleForRenderer(renderer());
+
+ if (m_shadowTreeRootElement->rendererIsNeeded(style)) {
+ m_shadowTreeRootElement->setRenderer(m_shadowTreeRootElement->createRenderer(document()->renderArena(), style));
+ if (RenderObject* shadowRenderer = m_shadowTreeRootElement->renderer()) {
+ shadowRenderer->setStyle(style);
+ renderer()->addChild(shadowRenderer, m_shadowTreeRootElement->nextRenderer());
+ m_shadowTreeRootElement->setAttached();
+ }
+ }
+
+ style->deref(document()->renderArena());
+
+ // This will take care of attaching all shadow tree child nodes.
+ for (Node* child = m_shadowTreeRootElement->firstChild(); child; child = child->nextSibling())
+ child->attach();
+ }
+}
+
+void SVGUseElement::associateInstancesWithShadowTreeElements(Node* target, SVGElementInstance* targetInstance)
+{
+ if (!target || !targetInstance)
+ return;
+
+ SVGElement* originalElement = targetInstance->correspondingElement();
+
+ if (originalElement->hasTagName(SVGNames::useTag)) {
+#if ENABLE(SVG) && ENABLE(SVG_USE)
+ // <use> gets replaced by <g>
+ ASSERT(target->nodeName() == SVGNames::gTag);
+#else
+ ASSERT(target->nodeName() == SVGNames::gTag || target->nodeName() == SVGNames::useTag);
+#endif
+ } else if (originalElement->hasTagName(SVGNames::symbolTag)) {
+ // <symbol> gets replaced by <svg>
+ ASSERT(target->nodeName() == SVGNames::svgTag);
+ } else
+ ASSERT(target->nodeName() == originalElement->nodeName());
+
+ SVGElement* element = 0;
+ if (target->isSVGElement())
+ element = static_cast<SVGElement*>(target);
+
+ ASSERT(!targetInstance->shadowTreeElement());
+ targetInstance->setShadowTreeElement(element);
+
+ Node* node = target->firstChild();
+ for (SVGElementInstance* instance = targetInstance->firstChild(); node && instance; instance = instance->nextSibling()) {
+ // Skip any non-svg elements in shadow tree
+ while (node && !node->isSVGElement())
+ node = node->nextSibling();
+
+ associateInstancesWithShadowTreeElements(node, instance);
+ node = node->nextSibling();
+ }
+}
+
+SVGElementInstance* SVGUseElement::instanceForShadowTreeElement(Node* element) const
+{
+ return instanceForShadowTreeElement(element, m_targetElementInstance.get());
+}
+
+SVGElementInstance* SVGUseElement::instanceForShadowTreeElement(Node* element, SVGElementInstance* instance) const
+{
+ ASSERT(element);
+ ASSERT(instance);
+ ASSERT(instance->shadowTreeElement());
+
+ if (element == instance->shadowTreeElement())
+ return instance;
+
+ for (SVGElementInstance* current = instance->firstChild(); current; current = current->nextSibling()) {
+ SVGElementInstance* search = instanceForShadowTreeElement(element, current);
+ if (search)
+ return search;
+ }
+
+ return 0;
+}
+
+void SVGUseElement::transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to) const
+{
+ ASSERT(from);
+ ASSERT(to);
+
+ *to->attributes() = *from->attributes();
+
+ ExceptionCode ec = 0;
+
+ to->removeAttribute(SVGNames::xAttr, ec);
+ ASSERT(ec == 0);
+
+ to->removeAttribute(SVGNames::yAttr, ec);
+ ASSERT(ec == 0);
+
+ to->removeAttribute(SVGNames::widthAttr, ec);
+ ASSERT(ec == 0);
+
+ to->removeAttribute(SVGNames::heightAttr, ec);
+ ASSERT(ec == 0);
+
+ to->removeAttribute(XLinkNames::hrefAttr, ec);
+ ASSERT(ec == 0);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGUseElement.h b/WebCore/svg/SVGUseElement.h
new file mode 100644
index 0000000..e307a8ec
--- /dev/null
+++ b/WebCore/svg/SVGUseElement.h
@@ -0,0 +1,116 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGUseElement_h
+#define SVGUseElement_h
+
+#if ENABLE(SVG)
+#include "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTests.h"
+#include "SVGURIReference.h"
+
+namespace WebCore {
+
+ class SVGElementInstance;
+ class SVGLength;
+
+ class SVGUseElement : public SVGStyledTransformableElement,
+ public SVGTests,
+ public SVGLangSpace,
+ public SVGExternalResourcesRequired,
+ public SVGURIReference {
+ public:
+ SVGUseElement(const QualifiedName&, Document*);
+ virtual ~SVGUseElement();
+
+ SVGElementInstance* instanceRoot() const;
+ SVGElementInstance* animatedInstanceRoot() const;
+
+ virtual bool isValid() const { return SVGTests::isValid(); }
+
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
+ virtual void buildPendingResource();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+
+ virtual void svgAttributeChanged(const QualifiedName&);
+ virtual void recalcStyle(StyleChange = NoChange);
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+ virtual void attach();
+ virtual void detach();
+
+ virtual Path toClipPath() const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
+
+ ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, Height, height)
+
+ private:
+ friend class SVGElement;
+ SVGElementInstance* instanceForShadowTreeElement(Node* element) const;
+
+ private:
+ // Instance tree handling
+ void buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstance, bool& foundCycle);
+ void handleDeepUseReferencing(SVGElement* use, SVGElementInstance* targetInstance, bool& foundCycle);
+
+ // Shadow tree handling
+ PassRefPtr<SVGSVGElement> buildShadowTreeForSymbolTag(SVGElement* target, SVGElementInstance* targetInstance);
+ void alterShadowTreeForSVGTag(SVGElement* target);
+ void removeDisallowedElementsFromSubtree(Node* element);
+
+ void buildShadowTree(SVGElement* target, SVGElementInstance* targetInstance);
+
+#if ENABLE(SVG) && ENABLE(SVG_USE)
+ void expandUseElementsInShadowTree(Node* element);
+ void expandSymbolElementsInShadowTree(Node* element);
+#endif
+
+ void attachShadowTree();
+
+ // "Tree connector"
+ void associateInstancesWithShadowTreeElements(Node* target, SVGElementInstance* targetInstance);
+
+ SVGElementInstance* instanceForShadowTreeElement(Node* element, SVGElementInstance* instance) const;
+ void transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to) const;
+
+ RefPtr<SVGElement> m_shadowTreeRootElement;
+ RefPtr<SVGElementInstance> m_targetElementInstance;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGUseElement.idl b/WebCore/svg/SVGUseElement.idl
new file mode 100644
index 0000000..0b3652d
--- /dev/null
+++ b/WebCore/svg/SVGUseElement.idl
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGUseElement : SVGElement,
+ SVGURIReference,
+ SVGTests,
+ SVGLangSpace,
+ SVGExternalResourcesRequired,
+ SVGStylable,
+ SVGTransformable {
+ readonly attribute SVGAnimatedLength x;
+ readonly attribute SVGAnimatedLength y;
+ readonly attribute SVGAnimatedLength width;
+ readonly attribute SVGAnimatedLength height;
+
+ readonly attribute SVGElementInstance instanceRoot;
+ readonly attribute SVGElementInstance animatedInstanceRoot;
+ };
+
+}
diff --git a/WebCore/svg/SVGViewElement.cpp b/WebCore/svg/SVGViewElement.cpp
new file mode 100644
index 0000000..cb16b62
--- /dev/null
+++ b/WebCore/svg/SVGViewElement.cpp
@@ -0,0 +1,73 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGViewElement.h"
+
+#include "Attr.h"
+#include "PlatformString.h"
+#include "SVGFitToViewBox.h"
+#include "SVGNames.h"
+#include "SVGStringList.h"
+#include "SVGZoomAndPan.h"
+
+namespace WebCore {
+
+SVGViewElement::SVGViewElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , SVGExternalResourcesRequired()
+ , SVGFitToViewBox()
+ , SVGZoomAndPan()
+{
+}
+
+SVGViewElement::~SVGViewElement()
+{
+}
+
+SVGStringList* SVGViewElement::viewTarget() const
+{
+ if (!m_viewTarget)
+ m_viewTarget = SVGStringList::create(SVGNames::viewTargetAttr);
+
+ return m_viewTarget.get();
+}
+
+void SVGViewElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::viewTargetAttr)
+ viewTarget()->reset(attr->value());
+ else {
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr)
+ || SVGFitToViewBox::parseMappedAttribute(attr)
+ || SVGZoomAndPan::parseMappedAttribute(attr))
+ return;
+
+ SVGStyledElement::parseMappedAttribute(attr);
+ }
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGViewElement.h b/WebCore/svg/SVGViewElement.h
new file mode 100644
index 0000000..17e0d1d
--- /dev/null
+++ b/WebCore/svg/SVGViewElement.h
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGViewElement_h
+#define SVGViewElement_h
+
+#if ENABLE(SVG)
+#include "SVGStyledElement.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGFitToViewBox.h"
+#include "SVGZoomAndPan.h"
+
+namespace WebCore {
+
+ class SVGStringList;
+ class SVGViewElement : public SVGStyledElement,
+ public SVGExternalResourcesRequired,
+ public SVGFitToViewBox,
+ public SVGZoomAndPan {
+ public:
+ SVGViewElement(const QualifiedName&, Document*);
+ virtual ~SVGViewElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ SVGStringList* viewTarget() const;
+
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ mutable RefPtr<SVGStringList> m_viewTarget;
+
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, FloatRect, ViewBox, viewBox)
+ ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, SVGPreserveAspectRatio*, PreserveAspectRatio, preserveAspectRatio)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGViewElement.idl b/WebCore/svg/SVGViewElement.idl
new file mode 100644
index 0000000..b80868a
--- /dev/null
+++ b/WebCore/svg/SVGViewElement.idl
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGViewElement : SVGElement,
+ SVGExternalResourcesRequired,
+ SVGFitToViewBox,
+ SVGZoomAndPan {
+ readonly attribute SVGStringList viewTarget;
+ };
+
+}
diff --git a/WebCore/svg/SVGViewSpec.cpp b/WebCore/svg/SVGViewSpec.cpp
new file mode 100644
index 0000000..d628d70
--- /dev/null
+++ b/WebCore/svg/SVGViewSpec.cpp
@@ -0,0 +1,178 @@
+/*
+ Copyright (C) 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGViewSpec.h"
+
+#include "PlatformString.h"
+#include "SVGParserUtilities.h"
+#include "SVGPreserveAspectRatio.h"
+#include "SVGSVGElement.h"
+#include "SVGTransformList.h"
+#include "SVGTransformable.h"
+
+namespace WebCore {
+
+SVGViewSpec::SVGViewSpec(const SVGSVGElement* contextElement)
+ : SVGFitToViewBox()
+ , SVGZoomAndPan()
+ , m_transform(SVGTransformList::create(SVGNames::transformAttr))
+ , m_contextElement(contextElement)
+{
+}
+
+SVGViewSpec::~SVGViewSpec()
+{
+}
+
+void SVGViewSpec::setTransform(const String& transform)
+{
+ SVGTransformable::parseTransformAttribute(m_transform.get(), transform);
+}
+
+void SVGViewSpec::setViewBoxString(const String& viewBox)
+{
+ float x, y, w, h;
+ const UChar* c = viewBox.characters();
+ const UChar* end = c + viewBox.length();
+ if (!parseViewBox(c, end, x, y, w, h, false))
+ return;
+ setViewBoxBaseValue(FloatRect(x, y, w, h));
+}
+
+void SVGViewSpec::setPreserveAspectRatioString(const String& preserve)
+{
+ const UChar* c = preserve.characters();
+ const UChar* end = c + preserve.length();
+ preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
+}
+
+void SVGViewSpec::setViewTargetString(const String& viewTargetString)
+{
+ m_viewTargetString = viewTargetString;
+}
+
+SVGElement* SVGViewSpec::viewTarget() const
+{
+ return static_cast<SVGElement*>(m_contextElement->ownerDocument()->getElementById(m_viewTargetString));
+}
+
+const SVGElement* SVGViewSpec::contextElement() const
+{
+ return m_contextElement;
+}
+
+static const UChar svgViewSpec[] = {'s','v','g','V', 'i', 'e', 'w'};
+static const UChar viewBoxSpec[] = {'v', 'i', 'e', 'w', 'B', 'o', 'x'};
+static const UChar preserveAspectRatioSpec[] = {'p', 'r', 'e', 's', 'e', 'r', 'v', 'e', 'A', 's', 'p', 'e', 'c', 't', 'R', 'a', 't', 'i', 'o'};
+static const UChar transformSpec[] = {'t', 'r', 'a', 'n', 's', 'f', 'o', 'r', 'm'};
+static const UChar zoomAndPanSpec[] = {'z', 'o', 'o', 'm', 'A', 'n', 'd', 'P', 'a', 'n'};
+static const UChar viewTargetSpec[] = {'v', 'i', 'e', 'w', 'T', 'a', 'r', 'g', 'e', 't'};
+
+bool SVGViewSpec::parseViewSpec(const String& viewSpec)
+{
+ const UChar* currViewSpec = viewSpec.characters();
+ const UChar* end = currViewSpec + viewSpec.length();
+
+ if (currViewSpec >= end)
+ return false;
+
+ if (!skipString(currViewSpec, end, svgViewSpec, sizeof(svgViewSpec) / sizeof(UChar)))
+ return false;
+
+ if (currViewSpec >= end || *currViewSpec != '(' )
+ return false;
+ currViewSpec++;
+
+ while (currViewSpec < end && *currViewSpec != ')') {
+ if (*currViewSpec == 'v') {
+ if (skipString(currViewSpec, end, viewBoxSpec, sizeof(viewBoxSpec) / sizeof(UChar))) {
+ if (currViewSpec >= end || *currViewSpec != '(')
+ return false;
+ currViewSpec++;
+ float x, y, w, h;
+ if (!parseViewBox(currViewSpec, end, x, y, w, h, false))
+ return false;
+ setViewBoxBaseValue(FloatRect(x, y, w, h));
+ if (currViewSpec >= end || *currViewSpec != ')')
+ return false;
+ currViewSpec++;
+ } else if (skipString(currViewSpec, end, viewTargetSpec, sizeof(viewTargetSpec) / sizeof(UChar))) {
+ if (currViewSpec >= end || *currViewSpec != '(')
+ return false;
+ const UChar* viewTargetStart = ++currViewSpec;
+ while (currViewSpec < end && *currViewSpec != ')')
+ currViewSpec++;
+ if (currViewSpec >= end)
+ return false;
+ setViewTargetString(String(viewTargetStart, currViewSpec - viewTargetStart));
+ currViewSpec++;
+ } else
+ return false;
+ } else if (*currViewSpec == 'z') {
+ if (!skipString(currViewSpec, end, zoomAndPanSpec, sizeof(zoomAndPanSpec) / sizeof(UChar)))
+ return false;
+ if (currViewSpec >= end || *currViewSpec != '(')
+ return false;
+ currViewSpec++;
+ if (!parseZoomAndPan(currViewSpec, end))
+ return false;
+ if (currViewSpec >= end || *currViewSpec != ')')
+ return false;
+ currViewSpec++;
+ } else if (*currViewSpec == 'p') {
+ if (!skipString(currViewSpec, end, preserveAspectRatioSpec, sizeof(preserveAspectRatioSpec) / sizeof(UChar)))
+ return false;
+ if (currViewSpec >= end || *currViewSpec != '(')
+ return false;
+ currViewSpec++;
+ if (!preserveAspectRatioBaseValue()->parsePreserveAspectRatio(currViewSpec, end, false))
+ return false;
+ if (currViewSpec >= end || *currViewSpec != ')')
+ return false;
+ currViewSpec++;
+ } else if (*currViewSpec == 't') {
+ if (!skipString(currViewSpec, end, transformSpec, sizeof(transformSpec) / sizeof(UChar)))
+ return false;
+ if (currViewSpec >= end || *currViewSpec != '(')
+ return false;
+ currViewSpec++;
+ SVGTransformable::parseTransformAttribute(m_transform.get(), currViewSpec, end);
+ if (currViewSpec >= end || *currViewSpec != ')')
+ return false;
+ currViewSpec++;
+ } else
+ return false;
+
+ if (currViewSpec < end && *currViewSpec == ';')
+ currViewSpec++;
+ }
+
+ if (currViewSpec >= end || *currViewSpec != ')')
+ return false;
+
+ return true;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGViewSpec.h b/WebCore/svg/SVGViewSpec.h
new file mode 100644
index 0000000..b143634
--- /dev/null
+++ b/WebCore/svg/SVGViewSpec.h
@@ -0,0 +1,68 @@
+/*
+ Copyright (C) 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGViewSpec_h
+#define SVGViewSpec_h
+
+#if ENABLE(SVG)
+#include "SVGFitToViewBox.h"
+#include "SVGZoomAndPan.h"
+
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+ class SVGElement;
+ class SVGSVGElement;
+ class SVGTransformList;
+
+ class SVGViewSpec : public SVGFitToViewBox,
+ public SVGZoomAndPan {
+ public:
+ SVGViewSpec(const SVGSVGElement*);
+ virtual ~SVGViewSpec();
+
+ bool parseViewSpec(const String&);
+
+ void setTransform(const String&);
+ SVGTransformList* transform() const { return m_transform.get(); }
+
+ void setViewBoxString(const String&);
+
+ void setPreserveAspectRatioString(const String&);
+
+ void setViewTargetString(const String&);
+ String viewTargetString() const { return m_viewTargetString; }
+ SVGElement* viewTarget() const;
+
+ protected:
+ virtual const SVGElement* contextElement() const;
+
+ private:
+ mutable RefPtr<SVGTransformList> m_transform;
+ const SVGSVGElement* m_contextElement;
+ String m_viewTargetString;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGViewSpec.idl b/WebCore/svg/SVGViewSpec.idl
new file mode 100644
index 0000000..46d4c8e
--- /dev/null
+++ b/WebCore/svg/SVGViewSpec.idl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, ObjCCustomInternalImpl] SVGViewSpec : SVGZoomAndPan, SVGFitToViewBox
+ {
+ readonly attribute SVGTransformList transform;
+ readonly attribute SVGElement viewTarget;
+ readonly attribute DOMString viewBoxString;
+ readonly attribute DOMString preserveAspectRatioString;
+ readonly attribute DOMString transformString;
+ readonly attribute DOMString viewTargetString;
+ };
+
+}
diff --git a/WebCore/svg/SVGZoomAndPan.cpp b/WebCore/svg/SVGZoomAndPan.cpp
new file mode 100644
index 0000000..c5eafb2
--- /dev/null
+++ b/WebCore/svg/SVGZoomAndPan.cpp
@@ -0,0 +1,87 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGZoomAndPan.h"
+
+#include "MappedAttribute.h"
+#include "SVGNames.h"
+#include "SVGParserUtilities.h"
+
+namespace WebCore {
+
+SVGZoomAndPan::SVGZoomAndPan()
+ : m_zoomAndPan(SVG_ZOOMANDPAN_MAGNIFY)
+{
+}
+
+SVGZoomAndPan::~SVGZoomAndPan()
+{
+}
+
+unsigned short SVGZoomAndPan::zoomAndPan() const
+{
+ return m_zoomAndPan;
+}
+
+void SVGZoomAndPan::setZoomAndPan(unsigned short zoomAndPan)
+{
+ m_zoomAndPan = zoomAndPan;
+}
+
+bool SVGZoomAndPan::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::zoomAndPanAttr) {
+ const UChar* start = attr->value().characters();
+ const UChar* end = start + attr->value().length();
+ parseZoomAndPan(start, end);
+ return true;
+ }
+
+ return false;
+}
+
+bool SVGZoomAndPan::isKnownAttribute(const QualifiedName& attrName)
+{
+ return attrName == SVGNames::zoomAndPanAttr;
+}
+
+static const UChar disable[] = {'d', 'i', 's', 'a', 'b', 'l', 'e'};
+static const UChar magnify[] = {'m', 'a', 'g', 'n', 'i', 'f', 'y'};
+
+bool SVGZoomAndPan::parseZoomAndPan(const UChar*& start, const UChar* end)
+{
+ if (skipString(start, end, disable, sizeof(disable) / sizeof(UChar)))
+ setZoomAndPan(SVG_ZOOMANDPAN_DISABLE);
+ else if (skipString(start, end, magnify, sizeof(magnify) / sizeof(UChar)))
+ setZoomAndPan(SVG_ZOOMANDPAN_MAGNIFY);
+ else
+ return false;
+
+ return true;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGZoomAndPan.h b/WebCore/svg/SVGZoomAndPan.h
new file mode 100644
index 0000000..d7be342
--- /dev/null
+++ b/WebCore/svg/SVGZoomAndPan.h
@@ -0,0 +1,60 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGZoomAndPan_h
+#define SVGZoomAndPan_h
+
+#if ENABLE(SVG)
+#include "PlatformString.h"
+
+namespace WebCore {
+
+ class MappedAttribute;
+ class QualifiedName;
+
+ class SVGZoomAndPan {
+ public:
+ enum SVGZoomAndPanType {
+ SVG_ZOOMANDPAN_UNKNOWN = 0,
+ SVG_ZOOMANDPAN_DISABLE = 1,
+ SVG_ZOOMANDPAN_MAGNIFY = 2
+ };
+
+ SVGZoomAndPan();
+ virtual ~SVGZoomAndPan();
+
+ unsigned short zoomAndPan() const;
+ virtual void setZoomAndPan(unsigned short zoomAndPan);
+
+ bool parseMappedAttribute(MappedAttribute*);
+ bool isKnownAttribute(const QualifiedName&);
+
+ bool parseZoomAndPan(const UChar*& start, const UChar* end);
+
+ private:
+ unsigned short m_zoomAndPan;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGZoomAndPan_h
diff --git a/WebCore/svg/SVGZoomAndPan.idl b/WebCore/svg/SVGZoomAndPan.idl
new file mode 100644
index 0000000..6d69583
--- /dev/null
+++ b/WebCore/svg/SVGZoomAndPan.idl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG, GenerateConstructor, ObjCProtocol] SVGZoomAndPan {
+ // Zoom and Pan Types
+ const unsigned short SVG_ZOOMANDPAN_UNKNOWN = 0;
+ const unsigned short SVG_ZOOMANDPAN_DISABLE = 1;
+ const unsigned short SVG_ZOOMANDPAN_MAGNIFY = 2;
+
+ attribute unsigned short zoomAndPan
+ /*setter raises(DOMException)*/;
+ };
+
+}
diff --git a/WebCore/svg/SVGZoomEvent.cpp b/WebCore/svg/SVGZoomEvent.cpp
new file mode 100644
index 0000000..2d5a870
--- /dev/null
+++ b/WebCore/svg/SVGZoomEvent.cpp
@@ -0,0 +1,84 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGZoomEvent.h"
+
+namespace WebCore {
+
+SVGZoomEvent::SVGZoomEvent()
+ : m_newScale(0.0f)
+ , m_previousScale(0.0f)
+{
+}
+
+SVGZoomEvent::~SVGZoomEvent()
+{
+}
+
+FloatRect SVGZoomEvent::zoomRectScreen() const
+{
+ return m_zoomRectScreen;
+}
+
+float SVGZoomEvent::previousScale() const
+{
+ return m_previousScale;
+}
+
+void SVGZoomEvent::setPreviousScale(float scale)
+{
+ m_previousScale = scale;
+}
+
+FloatPoint SVGZoomEvent::previousTranslate() const
+{
+ return m_previousTranslate;
+}
+
+float SVGZoomEvent::newScale() const
+{
+ return m_newScale;
+}
+
+void SVGZoomEvent::setNewScale(float scale)
+{
+ m_newScale = scale;
+}
+
+FloatPoint SVGZoomEvent::newTranslate() const
+{
+ return m_newTranslate;
+}
+
+bool SVGZoomEvent::isSVGZoomEvent() const
+{
+ return true;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGZoomEvent.h b/WebCore/svg/SVGZoomEvent.h
new file mode 100644
index 0000000..6a92481
--- /dev/null
+++ b/WebCore/svg/SVGZoomEvent.h
@@ -0,0 +1,68 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGZoomEvent_h
+#define SVGZoomEvent_h
+#if ENABLE(SVG)
+
+#include "FloatRect.h"
+#include "UIEvent.h"
+
+namespace WebCore {
+
+ class SVGZoomEvent : public UIEvent {
+ public:
+ SVGZoomEvent();
+ virtual ~SVGZoomEvent();
+
+ // 'SVGZoomEvent' functions
+ FloatRect zoomRectScreen() const;
+
+ float previousScale() const;
+ void setPreviousScale(float);
+
+ FloatPoint previousTranslate() const;
+
+ float newScale() const;
+ void setNewScale(float);
+
+ FloatPoint newTranslate() const;
+
+ virtual bool isSVGZoomEvent() const;
+
+ private:
+ float m_newScale;
+ float m_previousScale;
+
+ FloatRect m_zoomRectScreen;
+
+ FloatPoint m_newTranslate;
+ FloatPoint m_previousTranslate;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGZoomEvent_h
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGZoomEvent.idl b/WebCore/svg/SVGZoomEvent.idl
new file mode 100644
index 0000000..ac4a1a1
--- /dev/null
+++ b/WebCore/svg/SVGZoomEvent.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module svg {
+
+ interface [Conditional=SVG] SVGZoomEvent : events::UIEvent {
+ readonly attribute SVGRect zoomRectScreen;
+ readonly attribute float previousScale;
+ readonly attribute SVGPoint previousTranslate;
+ readonly attribute float newScale;
+ readonly attribute SVGPoint newTranslate;
+ };
+
+}
diff --git a/WebCore/svg/TimeScheduler.cpp b/WebCore/svg/TimeScheduler.cpp
new file mode 100644
index 0000000..25c365b
--- /dev/null
+++ b/WebCore/svg/TimeScheduler.cpp
@@ -0,0 +1,152 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Apple Computer, Inc.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "TimeScheduler.h"
+
+#include "Document.h"
+#include "SystemTime.h"
+#include "SVGTimer.h"
+
+namespace WebCore {
+
+const double staticTimerInterval = 0.050; // 50 ms
+
+TimeScheduler::TimeScheduler(Document* document)
+ : m_creationTime(currentTime())
+ , m_savedTime(0)
+ , m_document(document)
+{
+ // Don't start this timer yet.
+ m_intervalTimer = new SVGTimer(this, staticTimerInterval, false);
+}
+
+TimeScheduler::~TimeScheduler()
+{
+ deleteAllValues(m_timerSet);
+ delete m_intervalTimer;
+}
+
+void TimeScheduler::addTimer(SVGAnimationElement* element, unsigned ms)
+{
+#if ENABLE(SVG_ANIMATION)
+ SVGTimer* svgTimer = new SVGTimer(this, ms * 0.001, true);
+ svgTimer->addNotify(element, true);
+ m_timerSet.add(svgTimer);
+ m_intervalTimer->addNotify(element, false);
+#endif
+}
+
+void TimeScheduler::connectIntervalTimer(SVGAnimationElement* element)
+{
+#if ENABLE(SVG_ANIMATION)
+ m_intervalTimer->addNotify(element, true);
+#endif
+}
+
+void TimeScheduler::disconnectIntervalTimer(SVGAnimationElement* element)
+{
+#if ENABLE(SVG_ANIMATION)
+ m_intervalTimer->removeNotify(element);
+#endif
+}
+
+void TimeScheduler::startAnimations()
+{
+#if ENABLE(SVG_ANIMATION)
+ m_creationTime = currentTime();
+
+ SVGTimerSet::iterator end = m_timerSet.end();
+ for (SVGTimerSet::iterator it = m_timerSet.begin(); it != end; ++it) {
+ SVGTimer* svgTimer = *it;
+ if (svgTimer && !svgTimer->isActive())
+ svgTimer->start();
+ }
+#endif
+}
+
+void TimeScheduler::toggleAnimations()
+{
+#if ENABLE(SVG_ANIMATION)
+ if (m_intervalTimer->isActive()) {
+ m_intervalTimer->stop();
+ m_savedTime = currentTime();
+ } else {
+ if (m_savedTime != 0) {
+ m_creationTime += currentTime() - m_savedTime;
+ m_savedTime = 0;
+ }
+ m_intervalTimer->start();
+ }
+#endif
+}
+
+bool TimeScheduler::animationsPaused() const
+{
+ return !m_intervalTimer->isActive();
+}
+
+void TimeScheduler::timerFired(Timer<TimeScheduler>* baseTimer)
+{
+#if ENABLE(SVG_ANIMATION)
+ // Get the pointer now, because notifyAll could make the document,
+ // including this TimeScheduler, go away.
+ RefPtr<Document> doc = m_document;
+
+ SVGTimer* timer = SVGTimer::downcast(baseTimer);
+
+ timer->notifyAll();
+
+ // FIXME: Is it really safe to look at m_intervalTimer now?
+ // Isn't it possible the TimeScheduler was deleted already?
+ // If so, timer, m_timerSet, and m_intervalTimer have all
+ // been deleted. May need to reference count the TimeScheduler
+ // to work around this, and ref/deref it in this function.
+ if (timer != m_intervalTimer) {
+ ASSERT(!timer->isActive());
+ ASSERT(m_timerSet.contains(timer));
+ m_timerSet.remove(timer);
+ delete timer;
+
+ // The singleShot timers of ie. <animate> with begin="3s" are notified
+ // by the previous call, and now all connections to the interval timer
+ // are created and now we just need to fire that timer (Niko)
+ if (!m_intervalTimer->isActive())
+ m_intervalTimer->start();
+ }
+
+ // Update any 'dirty' shapes.
+ doc->updateRendering();
+#endif
+}
+
+double TimeScheduler::elapsed() const
+{
+ return currentTime() - m_creationTime;
+}
+
+} // namespace
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/TimeScheduler.h b/WebCore/svg/TimeScheduler.h
new file mode 100644
index 0000000..12c2439
--- /dev/null
+++ b/WebCore/svg/TimeScheduler.h
@@ -0,0 +1,77 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2006 Apple Computer, Inc.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef TimeScheduler_h
+#define TimeScheduler_h
+#if ENABLE(SVG)
+
+#include <wtf/HashSet.h>
+
+namespace WebCore {
+ class Document;
+ class SVGAnimationElement;
+ class SVGTimer;
+
+ template <typename T> class Timer;
+
+ typedef HashSet<SVGTimer*> SVGTimerSet;
+
+ class TimeScheduler {
+ public:
+ TimeScheduler(Document*);
+ ~TimeScheduler();
+
+ // Adds singleShot Timers
+ void addTimer(SVGAnimationElement*, unsigned int ms);
+
+ // (Dis-)Connects to interval timer with 'staticTimerInterval'
+ void connectIntervalTimer(SVGAnimationElement*);
+ void disconnectIntervalTimer(SVGAnimationElement*);
+
+ void startAnimations();
+ void toggleAnimations();
+ bool animationsPaused() const;
+
+ // time elapsed in seconds after creation of this object
+ double elapsed() const;
+
+ private:
+ friend class SVGTimer;
+ void timerFired(Timer<TimeScheduler>*);
+ Document* document() const { return m_document; }
+
+ private:
+ double m_creationTime;
+ double m_savedTime;
+
+ SVGTimerSet m_timerSet;
+
+ SVGTimer* m_intervalTimer;
+ Document* m_document;
+ };
+}
+
+#endif // ENABLE(SVG)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp
new file mode 100644
index 0000000..de868b7
--- /dev/null
+++ b/WebCore/svg/graphics/SVGImage.cpp
@@ -0,0 +1,214 @@
+/*
+ * Copyright (C) 2006 Eric Seidel (eric@webkit.org)
+ * Copyright (C) 2008 Apple, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#if ENABLE(SVG)
+#include "SVGImage.h"
+
+#include "CachedPage.h"
+#include "DocumentLoader.h"
+#include "EditCommand.h"
+#include "FloatRect.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "ImageObserver.h"
+#include "NotImplemented.h"
+#include "Page.h"
+#include "ResourceError.h"
+#include "SVGDocument.h"
+#include "SVGLength.h"
+#include "SVGRenderSupport.h"
+#include "SVGSVGElement.h"
+#include "Settings.h"
+
+#include "SVGImageEmptyClients.h"
+
+namespace WebCore {
+
+SVGImage::SVGImage(ImageObserver* observer)
+ : Image(observer)
+ , m_document(0)
+ , m_page(0)
+ , m_frame(0)
+ , m_frameView(0)
+{
+}
+
+SVGImage::~SVGImage()
+{
+ if (m_frame)
+ m_frame->loader()->frameDetached(); // Break both the loader and view references to the frame
+}
+
+void SVGImage::setContainerSize(const IntSize& containerSize)
+{
+ if (containerSize.width() <= 0 || containerSize.height() <= 0)
+ return;
+
+ SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement();
+ if (!rootElement)
+ return;
+
+ rootElement->setContainerSize(containerSize);
+}
+
+bool SVGImage::usesContainerSize() const
+{
+ SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement();
+ if (!rootElement)
+ return false;
+
+ return rootElement->hasSetContainerSize();
+}
+
+IntSize SVGImage::size() const
+{
+ if (!m_frame || !m_frame->document())
+ return IntSize();
+
+ SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement();
+ if (!rootElement)
+ return IntSize();
+
+ SVGLength width = rootElement->width();
+ SVGLength height = rootElement->height();
+
+ IntSize svgSize;
+ if (width.unitType() == LengthTypePercentage)
+ svgSize.setWidth(rootElement->relativeWidthValue());
+ else
+ svgSize.setWidth(static_cast<int>(width.value()));
+
+ if (height.unitType() == LengthTypePercentage)
+ svgSize.setHeight(rootElement->relativeHeightValue());
+ else
+ svgSize.setHeight(static_cast<int>(height.value()));
+
+ return svgSize;
+}
+
+bool SVGImage::hasRelativeWidth() const
+{
+ SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement();
+ if (!rootElement)
+ return false;
+
+ return rootElement->width().unitType() == LengthTypePercentage;
+}
+
+bool SVGImage::hasRelativeHeight() const
+{
+ SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement();
+ if (!rootElement)
+ return false;
+
+ return rootElement->height().unitType() == LengthTypePercentage;
+}
+
+void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator compositeOp)
+{
+ if (!m_frame)
+ return;
+
+ context->save();
+ context->clip(enclosingIntRect(dstRect));
+ context->translate(dstRect.location().x(), dstRect.location().y());
+ context->scale(FloatSize(dstRect.width()/srcRect.width(), dstRect.height()/srcRect.height()));
+
+ if (m_frame->view()->needsLayout())
+ m_frame->view()->layout();
+ m_frame->paint(context, enclosingIntRect(srcRect));
+
+ context->restore();
+
+ if (imageObserver())
+ imageObserver()->didDraw(this);
+}
+
+NativeImagePtr SVGImage::nativeImageForCurrentFrame()
+{
+ // FIXME: In order to support dynamic SVGs we need to have a way to invalidate this
+ // frame cache, or better yet, not use a cache for tiled drawing at all, instead
+ // having a tiled drawing callback (hopefully non-virtual).
+ if (!m_frameCache) {
+ m_frameCache.set(ImageBuffer::create(size(), false).release());
+ if (!m_frameCache) // failed to allocate image
+ return 0;
+ renderSubtreeToImage(m_frameCache.get(), m_frame->renderer());
+ }
+#if PLATFORM(CG)
+ return m_frameCache->cgImage();
+#elif PLATFORM(QT)
+ return m_frameCache->pixmap();
+#elif PLATFORM(CAIRO)
+ return m_frameCache->surface();
+#else
+ notImplemented();
+ return 0;
+#endif
+}
+
+bool SVGImage::dataChanged(bool allDataReceived)
+{
+ int length = m_data->size();
+ if (!length) // if this was an empty image
+ return true;
+
+ if (allDataReceived) {
+ static ChromeClient* dummyChromeClient = new SVGEmptyChromeClient;
+ static FrameLoaderClient* dummyFrameLoaderClient = new SVGEmptyFrameLoaderClient;
+ static EditorClient* dummyEditorClient = new SVGEmptyEditorClient;
+ static ContextMenuClient* dummyContextMenuClient = new SVGEmptyContextMenuClient;
+ static DragClient* dummyDragClient = new SVGEmptyDragClient;
+ static InspectorClient* dummyInspectorClient = new SVGEmptyInspectorClient;
+
+ // FIXME: If this SVG ends up loading itself, we'll leak this Frame (and associated DOM & render trees).
+ // The Cache code does not know about CachedImages holding Frames and won't know to break the cycle.
+ m_page.set(new Page(dummyChromeClient, dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient));
+ m_page->settings()->setJavaScriptEnabled(false);
+
+ m_frame = new Frame(m_page.get(), 0, dummyFrameLoaderClient);
+ m_frame->init();
+ m_frameView = new FrameView(m_frame.get());
+ m_frameView->deref(); // FIXME: FrameView starts with a refcount of 1
+ m_frame->setView(m_frameView.get());
+ ResourceRequest fakeRequest(KURL(""));
+ m_frame->loader()->load(fakeRequest); // Make sure the DocumentLoader is created
+ m_frame->loader()->cancelContentPolicyCheck(); // cancel any policy checks
+ m_frame->loader()->commitProvisionalLoad(0);
+ m_frame->loader()->setResponseMIMEType("image/svg+xml");
+ m_frame->loader()->begin(KURL()); // create the empty document
+ m_frame->loader()->write(m_data->data(), m_data->size());
+ m_frame->loader()->end();
+ }
+ return m_frameView;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/graphics/SVGImage.h b/WebCore/svg/graphics/SVGImage.h
new file mode 100644
index 0000000..3e67a7c
--- /dev/null
+++ b/WebCore/svg/graphics/SVGImage.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2006 Eric Seidel (eric@webkit.org)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGImage_h
+#define SVGImage_h
+
+#if ENABLE(SVG)
+
+#include "Image.h"
+#include "ImageBuffer.h"
+#include "IntSize.h"
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+ class SVGDocument;
+ class Frame;
+ class FrameView;
+ class Page;
+
+ class SVGImage : public Image {
+ public:
+ SVGImage(ImageObserver*);
+ ~SVGImage();
+
+ virtual void setContainerSize(const IntSize&);
+ virtual bool usesContainerSize() const;
+ virtual bool hasRelativeWidth() const;
+ virtual bool hasRelativeHeight() const;
+
+ virtual IntSize size() const;
+
+ virtual bool dataChanged(bool allDataReceived);
+
+ virtual NativeImagePtr frameAtIndex(size_t) { return 0; }
+
+private:
+ virtual void draw(GraphicsContext*, const FloatRect& fromRect, const FloatRect& toRect, CompositeOperator);
+
+ virtual NativeImagePtr nativeImageForCurrentFrame();
+
+ SVGDocument* m_document;
+ OwnPtr<Page> m_page;
+ RefPtr<Frame> m_frame;
+ RefPtr<FrameView> m_frameView;
+ IntSize m_minSize;
+ OwnPtr<ImageBuffer> m_frameCache;
+ };
+}
+
+#endif // ENABLE(SVG)
+
+#endif
diff --git a/WebCore/svg/graphics/SVGImageEmptyClients.h b/WebCore/svg/graphics/SVGImageEmptyClients.h
new file mode 100644
index 0000000..ce9296a
--- /dev/null
+++ b/WebCore/svg/graphics/SVGImageEmptyClients.h
@@ -0,0 +1,417 @@
+/*
+ * Copyright (C) 2006 Eric Seidel (eric@webkit.org)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGImageEmptyClients_h
+#define SVGImageEmptyClients_h
+
+#if ENABLE(SVG)
+
+#include "ChromeClient.h"
+#include "ContextMenuClient.h"
+#include "DragClient.h"
+#include "EditorClient.h"
+#include "FocusDirection.h"
+#include "FrameLoaderClient.h"
+#include "InspectorClient.h"
+#include "SharedBuffer.h"
+
+/*
+ This file holds empty Client stubs for use by SVGImage.
+ SVGImage needs to create a dummy Page->Frame->FrameView tree for use in parsing an SVGDocument.
+ This tree depends heavily on Clients (usually provided by WebKit classes).
+
+ SVGImage has no way to access the current Page (nor should it, since Images are not tied to a page).
+ See http://bugs.webkit.org/show_bug.cgi?id=5971 for more discussion on this issue.
+
+ Ideally, whenever you change a Client class, you should add a stub here.
+ Brittle, yes. Unfortunate, yes. Hopefully temporary.
+*/
+
+namespace WebCore {
+
+class SVGEmptyChromeClient : public ChromeClient {
+public:
+ virtual ~SVGEmptyChromeClient() { }
+ virtual void chromeDestroyed() { }
+
+ virtual void setWindowRect(const FloatRect&) { }
+ virtual FloatRect windowRect() { return FloatRect(); }
+
+ virtual FloatRect pageRect() { return FloatRect(); }
+
+ virtual float scaleFactor() { return 1.f; }
+
+ virtual void focus() { }
+ virtual void unfocus() { }
+
+ virtual bool canTakeFocus(FocusDirection) { return false; }
+ virtual void takeFocus(FocusDirection) { }
+
+ virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&) { return 0; }
+ virtual void show() { }
+
+ virtual bool canRunModal() { return false; }
+ virtual void runModal() { }
+
+ virtual void setToolbarsVisible(bool) { }
+ virtual bool toolbarsVisible() { return false; }
+
+ virtual void setStatusbarVisible(bool) { }
+ virtual bool statusbarVisible() { return false; }
+
+ virtual void setScrollbarsVisible(bool) { }
+ virtual bool scrollbarsVisible() { return false; }
+
+ virtual void setMenubarVisible(bool) { }
+ virtual bool menubarVisible() { return false; }
+
+ virtual void setResizable(bool) { }
+
+ virtual void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID) { }
+
+ virtual bool canRunBeforeUnloadConfirmPanel() { return false; }
+ virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame) { return true; }
+
+ virtual void closeWindowSoon() { }
+
+ virtual void runJavaScriptAlert(Frame*, const String&) { }
+ virtual bool runJavaScriptConfirm(Frame*, const String&) { return false; }
+ virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result) { return false; }
+ virtual bool shouldInterruptJavaScript() { return false; }
+
+ virtual void setStatusbarText(const String&) { }
+
+ virtual bool tabsToLinks() const { return false; }
+
+ virtual IntRect windowResizerRect() const { return IntRect(); }
+ virtual void addToDirtyRegion(const IntRect&) { }
+ virtual void scrollBackingStore(int dx, int dy, const IntRect& scrollViewRect, const IntRect& clipRect) { }
+ virtual void updateBackingStore() { }
+
+ virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) { }
+
+ virtual void setToolTip(const String&) { }
+
+ virtual void print(Frame*) { }
+
+ virtual void exceededDatabaseQuota(Frame*, const String&) { }
+};
+
+class SVGEmptyFrameLoaderClient : public FrameLoaderClient {
+public:
+ virtual ~SVGEmptyFrameLoaderClient() { }
+ virtual void frameLoaderDestroyed() { }
+
+ virtual bool hasWebView() const { return true; } // mainly for assertions
+ virtual bool hasFrameView() const { return true; } // ditto
+
+ virtual void makeRepresentation(DocumentLoader*) { }
+ virtual void forceLayout() { }
+ virtual void forceLayoutForNonHTML() { }
+
+ virtual void updateHistoryForCommit() { }
+
+ virtual void updateHistoryForBackForwardNavigation() { }
+ virtual void updateHistoryForReload() { }
+ virtual void updateHistoryForStandardLoad() { }
+ virtual void updateHistoryForInternalLoad() { }
+
+ virtual void updateHistoryAfterClientRedirect() { }
+
+ virtual void setCopiesOnScroll() { }
+
+ virtual void detachedFromParent2() { }
+ virtual void detachedFromParent3() { }
+ virtual void detachedFromParent4() { }
+
+ virtual void download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&) { }
+
+ virtual void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&) { }
+ virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse) { }
+ virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) { }
+ virtual void dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) { }
+ virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&) { }
+ virtual void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived) { }
+ virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) { }
+ virtual void dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&) { }
+ virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length) { return false; }
+
+ virtual void dispatchDidHandleOnloadEvents() { }
+ virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() { }
+ virtual void dispatchDidCancelClientRedirect() { }
+ virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate) { }
+ virtual void dispatchDidChangeLocationWithinPage() { }
+ virtual void dispatchWillClose() { }
+ virtual void dispatchDidReceiveIcon() { }
+ virtual void dispatchDidStartProvisionalLoad() { }
+ virtual void dispatchDidReceiveTitle(const String& title) { }
+ virtual void dispatchDidCommitLoad() { }
+ virtual void dispatchDidFailProvisionalLoad(const ResourceError&) { }
+ virtual void dispatchDidFailLoad(const ResourceError&) { }
+ virtual void dispatchDidFinishDocumentLoad() { }
+ virtual void dispatchDidFinishLoad() { }
+ virtual void dispatchDidFirstLayout() { }
+
+ virtual Frame* dispatchCreatePage() { return 0; }
+ virtual void dispatchShow() { }
+
+ virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction, const String& MIMEType, const ResourceRequest&) { }
+ virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, const String& frameName) { }
+ virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&) { }
+ virtual void cancelPolicyCheck() { }
+
+ virtual void dispatchUnableToImplementPolicy(const ResourceError&) { }
+
+ virtual void dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormState>) { }
+
+ virtual void dispatchDidLoadMainResource(DocumentLoader*) { }
+ virtual void revertToProvisionalState(DocumentLoader*) { }
+ virtual void setMainDocumentError(DocumentLoader*, const ResourceError&) { }
+ virtual void clearUnarchivingState(DocumentLoader*) { }
+
+ virtual void willChangeEstimatedProgress() { }
+ virtual void didChangeEstimatedProgress() { }
+ virtual void postProgressStartedNotification() { }
+ virtual void postProgressEstimateChangedNotification() { }
+ virtual void postProgressFinishedNotification() { }
+
+ virtual void setMainFrameDocumentReady(bool) { }
+
+ virtual void startDownload(const ResourceRequest&) { }
+
+ virtual void willChangeTitle(DocumentLoader*) { }
+ virtual void didChangeTitle(DocumentLoader*) { }
+
+ virtual void committedLoad(DocumentLoader*, const char*, int) { }
+ virtual void finishedLoading(DocumentLoader*) { }
+ virtual void finalSetupForReplace(DocumentLoader*) { }
+
+ virtual ResourceError cancelledError(const ResourceRequest&) { return ResourceError(); }
+ virtual ResourceError blockedError(const ResourceRequest&) { return ResourceError(); }
+ virtual ResourceError cannotShowURLError(const ResourceRequest&) { return ResourceError(); }
+ virtual ResourceError interruptForPolicyChangeError(const ResourceRequest&) { return ResourceError(); }
+
+ virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&) { return ResourceError(); }
+ virtual ResourceError fileDoesNotExistError(const ResourceResponse&) { return ResourceError(); }
+
+ virtual bool shouldFallBack(const ResourceError&) { return false; }
+
+ virtual void setDefersLoading(bool) { }
+
+ virtual bool willUseArchive(ResourceLoader*, const ResourceRequest&, const KURL& originalURL) const { return false; }
+ virtual bool isArchiveLoadPending(ResourceLoader*) const { return false; }
+ virtual void cancelPendingArchiveLoad(ResourceLoader*) { }
+ virtual void clearArchivedResources() { }
+
+ virtual bool canHandleRequest(const ResourceRequest&) const { return false; }
+ virtual bool canShowMIMEType(const String& MIMEType) const { return false; }
+ virtual bool representationExistsForURLScheme(const String& URLScheme) const { return false; }
+ virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const { return ""; }
+
+ virtual void frameLoadCompleted() { }
+ virtual void restoreViewState() { }
+ virtual void provisionalLoadStarted() { }
+ virtual bool shouldTreatURLAsSameAsCurrent(const KURL&) const { return false; }
+ virtual void addHistoryItemForFragmentScroll() { }
+ virtual void didFinishLoad() { }
+ virtual void prepareForDataSourceReplacement() { }
+
+ virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData) { return new DocumentLoader(request, substituteData); }
+ virtual void setTitle(const String& title, const KURL&) { }
+
+ virtual String userAgent(const KURL&) { return ""; }
+
+ virtual void savePlatformDataToCachedPage(CachedPage*) { }
+ virtual void transitionToCommittedFromCachedPage(CachedPage*) { }
+ virtual void transitionToCommittedForNewPage() { }
+
+ virtual void updateGlobalHistory(const KURL&) { }
+ virtual bool shouldGoToHistoryItem(HistoryItem*) const { return false; }
+ virtual void saveViewStateToItem(HistoryItem*) { }
+ virtual bool canCachePage() const { return false; }
+
+ virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
+ const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) { return 0; }
+ virtual Widget* createPlugin(const IntSize&,Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool) { return 0; }
+ virtual Widget* createJavaAppletWidget(const IntSize&, Element*, const KURL&, const Vector<String>&, const Vector<String>&) { return 0; }
+
+ virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType) { return ObjectContentType(); }
+ virtual String overrideMediaType() const { return String(); }
+
+ virtual void redirectDataToPlugin(Widget*) {}
+ virtual void windowObjectCleared() {}
+ virtual void didPerformFirstNavigation() const {}
+
+ virtual void registerForIconNotification(bool listen) {}
+
+#if PLATFORM(MAC)
+ virtual NSCachedURLResponse* willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse* response) const { return response; }
+#endif
+
+};
+
+class SVGEmptyEditorClient : public EditorClient {
+public:
+ virtual ~SVGEmptyEditorClient() { }
+ virtual void pageDestroyed() { }
+
+ virtual bool shouldDeleteRange(Range*) { return false; }
+ virtual bool shouldShowDeleteInterface(HTMLElement*) { return false; }
+ virtual bool smartInsertDeleteEnabled() { return false; }
+ virtual bool isContinuousSpellCheckingEnabled() { return false; }
+ virtual void toggleContinuousSpellChecking() { }
+ virtual bool isGrammarCheckingEnabled() { return false; }
+ virtual void toggleGrammarChecking() { }
+ virtual int spellCheckerDocumentTag() { return -1; }
+
+ virtual bool selectWordBeforeMenuEvent() { return false; }
+ virtual bool isEditable() { return false; }
+
+ virtual bool shouldBeginEditing(Range*) { return false; }
+ virtual bool shouldEndEditing(Range*) { return false; }
+ virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction) { return false; }
+ // virtual bool shouldInsertNode(Node*, Range* replacingRange, WebViewInsertAction) { return false; }
+ virtual bool shouldInsertText(String, Range*, EditorInsertAction) { return false; }
+ virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting) { return false; }
+
+ virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*) { return false; }
+ virtual bool shouldMoveRangeAfterDelete(Range*, Range*) { return false; }
+ // virtual bool shouldChangeTypingStyle(CSSStyleDeclaration* fromStyle, CSSStyleDeclaration* toStyle) { return false; }
+ // virtual bool doCommandBySelector(SEL selector) { return false; }
+ //
+ virtual void didBeginEditing() { }
+ virtual void respondToChangedContents() { }
+ virtual void respondToChangedSelection() { }
+ virtual void didEndEditing() { }
+ virtual void didWriteSelectionToPasteboard() { }
+ virtual void didSetSelectionTypesForPasteboard() { }
+ // virtual void webViewDidChangeTypingStyle:(NSNotification *)notification { }
+ // virtual void webViewDidChangeSelection:(NSNotification *)notification { }
+ // virtual NSUndoManager* undoManagerForWebView:(WebView *)webView { return 0; }
+
+ virtual void registerCommandForUndo(PassRefPtr<EditCommand>) { }
+ virtual void registerCommandForRedo(PassRefPtr<EditCommand>) { }
+ virtual void clearUndoRedoOperations() { }
+
+ virtual bool canUndo() const { return false; }
+ virtual bool canRedo() const { return false; }
+
+ virtual void undo() { }
+ virtual void redo() { }
+
+ virtual void handleKeyboardEvent(KeyboardEvent*) { }
+ virtual void handleInputMethodKeydown(KeyboardEvent*) { }
+
+ virtual void textFieldDidBeginEditing(Element*) { }
+ virtual void textFieldDidEndEditing(Element*) { }
+ virtual void textDidChangeInTextField(Element*) { }
+ virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*) { return false; }
+ virtual void textWillBeDeletedInTextField(Element*) { }
+ virtual void textDidChangeInTextArea(Element*) { }
+
+#if PLATFORM(MAC)
+ virtual void markedTextAbandoned(Frame*) { }
+
+ // FIXME: This should become SelectionController::toWebArchive()
+ virtual NSData* dataForArchivedSelection(Frame*) { return 0; }
+
+ virtual NSString* userVisibleString(NSURL*) { return 0; }
+#ifdef BUILDING_ON_TIGER
+ virtual NSArray* pasteboardTypesForSelection(Frame*) { return 0; }
+#endif
+#endif
+ virtual void ignoreWordInSpellDocument(const String&) { }
+ virtual void learnWord(const String&) { }
+ virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength) { }
+ virtual void checkGrammarOfString(const UChar*, int length, Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) { }
+ virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&) { }
+ virtual void updateSpellingUIWithMisspelledWord(const String&) { }
+ virtual void showSpellingUI(bool show) { }
+ virtual bool spellingUIIsShowing() { return false; }
+ virtual void getGuessesForWord(const String&, Vector<String>& guesses) { }
+ virtual void setInputMethodState(bool enabled) { }
+
+
+};
+
+class SVGEmptyContextMenuClient : public ContextMenuClient {
+public:
+ virtual ~SVGEmptyContextMenuClient() { }
+ virtual void contextMenuDestroyed() { }
+
+ virtual PlatformMenuDescription getCustomMenuFromDefaultItems(ContextMenu*) { return 0; }
+ virtual void contextMenuItemSelected(ContextMenuItem*, const ContextMenu*) { }
+
+ virtual void downloadURL(const KURL& url) { }
+ virtual void copyImageToClipboard(const HitTestResult&) { }
+ virtual void searchWithGoogle(const Frame*) { }
+ virtual void lookUpInDictionary(Frame*) { }
+ virtual void speak(const String&) { }
+ virtual void stopSpeaking() { }
+
+#if PLATFORM(MAC)
+ virtual void searchWithSpotlight() { }
+#endif
+};
+
+class SVGEmptyDragClient : public DragClient {
+public:
+ virtual ~SVGEmptyDragClient() {}
+ virtual void willPerformDragDestinationAction(DragDestinationAction, DragData*) { }
+ virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*) { }
+ virtual DragDestinationAction actionMaskForDrag(DragData*) { return DragDestinationActionNone; }
+ virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint&) { return DragSourceActionNone; }
+ virtual void startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool) { }
+ virtual DragImageRef createDragImageForLink(KURL&, const String& label, Frame*) { return 0; }
+ virtual void dragControllerDestroyed() { }
+};
+
+class SVGEmptyInspectorClient : public InspectorClient {
+public:
+ virtual ~SVGEmptyInspectorClient() {}
+
+ virtual void inspectorDestroyed() {};
+
+ virtual Page* createPage() { return 0; };
+
+ virtual String localizedStringsURL() { return String(); };
+
+ virtual void showWindow() {};
+ virtual void closeWindow() {};
+
+ virtual void attachWindow() {};
+ virtual void detachWindow() {};
+
+ virtual void highlight(Node*) {};
+ virtual void hideHighlight() {};
+ virtual void inspectedURLChanged(const String& newURL) {};
+};
+
+}
+
+#endif // ENABLE(SVG)
+
+#endif // SVGImageEmptyClients_h
+
diff --git a/WebCore/svg/graphics/SVGPaintServer.cpp b/WebCore/svg/graphics/SVGPaintServer.cpp
new file mode 100644
index 0000000..9a59683
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServer.cpp
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * 2007 Rob Buis <buis@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServer.h"
+
+#include "RenderObject.h"
+#include "RenderStyle.h"
+#include "SVGPaintServerSolid.h"
+#include "SVGStyledElement.h"
+#include "SVGURIReference.h"
+
+namespace WebCore {
+
+SVGPaintServer::SVGPaintServer()
+{
+}
+
+SVGPaintServer::~SVGPaintServer()
+{
+}
+
+TextStream& operator<<(TextStream& ts, const SVGPaintServer& paintServer)
+{
+ return paintServer.externalRepresentation(ts);
+}
+
+SVGPaintServer* getPaintServerById(Document* document, const AtomicString& id)
+{
+ SVGResource* resource = getResourceById(document, id);
+ if (resource && resource->isPaintServer())
+ return static_cast<SVGPaintServer*>(resource);
+
+ return 0;
+}
+
+SVGPaintServerSolid* SVGPaintServer::sharedSolidPaintServer()
+{
+ static SVGPaintServerSolid* _sharedSolidPaintServer = SVGPaintServerSolid::create().releaseRef();
+
+ return _sharedSolidPaintServer;
+}
+
+SVGPaintServer* SVGPaintServer::fillPaintServer(const RenderStyle* style, const RenderObject* item)
+{
+ if (!style->svgStyle()->hasFill())
+ return 0;
+
+ SVGPaint* fill = style->svgStyle()->fillPaint();
+
+ SVGPaintServer* fillPaintServer = 0;
+ SVGPaint::SVGPaintType paintType = fill->paintType();
+ if (paintType == SVGPaint::SVG_PAINTTYPE_URI ||
+ paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR) {
+ AtomicString id(SVGURIReference::getTarget(fill->uri()));
+ fillPaintServer = getPaintServerById(item->document(), id);
+
+ SVGElement* svgElement = static_cast<SVGElement*>(item->element());
+ ASSERT(svgElement && svgElement->document() && svgElement->isStyled());
+
+ if (item->isRenderPath() && fillPaintServer)
+ fillPaintServer->addClient(static_cast<SVGStyledElement*>(svgElement));
+ else if (!fillPaintServer && paintType == SVGPaint::SVG_PAINTTYPE_URI)
+ svgElement->document()->accessSVGExtensions()->addPendingResource(id, static_cast<SVGStyledElement*>(svgElement));
+ }
+ if (paintType != SVGPaint::SVG_PAINTTYPE_URI && !fillPaintServer) {
+ fillPaintServer = sharedSolidPaintServer();
+ SVGPaintServerSolid* fillPaintServerSolid = static_cast<SVGPaintServerSolid*>(fillPaintServer);
+ if (paintType == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR)
+ fillPaintServerSolid->setColor(style->color());
+ else
+ fillPaintServerSolid->setColor(fill->color());
+ // FIXME: Ideally invalid colors would never get set on the RenderStyle and this could turn into an ASSERT
+ if (!fillPaintServerSolid->color().isValid())
+ fillPaintServer = 0;
+ }
+ if (!fillPaintServer) {
+ // default value (black), see bug 11017
+ fillPaintServer = sharedSolidPaintServer();
+ static_cast<SVGPaintServerSolid*>(fillPaintServer)->setColor(Color::black);
+ }
+ return fillPaintServer;
+}
+
+SVGPaintServer* SVGPaintServer::strokePaintServer(const RenderStyle* style, const RenderObject* item)
+{
+ if (!style->svgStyle()->hasStroke())
+ return 0;
+
+ SVGPaint* stroke = style->svgStyle()->strokePaint();
+
+ SVGPaintServer* strokePaintServer = 0;
+ SVGPaint::SVGPaintType paintType = stroke->paintType();
+ if (paintType == SVGPaint::SVG_PAINTTYPE_URI ||
+ paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR) {
+ AtomicString id(SVGURIReference::getTarget(stroke->uri()));
+ strokePaintServer = getPaintServerById(item->document(), id);
+
+ SVGElement* svgElement = static_cast<SVGElement*>(item->element());
+ ASSERT(svgElement && svgElement->document() && svgElement->isStyled());
+
+ if (item->isRenderPath() && strokePaintServer)
+ strokePaintServer->addClient(static_cast<SVGStyledElement*>(svgElement));
+ else if (!strokePaintServer && paintType == SVGPaint::SVG_PAINTTYPE_URI)
+ svgElement->document()->accessSVGExtensions()->addPendingResource(id, static_cast<SVGStyledElement*>(svgElement));
+ }
+ if (paintType != SVGPaint::SVG_PAINTTYPE_URI && !strokePaintServer) {
+ strokePaintServer = sharedSolidPaintServer();
+ SVGPaintServerSolid* strokePaintServerSolid = static_cast<SVGPaintServerSolid*>(strokePaintServer);
+ if (paintType == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR)
+ strokePaintServerSolid->setColor(style->color());
+ else
+ strokePaintServerSolid->setColor(stroke->color());
+ // FIXME: Ideally invalid colors would never get set on the RenderStyle and this could turn into an ASSERT
+ if (!strokePaintServerSolid->color().isValid())
+ strokePaintServer = 0;
+ }
+
+ return strokePaintServer;
+}
+
+DashArray dashArrayFromRenderingStyle(const RenderStyle* style)
+{
+ DashArray array;
+
+ CSSValueList* dashes = style->svgStyle()->strokeDashArray();
+ if (dashes) {
+ CSSPrimitiveValue* dash = 0;
+ unsigned long len = dashes->length();
+ for (unsigned long i = 0; i < len; i++) {
+ dash = static_cast<CSSPrimitiveValue*>(dashes->item(i));
+ if (!dash)
+ continue;
+
+ array.append((float) dash->computeLengthFloat(const_cast<RenderStyle*>(style)));
+ }
+ }
+
+ return array;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/SVGPaintServer.h b/WebCore/svg/graphics/SVGPaintServer.h
new file mode 100644
index 0000000..2df381e
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServer.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGPaintServer_h
+#define SVGPaintServer_h
+
+#if ENABLE(SVG)
+
+#include "SVGResource.h"
+
+#if PLATFORM(CG)
+#include <ApplicationServices/ApplicationServices.h>
+#endif
+
+#if PLATFORM(QT)
+class QPen;
+#endif
+
+#if PLATFORM(CG)
+ typedef Vector<CGFloat> DashArray;
+#else
+ typedef Vector<float> DashArray;
+#endif
+
+namespace WebCore {
+
+ enum SVGPaintServerType {
+ // Painting mode
+ SolidPaintServer = 0,
+ PatternPaintServer = 1,
+ LinearGradientPaintServer = 2,
+ RadialGradientPaintServer = 3
+ };
+
+ enum SVGPaintTargetType {
+ // Target mode
+ ApplyToFillTargetType = 1,
+ ApplyToStrokeTargetType = 2
+ };
+
+ class GraphicsContext;
+ class RenderObject;
+ class RenderStyle;
+ class SVGPaintServerSolid;
+
+ class SVGPaintServer : public SVGResource {
+ public:
+ virtual ~SVGPaintServer();
+
+ virtual SVGResourceType resourceType() const { return PaintServerResourceType; }
+
+ virtual SVGPaintServerType type() const = 0;
+ virtual TextStream& externalRepresentation(TextStream&) const = 0;
+
+ // To be implemented in platform specific code.
+ virtual void draw(GraphicsContext*&, const RenderObject*, SVGPaintTargetType) const;
+ virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText = false) const;
+ virtual void renderPath(GraphicsContext*&, const RenderObject*, SVGPaintTargetType) const;
+
+ virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText = false) const = 0;
+
+ static SVGPaintServer* strokePaintServer(const RenderStyle*, const RenderObject*);
+ static SVGPaintServer* fillPaintServer(const RenderStyle*, const RenderObject*);
+ static SVGPaintServerSolid* sharedSolidPaintServer();
+
+ protected:
+#if PLATFORM(CG)
+ void strokePath(CGContextRef, const RenderObject*) const;
+ void clipToStrokePath(CGContextRef, const RenderObject*) const;
+ void fillPath(CGContextRef, const RenderObject*) const;
+ void clipToFillPath(CGContextRef, const RenderObject*) const;
+#endif
+
+#if PLATFORM(QT)
+ void setPenProperties(const RenderObject*, const RenderStyle*, QPen&) const;
+#endif
+ protected:
+ SVGPaintServer();
+ };
+
+ TextStream& operator<<(TextStream&, const SVGPaintServer&);
+
+ SVGPaintServer* getPaintServerById(Document*, const AtomicString&);
+
+ DashArray dashArrayFromRenderingStyle(const RenderStyle* style);
+} // namespace WebCore
+
+#endif
+
+#endif // SVGPaintServer_h
diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.cpp b/WebCore/svg/graphics/SVGPaintServerGradient.cpp
new file mode 100644
index 0000000..6a701b8
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServerGradient.cpp
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerGradient.h"
+
+#include "SVGGradientElement.h"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+TextStream& operator<<(TextStream& ts, SVGGradientSpreadMethod m)
+{
+ switch (m) {
+ case SPREADMETHOD_PAD:
+ ts << "PAD"; break;
+ case SPREADMETHOD_REPEAT:
+ ts << "REPEAT"; break;
+ case SPREADMETHOD_REFLECT:
+ ts << "REFLECT"; break;
+ }
+
+ return ts;
+}
+
+TextStream& operator<<(TextStream& ts, const Vector<SVGGradientStop>& l)
+{
+ ts << "[";
+ for (Vector<SVGGradientStop>::const_iterator it = l.begin(); it != l.end(); ++it) {
+ ts << "(" << it->first << "," << it->second << ")";
+ if (it + 1 != l.end())
+ ts << ", ";
+ }
+ ts << "]";
+ return ts;
+}
+
+SVGPaintServerGradient::SVGPaintServerGradient(const SVGGradientElement* owner)
+ : m_spreadMethod(SPREADMETHOD_PAD)
+ , m_boundingBoxMode(true)
+ , m_ownerElement(owner)
+
+#if PLATFORM(CG)
+ , m_stopsCache(0)
+ , m_shadingCache(0)
+ , m_savedContext(0)
+ , m_imageBuffer(0)
+#endif
+{
+ ASSERT(owner);
+}
+
+SVGPaintServerGradient::~SVGPaintServerGradient()
+{
+#if PLATFORM(CG)
+ CGShadingRelease(m_shadingCache);
+#endif
+}
+
+const Vector<SVGGradientStop>& SVGPaintServerGradient::gradientStops() const
+{
+ return m_stops;
+}
+
+void SVGPaintServerGradient::setGradientStops(const Vector<SVGGradientStop>& stops)
+{
+ m_stops = stops;
+}
+
+SVGGradientSpreadMethod SVGPaintServerGradient::spreadMethod() const
+{
+ return m_spreadMethod;
+}
+
+void SVGPaintServerGradient::setGradientSpreadMethod(const SVGGradientSpreadMethod& method)
+{
+ m_spreadMethod = method;
+}
+
+bool SVGPaintServerGradient::boundingBoxMode() const
+{
+ return m_boundingBoxMode;
+}
+
+void SVGPaintServerGradient::setBoundingBoxMode(bool mode)
+{
+ m_boundingBoxMode = mode;
+}
+
+AffineTransform SVGPaintServerGradient::gradientTransform() const
+{
+ return m_gradientTransform;
+}
+
+void SVGPaintServerGradient::setGradientTransform(const AffineTransform& transform)
+{
+ m_gradientTransform = transform;
+}
+
+TextStream& SVGPaintServerGradient::externalRepresentation(TextStream& ts) const
+{
+ // Gradients/patterns aren't setup, until they are used for painting. Work around that fact.
+ m_ownerElement->buildGradient();
+
+ // abstract, don't stream type
+ ts << "[stops=" << gradientStops() << "]";
+ if (spreadMethod() != SPREADMETHOD_PAD)
+ ts << "[method=" << spreadMethod() << "]";
+ if (!boundingBoxMode())
+ ts << " [bounding box mode=" << boundingBoxMode() << "]";
+ if (!gradientTransform().isIdentity())
+ ts << " [transform=" << gradientTransform() << "]";
+
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.h b/WebCore/svg/graphics/SVGPaintServerGradient.h
new file mode 100644
index 0000000..a4af37b
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServerGradient.h
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGPaintServerGradient_h
+#define SVGPaintServerGradient_h
+
+#if ENABLE(SVG)
+
+#include "AffineTransform.h"
+#include "Color.h"
+#include "SVGPaintServer.h"
+
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+#if PLATFORM(QT)
+class QGradient;
+#endif
+
+namespace WebCore {
+
+ class ImageBuffer;
+ class SVGGradientElement;
+
+ // FIXME: Remove the spread method enum in SVGGradientElement
+ enum SVGGradientSpreadMethod {
+ SPREADMETHOD_PAD = 1,
+ SPREADMETHOD_REFLECT = 2,
+ SPREADMETHOD_REPEAT = 3
+ };
+
+#if PLATFORM(CG)
+ typedef std::pair<CGFloat, Color> SVGGradientStop;
+#else
+ typedef std::pair<float, Color> SVGGradientStop;
+#endif
+
+
+ class SVGPaintServerGradient : public SVGPaintServer {
+ public:
+ virtual ~SVGPaintServerGradient();
+
+ const Vector<SVGGradientStop>& gradientStops() const;
+ void setGradientStops(const Vector<SVGGradientStop>&);
+
+ SVGGradientSpreadMethod spreadMethod() const;
+ void setGradientSpreadMethod(const SVGGradientSpreadMethod&);
+
+ // Gradient start and end points are percentages when used in boundingBox mode.
+ // For instance start point with value (0,0) is top-left and end point with
+ // value (100, 100) is bottom-right. BoundingBox mode is enabled by default.
+ bool boundingBoxMode() const;
+ void setBoundingBoxMode(bool mode = true);
+
+ AffineTransform gradientTransform() const;
+ void setGradientTransform(const AffineTransform&);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+ virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
+#if PLATFORM(CG)
+ virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
+ virtual void renderPath(GraphicsContext*&, const RenderObject*, SVGPaintTargetType) const;
+
+ virtual void invalidate();
+
+ // Helpers
+ void updateQuartzGradientStopsCache(const Vector<SVGGradientStop>&);
+ void updateQuartzGradientCache(const SVGPaintServerGradient*);
+ void handleBoundingBoxModeAndGradientTransformation(GraphicsContext*, const FloatRect& targetRect) const;
+#endif
+
+#if PLATFORM(QT)
+ protected:
+ void fillColorArray(QGradient&, const Vector<SVGGradientStop>&, float opacity) const;
+ virtual QGradient setupGradient(GraphicsContext*&, const RenderObject*) const = 0;
+#endif
+
+ protected:
+ SVGPaintServerGradient(const SVGGradientElement* owner);
+
+ private:
+ Vector<SVGGradientStop> m_stops;
+ SVGGradientSpreadMethod m_spreadMethod;
+ bool m_boundingBoxMode;
+ AffineTransform m_gradientTransform;
+ const SVGGradientElement* m_ownerElement;
+
+#if PLATFORM(CG)
+ public:
+ typedef struct {
+ CGFloat colorArray[4];
+ CGFloat offset;
+ CGFloat previousDeltaInverse;
+ } QuartzGradientStop;
+
+ struct SharedStopCache : public RefCounted<SharedStopCache> {
+ public:
+ static PassRefPtr<SharedStopCache> create() { return adoptRef(new SharedStopCache); }
+
+ Vector<QuartzGradientStop> m_stops;
+
+ private:
+ SharedStopCache() { }
+ };
+
+ RefPtr<SharedStopCache> m_stopsCache;
+
+ CGShadingRef m_shadingCache;
+ mutable GraphicsContext* m_savedContext;
+ mutable ImageBuffer* m_imageBuffer;
+#endif
+ };
+
+ inline SVGGradientStop makeGradientStop(float offset, const Color& color)
+ {
+ return std::make_pair(offset, color);
+ }
+
+} // namespace WebCore
+
+#endif
+
+#endif // SVGPaintServerGradient_h
diff --git a/WebCore/svg/graphics/SVGPaintServerLinearGradient.cpp b/WebCore/svg/graphics/SVGPaintServerLinearGradient.cpp
new file mode 100644
index 0000000..08db2d2
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServerLinearGradient.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerLinearGradient.h"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+SVGPaintServerLinearGradient::SVGPaintServerLinearGradient(const SVGGradientElement* owner)
+ : SVGPaintServerGradient(owner)
+{
+}
+
+SVGPaintServerLinearGradient::~SVGPaintServerLinearGradient()
+{
+}
+
+FloatPoint SVGPaintServerLinearGradient::gradientStart() const
+{
+ return m_start;
+}
+
+void SVGPaintServerLinearGradient::setGradientStart(const FloatPoint& start)
+{
+ m_start = start;
+}
+
+FloatPoint SVGPaintServerLinearGradient::gradientEnd() const
+{
+ return m_end;
+}
+
+void SVGPaintServerLinearGradient::setGradientEnd(const FloatPoint& end)
+{
+ m_end = end;
+}
+
+TextStream& SVGPaintServerLinearGradient::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=LINEAR-GRADIENT] ";
+ SVGPaintServerGradient::externalRepresentation(ts);
+ ts << " [start=" << gradientStart() << "]"
+ << " [end=" << gradientEnd() << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/SVGPaintServerLinearGradient.h b/WebCore/svg/graphics/SVGPaintServerLinearGradient.h
new file mode 100644
index 0000000..4b7da32
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServerLinearGradient.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGPaintServerLinearGradient_h
+#define SVGPaintServerLinearGradient_h
+
+#if ENABLE(SVG)
+
+#include "FloatPoint.h"
+#include "SVGPaintServerGradient.h"
+
+namespace WebCore {
+
+ class SVGPaintServerLinearGradient : public SVGPaintServerGradient {
+ public:
+ static PassRefPtr<SVGPaintServerLinearGradient> create(const SVGGradientElement* owner) { return adoptRef(new SVGPaintServerLinearGradient(owner)); }
+ virtual ~SVGPaintServerLinearGradient();
+
+ virtual SVGPaintServerType type() const { return LinearGradientPaintServer; }
+
+ FloatPoint gradientStart() const;
+ void setGradientStart(const FloatPoint&);
+
+ FloatPoint gradientEnd() const;
+ void setGradientEnd(const FloatPoint&);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(QT)
+ virtual QGradient setupGradient(GraphicsContext*&, const RenderObject*) const;
+#endif
+
+ private:
+ SVGPaintServerLinearGradient(const SVGGradientElement* owner);
+
+ FloatPoint m_start;
+ FloatPoint m_end;
+ };
+
+} // namespace WebCore
+
+#endif
+
+#endif // SVGPaintServerLinearGradient_h
diff --git a/WebCore/svg/graphics/SVGPaintServerPattern.cpp b/WebCore/svg/graphics/SVGPaintServerPattern.cpp
new file mode 100644
index 0000000..c0e5b07
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServerPattern.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerPattern.h"
+
+#include "ImageBuffer.h"
+#include "SVGPatternElement.h"
+#include "SVGRenderTreeAsText.h"
+
+using namespace std;
+
+namespace WebCore {
+
+SVGPaintServerPattern::SVGPaintServerPattern(const SVGPatternElement* owner)
+ : m_ownerElement(owner)
+#if PLATFORM(CG)
+ , m_patternSpace(0)
+ , m_pattern(0)
+#endif
+{
+ ASSERT(owner);
+}
+
+SVGPaintServerPattern::~SVGPaintServerPattern()
+{
+#if PLATFORM(CG)
+ CGPatternRelease(m_pattern);
+ CGColorSpaceRelease(m_patternSpace);
+#endif
+}
+
+FloatRect SVGPaintServerPattern::patternBoundaries() const
+{
+ return m_patternBoundaries;
+}
+
+void SVGPaintServerPattern::setPatternBoundaries(const FloatRect& rect)
+{
+ m_patternBoundaries = rect;
+}
+
+ImageBuffer* SVGPaintServerPattern::tile() const
+{
+ return m_tile.get();
+}
+
+void SVGPaintServerPattern::setTile(auto_ptr<ImageBuffer> tile)
+{
+ m_tile.set(tile.release());
+}
+
+AffineTransform SVGPaintServerPattern::patternTransform() const
+{
+ return m_patternTransform;
+}
+
+void SVGPaintServerPattern::setPatternTransform(const AffineTransform& transform)
+{
+ m_patternTransform = transform;
+}
+
+TextStream& SVGPaintServerPattern::externalRepresentation(TextStream& ts) const
+{
+ // Gradients/patterns aren't setup, until they are used for painting. Work around that fact.
+ m_ownerElement->buildPattern(FloatRect(0.0f, 0.0f, 1.0f, 1.0f));
+
+ ts << "[type=PATTERN]"
+ << " [bbox=" << patternBoundaries() << "]";
+ if (!patternTransform().isIdentity())
+ ts << " [pattern transform=" << patternTransform() << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/SVGPaintServerPattern.h b/WebCore/svg/graphics/SVGPaintServerPattern.h
new file mode 100644
index 0000000..8f88326
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServerPattern.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGPaintServerPattern_h
+#define SVGPaintServerPattern_h
+
+#if ENABLE(SVG)
+
+#include "AffineTransform.h"
+#include "FloatRect.h"
+#include "SVGPaintServer.h"
+
+#include <memory>
+
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+ class GraphicsContext;
+ class ImageBuffer;
+ class SVGPatternElement;
+
+ class SVGPaintServerPattern : public SVGPaintServer {
+ public:
+ static PassRefPtr<SVGPaintServerPattern> create(const SVGPatternElement* owner) { return adoptRef(new SVGPaintServerPattern(owner)); }
+
+ virtual ~SVGPaintServerPattern();
+
+ virtual SVGPaintServerType type() const { return PatternPaintServer; }
+
+ // Pattern boundaries
+ void setPatternBoundaries(const FloatRect&);
+ FloatRect patternBoundaries() const;
+
+ ImageBuffer* tile() const;
+ void setTile(std::auto_ptr<ImageBuffer>);
+
+ AffineTransform patternTransform() const;
+ void setPatternTransform(const AffineTransform&);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CG)
+ virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
+ virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
+#endif
+
+#if PLATFORM(QT) || PLATFORM(CAIRO)
+ virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
+#endif
+
+ private:
+ SVGPaintServerPattern(const SVGPatternElement*);
+
+ OwnPtr<ImageBuffer> m_tile;
+ const SVGPatternElement* m_ownerElement;
+ AffineTransform m_patternTransform;
+ FloatRect m_patternBoundaries;
+
+#if PLATFORM(CG)
+ mutable CGColorSpaceRef m_patternSpace;
+ mutable CGPatternRef m_pattern;
+#endif
+ };
+
+} // namespace WebCore
+
+#endif
+
+#endif // SVGPaintServerPattern_h
diff --git a/WebCore/svg/graphics/SVGPaintServerRadialGradient.cpp b/WebCore/svg/graphics/SVGPaintServerRadialGradient.cpp
new file mode 100644
index 0000000..a795ab5
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServerRadialGradient.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerRadialGradient.h"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+SVGPaintServerRadialGradient::SVGPaintServerRadialGradient(const SVGGradientElement* owner)
+ : SVGPaintServerGradient(owner)
+ , m_radius(0.0f)
+{
+}
+
+SVGPaintServerRadialGradient::~SVGPaintServerRadialGradient()
+{
+}
+
+
+FloatPoint SVGPaintServerRadialGradient::gradientCenter() const
+{
+ return m_center;
+}
+
+void SVGPaintServerRadialGradient::setGradientCenter(const FloatPoint& center)
+{
+ m_center = center;
+}
+
+FloatPoint SVGPaintServerRadialGradient::gradientFocal() const
+{
+ return m_focal;
+}
+
+void SVGPaintServerRadialGradient::setGradientFocal(const FloatPoint& focal)
+{
+ m_focal = focal;
+}
+
+float SVGPaintServerRadialGradient::gradientRadius() const
+{
+ return m_radius;
+}
+
+void SVGPaintServerRadialGradient::setGradientRadius(float radius)
+{
+ m_radius = radius;
+}
+
+TextStream& SVGPaintServerRadialGradient::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=RADIAL-GRADIENT] ";
+ SVGPaintServerGradient::externalRepresentation(ts);
+ ts << " [center=" << gradientCenter() << "]"
+ << " [focal=" << gradientFocal() << "]"
+ << " [radius=" << gradientRadius() << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/SVGPaintServerRadialGradient.h b/WebCore/svg/graphics/SVGPaintServerRadialGradient.h
new file mode 100644
index 0000000..265f76b
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServerRadialGradient.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGPaintServerRadialGradient_h
+#define SVGPaintServerRadialGradient_h
+
+#if ENABLE(SVG)
+
+#include "FloatPoint.h"
+#include "SVGPaintServerGradient.h"
+
+namespace WebCore {
+
+ class SVGPaintServerRadialGradient : public SVGPaintServerGradient {
+ public:
+ static PassRefPtr<SVGPaintServerRadialGradient> create(const SVGGradientElement* owner) { return adoptRef(new SVGPaintServerRadialGradient(owner)); }
+ virtual ~SVGPaintServerRadialGradient();
+
+ virtual SVGPaintServerType type() const { return RadialGradientPaintServer; }
+
+ FloatPoint gradientCenter() const;
+ void setGradientCenter(const FloatPoint&);
+
+ FloatPoint gradientFocal() const;
+ void setGradientFocal(const FloatPoint&);
+
+ float gradientRadius() const;
+ void setGradientRadius(float);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(QT)
+ virtual QGradient setupGradient(GraphicsContext*&, const RenderObject*) const;
+#endif
+
+ private:
+ SVGPaintServerRadialGradient(const SVGGradientElement* owner);
+
+ float m_radius;
+ FloatPoint m_center;
+ FloatPoint m_focal;
+ };
+
+} // namespace WebCore
+
+#endif
+
+#endif // SVGPaintServerRadialGradient_h
diff --git a/WebCore/svg/graphics/SVGPaintServerSolid.cpp b/WebCore/svg/graphics/SVGPaintServerSolid.cpp
new file mode 100644
index 0000000..cb58a3a
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServerSolid.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerSolid.h"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+SVGPaintServerSolid::SVGPaintServerSolid()
+{
+}
+
+SVGPaintServerSolid::~SVGPaintServerSolid()
+{
+}
+
+Color SVGPaintServerSolid::color() const
+{
+ return m_color;
+}
+
+void SVGPaintServerSolid::setColor(const Color& color)
+{
+ m_color = color;
+}
+
+TextStream& SVGPaintServerSolid::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=SOLID]"
+ << " [color="<< color() << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/SVGPaintServerSolid.h b/WebCore/svg/graphics/SVGPaintServerSolid.h
new file mode 100644
index 0000000..2dd54ab
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServerSolid.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGPaintServerSolid_h
+#define SVGPaintServerSolid_h
+
+#if ENABLE(SVG)
+
+#include "Color.h"
+#include "SVGPaintServer.h"
+
+namespace WebCore {
+
+ class SVGPaintServerSolid : public SVGPaintServer {
+ public:
+ static PassRefPtr<SVGPaintServerSolid> create() { return adoptRef(new SVGPaintServerSolid); }
+ virtual ~SVGPaintServerSolid();
+
+ virtual SVGPaintServerType type() const { return SolidPaintServer; }
+
+ Color color() const;
+ void setColor(const Color&);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(CAIRO)
+ virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
+#endif
+
+ private:
+ SVGPaintServerSolid();
+
+ Color m_color;
+ };
+
+} // namespace WebCore
+
+#endif
+
+#endif // SVGPaintServerSolid_h
diff --git a/WebCore/svg/graphics/SVGResource.cpp b/WebCore/svg/graphics/SVGResource.cpp
new file mode 100644
index 0000000..10d6648
--- /dev/null
+++ b/WebCore/svg/graphics/SVGResource.cpp
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGResource.h"
+
+#include "RenderPath.h"
+#include "SVGElement.h"
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+SVGResource::SVGResource()
+{
+}
+
+struct ResourceSet {
+ ResourceSet()
+ {
+ for (int i = 0; i < _ResourceTypeCount; i++)
+ resources[i] = 0;
+ }
+ SVGResource* resources[_ResourceTypeCount];
+};
+
+static HashMap<SVGStyledElement*, ResourceSet*>& clientMap() {
+ static HashMap<SVGStyledElement*, ResourceSet*> map;
+ return map;
+}
+
+SVGResource::~SVGResource()
+{
+ int type = -1;
+ HashSet<SVGStyledElement*>::iterator itr = m_clients.begin();
+
+ for (; type < 0 && itr != m_clients.end(); ++itr) {
+ ResourceSet* target = clientMap().get(*itr);
+ if (!target)
+ continue;
+
+ for (int i = 0; i < _ResourceTypeCount; i++) {
+ if (target->resources[i] != this)
+ continue;
+ type = i;
+ target->resources[i] = 0;
+ break;
+ }
+ }
+
+ if (type < 0)
+ return;
+
+ for (; itr != m_clients.end(); ++itr) {
+ ResourceSet* target = clientMap().get(*itr);
+ if (!target)
+ continue;
+
+ if (target->resources[type] == this)
+ target->resources[type] = 0;
+ }
+}
+
+void SVGResource::invalidate()
+{
+ HashSet<SVGStyledElement*>::const_iterator it = m_clients.begin();
+ const HashSet<SVGStyledElement*>::const_iterator end = m_clients.end();
+
+ for (; it != end; ++it) {
+ SVGStyledElement* cur = *it;
+
+ if (cur->renderer())
+ cur->renderer()->setNeedsLayout(true);
+
+ cur->invalidateResourcesInAncestorChain();
+ }
+}
+
+void SVGResource::invalidateClients(HashSet<SVGStyledElement*> clients)
+{
+ HashSet<SVGStyledElement*>::const_iterator it = clients.begin();
+ const HashSet<SVGStyledElement*>::const_iterator end = clients.end();
+
+ for (; it != end; ++it) {
+ SVGStyledElement* cur = *it;
+
+ if (cur->renderer())
+ cur->renderer()->setNeedsLayout(true);
+
+ cur->invalidateResourcesInAncestorChain();
+ }
+}
+
+void SVGResource::removeClient(SVGStyledElement* item)
+{
+ HashMap<SVGStyledElement*, ResourceSet*>::iterator resourcePtr = clientMap().find(item);
+ if (resourcePtr == clientMap().end())
+ return;
+
+ ResourceSet* set = resourcePtr->second;
+ ASSERT(set);
+
+ clientMap().remove(resourcePtr);
+
+ for (int i = 0; i < _ResourceTypeCount; i++)
+ if (set->resources[i])
+ set->resources[i]->m_clients.remove(item);
+
+ delete set;
+}
+
+void SVGResource::addClient(SVGStyledElement* item)
+{
+ if (m_clients.contains(item))
+ return;
+
+ m_clients.add(item);
+
+ ResourceSet* target = clientMap().get(item);
+ if (!target)
+ target = new ResourceSet;
+
+ SVGResourceType type = resourceType();
+ if (SVGResource* oldResource = target->resources[type])
+ oldResource->m_clients.remove(item);
+
+ target->resources[type] = this;
+ clientMap().set(item, target);
+}
+
+TextStream& SVGResource::externalRepresentation(TextStream& ts) const
+{
+ return ts;
+}
+
+SVGResource* getResourceById(Document* document, const AtomicString& id)
+{
+ if (id.isEmpty())
+ return 0;
+
+ Element* element = document->getElementById(id);
+ SVGElement* svgElement = 0;
+ if (element && element->isSVGElement())
+ svgElement = static_cast<SVGElement*>(element);
+
+ if (svgElement && svgElement->isStyled())
+ return static_cast<SVGStyledElement*>(svgElement)->canvasResource();
+
+ return 0;
+}
+
+TextStream& operator<<(TextStream& ts, const SVGResource& r)
+{
+ return r.externalRepresentation(ts);
+}
+
+}
+
+#endif
diff --git a/WebCore/svg/graphics/SVGResource.h b/WebCore/svg/graphics/SVGResource.h
new file mode 100644
index 0000000..7ee98f6
--- /dev/null
+++ b/WebCore/svg/graphics/SVGResource.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGResource_h
+#define SVGResource_h
+
+#if ENABLE(SVG)
+#include "PlatformString.h"
+#include "StringHash.h"
+
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class AtomicString;
+ class Document;
+ class SVGStyledElement;
+ class TextStream;
+
+ enum SVGResourceType {
+ // Painting mode
+ ClipperResourceType = 0,
+ MarkerResourceType,
+ ImageResourceType,
+ FilterResourceType,
+ MaskerResourceType,
+ PaintServerResourceType,
+
+ // For resource tracking we need to know how many types of resource there are
+ _ResourceTypeCount
+ };
+
+ // The SVGResource file represent various graphics resources:
+ // - Filter resource
+ // - Clipper resource
+ // - Masker resource
+ // - Marker resource
+ // - Pattern resource
+ // - Linear/Radial gradient resource
+ //
+ // SVG creates/uses these resources.
+
+ class SVGResource : public RefCounted<SVGResource> {
+ public:
+ virtual ~SVGResource();
+
+ virtual void invalidate();
+
+ void addClient(SVGStyledElement*);
+ virtual SVGResourceType resourceType() const = 0;
+
+ bool isPaintServer() const { return resourceType() == PaintServerResourceType; }
+ bool isFilter() const { return resourceType() == FilterResourceType; }
+ bool isClipper() const { return resourceType() == ClipperResourceType; }
+ bool isMarker() const { return resourceType() == MarkerResourceType; }
+ bool isMasker() const { return resourceType() == MaskerResourceType; }
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+ static void invalidateClients(HashSet<SVGStyledElement*>);
+ static void removeClient(SVGStyledElement*);
+
+ protected:
+ SVGResource();
+
+ private:
+ HashSet<SVGStyledElement*> m_clients;
+ };
+
+ SVGResource* getResourceById(Document*, const AtomicString&);
+
+ TextStream& operator<<(TextStream&, const SVGResource&);
+
+} // namespace WebCore
+
+#endif
+#endif // SVGResource_h
diff --git a/WebCore/svg/graphics/SVGResourceClipper.cpp b/WebCore/svg/graphics/SVGResourceClipper.cpp
new file mode 100644
index 0000000..f03f5c2
--- /dev/null
+++ b/WebCore/svg/graphics/SVGResourceClipper.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGResourceClipper.h"
+
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+SVGResourceClipper::SVGResourceClipper()
+ : SVGResource()
+{
+}
+
+SVGResourceClipper::~SVGResourceClipper()
+{
+}
+
+void SVGResourceClipper::resetClipData()
+{
+ m_clipData.clear();
+}
+
+void SVGResourceClipper::addClipData(const Path& path, WindRule rule, bool bboxUnits)
+{
+ m_clipData.addPath(path, rule, bboxUnits);
+}
+
+const ClipDataList& SVGResourceClipper::clipData() const
+{
+ return m_clipData;
+}
+
+TextStream& SVGResourceClipper::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=CLIPPER]";
+ ts << " [clip data=" << clipData().clipData() << "]";
+ return ts;
+}
+
+TextStream& operator<<(TextStream& ts, WindRule rule)
+{
+ switch (rule) {
+ case RULE_NONZERO:
+ ts << "NON-ZERO"; break;
+ case RULE_EVENODD:
+ ts << "EVEN-ODD"; break;
+ }
+
+ return ts;
+}
+
+TextStream& operator<<(TextStream& ts, const ClipData& d)
+{
+ ts << "[winding=" << d.windRule << "]";
+
+ if (d.bboxUnits)
+ ts << " [bounding box mode=" << d.bboxUnits << "]";
+
+ ts << " [path=" << d.path.debugString() << "]";
+ return ts;
+}
+
+SVGResourceClipper* getClipperById(Document* document, const AtomicString& id)
+{
+ SVGResource* resource = getResourceById(document, id);
+ if (resource && resource->isClipper())
+ return static_cast<SVGResourceClipper*>(resource);
+
+ return 0;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/SVGResourceClipper.h b/WebCore/svg/graphics/SVGResourceClipper.h
new file mode 100644
index 0000000..98c295f
--- /dev/null
+++ b/WebCore/svg/graphics/SVGResourceClipper.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGResourceClipper_h
+#define SVGResourceClipper_h
+
+#if ENABLE(SVG)
+
+#include "SVGResource.h"
+#include "Path.h"
+
+namespace WebCore {
+
+ struct ClipData {
+ Path path;
+ WindRule windRule;
+ bool bboxUnits : 1;
+ };
+
+ class ClipDataList {
+ public:
+ void addPath(const Path& pathData, WindRule windRule, bool bboxUnits)
+ {
+ ClipData clipData;
+
+ clipData.path = pathData;
+ clipData.windRule = windRule;
+ clipData.bboxUnits = bboxUnits;
+
+ m_clipData.append(clipData);
+ }
+
+ void clear() { m_clipData.clear(); }
+ const Vector<ClipData>& clipData() const { return m_clipData; }
+ bool isEmpty() const { return m_clipData.isEmpty(); }
+ private:
+ Vector<ClipData> m_clipData;
+ };
+
+ class GraphicsContext;
+
+ class SVGResourceClipper : public SVGResource {
+ public:
+ static PassRefPtr<SVGResourceClipper> create() { return adoptRef(new SVGResourceClipper); }
+ virtual ~SVGResourceClipper();
+
+ void resetClipData();
+ void addClipData(const Path&, WindRule, bool bboxUnits);
+
+ const ClipDataList& clipData() const;
+
+ virtual SVGResourceType resourceType() const { return ClipperResourceType; }
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+ // To be implemented by the specific rendering devices
+ void applyClip(GraphicsContext*, const FloatRect& boundingBox) const;
+ private:
+ SVGResourceClipper();
+ ClipDataList m_clipData;
+ };
+
+ TextStream& operator<<(TextStream&, WindRule);
+ TextStream& operator<<(TextStream&, const ClipData&);
+
+ SVGResourceClipper* getClipperById(Document*, const AtomicString&);
+
+} // namespace WebCore
+
+#endif
+
+#endif // SVGResourceClipper_h
diff --git a/WebCore/svg/graphics/SVGResourceFilter.cpp b/WebCore/svg/graphics/SVGResourceFilter.cpp
new file mode 100644
index 0000000..8fb2dfa
--- /dev/null
+++ b/WebCore/svg/graphics/SVGResourceFilter.cpp
@@ -0,0 +1,123 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGResourceFilter.h"
+
+#include "SVGRenderTreeAsText.h"
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+SVGResourceFilter::SVGResourceFilter()
+ : m_platformData(createPlatformData())
+ , m_filterBBoxMode(false)
+ , m_effectBBoxMode(false)
+ , m_xBBoxMode(false)
+ , m_yBBoxMode(false)
+{
+}
+
+void SVGResourceFilter::clearEffects()
+{
+ m_effects.clear();
+}
+
+void SVGResourceFilter::addFilterEffect(SVGFilterEffect* effect)
+{
+ ASSERT(effect);
+
+ if (effect) {
+ ASSERT(effect->filter() == this);
+ m_effects.append(effect);
+ }
+}
+
+FloatRect SVGResourceFilter::filterBBoxForItemBBox(const FloatRect& itemBBox) const
+{
+ FloatRect filterBBox = filterRect();
+
+ float xOffset = 0.0f;
+ float yOffset = 0.0f;
+
+ if (!effectBoundingBoxMode()) {
+ xOffset = itemBBox.x();
+ yOffset = itemBBox.y();
+ }
+
+ if (filterBoundingBoxMode()) {
+ filterBBox = FloatRect(xOffset + filterBBox.x() * itemBBox.width(),
+ yOffset + filterBBox.y() * itemBBox.height(),
+ filterBBox.width() * itemBBox.width(),
+ filterBBox.height() * itemBBox.height());
+ } else {
+ if (xBoundingBoxMode())
+ filterBBox.setX(xOffset + filterBBox.x());
+
+ if (yBoundingBoxMode())
+ filterBBox.setY(yOffset + filterBBox.y());
+ }
+
+ return filterBBox;
+}
+
+TextStream& SVGResourceFilter::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=FILTER] ";
+
+ FloatRect bbox = filterRect();
+ static FloatRect defaultFilterRect(0, 0, 1, 1);
+
+ if (!filterBoundingBoxMode() || bbox != defaultFilterRect) {
+ ts << " [bounding box=";
+ if (filterBoundingBoxMode()) {
+ bbox.scale(100.f);
+ ts << "at (" << bbox.x() << "%," << bbox.y() << "%) size " << bbox.width() << "%x" << bbox.height() << "%";
+ } else
+ ts << filterRect();
+ ts << "]";
+ }
+
+ if (!filterBoundingBoxMode()) // default is true
+ ts << " [bounding box mode=" << filterBoundingBoxMode() << "]";
+ if (effectBoundingBoxMode()) // default is false
+ ts << " [effect bounding box mode=" << effectBoundingBoxMode() << "]";
+ if (m_effects.size() > 0)
+ ts << " [effects=" << m_effects << "]";
+
+ return ts;
+}
+
+SVGResourceFilter* getFilterById(Document* document, const AtomicString& id)
+{
+ SVGResource* resource = getResourceById(document, id);
+ if (resource && resource->isFilter())
+ return static_cast<SVGResourceFilter*>(resource);
+
+ return 0;
+}
+
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/graphics/SVGResourceFilter.h b/WebCore/svg/graphics/SVGResourceFilter.h
new file mode 100644
index 0000000..646c732
--- /dev/null
+++ b/WebCore/svg/graphics/SVGResourceFilter.h
@@ -0,0 +1,99 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGResourceFilter_h
+#define SVGResourceFilter_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGResource.h"
+#include "SVGFilterEffect.h"
+
+#include "FloatRect.h"
+
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+class GraphicsContext;
+class SVGFilterEffect;
+
+class SVGResourceFilterPlatformData {
+public:
+ virtual ~SVGResourceFilterPlatformData() {}
+};
+
+class SVGResourceFilter : public SVGResource {
+public:
+ SVGResourceFilter();
+
+ virtual SVGResourceType resourceType() const { return FilterResourceType; }
+
+ bool filterBoundingBoxMode() const { return m_filterBBoxMode; }
+ void setFilterBoundingBoxMode(bool bboxMode) { m_filterBBoxMode = bboxMode; }
+
+ bool effectBoundingBoxMode() const { return m_effectBBoxMode; }
+ void setEffectBoundingBoxMode(bool bboxMode) { m_effectBBoxMode = bboxMode; }
+
+ bool xBoundingBoxMode() const { return m_xBBoxMode; }
+ void setXBoundingBoxMode(bool bboxMode) { m_xBBoxMode = bboxMode; }
+
+ bool yBoundingBoxMode() const { return m_yBBoxMode; }
+ void setYBoundingBoxMode(bool bboxMode) { m_yBBoxMode = bboxMode; }
+
+ FloatRect filterRect() const { return m_filterRect; }
+ void setFilterRect(const FloatRect& rect) { m_filterRect = rect; }
+
+ FloatRect filterBBoxForItemBBox(const FloatRect& itemBBox) const;
+
+ void clearEffects();
+ void addFilterEffect(SVGFilterEffect*);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+ // To be implemented in platform specific code.
+ void prepareFilter(GraphicsContext*&, const FloatRect& bbox);
+ void applyFilter(GraphicsContext*&, const FloatRect& bbox);
+
+ SVGResourceFilterPlatformData* platformData() { return m_platformData.get(); }
+ const Vector<SVGFilterEffect*>& effects() { return m_effects; }
+
+private:
+ SVGResourceFilterPlatformData* createPlatformData();
+
+ OwnPtr<SVGResourceFilterPlatformData> m_platformData;
+
+ bool m_filterBBoxMode : 1;
+ bool m_effectBBoxMode : 1;
+
+ bool m_xBBoxMode : 1;
+ bool m_yBBoxMode : 1;
+
+ FloatRect m_filterRect;
+ Vector<SVGFilterEffect*> m_effects;
+};
+
+SVGResourceFilter* getFilterById(Document*, const AtomicString&);
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+
+#endif // SVGResourceFilter_h
diff --git a/WebCore/svg/graphics/SVGResourceListener.h b/WebCore/svg/graphics/SVGResourceListener.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/WebCore/svg/graphics/SVGResourceListener.h
diff --git a/WebCore/svg/graphics/SVGResourceMarker.cpp b/WebCore/svg/graphics/SVGResourceMarker.cpp
new file mode 100644
index 0000000..3649321
--- /dev/null
+++ b/WebCore/svg/graphics/SVGResourceMarker.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGResourceMarker.h"
+
+#include "AffineTransform.h"
+#include "GraphicsContext.h"
+#include "RenderSVGViewportContainer.h"
+#include "TextStream.h"
+
+namespace WebCore {
+
+SVGResourceMarker::SVGResourceMarker()
+ : SVGResource()
+ , m_refX(0.0)
+ , m_refY(0.0)
+ , m_angle(-1) // just like using setAutoAngle()
+ , m_marker(0)
+ , m_useStrokeWidth(true)
+{
+}
+
+SVGResourceMarker::~SVGResourceMarker()
+{
+}
+
+void SVGResourceMarker::setMarker(RenderSVGViewportContainer* marker)
+{
+ m_marker = marker;
+}
+
+void SVGResourceMarker::setRef(double refX, double refY)
+{
+ m_refX = refX;
+ m_refY = refY;
+}
+
+void SVGResourceMarker::draw(GraphicsContext* context, const FloatRect& rect, double x, double y, double strokeWidth, double angle)
+{
+ if (!m_marker)
+ return;
+
+ static HashSet<SVGResourceMarker*> currentlyDrawingMarkers;
+
+ // avoid drawing circular marker references
+ if (currentlyDrawingMarkers.contains(this))
+ return;
+
+ currentlyDrawingMarkers.add(this);
+
+ AffineTransform transform;
+ transform.translate(x, y);
+ transform.rotate(m_angle > -1 ? m_angle : angle);
+
+ // refX and refY are given in coordinates relative to the viewport established by the marker, yet they affect
+ // the translation performed on the viewport itself.
+ AffineTransform viewportTransform;
+ if (m_useStrokeWidth)
+ viewportTransform.scale(strokeWidth, strokeWidth);
+ viewportTransform *= m_marker->viewportTransform();
+ double refX, refY;
+ viewportTransform.map(m_refX, m_refY, &refX, &refY);
+ transform.translate(-refX, -refY);
+
+ if (m_useStrokeWidth)
+ transform.scale(strokeWidth, strokeWidth);
+
+ // FIXME: PaintInfo should be passed into this method instead of being created here
+ // FIXME: bounding box fractions are lost
+ RenderObject::PaintInfo info(context, enclosingIntRect(rect), PaintPhaseForeground, 0, 0, 0);
+
+ context->save();
+ context->concatCTM(transform);
+ m_marker->setDrawsContents(true);
+ m_marker->paint(info, 0, 0);
+ m_marker->setDrawsContents(false);
+ context->restore();
+
+ m_cachedBounds = transform.mapRect(m_marker->absoluteClippedOverflowRect());
+
+ currentlyDrawingMarkers.remove(this);
+}
+
+FloatRect SVGResourceMarker::cachedBounds() const
+{
+ return m_cachedBounds;
+}
+
+TextStream& SVGResourceMarker::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=MARKER]"
+ << " [angle=";
+
+ if (angle() == -1)
+ ts << "auto" << "]";
+ else
+ ts << angle() << "]";
+
+ ts << " [ref x=" << refX() << " y=" << refY() << "]";
+ return ts;
+}
+
+SVGResourceMarker* getMarkerById(Document* document, const AtomicString& id)
+{
+ SVGResource* resource = getResourceById(document, id);
+ if (resource && resource->isMarker())
+ return static_cast<SVGResourceMarker*>(resource);
+
+ return 0;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/SVGResourceMarker.h b/WebCore/svg/graphics/SVGResourceMarker.h
new file mode 100644
index 0000000..bb4039c
--- /dev/null
+++ b/WebCore/svg/graphics/SVGResourceMarker.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGResourceMarker_h
+#define SVGResourceMarker_h
+
+#if ENABLE(SVG)
+
+#include "FloatRect.h"
+#include "SVGResource.h"
+
+namespace WebCore {
+
+ class GraphicsContext;
+ class RenderSVGViewportContainer;
+
+ class SVGResourceMarker : public SVGResource {
+ public:
+ static PassRefPtr<SVGResourceMarker> create() { return adoptRef(new SVGResourceMarker); }
+ virtual ~SVGResourceMarker();
+
+ void setMarker(RenderSVGViewportContainer*);
+
+ void setRef(double refX, double refY);
+ double refX() const { return m_refX; }
+ double refY() const { return m_refY; }
+
+ void setAngle(float angle) { m_angle = angle; }
+ void setAutoAngle() { m_angle = -1; }
+ float angle() const { return m_angle; }
+
+ void setUseStrokeWidth(bool useStrokeWidth = true) { m_useStrokeWidth = useStrokeWidth; }
+ bool useStrokeWidth() const { return m_useStrokeWidth; }
+
+ FloatRect cachedBounds() const;
+ void draw(GraphicsContext*, const FloatRect&, double x, double y, double strokeWidth = 1, double angle = 0);
+
+ virtual SVGResourceType resourceType() const { return MarkerResourceType; }
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+ private:
+ SVGResourceMarker();
+ double m_refX, m_refY;
+ FloatRect m_cachedBounds;
+ float m_angle;
+ RenderSVGViewportContainer* m_marker;
+ bool m_useStrokeWidth;
+ };
+
+ SVGResourceMarker* getMarkerById(Document*, const AtomicString&);
+
+} // namespace WebCore
+
+#endif
+
+#endif // SVGResourceMarker_h
diff --git a/WebCore/svg/graphics/SVGResourceMasker.cpp b/WebCore/svg/graphics/SVGResourceMasker.cpp
new file mode 100644
index 0000000..842f04f
--- /dev/null
+++ b/WebCore/svg/graphics/SVGResourceMasker.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGResourceMasker.h"
+
+#include "ImageBuffer.h"
+#include "TextStream.h"
+
+using namespace std;
+
+namespace WebCore {
+
+SVGResourceMasker::SVGResourceMasker(const SVGMaskElement* ownerElement)
+ : SVGResource()
+ , m_ownerElement(ownerElement)
+{
+}
+
+SVGResourceMasker::~SVGResourceMasker()
+{
+}
+
+void SVGResourceMasker::invalidate()
+{
+ SVGResource::invalidate();
+ m_mask.clear();
+}
+
+TextStream& SVGResourceMasker::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=MASKER]";
+ return ts;
+}
+
+SVGResourceMasker* getMaskerById(Document* document, const AtomicString& id)
+{
+ SVGResource* resource = getResourceById(document, id);
+ if (resource && resource->isMasker())
+ return static_cast<SVGResourceMasker*>(resource);
+
+ return 0;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/SVGResourceMasker.h b/WebCore/svg/graphics/SVGResourceMasker.h
new file mode 100644
index 0000000..f945f56
--- /dev/null
+++ b/WebCore/svg/graphics/SVGResourceMasker.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGResourceMasker_h
+#define SVGResourceMasker_h
+
+#if ENABLE(SVG)
+
+#include "GraphicsContext.h"
+#include "SVGResource.h"
+
+#include <memory>
+
+#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+ class FloatRect;
+ class ImageBuffer;
+ class SVGMaskElement;
+
+ class SVGResourceMasker : public SVGResource {
+ public:
+ static PassRefPtr<SVGResourceMasker> create(const SVGMaskElement* ownerElement) { return adoptRef(new SVGResourceMasker(ownerElement)); }
+ virtual ~SVGResourceMasker();
+
+ virtual void invalidate();
+
+ virtual SVGResourceType resourceType() const { return MaskerResourceType; }
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+ // To be implemented by the specific rendering devices
+ void applyMask(GraphicsContext*, const FloatRect& boundingBox);
+
+ private:
+ SVGResourceMasker(const SVGMaskElement*);
+
+ const SVGMaskElement* m_ownerElement;
+
+ OwnPtr<ImageBuffer> m_mask;
+ FloatRect m_maskRect;
+ };
+
+ SVGResourceMasker* getMaskerById(Document*, const AtomicString&);
+
+} // namespace WebCore
+
+#endif
+
+#endif // SVGResourceMasker_h
diff --git a/WebCore/svg/graphics/cairo/RenderPathCairo.cpp b/WebCore/svg/graphics/cairo/RenderPathCairo.cpp
new file mode 100644
index 0000000..72379b5
--- /dev/null
+++ b/WebCore/svg/graphics/cairo/RenderPathCairo.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "RenderPath.h"
+
+#include "CairoPath.h"
+#include "SVGPaintServer.h"
+
+namespace WebCore {
+
+bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const
+{
+ if (requiresStroke && !SVGPaintServer::strokePaintServer(style(), this))
+ return false;
+
+ cairo_t* cr = path().platformPath()->m_cr;
+
+ // TODO: set stroke properties
+ return cairo_in_stroke(cr, point.x(), point.y());
+}
+
+FloatRect RenderPath::strokeBBox() const
+{
+ // TODO: this implementation is naive
+
+ cairo_t* cr = path().platformPath()->m_cr;
+
+ double x0, x1, y0, y1;
+ cairo_stroke_extents(cr, &x0, &y0, &x1, &y1);
+ FloatRect bbox = FloatRect(x0, y0, x1 - x0, y1 - y0);
+
+ return bbox;
+}
+
+}
diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerCairo.cpp
new file mode 100644
index 0000000..37cab6f
--- /dev/null
+++ b/WebCore/svg/graphics/cairo/SVGPaintServerCairo.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServer.h"
+
+#include "GraphicsContext.h"
+#include "SVGPaintServer.h"
+#include "RenderPath.h"
+
+#include <cairo.h>
+
+namespace WebCore {
+
+void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
+{
+ if (!setup(context, path, type))
+ return;
+
+ renderPath(context, path, type);
+ teardown(context, path, type);
+}
+
+void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const
+{
+ // no-op
+}
+
+void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
+{
+ cairo_t* cr = context->platformContext();
+ const SVGRenderStyle* style = path->style()->svgStyle();
+
+ cairo_set_fill_rule(cr, style->fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
+
+ if ((type & ApplyToFillTargetType) && style->hasFill())
+ cairo_fill_preserve(cr);
+
+ if ((type & ApplyToStrokeTargetType) && style->hasStroke())
+ cairo_stroke_preserve(cr);
+
+ cairo_new_path(cr);
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp
new file mode 100644
index 0000000..7b22f4f
--- /dev/null
+++ b/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerGradient.h"
+#include "SVGPaintServerLinearGradient.h"
+#include "SVGPaintServerRadialGradient.h"
+
+#include "GraphicsContext.h"
+#include "RenderObject.h"
+#include "RenderPath.h"
+#include "RenderStyle.h"
+#include "SVGGradientElement.h"
+
+namespace WebCore {
+
+bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ m_ownerElement->buildGradient();
+
+ cairo_t* cr = context->platformContext();
+ cairo_pattern_t* pattern;
+
+ cairo_matrix_t matrix;
+ cairo_matrix_init_identity (&matrix);
+ const cairo_matrix_t gradient_matrix = gradientTransform();
+
+ // TODO: revise this code, it is known not to work in many cases
+ if (this->type() == LinearGradientPaintServer) {
+ const SVGPaintServerLinearGradient* linear = static_cast<const SVGPaintServerLinearGradient*>(this);
+
+ if (boundingBoxMode()) {
+ // TODO: use RenderPathCairo's strokeBBox?
+ double x1, y1, x2, y2;
+ cairo_fill_extents(cr, &x1, &y1, &x2, &y2);
+ cairo_matrix_translate(&matrix, x1, y1);
+ cairo_matrix_scale(&matrix, x2 - x1, y2 - y1);
+ cairo_matrix_multiply(&matrix, &matrix, &gradient_matrix);
+ cairo_matrix_invert(&matrix);
+ }
+
+ double x0, x1, y0, y1;
+ x0 = linear->gradientStart().x();
+ y0 = linear->gradientStart().y();
+ x1 = linear->gradientEnd().x();
+ y1 = linear->gradientEnd().y();
+ pattern = cairo_pattern_create_linear(x0, y0, x1, y1);
+
+ } else if (this->type() == RadialGradientPaintServer) {
+ // const SVGPaintServerRadialGradient* radial = static_cast<const SVGPaintServerRadialGradient*>(this);
+ // TODO: pattern = cairo_pattern_create_radial();
+ return false;
+ } else {
+ return false;
+ }
+
+ cairo_pattern_set_filter(pattern, CAIRO_FILTER_BILINEAR);
+
+ switch (spreadMethod()) {
+ case SPREADMETHOD_PAD:
+ cairo_pattern_set_extend(pattern, CAIRO_EXTEND_PAD);
+ break;
+ case SPREADMETHOD_REFLECT:
+ cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REFLECT);
+ break;
+ case SPREADMETHOD_REPEAT:
+ cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
+ break;
+ default:
+ cairo_pattern_set_extend(pattern, CAIRO_EXTEND_NONE);
+ break;
+ }
+
+ cairo_pattern_set_matrix(pattern, &matrix);
+
+ const Vector<SVGGradientStop>& stops = gradientStops();
+
+ for (unsigned i = 0; i < stops.size(); ++i) {
+ float offset = stops[i].first;
+ Color color = stops[i].second;
+
+ cairo_pattern_add_color_stop_rgba(pattern, offset, color.red(), color.green(), color.blue(), color.alpha());
+ }
+
+ cairo_set_source(cr, pattern);
+ cairo_pattern_destroy(pattern);
+
+ return true;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp
new file mode 100644
index 0000000..6381277
--- /dev/null
+++ b/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "NotImplemented.h"
+#include "SVGPaintServerPattern.h"
+
+namespace WebCore {
+
+bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ notImplemented();
+ return true;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp
new file mode 100644
index 0000000..6acc9b2
--- /dev/null
+++ b/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerSolid.h"
+
+#include "GraphicsContext.h"
+#include "SVGPaintServer.h"
+#include "RenderPath.h"
+
+namespace WebCore {
+
+bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ // TODO: share this code with other PaintServers
+
+ cairo_t* cr = context->platformContext();
+ const SVGRenderStyle* style = object->style()->svgStyle();
+
+ float red, green, blue, alpha;
+ color().getRGBA(red, green, blue, alpha);
+
+ if ((type & ApplyToFillTargetType) && style->hasFill()) {
+ alpha = style->fillOpacity();
+
+ cairo_set_fill_rule(cr, style->fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
+ }
+
+ if ((type & ApplyToStrokeTargetType) && style->hasStroke()) {
+ alpha = style->strokeOpacity();
+
+ cairo_set_line_width(cr, SVGRenderStyle::cssPrimitiveToLength(object, style->strokeWidth(), 1.0));
+ context->setLineCap(style->capStyle());
+ context->setLineJoin(style->joinStyle());
+ if (style->joinStyle() == MiterJoin)
+ context->setMiterLimit(style->strokeMiterLimit());
+
+ const DashArray& dashes = dashArrayFromRenderingStyle(object->style());
+ double* dsh = new double[dashes.size()];
+ for (unsigned i = 0 ; i < dashes.size() ; i++)
+ dsh[i] = dashes[i];
+ double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->strokeDashOffset(), 0.0);
+ cairo_set_dash(cr, dsh, dashes.size(), dashOffset);
+ delete[] dsh;
+ }
+
+ cairo_set_source_rgba(cr, red, green, blue, alpha);
+
+ return true;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp b/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp
new file mode 100644
index 0000000..5900fcd
--- /dev/null
+++ b/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGResourceClipper.h"
+#include "AffineTransform.h"
+#include "GraphicsContext.h"
+
+#include <cairo.h>
+
+namespace WebCore {
+
+void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
+{
+ Vector<ClipData> data = m_clipData.clipData();
+ unsigned int count = data.size();
+ if (!count)
+ return;
+
+ cairo_t* cr = context->platformContext();
+ cairo_reset_clip(cr);
+
+ for (unsigned int x = 0; x < count; x++) {
+ Path path = data[x].path;
+ if (path.isEmpty())
+ continue;
+ path.closeSubpath();
+
+ if (data[x].bboxUnits) {
+ // Make use of the clipping units
+ AffineTransform transform;
+ transform.translate(boundingBox.x(), boundingBox.y());
+ transform.scale(boundingBox.width(), boundingBox.height());
+ path.transform(transform);
+ }
+
+ cairo_set_fill_rule(cr, data[x].windRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
+
+ // TODO: review this code, clipping may not be having the desired effect
+ context->clip(path);
+ }
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/cairo/SVGResourceFilterCairo.cpp b/WebCore/svg/graphics/cairo/SVGResourceFilterCairo.cpp
new file mode 100644
index 0000000..a27038a
--- /dev/null
+++ b/WebCore/svg/graphics/cairo/SVGResourceFilterCairo.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2008 Collabora Ltd. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#include "NotImplemented.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGResourceFilterPlatformData* SVGResourceFilter::createPlatformData()
+{
+ notImplemented();
+ return 0;
+}
+
+void SVGResourceFilter::prepareFilter(GraphicsContext*&, const FloatRect&)
+{
+ notImplemented();
+}
+
+void SVGResourceFilter::applyFilter(GraphicsContext*&, const FloatRect&)
+{
+ notImplemented();
+}
+
+} // namespace WebCore
+
+#endif
+
diff --git a/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp b/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp
new file mode 100644
index 0000000..78ea76b
--- /dev/null
+++ b/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGResourceMasker.h"
+#include "ImageBuffer.h"
+#include "GraphicsContext.h"
+
+#include <cairo.h>
+
+namespace WebCore {
+
+void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& boundingBox)
+{
+ cairo_t* cr = context->platformContext();
+ cairo_surface_t* surface = m_mask->surface();
+ if (!surface)
+ return;
+ cairo_pattern_t* mask = cairo_pattern_create_for_surface(surface);
+ cairo_mask(cr, mask);
+ cairo_pattern_destroy(mask);
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/cg/CgSupport.cpp b/WebCore/svg/graphics/cg/CgSupport.cpp
new file mode 100644
index 0000000..9d4eec7
--- /dev/null
+++ b/WebCore/svg/graphics/cg/CgSupport.cpp
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ * 2006 Rob Buis <buis@kde.org>
+ * 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "CgSupport.h"
+
+#include <ApplicationServices/ApplicationServices.h>
+#include "FloatConversion.h"
+#include "GraphicsContext.h"
+#include "RenderStyle.h"
+#include "SVGPaintServer.h"
+#include "SVGRenderStyle.h"
+#include <wtf/Assertions.h>
+
+namespace WebCore {
+
+CGAffineTransform CGAffineTransformMakeMapBetweenRects(CGRect source, CGRect dest)
+{
+ CGAffineTransform transform = CGAffineTransformMakeTranslation(dest.origin.x - source.origin.x, dest.origin.y - source.origin.y);
+ transform = CGAffineTransformScale(transform, dest.size.width/source.size.width, dest.size.height/source.size.height);
+ return transform;
+}
+
+void applyStrokeStyleToContext(GraphicsContext* context, RenderStyle* style, const RenderObject* object)
+{
+ context->setStrokeThickness(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0f));
+ context->setLineCap(style->svgStyle()->capStyle());
+ context->setLineJoin(style->svgStyle()->joinStyle());
+ context->setMiterLimit(style->svgStyle()->strokeMiterLimit());
+
+ const DashArray& dashes = dashArrayFromRenderingStyle(style);
+ double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0f);
+
+ CGContextSetLineDash(context->platformContext(), narrowPrecisionToCGFloat(dashOffset), dashes.data(), dashes.size());
+}
+
+CGContextRef scratchContext()
+{
+ static CGContextRef scratch = 0;
+ if (!scratch) {
+ CFMutableDataRef empty = CFDataCreateMutable(NULL, 0);
+ CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData(empty);
+ scratch = CGPDFContextCreate(consumer, NULL, NULL);
+ CGDataConsumerRelease(consumer);
+ CFRelease(empty);
+
+ CGFloat black[4] = {0, 0, 0, 1};
+ CGContextSetFillColor(scratch, black);
+ CGContextSetStrokeColor(scratch, black);
+ }
+ return scratch;
+}
+
+FloatRect strokeBoundingBox(const Path& path, RenderStyle* style, const RenderObject* object)
+ {
+ // the bbox might grow if the path is stroked.
+ // and CGPathGetBoundingBox doesn't support that, so we'll have
+ // to make an alternative call...
+
+ // FIXME: since this is mainly used to decide what to repaint,
+ // perhaps it would be sufficien to just outset the fill bbox by
+ // the stroke width - that should be way cheaper and simpler than
+ // what we do here.
+
+ CGPathRef cgPath = path.platformPath();
+
+ CGContextRef context = scratchContext();
+ CGContextSaveGState(context);
+
+ CGContextBeginPath(context);
+ CGContextAddPath(context, cgPath);
+
+ GraphicsContext gc(context);
+ applyStrokeStyleToContext(&gc, style, object);
+
+ CGContextReplacePathWithStrokedPath(context);
+ if (CGContextIsPathEmpty(context)) {
+ // CGContextReplacePathWithStrokedPath seems to fail to create a path sometimes, this is not well understood.
+ // returning here prevents CG from logging to the console from CGContextGetPathBoundingBox
+ CGContextRestoreGState(context);
+ return FloatRect();
+ }
+
+ CGRect box = CGContextGetPathBoundingBox(context);
+ CGContextRestoreGState(context);
+
+ return FloatRect(box);
+}
+
+}
+
+#endif // ENABLE(SVG)
+
diff --git a/WebCore/svg/graphics/cg/CgSupport.h b/WebCore/svg/graphics/cg/CgSupport.h
new file mode 100644
index 0000000..454e5b9
--- /dev/null
+++ b/WebCore/svg/graphics/cg/CgSupport.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CgSupport_h
+#define CgSupport_h
+
+#if ENABLE(SVG)
+
+#include <ApplicationServices/ApplicationServices.h>
+#include "GraphicsTypes.h"
+
+namespace WebCore {
+
+typedef struct CGPath *CGMutablePathRef;
+
+class Path;
+class FloatRect;
+class RenderStyle;
+class RenderObject;
+class GraphicsContext;
+
+CGAffineTransform CGAffineTransformMakeMapBetweenRects(CGRect source, CGRect dest);
+
+void applyStrokeStyleToContext(GraphicsContext*, RenderStyle*, const RenderObject*);
+
+CGContextRef scratchContext();
+FloatRect strokeBoundingBox(const Path& path, RenderStyle*, const RenderObject*);
+
+}
+
+#endif // ENABLE(SVG)
+#endif // !CgSupport_h
diff --git a/WebCore/svg/graphics/cg/RenderPathCg.cpp b/WebCore/svg/graphics/cg/RenderPathCg.cpp
new file mode 100644
index 0000000..eb8e482
--- /dev/null
+++ b/WebCore/svg/graphics/cg/RenderPathCg.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ * (C) 2006 Alexander Kellett <lypanov@kde.org>
+ * 2006 Rob Buis <buis@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "RenderPath.h"
+
+#include <ApplicationServices/ApplicationServices.h>
+#include "CgSupport.h"
+#include "GraphicsContext.h"
+#include "SVGPaintServer.h"
+#include "SVGRenderStyle.h"
+#include "SVGStyledElement.h"
+#include <wtf/Assertions.h>
+
+namespace WebCore {
+
+FloatRect RenderPath::strokeBBox() const
+{
+ if (style()->svgStyle()->hasStroke())
+ return strokeBoundingBox(path(), style(), this);
+
+ return path().boundingRect();
+}
+
+
+bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const
+{
+ if (path().isEmpty())
+ return false;
+
+ if (requiresStroke && !SVGPaintServer::strokePaintServer(style(), this))
+ return false;
+
+ CGMutablePathRef cgPath = path().platformPath();
+
+ CGContextRef context = scratchContext();
+ CGContextSaveGState(context);
+
+ CGContextBeginPath(context);
+ CGContextAddPath(context, cgPath);
+
+ GraphicsContext gc(context);
+ applyStrokeStyleToContext(&gc, style(), this);
+
+ bool hitSuccess = CGContextPathContainsPoint(context, point, kCGPathStroke);
+ CGContextRestoreGState(context);
+
+ return hitSuccess;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/graphics/cg/SVGPaintServerCg.cpp b/WebCore/svg/graphics/cg/SVGPaintServerCg.cpp
new file mode 100644
index 0000000..35eb239
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGPaintServerCg.cpp
@@ -0,0 +1,89 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServer.h"
+
+#include "GraphicsContext.h"
+#include "RenderObject.h"
+
+namespace WebCore {
+
+void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
+{
+ if (!setup(context, path, type))
+ return;
+
+ renderPath(context, path, type);
+ teardown(context, path, type);
+}
+
+void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const
+{
+ // no-op
+}
+
+void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
+{
+ RenderStyle* style = path ? path->style() : 0;
+ CGContextRef contextRef = context->platformContext();
+
+ if ((type & ApplyToFillTargetType) && (!style || style->svgStyle()->hasFill()))
+ fillPath(contextRef, path);
+
+ if ((type & ApplyToStrokeTargetType) && (!style || style->svgStyle()->hasStroke()))
+ strokePath(contextRef, path);
+}
+
+void SVGPaintServer::strokePath(CGContextRef context, const RenderObject*) const
+{
+ CGContextStrokePath(context);
+}
+
+void SVGPaintServer::clipToStrokePath(CGContextRef context, const RenderObject*) const
+{
+ CGContextReplacePathWithStrokedPath(context);
+ CGContextClip(context);
+}
+
+void SVGPaintServer::fillPath(CGContextRef context, const RenderObject* path) const
+{
+ if (!path || path->style()->svgStyle()->fillRule() == RULE_EVENODD)
+ CGContextEOFillPath(context);
+ else
+ CGContextFillPath(context);
+}
+
+void SVGPaintServer::clipToFillPath(CGContextRef context, const RenderObject* path) const
+{
+ if (!path || path->style()->svgStyle()->fillRule() == RULE_EVENODD)
+ CGContextEOClip(context);
+ else
+ CGContextClip(context);
+}
+
+} // namespace WebCore
+
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp b/WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp
new file mode 100644
index 0000000..4d41d88
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp
@@ -0,0 +1,341 @@
+/*
+ Copyright (C) 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerGradient.h"
+
+#include "CgSupport.h"
+#include "FloatConversion.h"
+#include "GraphicsContext.h"
+#include "ImageBuffer.h"
+#include "RenderObject.h"
+#include "SVGGradientElement.h"
+#include "SVGPaintServerLinearGradient.h"
+#include "SVGPaintServerRadialGradient.h"
+#include "SVGRenderSupport.h"
+
+#include <wtf/MathExtras.h>
+
+using namespace std;
+
+namespace WebCore {
+
+static void releaseCachedStops(void* info)
+{
+ static_cast<SVGPaintServerGradient::SharedStopCache*>(info)->deref();
+}
+
+static void cgGradientCallback(void* info, const CGFloat* inValues, CGFloat* outColor)
+{
+ SVGPaintServerGradient::SharedStopCache* stopsCache = static_cast<SVGPaintServerGradient::SharedStopCache*>(info);
+
+ SVGPaintServerGradient::QuartzGradientStop* stops = stopsCache->m_stops.data();
+
+ int stopsCount = stopsCache->m_stops.size();
+
+ CGFloat inValue = inValues[0];
+
+ if (!stopsCount) {
+ outColor[0] = 0;
+ outColor[1] = 0;
+ outColor[2] = 0;
+ outColor[3] = 0;
+ return;
+ } else if (stopsCount == 1) {
+ memcpy(outColor, stops[0].colorArray, 4 * sizeof(CGFloat));
+ return;
+ }
+
+ if (!(inValue > stops[0].offset))
+ memcpy(outColor, stops[0].colorArray, 4 * sizeof(CGFloat));
+ else if (!(inValue < stops[stopsCount - 1].offset))
+ memcpy(outColor, stops[stopsCount - 1].colorArray, 4 * sizeof(CGFloat));
+ else {
+ int nextStopIndex = 0;
+ while ((nextStopIndex < stopsCount) && (stops[nextStopIndex].offset < inValue))
+ nextStopIndex++;
+
+ CGFloat* nextColorArray = stops[nextStopIndex].colorArray;
+ CGFloat* previousColorArray = stops[nextStopIndex - 1].colorArray;
+ CGFloat diffFromPrevious = inValue - stops[nextStopIndex - 1].offset;
+ CGFloat percent = diffFromPrevious * stops[nextStopIndex].previousDeltaInverse;
+
+ outColor[0] = ((1.0f - percent) * previousColorArray[0] + percent * nextColorArray[0]);
+ outColor[1] = ((1.0f - percent) * previousColorArray[1] + percent * nextColorArray[1]);
+ outColor[2] = ((1.0f - percent) * previousColorArray[2] + percent * nextColorArray[2]);
+ outColor[3] = ((1.0f - percent) * previousColorArray[3] + percent * nextColorArray[3]);
+ }
+ // FIXME: have to handle the spreadMethod()s here SPREADMETHOD_REPEAT, etc.
+}
+
+static CGShadingRef CGShadingRefForLinearGradient(const SVGPaintServerLinearGradient* server)
+{
+ CGPoint start = CGPoint(server->gradientStart());
+ CGPoint end = CGPoint(server->gradientEnd());
+
+ CGFunctionCallbacks callbacks = {0, cgGradientCallback, releaseCachedStops};
+ CGFloat domainLimits[2] = {0, 1};
+ CGFloat rangeLimits[8] = {0, 1, 0, 1, 0, 1, 0, 1};
+ server->m_stopsCache->ref();
+ CGFunctionRef shadingFunction = CGFunctionCreate(server->m_stopsCache.get(), 1, domainLimits, 4, rangeLimits, &callbacks);
+
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ CGShadingRef shading = CGShadingCreateAxial(colorSpace, start, end, shadingFunction, true, true);
+ CGColorSpaceRelease(colorSpace);
+ CGFunctionRelease(shadingFunction);
+ return shading;
+}
+
+static CGShadingRef CGShadingRefForRadialGradient(const SVGPaintServerRadialGradient* server)
+{
+ CGPoint center = CGPoint(server->gradientCenter());
+ CGPoint focus = CGPoint(server->gradientFocal());
+ double radius = server->gradientRadius();
+
+ double fdx = focus.x - center.x;
+ double fdy = focus.y - center.y;
+
+ // Spec: If (fx, fy) lies outside the circle defined by (cx, cy) and r, set (fx, fy)
+ // to the point of intersection of the line through (fx, fy) and the circle.
+ if (sqrt(fdx * fdx + fdy * fdy) > radius) {
+ double angle = atan2(focus.y * 100.0, focus.x * 100.0);
+ focus.x = narrowPrecisionToCGFloat(cos(angle) * radius);
+ focus.y = narrowPrecisionToCGFloat(sin(angle) * radius);
+ }
+
+ CGFunctionCallbacks callbacks = {0, cgGradientCallback, releaseCachedStops};
+ CGFloat domainLimits[2] = {0, 1};
+ CGFloat rangeLimits[8] = {0, 1, 0, 1, 0, 1, 0, 1};
+ server->m_stopsCache->ref();
+ CGFunctionRef shadingFunction = CGFunctionCreate(server->m_stopsCache.get(), 1, domainLimits, 4, rangeLimits, &callbacks);
+
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ CGShadingRef shading = CGShadingCreateRadial(colorSpace, focus, 0, center, narrowPrecisionToCGFloat(radius), shadingFunction, true, true);
+ CGColorSpaceRelease(colorSpace);
+ CGFunctionRelease(shadingFunction);
+ return shading;
+}
+
+void SVGPaintServerGradient::updateQuartzGradientStopsCache(const Vector<SVGGradientStop>& stops)
+{
+ m_stopsCache = SharedStopCache::create();
+ Vector<QuartzGradientStop>& stopsCache = m_stopsCache->m_stops;
+ stopsCache.resize(stops.size());
+ CGFloat previousOffset = 0.0f;
+ for (unsigned i = 0; i < stops.size(); ++i) {
+ CGFloat currOffset = min(max(stops[i].first, previousOffset), static_cast<CGFloat>(1.0));
+ stopsCache[i].offset = currOffset;
+ stopsCache[i].previousDeltaInverse = 1.0f / (currOffset - previousOffset);
+ previousOffset = currOffset;
+ CGFloat* ca = stopsCache[i].colorArray;
+ stops[i].second.getRGBA(ca[0], ca[1], ca[2], ca[3]);
+ }
+}
+
+void SVGPaintServerGradient::updateQuartzGradientCache(const SVGPaintServerGradient* server)
+{
+ // cache our own copy of the stops for faster access.
+ // this is legacy code, probably could be reworked.
+ if (!m_stopsCache)
+ updateQuartzGradientStopsCache(gradientStops());
+
+ CGShadingRelease(m_shadingCache);
+
+ if (type() == RadialGradientPaintServer) {
+ const SVGPaintServerRadialGradient* radial = static_cast<const SVGPaintServerRadialGradient*>(server);
+ m_shadingCache = CGShadingRefForRadialGradient(radial);
+ } else if (type() == LinearGradientPaintServer) {
+ const SVGPaintServerLinearGradient* linear = static_cast<const SVGPaintServerLinearGradient*>(server);
+ m_shadingCache = CGShadingRefForLinearGradient(linear);
+ }
+}
+
+// Helper function for text painting
+static inline const RenderObject* findTextRootObject(const RenderObject* start)
+{
+ while (start && !start->isSVGText())
+ start = start->parent();
+
+ ASSERT(start);
+ ASSERT(start->isSVGText());
+
+ return start;
+}
+
+void SVGPaintServerGradient::teardown(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ CGShadingRef shading = m_shadingCache;
+ CGContextRef contextRef = context->platformContext();
+ ASSERT(contextRef);
+
+ // As renderPath() is not used when painting text, special logic needed here.
+ if (isPaintingText) {
+ if (m_savedContext) {
+ FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->relativeBBox(false);
+
+ // Fixup transformations to be able to clip to mask
+ AffineTransform transform = object->absoluteTransform();
+ FloatRect textBoundary = transform.mapRect(maskBBox);
+
+ IntSize maskSize(lroundf(textBoundary.width()), lroundf(textBoundary.height()));
+ clampImageBufferSizeToViewport(object->document()->renderer(), maskSize);
+
+ if (maskSize.width() < static_cast<int>(textBoundary.width()))
+ textBoundary.setWidth(maskSize.width());
+
+ if (maskSize.height() < static_cast<int>(textBoundary.height()))
+ textBoundary.setHeight(maskSize.height());
+
+ // Clip current context to mask image (gradient)
+ m_savedContext->concatCTM(transform.inverse());
+ CGContextClipToMask(m_savedContext->platformContext(), CGRect(textBoundary), m_imageBuffer->cgImage());
+ m_savedContext->concatCTM(transform);
+
+ handleBoundingBoxModeAndGradientTransformation(m_savedContext, maskBBox);
+
+ // Restore on-screen drawing context, after we got the image of the gradient
+ delete m_imageBuffer;
+
+ context = m_savedContext;
+ contextRef = context->platformContext();
+
+ m_savedContext = 0;
+ m_imageBuffer = 0;
+ }
+ }
+
+ CGContextDrawShading(contextRef, shading);
+ context->restore();
+}
+
+void SVGPaintServerGradient::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
+{
+ RenderStyle* style = path->style();
+ CGContextRef contextRef = context->platformContext();
+ ASSERT(contextRef);
+
+ bool isFilled = (type & ApplyToFillTargetType) && style->svgStyle()->hasFill();
+
+ // Compute destination object bounding box
+ FloatRect objectBBox;
+ if (boundingBoxMode()) {
+ FloatRect bbox = path->relativeBBox(false);
+ if (bbox.width() > 0 && bbox.height() > 0)
+ objectBBox = bbox;
+ }
+
+ if (isFilled)
+ clipToFillPath(contextRef, path);
+ else
+ clipToStrokePath(contextRef, path);
+
+ handleBoundingBoxModeAndGradientTransformation(context, objectBBox);
+}
+
+void SVGPaintServerGradient::handleBoundingBoxModeAndGradientTransformation(GraphicsContext* context, const FloatRect& targetRect) const
+{
+ CGContextRef contextRef = context->platformContext();
+
+ if (boundingBoxMode()) {
+ // Choose default gradient bounding box
+ CGRect gradientBBox = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
+
+ // Generate a transform to map between both bounding boxes
+ CGAffineTransform gradientIntoObjectBBox = CGAffineTransformMakeMapBetweenRects(gradientBBox, CGRect(targetRect));
+ CGContextConcatCTM(contextRef, gradientIntoObjectBBox);
+ }
+
+ // Apply the gradient's own transform
+ CGAffineTransform transform = gradientTransform();
+ CGContextConcatCTM(contextRef, transform);
+}
+
+bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ m_ownerElement->buildGradient();
+
+ // We need a hook to call this when the gradient gets updated, before drawn.
+ if (!m_shadingCache)
+ const_cast<SVGPaintServerGradient*>(this)->updateQuartzGradientCache(this);
+
+ CGContextRef contextRef = context->platformContext();
+ ASSERT(contextRef);
+
+ RenderStyle* style = object->style();
+
+ bool isFilled = (type & ApplyToFillTargetType) && style->svgStyle()->hasFill();
+ bool isStroked = (type & ApplyToStrokeTargetType) && style->svgStyle()->hasStroke();
+
+ ASSERT(isFilled && !isStroked || !isFilled && isStroked);
+
+ context->save();
+ CGContextSetAlpha(contextRef, isFilled ? style->svgStyle()->fillOpacity() : style->svgStyle()->strokeOpacity());
+
+ if (isPaintingText) {
+ FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->relativeBBox(false);
+ IntRect maskRect = enclosingIntRect(object->absoluteTransform().mapRect(maskBBox));
+
+ IntSize maskSize(maskRect.width(), maskRect.height());
+ clampImageBufferSizeToViewport(object->document()->renderer(), maskSize);
+
+ auto_ptr<ImageBuffer> maskImage = ImageBuffer::create(maskSize, false);
+
+ if (!maskImage.get()) {
+ context->restore();
+ return false;
+ }
+
+ GraphicsContext* maskImageContext = maskImage->context();
+ maskImageContext->save();
+
+ maskImageContext->setTextDrawingMode(isFilled ? cTextFill : cTextStroke);
+ maskImageContext->translate(-maskRect.x(), -maskRect.y());
+ maskImageContext->concatCTM(object->absoluteTransform());
+
+ m_imageBuffer = maskImage.release();
+ m_savedContext = context;
+
+ context = maskImageContext;
+ contextRef = context->platformContext();
+ }
+
+ if (isStroked)
+ applyStrokeStyleToContext(context, style, object);
+
+ return true;
+}
+
+void SVGPaintServerGradient::invalidate()
+{
+ SVGPaintServer::invalidate();
+
+ // Invalidate caches
+ CGShadingRelease(m_shadingCache);
+
+ m_stopsCache = 0;
+ m_shadingCache = 0;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp b/WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp
new file mode 100644
index 0000000..e12ff77
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp
@@ -0,0 +1,126 @@
+/*
+ Copyright (C) 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerPattern.h"
+
+#include "CgSupport.h"
+#include "GraphicsContext.h"
+#include "ImageBuffer.h"
+#include "RenderObject.h"
+#include "SVGPatternElement.h"
+
+namespace WebCore {
+
+static void patternCallback(void* info, CGContextRef context)
+{
+ ImageBuffer* patternImage = reinterpret_cast<ImageBuffer*>(info);
+ CGContextDrawImage(context, CGRect(FloatRect(FloatPoint(), patternImage->size())), patternImage->cgImage());
+}
+
+bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ CGContextRef contextRef = context->platformContext();
+
+ // Build pattern tile, passing destination object bounding box
+ FloatRect targetRect;
+ if (isPaintingText) {
+ IntRect textBoundary = const_cast<RenderObject*>(object)->absoluteBoundingBoxRect();
+ targetRect = object->absoluteTransform().inverse().mapRect(textBoundary);
+ } else
+ targetRect = object->relativeBBox(false);
+
+ m_ownerElement->buildPattern(targetRect);
+
+ if (!tile())
+ return false;
+
+ context->save();
+
+ // Respect local pattern transformation
+ context->concatCTM(patternTransform());
+
+ // Apply pattern space transformation
+ context->translate(patternBoundaries().x(), patternBoundaries().y());
+
+ // Crude hack to support overflow="visible".
+ // When the patternBoundaries() size is smaller than the actual tile() size, we run into a problem:
+ // Our tile contains content which is larger than the pattern cell size. We just draw the pattern
+ // "out of" cell boundaries, to draw the overflown content, instead of clipping it away. The uppermost
+ // cell doesn't include the overflown content of the cell right above it though -> that's why we're moving
+ // down the phase by a very small amount, so we're sure the "cell right above"'s overflown content gets drawn.
+ CGContextSetPatternPhase(contextRef, CGSizeMake(0.0f, -0.01f));
+
+ RenderStyle* style = object->style();
+ CGContextSetAlpha(contextRef, style->opacity());
+
+ CGPatternCallbacks callbacks = {0, patternCallback, 0};
+
+ ASSERT(!m_pattern);
+ m_pattern = CGPatternCreate(tile(),
+ CGRect(FloatRect(FloatPoint(), tile()->size())),
+ CGContextGetCTM(contextRef),
+ patternBoundaries().width(),
+ patternBoundaries().height(),
+ kCGPatternTilingConstantSpacing,
+ true, // has color
+ &callbacks);
+
+ if (!m_patternSpace)
+ m_patternSpace = CGColorSpaceCreatePattern(0);
+
+ if ((type & ApplyToFillTargetType) && style->svgStyle()->hasFill()) {
+ CGFloat alpha = style->svgStyle()->fillOpacity();
+ CGContextSetFillColorSpace(contextRef, m_patternSpace);
+ CGContextSetFillPattern(contextRef, m_pattern, &alpha);
+
+ if (isPaintingText)
+ context->setTextDrawingMode(cTextFill);
+ }
+
+ if ((type & ApplyToStrokeTargetType) && style->svgStyle()->hasStroke()) {
+ CGFloat alpha = style->svgStyle()->strokeOpacity();
+ CGContextSetStrokeColorSpace(contextRef, m_patternSpace);
+ CGContextSetStrokePattern(contextRef, m_pattern, &alpha);
+ applyStrokeStyleToContext(context, style, object);
+
+ if (isPaintingText)
+ context->setTextDrawingMode(cTextStroke);
+ }
+
+ return true;
+}
+
+void SVGPaintServerPattern::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const
+{
+ CGPatternRelease(m_pattern);
+ m_pattern = 0;
+
+ context->restore();
+}
+
+} // namespace WebCore
+
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp b/WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp
new file mode 100644
index 0000000..706f39c
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerSolid.h"
+
+#include "GraphicsContext.h"
+#include "RenderObject.h"
+#include "CgSupport.h"
+
+namespace WebCore {
+
+bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ CGContextRef contextRef = context->platformContext();
+ RenderStyle* style = object ? object->style() : 0;
+
+ static CGColorSpaceRef deviceRGBColorSpace = CGColorSpaceCreateDeviceRGB(); // This should be shared from GraphicsContext, or some other central location
+
+ if ((type & ApplyToFillTargetType) && (!style || style->svgStyle()->hasFill())) {
+ CGFloat colorComponents[4];
+ color().getRGBA(colorComponents[0], colorComponents[1], colorComponents[2], colorComponents[3]);
+ ASSERT(!color().hasAlpha());
+ if (style)
+ colorComponents[3] = style->svgStyle()->fillOpacity(); // SVG/CSS colors are not specified w/o alpha
+
+ CGContextSetFillColorSpace(contextRef, deviceRGBColorSpace);
+ CGContextSetFillColor(contextRef, colorComponents);
+
+ if (isPaintingText)
+ context->setTextDrawingMode(cTextFill);
+ }
+
+ if ((type & ApplyToStrokeTargetType) && (!style || style->svgStyle()->hasStroke())) {
+ CGFloat colorComponents[4];
+ color().getRGBA(colorComponents[0], colorComponents[1], colorComponents[2], colorComponents[3]);
+ ASSERT(!color().hasAlpha());
+ if (style)
+ colorComponents[3] = style->svgStyle()->strokeOpacity(); // SVG/CSS colors are not specified w/o alpha
+
+ CGContextSetStrokeColorSpace(contextRef, deviceRGBColorSpace);
+ CGContextSetStrokeColor(contextRef, colorComponents);
+
+ if (style)
+ applyStrokeStyleToContext(context, style, object);
+
+ if (isPaintingText)
+ context->setTextDrawingMode(cTextStroke);
+ }
+
+ return true;
+}
+
+} // namespace WebCore
+
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp b/WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp
new file mode 100644
index 0000000..071afe2
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ * 2005 Alexander Kellett <lypanov@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGResourceClipper.h"
+
+#include "GraphicsContext.h"
+#include "CgSupport.h"
+
+namespace WebCore {
+
+void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
+{
+ CGContextRef cgContext = context->platformContext();
+ if (m_clipData.clipData().size() < 1)
+ return;
+
+ bool heterogenousClipRules = false;
+ WindRule clipRule = m_clipData.clipData()[0].windRule;
+
+ context->beginPath();
+
+ CGAffineTransform bboxTransform = CGAffineTransformMakeMapBetweenRects(CGRectMake(0,0,1,1), CGRect(boundingBox));
+
+ for (unsigned x = 0; x < m_clipData.clipData().size(); x++) {
+ ClipData data = m_clipData.clipData()[x];
+ if (data.windRule != clipRule)
+ heterogenousClipRules = true;
+
+ CGPathRef clipPath = data.path.platformPath();
+
+ if (data.bboxUnits) {
+ CGMutablePathRef transformedPath = CGPathCreateMutable();
+ CGPathAddPath(transformedPath, &bboxTransform, clipPath);
+ CGContextAddPath(cgContext, transformedPath);
+ CGPathRelease(transformedPath);
+ } else
+ CGContextAddPath(cgContext, clipPath);
+ }
+
+ if (m_clipData.clipData().size()) {
+ // FIXME!
+ // We don't currently allow for heterogenous clip rules.
+ // we would have to detect such, draw to a mask, and then clip
+ // to that mask
+ if (!CGContextIsPathEmpty(cgContext)) {
+ if (clipRule == RULE_EVENODD)
+ CGContextEOClip(cgContext);
+ else
+ CGContextClip(cgContext);
+ }
+ }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/graphics/cg/SVGResourceFilterCg.cpp b/WebCore/svg/graphics/cg/SVGResourceFilterCg.cpp
new file mode 100644
index 0000000..ecfcdd8
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGResourceFilterCg.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Dave MacLachlan (dmaclach@mac.com)
+ * 2006 Rob Buis <buis@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "config.h"
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "NotImplemented.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGResourceFilterPlatformData* SVGResourceFilter::createPlatformData()
+{
+ return 0;
+}
+
+void SVGResourceFilter::prepareFilter(GraphicsContext*&, const FloatRect&)
+{
+ notImplemented();
+}
+
+void SVGResourceFilter::applyFilter(GraphicsContext*&, const FloatRect&)
+{
+ notImplemented();
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/cg/SVGResourceFilterCg.mm b/WebCore/svg/graphics/cg/SVGResourceFilterCg.mm
new file mode 100644
index 0000000..f3dc819
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGResourceFilterCg.mm
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ * (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGResourceFilter.h"
+
+#include "AffineTransform.h"
+#include "FoundationExtras.h"
+#include "GraphicsContext.h"
+
+#include "SVGResourceFilterPlatformDataMac.h"
+
+#include <QuartzCore/CoreImage.h>
+
+// Setting to a value > 0 allows to dump the output image as JPEG.
+#define DEBUG_OUTPUT_IMAGE 0
+
+namespace WebCore {
+
+SVGResourceFilterPlatformData* SVGResourceFilter::createPlatformData()
+{
+ return new SVGResourceFilterPlatformDataMac(this);
+}
+
+void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const FloatRect& bbox)
+{
+ if (bbox.isEmpty() || m_effects.isEmpty())
+ return;
+
+ SVGResourceFilterPlatformDataMac* platform = static_cast<SVGResourceFilterPlatformDataMac*>(platformData());
+
+ CGContextRef cgContext = context->platformContext();
+
+ // Use of CGBegin/EndTransparencyLayer around this call causes over release
+ // of cgContext due to it being created on an autorelease pool, and released
+ // after CGEndTransparencyLayer. Create local pool to fix.
+ // <http://bugs.webkit.org/show_bug.cgi?id=8425>
+ // <http://bugs.webkit.org/show_bug.cgi?id=6947>
+ // <rdar://problem/4647735>
+ NSAutoreleasePool* filterContextPool = [[NSAutoreleasePool alloc] init];
+ platform->m_filterCIContext = HardRetain([CIContext contextWithCGContext:cgContext options:nil]);
+ [filterContextPool drain];
+
+ FloatRect filterRect = filterBBoxForItemBBox(bbox);
+
+ // TODO: Ensure the size is not greater than the nearest <svg> size and/or the window size.
+ // This is also needed for masking & gradients-on-stroke-of-text. File a bug on this.
+ float width = filterRect.width();
+ float height = filterRect.height();
+
+ platform->m_filterCGLayer = [platform->m_filterCIContext createCGLayerWithSize:CGSizeMake(width, height) info:NULL];
+
+ context = new GraphicsContext(CGLayerGetContext(platform->m_filterCGLayer));
+ context->save();
+
+ context->translate(-filterRect.x(), -filterRect.y());
+}
+
+#ifndef NDEBUG
+// Extremly helpful debugging utilities for any paint server / resource that creates
+// internal image buffers (ie. gradients on text, masks, filters...)
+void dumpCIOutputImage(CIImage* outputImage, NSString* fileName)
+{
+ CGSize extentSize = [outputImage extent].size;
+ NSImage* image = [[[NSImage alloc] initWithSize:NSMakeSize(extentSize.width, extentSize.height)] autorelease];
+ [image addRepresentation:[NSCIImageRep imageRepWithCIImage:outputImage]];
+
+ NSData* imageData = [image TIFFRepresentation];
+ NSBitmapImageRep* imageRep = [NSBitmapImageRep imageRepWithData:imageData];
+ imageData = [imageRep representationUsingType:NSJPEGFileType properties:nil];
+
+ [imageData writeToFile:fileName atomically:YES];
+}
+
+void dumpCGOutputImage(CGImage* outputImage, NSString* fileName)
+{
+ if (CIImage* ciOutputImage = [CIImage imageWithCGImage:outputImage])
+ dumpCIOutputImage(ciOutputImage, fileName);
+}
+#endif
+
+void SVGResourceFilter::applyFilter(GraphicsContext*& context, const FloatRect& bbox)
+{
+ if (bbox.isEmpty() || m_effects.isEmpty())
+ return;
+
+ SVGResourceFilterPlatformDataMac* platform = static_cast<SVGResourceFilterPlatformDataMac*>(platformData());
+
+ // actually apply the filter effects
+ CIImage* inputImage = [CIImage imageWithCGLayer:platform->m_filterCGLayer];
+ NSArray* filterStack = platform->getCIFilterStack(inputImage, bbox);
+ if ([filterStack count]) {
+ CIImage* outputImage = [[filterStack lastObject] valueForKey:@"outputImage"];
+
+ if (outputImage) {
+#if DEBUG_OUTPUT_IMAGE > 0
+ dumpOutputImage(outputImage);
+#endif
+
+ FloatRect filterRect = filterBBoxForItemBBox(bbox);
+ FloatPoint destOrigin = filterRect.location();
+ filterRect.setLocation(FloatPoint(0.0f, 0.0f));
+
+ [platform->m_filterCIContext drawImage:outputImage atPoint:CGPoint(destOrigin) fromRect:filterRect];
+ }
+ }
+
+ CGLayerRelease(platform->m_filterCGLayer);
+ platform->m_filterCGLayer = 0;
+
+ HardRelease(platform->m_filterCIContext);
+ platform->m_filterCIContext = 0;
+
+ delete context;
+ context = 0;
+}
+
+}
+
+#endif // ENABLE(SVG) ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/cg/SVGResourceMaskerCg.cpp b/WebCore/svg/graphics/cg/SVGResourceMaskerCg.cpp
new file mode 100644
index 0000000..4d2100b
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGResourceMaskerCg.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2007 Apple Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGResourceMasker.h"
+#include "NotImplemented.h"
+
+namespace WebCore {
+
+void SVGResourceMasker::applyMask(GraphicsContext*, const FloatRect&)
+{
+ notImplemented();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm b/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm
new file mode 100644
index 0000000..00e62e7
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2005, 2006 Alexander Kellett <lypanov@kde.org>
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#import "SVGResourceMasker.h"
+
+#import "BlockExceptions.h"
+#import "CgSupport.h"
+#import "GraphicsContext.h"
+#import "ImageBuffer.h"
+#import "SVGMaskElement.h"
+#import "SVGRenderSupport.h"
+#import "SVGRenderStyle.h"
+#import "SVGResourceFilter.h"
+#import <QuartzCore/CIFilter.h>
+#import <QuartzCore/CoreImage.h>
+
+using namespace std;
+
+namespace WebCore {
+
+static CIImage* applyLuminanceToAlphaFilter(CIImage* inputImage)
+{
+ CIFilter* luminanceToAlpha = [CIFilter filterWithName:@"CIColorMatrix"];
+ [luminanceToAlpha setDefaults];
+ CGFloat alpha[4] = {0.2125f, 0.7154f, 0.0721f, 0.0f};
+ CGFloat zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ [luminanceToAlpha setValue:inputImage forKey:@"inputImage"];
+ [luminanceToAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputRVector"];
+ [luminanceToAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputGVector"];
+ [luminanceToAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBVector"];
+ [luminanceToAlpha setValue:[CIVector vectorWithValues:alpha count:4] forKey:@"inputAVector"];
+ [luminanceToAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBiasVector"];
+ return [luminanceToAlpha valueForKey:@"outputImage"];
+}
+
+static CIImage* applyExpandAlphatoGrayscaleFilter(CIImage* inputImage)
+{
+ CIFilter* alphaToGrayscale = [CIFilter filterWithName:@"CIColorMatrix"];
+ CGFloat zero[4] = {0, 0, 0, 0};
+ [alphaToGrayscale setDefaults];
+ [alphaToGrayscale setValue:inputImage forKey:@"inputImage"];
+ [alphaToGrayscale setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputRVector"];
+ [alphaToGrayscale setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputGVector"];
+ [alphaToGrayscale setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBVector"];
+ [alphaToGrayscale setValue:[CIVector vectorWithX:0.0f Y:0.0f Z:0.0f W:1.0f] forKey:@"inputAVector"];
+ [alphaToGrayscale setValue:[CIVector vectorWithX:1.0f Y:1.0f Z:1.0f W:0.0f] forKey:@"inputBiasVector"];
+ return [alphaToGrayscale valueForKey:@"outputImage"];
+}
+
+static CIImage* transformImageIntoGrayscaleMask(CIImage* inputImage)
+{
+ CIFilter* blackBackground = [CIFilter filterWithName:@"CIConstantColorGenerator"];
+ [blackBackground setValue:[CIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:1.0f] forKey:@"inputColor"];
+
+ CIFilter* layerOverBlack = [CIFilter filterWithName:@"CISourceOverCompositing"];
+ [layerOverBlack setValue:[blackBackground valueForKey:@"outputImage"] forKey:@"inputBackgroundImage"];
+ [layerOverBlack setValue:inputImage forKey:@"inputImage"];
+
+ CIImage* luminanceAlpha = applyLuminanceToAlphaFilter([layerOverBlack valueForKey:@"outputImage"]);
+ CIImage* luminanceAsGrayscale = applyExpandAlphatoGrayscaleFilter(luminanceAlpha);
+ CIImage* alphaAsGrayscale = applyExpandAlphatoGrayscaleFilter(inputImage);
+
+ CIFilter* multipliedGrayscale = [CIFilter filterWithName:@"CIMultiplyCompositing"];
+ [multipliedGrayscale setValue:luminanceAsGrayscale forKey:@"inputBackgroundImage"];
+ [multipliedGrayscale setValue:alphaAsGrayscale forKey:@"inputImage"];
+ return [multipliedGrayscale valueForKey:@"outputImage"];
+}
+
+void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& boundingBox)
+{
+ if (!m_mask)
+ m_mask.set(m_ownerElement->drawMaskerContent(boundingBox, m_maskRect).release());
+ if (!m_mask)
+ return;
+
+ IntSize maskSize(static_cast<int>(m_maskRect.width()), static_cast<int>(m_maskRect.height()));
+ clampImageBufferSizeToViewport(m_ownerElement->document()->renderer(), maskSize);
+
+ // Create new graphics context in gray scale mode for image rendering
+ auto_ptr<ImageBuffer> grayScaleImage(ImageBuffer::create(maskSize, true));
+ if (!grayScaleImage.get())
+ return;
+
+ BEGIN_BLOCK_OBJC_EXCEPTIONS
+ CGContextRef grayScaleContext = grayScaleImage->context()->platformContext();
+ CIContext* ciGrayscaleContext = [CIContext contextWithCGContext:grayScaleContext options:nil];
+
+ // Transform colorized mask to gray scale
+ CIImage* colorMask = [CIImage imageWithCGImage:m_mask->cgImage()];
+ if (!colorMask)
+ return;
+ CIImage* grayScaleMask = transformImageIntoGrayscaleMask(colorMask);
+ [ciGrayscaleContext drawImage:grayScaleMask atPoint:CGPointZero fromRect:CGRectMake(0, 0, maskSize.width(), maskSize.height())];
+
+ CGContextClipToMask(context->platformContext(), m_maskRect, grayScaleImage->cgImage());
+ END_BLOCK_OBJC_EXCEPTIONS
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/graphics/filters/SVGDistantLightSource.h b/WebCore/svg/graphics/filters/SVGDistantLightSource.h
new file mode 100644
index 0000000..c4ff9b7
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGDistantLightSource.h
@@ -0,0 +1,52 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGDistantLightSource_h
+#define SVGDistantLightSource_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGLightSource.h"
+
+namespace WebCore {
+
+class SVGDistantLightSource : public SVGLightSource {
+public:
+ SVGDistantLightSource(float azimuth, float elevation)
+ : SVGLightSource(LS_DISTANT)
+ , m_azimuth(azimuth)
+ , m_elevation(elevation)
+ { }
+
+ float azimuth() const { return m_azimuth; }
+ float elevation() const { return m_elevation; }
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+private:
+ float m_azimuth;
+ float m_elevation;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGDistantLightSource_h
diff --git a/WebCore/svg/graphics/filters/SVGFEBlend.cpp b/WebCore/svg/graphics/filters/SVGFEBlend.cpp
new file mode 100644
index 0000000..a1f2e5b
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEBlend.cpp
@@ -0,0 +1,87 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEBlend.h"
+
+namespace WebCore {
+
+SVGFEBlend::SVGFEBlend(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+ , m_mode(SVG_FEBLEND_MODE_UNKNOWN)
+{
+}
+
+String SVGFEBlend::in2() const
+{
+ return m_in2;
+}
+
+void SVGFEBlend::setIn2(const String& in2)
+{
+ m_in2 = in2;
+}
+
+SVGBlendModeType SVGFEBlend::blendMode() const
+{
+ return m_mode;
+}
+
+void SVGFEBlend::setBlendMode(SVGBlendModeType mode)
+{
+ m_mode = mode;
+}
+
+static TextStream& operator<<(TextStream& ts, SVGBlendModeType t)
+{
+ switch (t)
+ {
+ case SVG_FEBLEND_MODE_UNKNOWN:
+ ts << "UNKNOWN"; break;
+ case SVG_FEBLEND_MODE_NORMAL:
+ ts << "NORMAL"; break;
+ case SVG_FEBLEND_MODE_MULTIPLY:
+ ts << "MULTIPLY"; break;
+ case SVG_FEBLEND_MODE_SCREEN:
+ ts << "SCREEN"; break;
+ case SVG_FEBLEND_MODE_DARKEN:
+ ts << "DARKEN"; break;
+ case SVG_FEBLEND_MODE_LIGHTEN:
+ ts << "LIGHTEN"; break;
+ }
+ return ts;
+}
+
+TextStream& SVGFEBlend::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=BLEND] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ if (!m_in2.isEmpty())
+ ts << " [in2=\"" << m_in2 << "\"]";
+ ts << " [blend mode=" << m_mode << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEBlend.h b/WebCore/svg/graphics/filters/SVGFEBlend.h
new file mode 100644
index 0000000..f8063f7
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEBlend.h
@@ -0,0 +1,64 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEBlend_h
+#define SVGFEBlend_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+enum SVGBlendModeType {
+ SVG_FEBLEND_MODE_UNKNOWN = 0,
+ SVG_FEBLEND_MODE_NORMAL = 1,
+ SVG_FEBLEND_MODE_MULTIPLY = 2,
+ SVG_FEBLEND_MODE_SCREEN = 3,
+ SVG_FEBLEND_MODE_DARKEN = 4,
+ SVG_FEBLEND_MODE_LIGHTEN = 5
+};
+
+class SVGFEBlend : public SVGFilterEffect {
+public:
+ SVGFEBlend(SVGResourceFilter*);
+
+ String in2() const;
+ void setIn2(const String&);
+
+ SVGBlendModeType blendMode() const;
+ void setBlendMode(SVGBlendModeType);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+#endif
+
+private:
+ SVGBlendModeType m_mode;
+ String m_in2;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFEBlend_h
diff --git a/WebCore/svg/graphics/filters/SVGFEColorMatrix.cpp b/WebCore/svg/graphics/filters/SVGFEColorMatrix.cpp
new file mode 100644
index 0000000..8eb2572
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEColorMatrix.cpp
@@ -0,0 +1,84 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEColorMatrix.h"
+
+namespace WebCore {
+
+SVGFEColorMatrix::SVGFEColorMatrix(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+ , m_type(SVG_FECOLORMATRIX_TYPE_UNKNOWN)
+{
+}
+
+SVGColorMatrixType SVGFEColorMatrix::type() const
+{
+ return m_type;
+}
+
+void SVGFEColorMatrix::setType(SVGColorMatrixType type)
+{
+ m_type = type;
+}
+
+const Vector<float>& SVGFEColorMatrix::values() const
+{
+ return m_values;
+}
+
+void SVGFEColorMatrix::setValues(const Vector<float> &values)
+{
+ m_values = values;
+}
+
+static TextStream& operator<<(TextStream& ts, SVGColorMatrixType t)
+{
+ switch (t)
+ {
+ case SVG_FECOLORMATRIX_TYPE_UNKNOWN:
+ ts << "UNKNOWN"; break;
+ case SVG_FECOLORMATRIX_TYPE_MATRIX:
+ ts << "CMT_MATRIX"; break;
+ case SVG_FECOLORMATRIX_TYPE_SATURATE:
+ ts << "CMT_SATURATE"; break;
+ case SVG_FECOLORMATRIX_TYPE_HUEROTATE:
+ ts << "HUE-ROTATE"; break;
+ case SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
+ ts << "LUMINANCE-TO-ALPHA"; break;
+ }
+ return ts;
+}
+
+TextStream& SVGFEColorMatrix::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=COLOR-MATRIX] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ ts << " [color matrix type=" << type() << "]"
+ << " [values=" << values() << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEColorMatrix.h b/WebCore/svg/graphics/filters/SVGFEColorMatrix.h
new file mode 100644
index 0000000..0d4eb23
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEColorMatrix.h
@@ -0,0 +1,64 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEColorMatrix_h
+#define SVGFEColorMatrix_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterEffect.h"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+enum SVGColorMatrixType {
+ SVG_FECOLORMATRIX_TYPE_UNKNOWN = 0,
+ SVG_FECOLORMATRIX_TYPE_MATRIX = 1,
+ SVG_FECOLORMATRIX_TYPE_SATURATE = 2,
+ SVG_FECOLORMATRIX_TYPE_HUEROTATE = 3,
+ SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA = 4
+};
+
+class SVGFEColorMatrix : public SVGFilterEffect {
+public:
+ SVGFEColorMatrix(SVGResourceFilter*);
+
+ SVGColorMatrixType type() const;
+ void setType(SVGColorMatrixType);
+
+ const Vector<float>& values() const;
+ void setValues(const Vector<float>&);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+#endif
+
+private:
+ SVGColorMatrixType m_type;
+ Vector<float> m_values;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFEColorMatrix_h
diff --git a/WebCore/svg/graphics/filters/SVGFEComponentTransfer.cpp b/WebCore/svg/graphics/filters/SVGFEComponentTransfer.cpp
new file mode 100644
index 0000000..d937c63
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEComponentTransfer.cpp
@@ -0,0 +1,141 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEComponentTransfer.h"
+
+namespace WebCore {
+
+SVGFEComponentTransfer::SVGFEComponentTransfer(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+{
+}
+
+SVGComponentTransferFunction SVGFEComponentTransfer::redFunction() const
+{
+ return m_redFunc;
+}
+
+void SVGFEComponentTransfer::setRedFunction(const SVGComponentTransferFunction& func)
+{
+ m_redFunc = func;
+}
+
+SVGComponentTransferFunction SVGFEComponentTransfer::greenFunction() const
+{
+ return m_greenFunc;
+}
+
+void SVGFEComponentTransfer::setGreenFunction(const SVGComponentTransferFunction& func)
+{
+ m_greenFunc = func;
+}
+
+SVGComponentTransferFunction SVGFEComponentTransfer::blueFunction() const
+{
+ return m_blueFunc;
+}
+
+void SVGFEComponentTransfer::setBlueFunction(const SVGComponentTransferFunction& func)
+{
+ m_blueFunc = func;
+}
+
+SVGComponentTransferFunction SVGFEComponentTransfer::alphaFunction() const
+{
+ return m_alphaFunc;
+}
+
+void SVGFEComponentTransfer::setAlphaFunction(const SVGComponentTransferFunction& func)
+{
+ m_alphaFunc = func;
+}
+
+static TextStream& operator<<(TextStream& ts, SVGComponentTransferType t)
+{
+ switch (t)
+ {
+ case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
+ ts << "UNKNOWN"; break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY:
+ ts << "IDENTITY"; break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
+ ts << "TABLE"; break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
+ ts << "DISCRETE"; break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
+ ts << "LINEAR"; break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
+ ts << "GAMMA"; break;
+ }
+ return ts;
+}
+
+static TextStream& operator<<(TextStream& ts, const SVGComponentTransferFunction &func)
+{
+ ts << "[type=" << func.type << "]";
+ switch (func.type) {
+ case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
+ case SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY:
+ break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
+ case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
+ {
+ ts << " [table values=";
+ Vector<float>::const_iterator itr=func.tableValues.begin();
+ if (itr != func.tableValues.end()) {
+ ts << *itr++;
+ for (; itr!=func.tableValues.end(); itr++) {
+ ts << " " << *itr;
+ }
+ }
+ ts << "]";
+ break;
+ }
+ case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
+ ts << " [slope=" << func.slope << "]"
+ << " [intercept=" << func.intercept << "]";
+ break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
+ ts << " [amplitude=" << func.amplitude << "]"
+ << " [exponent=" << func.exponent << "]"
+ << " [offset=" << func.offset << "]";
+ break;
+ }
+ return ts;
+}
+
+TextStream& SVGFEComponentTransfer::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=COMPONENT-TRANSFER] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ ts << " [red func=" << redFunction() << "]"
+ << " [green func=" << greenFunction() << "]"
+ << " [blue func=" << blueFunction() << "]"
+ << " [alpha func=" << alphaFunction() << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEComponentTransfer.h b/WebCore/svg/graphics/filters/SVGFEComponentTransfer.h
new file mode 100644
index 0000000..32d5e14
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEComponentTransfer.h
@@ -0,0 +1,110 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEComponentTransfer_h
+#define SVGFEComponentTransfer_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include <wtf/Vector.h>
+
+#include "SVGFilterEffect.h"
+#include "SVGFEDisplacementMap.h"
+
+#if PLATFORM(CI)
+#ifdef __OBJC__
+@class CIImage;
+@class CIFilter;
+#else
+class CIImage;
+class CIFilter;
+#endif
+#endif
+
+namespace WebCore {
+
+enum SVGComponentTransferType {
+ SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN = 0,
+ SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY = 1,
+ SVG_FECOMPONENTTRANSFER_TYPE_TABLE = 2,
+ SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE = 3,
+ SVG_FECOMPONENTTRANSFER_TYPE_LINEAR = 4,
+ SVG_FECOMPONENTTRANSFER_TYPE_GAMMA = 5
+};
+
+struct SVGComponentTransferFunction {
+ SVGComponentTransferFunction()
+ : type(SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN)
+ , slope(0.0f)
+ , intercept(0.0f)
+ , amplitude(0.0f)
+ , exponent(0.0f)
+ , offset(0.0f)
+ {
+ }
+
+ SVGComponentTransferType type;
+
+ float slope;
+ float intercept;
+ float amplitude;
+ float exponent;
+ float offset;
+
+ Vector<float> tableValues;
+};
+
+class SVGFEComponentTransfer : public SVGFilterEffect {
+public:
+ SVGFEComponentTransfer(SVGResourceFilter*);
+
+ SVGComponentTransferFunction redFunction() const;
+ void setRedFunction(const SVGComponentTransferFunction&);
+
+ SVGComponentTransferFunction greenFunction() const;
+ void setGreenFunction(const SVGComponentTransferFunction&);
+
+ SVGComponentTransferFunction blueFunction() const;
+ void setBlueFunction(const SVGComponentTransferFunction&);
+
+ SVGComponentTransferFunction alphaFunction() const;
+ void setAlphaFunction(const SVGComponentTransferFunction&);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+
+private:
+ CIFilter* getFunctionFilter(SVGChannelSelectorType, CIImage* inputImage) const;
+#endif
+
+private:
+ SVGComponentTransferFunction m_redFunc;
+ SVGComponentTransferFunction m_greenFunc;
+ SVGComponentTransferFunction m_blueFunc;
+ SVGComponentTransferFunction m_alphaFunc;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFEComponentTransfer_h
diff --git a/WebCore/svg/graphics/filters/SVGFEComposite.cpp b/WebCore/svg/graphics/filters/SVGFEComposite.cpp
new file mode 100644
index 0000000..0be84f9
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEComposite.cpp
@@ -0,0 +1,111 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEComposite.h"
+
+namespace WebCore {
+
+SVGFEComposite::SVGFEComposite(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+ , m_operation(SVG_FECOMPOSITE_OPERATOR_UNKNOWN)
+ , m_k1(0.0f)
+ , m_k2(0.0f)
+ , m_k3(0.0f)
+ , m_k4(0.0f)
+{
+}
+
+String SVGFEComposite::in2() const
+{
+ return m_in2;
+}
+
+void SVGFEComposite::setIn2(const String& in2)
+{
+ m_in2 = in2;
+}
+
+SVGCompositeOperationType SVGFEComposite::operation() const
+{
+ return m_operation;
+}
+
+void SVGFEComposite::setOperation(SVGCompositeOperationType oper)
+{
+ m_operation = oper;
+}
+
+float SVGFEComposite::k1() const
+{
+ return m_k1;
+}
+
+void SVGFEComposite::setK1(float k1)
+{
+ m_k1 = k1;
+}
+
+float SVGFEComposite::k2() const
+{
+ return m_k2;
+}
+
+void SVGFEComposite::setK2(float k2)
+{
+ m_k2 = k2;
+}
+
+float SVGFEComposite::k3() const
+{
+ return m_k3;
+}
+
+void SVGFEComposite::setK3(float k3)
+{
+ m_k3 = k3;
+}
+
+float SVGFEComposite::k4() const
+{
+ return m_k4;
+}
+
+void SVGFEComposite::setK4(float k4)
+{
+ m_k4 = k4;
+}
+
+TextStream& SVGFEComposite::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=COMPOSITE] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ if (!in2().isEmpty())
+ ts << " [in2=\"" << in2() << "\"]";
+ ts << " [k1=" << k1() << " k2=" << k2() << " k3=" << k3() << " k4=" << k4() << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEComposite.h b/WebCore/svg/graphics/filters/SVGFEComposite.h
new file mode 100644
index 0000000..7a18047
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEComposite.h
@@ -0,0 +1,81 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEComposite_h
+#define SVGFEComposite_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+enum SVGCompositeOperationType {
+ SVG_FECOMPOSITE_OPERATOR_UNKNOWN = 0,
+ SVG_FECOMPOSITE_OPERATOR_OVER = 1,
+ SVG_FECOMPOSITE_OPERATOR_IN = 2,
+ SVG_FECOMPOSITE_OPERATOR_OUT = 3,
+ SVG_FECOMPOSITE_OPERATOR_ATOP = 4,
+ SVG_FECOMPOSITE_OPERATOR_XOR = 5,
+ SVG_FECOMPOSITE_OPERATOR_ARITHMETIC = 6
+};
+
+class SVGFEComposite : public SVGFilterEffect {
+public:
+ SVGFEComposite(SVGResourceFilter*);
+
+ String in2() const;
+ void setIn2(const String&);
+
+ SVGCompositeOperationType operation() const;
+ void setOperation(SVGCompositeOperationType);
+
+ float k1() const;
+ void setK1(float);
+
+ float k2() const;
+ void setK2(float);
+
+ float k3() const;
+ void setK3(float);
+
+ float k4() const;
+ void setK4(float);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+#endif
+
+private:
+ SVGCompositeOperationType m_operation;
+ float m_k1;
+ float m_k2;
+ float m_k3;
+ float m_k4;
+ String m_in2;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFEComposite_h
diff --git a/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp
new file mode 100644
index 0000000..af2b693
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp
@@ -0,0 +1,155 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGRenderTreeAsText.h"
+#include "SVGFEConvolveMatrix.h"
+
+namespace WebCore {
+
+SVGFEConvolveMatrix::SVGFEConvolveMatrix(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+ , m_kernelSize()
+ , m_divisor(0.0f)
+ , m_bias(0.0f)
+ , m_targetOffset()
+ , m_edgeMode(SVG_EDGEMODE_UNKNOWN)
+ , m_kernelUnitLength()
+ , m_preserveAlpha(false)
+{
+}
+
+FloatSize SVGFEConvolveMatrix::kernelSize() const
+{
+ return m_kernelSize;
+}
+
+void SVGFEConvolveMatrix::setKernelSize(FloatSize kernelSize)
+{
+ m_kernelSize = kernelSize;
+}
+
+const Vector<float>& SVGFEConvolveMatrix::kernel() const
+{
+ return m_kernelMatrix;
+}
+
+void SVGFEConvolveMatrix::setKernel(const Vector<float>& kernel)
+{
+ m_kernelMatrix = kernel;
+}
+
+float SVGFEConvolveMatrix::divisor() const
+{
+ return m_divisor;
+}
+
+void SVGFEConvolveMatrix::setDivisor(float divisor)
+{
+ m_divisor = divisor;
+}
+
+float SVGFEConvolveMatrix::bias() const
+{
+ return m_bias;
+}
+
+void SVGFEConvolveMatrix::setBias(float bias)
+{
+ m_bias = bias;
+}
+
+FloatSize SVGFEConvolveMatrix::targetOffset() const
+{
+ return m_targetOffset;
+}
+
+void SVGFEConvolveMatrix::setTargetOffset(FloatSize targetOffset)
+{
+ m_targetOffset = targetOffset;
+}
+
+SVGEdgeModeType SVGFEConvolveMatrix::edgeMode() const
+{
+ return m_edgeMode;
+}
+
+void SVGFEConvolveMatrix::setEdgeMode(SVGEdgeModeType edgeMode)
+{
+ m_edgeMode = edgeMode;
+}
+
+FloatPoint SVGFEConvolveMatrix::kernelUnitLength() const
+{
+ return m_kernelUnitLength;
+}
+
+void SVGFEConvolveMatrix::setKernelUnitLength(FloatPoint kernelUnitLength)
+{
+ m_kernelUnitLength = kernelUnitLength;
+}
+
+bool SVGFEConvolveMatrix::preserveAlpha() const
+{
+ return m_preserveAlpha;
+}
+
+void SVGFEConvolveMatrix::setPreserveAlpha(bool preserveAlpha)
+{
+ m_preserveAlpha = preserveAlpha;
+}
+
+static TextStream& operator<<(TextStream& ts, SVGEdgeModeType t)
+{
+ switch (t)
+ {
+ case SVG_EDGEMODE_UNKNOWN:
+ ts << "UNKNOWN";break;
+ case SVG_EDGEMODE_DUPLICATE:
+ ts << "DUPLICATE";break;
+ case SVG_EDGEMODE_WRAP:
+ ts << "WRAP"; break;
+ case SVG_EDGEMODE_NONE:
+ ts << "NONE"; break;
+ }
+ return ts;
+}
+
+TextStream& SVGFEConvolveMatrix::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=CONVOLVE-MATRIX] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ ts << " [order " << m_kernelSize << "]"
+ << " [kernel matrix=" << m_kernelMatrix << "]"
+ << " [divisor=" << m_divisor << "]"
+ << " [bias=" << m_bias << "]"
+ << " [target " << m_targetOffset << "]"
+ << " [edge mode=" << m_edgeMode << "]"
+ << " [kernel unit length " << m_kernelUnitLength << "]"
+ << " [preserve alpha=" << m_preserveAlpha << "]";
+ return ts;
+}
+
+}; // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h
new file mode 100644
index 0000000..b9744fa
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h
@@ -0,0 +1,82 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEConvolveMatrix_h
+#define SVGFEConvolveMatrix_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+enum SVGEdgeModeType {
+ SVG_EDGEMODE_UNKNOWN = 0,
+ SVG_EDGEMODE_DUPLICATE = 1,
+ SVG_EDGEMODE_WRAP = 2,
+ SVG_EDGEMODE_NONE = 3
+};
+
+class SVGFEConvolveMatrix : public SVGFilterEffect {
+public:
+ SVGFEConvolveMatrix(SVGResourceFilter*);
+
+ FloatSize kernelSize() const;
+ void setKernelSize(FloatSize);
+
+ const Vector<float>& kernel() const;
+ void setKernel(const Vector<float>&);
+
+ float divisor() const;
+ void setDivisor(float);
+
+ float bias() const;
+ void setBias(float);
+
+ FloatSize targetOffset() const;
+ void setTargetOffset(FloatSize);
+
+ SVGEdgeModeType edgeMode() const;
+ void setEdgeMode(SVGEdgeModeType);
+
+ FloatPoint kernelUnitLength() const;
+ void setKernelUnitLength(FloatPoint);
+
+ bool preserveAlpha() const;
+ void setPreserveAlpha(bool);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+private:
+ FloatSize m_kernelSize;
+ float m_divisor;
+ float m_bias;
+ FloatSize m_targetOffset;
+ SVGEdgeModeType m_edgeMode;
+ FloatPoint m_kernelUnitLength;
+ bool m_preserveAlpha;
+ Vector<float> m_kernelMatrix; // maybe should be a real matrix?
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFEConvolveMatrix_h
diff --git a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp
new file mode 100644
index 0000000..937dfb9
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp
@@ -0,0 +1,121 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGLightSource.h"
+#include "SVGFEDiffuseLighting.h"
+
+namespace WebCore {
+
+SVGFEDiffuseLighting::SVGFEDiffuseLighting(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+ , m_lightingColor()
+ , m_surfaceScale(0.0f)
+ , m_diffuseConstant(0.0f)
+ , m_kernelUnitLengthX(0.0f)
+ , m_kernelUnitLengthY(0.0f)
+ , m_lightSource(0)
+{
+}
+
+SVGFEDiffuseLighting::~SVGFEDiffuseLighting()
+{
+ delete m_lightSource;
+}
+
+Color SVGFEDiffuseLighting::lightingColor() const
+{
+ return m_lightingColor;
+}
+
+void SVGFEDiffuseLighting::setLightingColor(const Color& lightingColor)
+{
+ m_lightingColor = lightingColor;
+}
+
+float SVGFEDiffuseLighting::surfaceScale() const
+{
+ return m_surfaceScale;
+}
+
+void SVGFEDiffuseLighting::setSurfaceScale(float surfaceScale)
+{
+ m_surfaceScale = surfaceScale;
+}
+
+float SVGFEDiffuseLighting::diffuseConstant() const
+{
+ return m_diffuseConstant;
+}
+
+void SVGFEDiffuseLighting::setDiffuseConstant(float diffuseConstant)
+{
+ m_diffuseConstant = diffuseConstant;
+}
+
+float SVGFEDiffuseLighting::kernelUnitLengthX() const
+{
+ return m_kernelUnitLengthX;
+}
+
+void SVGFEDiffuseLighting::setKernelUnitLengthX(float kernelUnitLengthX)
+{
+ m_kernelUnitLengthX = kernelUnitLengthX;
+}
+
+float SVGFEDiffuseLighting::kernelUnitLengthY() const
+{
+ return m_kernelUnitLengthY;
+}
+
+void SVGFEDiffuseLighting::setKernelUnitLengthY(float kernelUnitLengthY)
+{
+ m_kernelUnitLengthY = kernelUnitLengthY;
+}
+
+const SVGLightSource* SVGFEDiffuseLighting::lightSource() const
+{
+ return m_lightSource;
+}
+
+void SVGFEDiffuseLighting::setLightSource(SVGLightSource* lightSource)
+{
+ if (m_lightSource != lightSource) {
+ delete m_lightSource;
+ m_lightSource = lightSource;
+ }
+}
+
+TextStream& SVGFEDiffuseLighting::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=DIFFUSE-LIGHTING] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ ts << " [surface scale=" << m_surfaceScale << "]"
+ << " [diffuse constant=" << m_diffuseConstant << "]"
+ << " [kernel unit length " << m_kernelUnitLengthX << ", " << m_kernelUnitLengthY << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h
new file mode 100644
index 0000000..a2ed775
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h
@@ -0,0 +1,75 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEDiffuseLighting_h
+#define SVGFEDiffuseLighting_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "Color.h"
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+class SVGLightSource;
+
+class SVGFEDiffuseLighting : public SVGFilterEffect {
+public:
+ SVGFEDiffuseLighting(SVGResourceFilter*);
+ virtual ~SVGFEDiffuseLighting();
+
+ Color lightingColor() const;
+ void setLightingColor(const Color&);
+
+ float surfaceScale() const;
+ void setSurfaceScale(float);
+
+ float diffuseConstant() const;
+ void setDiffuseConstant(float);
+
+ float kernelUnitLengthX() const;
+ void setKernelUnitLengthX(float);
+
+ float kernelUnitLengthY() const;
+ void setKernelUnitLengthY(float);
+
+ const SVGLightSource* lightSource() const;
+ void setLightSource(SVGLightSource*);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+#endif
+
+private:
+ Color m_lightingColor;
+ float m_surfaceScale;
+ float m_diffuseConstant;
+ float m_kernelUnitLengthX;
+ float m_kernelUnitLengthY;
+ SVGLightSource* m_lightSource;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFEDiffuseLighting_h
diff --git a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp
new file mode 100644
index 0000000..39b012b
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp
@@ -0,0 +1,110 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGRenderTreeAsText.h"
+#include "SVGFEDisplacementMap.h"
+
+namespace WebCore {
+
+SVGFEDisplacementMap::SVGFEDisplacementMap(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+ , m_xChannelSelector(SVG_CHANNEL_UNKNOWN)
+ , m_yChannelSelector(SVG_CHANNEL_UNKNOWN)
+ , m_scale(0)
+{
+}
+
+String SVGFEDisplacementMap::in2() const
+{
+ return m_in2;
+}
+
+void SVGFEDisplacementMap::setIn2(const String &in2)
+{
+ m_in2 = in2;
+}
+
+SVGChannelSelectorType SVGFEDisplacementMap::xChannelSelector() const
+{
+ return m_xChannelSelector;
+}
+
+void SVGFEDisplacementMap::setXChannelSelector(const SVGChannelSelectorType xChannelSelector)
+{
+ m_xChannelSelector = xChannelSelector;
+}
+
+SVGChannelSelectorType SVGFEDisplacementMap::yChannelSelector() const
+{
+ return m_yChannelSelector;
+}
+
+void SVGFEDisplacementMap::setYChannelSelector(const SVGChannelSelectorType yChannelSelector)
+{
+ m_yChannelSelector = yChannelSelector;
+}
+
+float SVGFEDisplacementMap::scale() const
+{
+ return m_scale;
+}
+
+void SVGFEDisplacementMap::setScale(float scale)
+{
+ m_scale = scale;
+}
+
+static TextStream& operator<<(TextStream& ts, SVGChannelSelectorType t)
+{
+ switch (t)
+ {
+ case SVG_CHANNEL_UNKNOWN:
+ ts << "UNKNOWN"; break;
+ case SVG_CHANNEL_R:
+ ts << "RED"; break;
+ case SVG_CHANNEL_G:
+ ts << "GREEN"; break;
+ case SVG_CHANNEL_B:
+ ts << "BLUE"; break;
+ case SVG_CHANNEL_A:
+ ts << "ALPHA"; break;
+ }
+ return ts;
+}
+
+TextStream& SVGFEDisplacementMap::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=DISPLACEMENT-MAP] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ if (!in2().isEmpty())
+ ts << " [in2=" << in2() << "]";
+ ts << " [scale=" << m_scale << "]"
+ << " [x channel selector=" << m_xChannelSelector << "]"
+ << " [y channel selector=" << m_yChannelSelector << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h
new file mode 100644
index 0000000..bc45728
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h
@@ -0,0 +1,71 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEDisplacementMap_h
+#define SVGFEDisplacementMap_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+enum SVGChannelSelectorType {
+ SVG_CHANNEL_UNKNOWN = 0,
+ SVG_CHANNEL_R = 1,
+ SVG_CHANNEL_G = 2,
+ SVG_CHANNEL_B = 3,
+ SVG_CHANNEL_A = 4
+};
+
+class SVGFEDisplacementMap : public SVGFilterEffect {
+public:
+ SVGFEDisplacementMap(SVGResourceFilter*);
+
+ String in2() const;
+ void setIn2(const String&);
+
+ SVGChannelSelectorType xChannelSelector() const;
+ void setXChannelSelector(const SVGChannelSelectorType);
+
+ SVGChannelSelectorType yChannelSelector() const;
+ void setYChannelSelector(const SVGChannelSelectorType);
+
+ float scale() const;
+ void setScale(float scale);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+#endif
+
+private:
+ SVGChannelSelectorType m_xChannelSelector;
+ SVGChannelSelectorType m_yChannelSelector;
+ float m_scale;
+ String m_in2;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFEDisplacementMap_h
diff --git a/WebCore/svg/graphics/filters/SVGFEFlood.cpp b/WebCore/svg/graphics/filters/SVGFEFlood.cpp
new file mode 100644
index 0000000..2baeb2e
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEFlood.cpp
@@ -0,0 +1,68 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGRenderTreeAsText.h"
+#include "SVGFEFlood.h"
+
+namespace WebCore {
+
+SVGFEFlood::SVGFEFlood(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+ , m_floodColor()
+ , m_floodOpacity(0.0f)
+{
+}
+
+Color SVGFEFlood::floodColor() const
+{
+ return m_floodColor;
+}
+
+void SVGFEFlood::setFloodColor(const Color& color)
+{
+ m_floodColor = color;
+}
+
+float SVGFEFlood::floodOpacity() const
+{
+ return m_floodOpacity;
+}
+
+void SVGFEFlood::setFloodOpacity(float floodOpacity)
+{
+ m_floodOpacity = floodOpacity;
+}
+
+TextStream& SVGFEFlood::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=FLOOD] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ ts << " [color=" << floodColor() << "]"
+ << " [opacity=" << floodOpacity() << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEFlood.h b/WebCore/svg/graphics/filters/SVGFEFlood.h
new file mode 100644
index 0000000..4cadf9a
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEFlood.h
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEFlood_h
+#define SVGFEFlood_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "Color.h"
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+class SVGFEFlood : public SVGFilterEffect {
+public:
+ SVGFEFlood(SVGResourceFilter*);
+
+ Color floodColor() const;
+ void setFloodColor(const Color &);
+
+ float floodOpacity() const;
+ void setFloodOpacity(float);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+#endif
+
+private:
+ Color m_floodColor;
+ float m_floodOpacity;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFEFlood_h
diff --git a/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp
new file mode 100644
index 0000000..a893f9d
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp
@@ -0,0 +1,66 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEGaussianBlur.h"
+
+namespace WebCore {
+
+SVGFEGaussianBlur::SVGFEGaussianBlur(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+ , m_x(0.0f)
+ , m_y(0.0f)
+{
+}
+
+float SVGFEGaussianBlur::stdDeviationX() const
+{
+ return m_x;
+}
+
+void SVGFEGaussianBlur::setStdDeviationX(float x)
+{
+ m_x = x;
+}
+
+float SVGFEGaussianBlur::stdDeviationY() const
+{
+ return m_y;
+}
+
+void SVGFEGaussianBlur::setStdDeviationY(float y)
+{
+ m_y = y;
+}
+
+TextStream& SVGFEGaussianBlur::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=GAUSSIAN-BLUR] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ ts << " [std dev. x=" << stdDeviationX() << " y=" << stdDeviationY() << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h
new file mode 100644
index 0000000..28cb9e0
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h
@@ -0,0 +1,55 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEGaussianBlur_h
+#define SVGFEGaussianBlur_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+class SVGFEGaussianBlur : public SVGFilterEffect {
+public:
+ SVGFEGaussianBlur(SVGResourceFilter*);
+
+ float stdDeviationX() const;
+ void setStdDeviationX(float);
+
+ float stdDeviationY() const;
+ void setStdDeviationY(float);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+#endif
+
+private:
+ float m_x;
+ float m_y;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFEGaussianBlur_h
diff --git a/WebCore/svg/graphics/filters/SVGFEImage.cpp b/WebCore/svg/graphics/filters/SVGFEImage.cpp
new file mode 100644
index 0000000..d7520be
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEImage.cpp
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEImage.h"
+
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFEImage::SVGFEImage(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+ , m_cachedImage(0)
+{
+}
+
+SVGFEImage::~SVGFEImage()
+{
+ if (m_cachedImage)
+ m_cachedImage->deref(this);
+}
+
+CachedImage* SVGFEImage::cachedImage() const
+{
+ return m_cachedImage;
+}
+
+void SVGFEImage::setCachedImage(CachedImage* image)
+{
+ if (m_cachedImage == image)
+ return;
+
+ if (m_cachedImage)
+ m_cachedImage->deref(this);
+
+ m_cachedImage = image;
+
+ if (m_cachedImage)
+ m_cachedImage->ref(this);
+}
+
+TextStream& SVGFEImage::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=IMAGE] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ // FIXME: should this dump also object returned by SVGFEImage::image() ?
+ return ts;
+
+}
+
+void SVGFEImage::imageChanged(CachedImage*)
+{
+ if (SVGResourceFilter* filterResource = filter())
+ filterResource->invalidate();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEImage.h b/WebCore/svg/graphics/filters/SVGFEImage.h
new file mode 100644
index 0000000..8245d10
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEImage.h
@@ -0,0 +1,59 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEImage_h
+#define SVGFEImage_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "CachedImage.h"
+#include "CachedResourceClient.h"
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+class SVGFEImage : public SVGFilterEffect
+ , public CachedResourceClient {
+public:
+ SVGFEImage(SVGResourceFilter*);
+ virtual ~SVGFEImage();
+
+ // FIXME: We need to support <svg> (RenderObject*) as well as image data.
+
+ CachedImage* cachedImage() const;
+ void setCachedImage(CachedImage*);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+#endif
+
+ virtual void imageChanged(CachedImage*);
+
+private:
+ CachedImage* m_cachedImage;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFEImage_h
diff --git a/WebCore/svg/graphics/filters/SVGFEMerge.cpp b/WebCore/svg/graphics/filters/SVGFEMerge.cpp
new file mode 100644
index 0000000..ff92eaa
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEMerge.cpp
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEMerge.h"
+
+namespace WebCore {
+
+const Vector<String>& SVGFEMerge::mergeInputs() const
+{
+ return m_mergeInputs;
+}
+
+void SVGFEMerge::setMergeInputs(const Vector<String>& mergeInputs)
+{
+ m_mergeInputs = mergeInputs;
+}
+
+TextStream& SVGFEMerge::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=MERGE] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ ts << "[merge inputs=[";
+ unsigned x = 0;
+ unsigned size = m_mergeInputs.size();
+ while (x < size) {
+ ts << m_mergeInputs[x];
+ x++;
+ if (x < m_mergeInputs.size())
+ ts << ", ";
+ }
+ ts << "]]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEMerge.h b/WebCore/svg/graphics/filters/SVGFEMerge.h
new file mode 100644
index 0000000..9a0e867
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEMerge.h
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEMerge_h
+#define SVGFEMerge_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+class SVGFEMerge : public SVGFilterEffect {
+public:
+ SVGFEMerge(SVGResourceFilter* filter) : SVGFilterEffect(filter) { }
+
+ const Vector<String>& mergeInputs() const;
+ void setMergeInputs(const Vector<String>& mergeInputs);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+#endif
+
+private:
+ Vector<String> m_mergeInputs;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFEMerge_h
diff --git a/WebCore/svg/graphics/filters/SVGFEMorphology.cpp b/WebCore/svg/graphics/filters/SVGFEMorphology.cpp
new file mode 100644
index 0000000..06157ca
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEMorphology.cpp
@@ -0,0 +1,92 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEMorphology.h"
+
+namespace WebCore {
+
+SVGFEMorphology::SVGFEMorphology(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+ , m_operator(SVG_MORPHOLOGY_OPERATOR_UNKNOWN)
+ , m_radiusX(0.0f)
+ , m_radiusY(0.0f)
+{
+}
+
+SVGMorphologyOperatorType SVGFEMorphology::morphologyOperator() const
+{
+ return m_operator;
+}
+
+void SVGFEMorphology::setMorphologyOperator(SVGMorphologyOperatorType _operator)
+{
+ m_operator = _operator;
+}
+
+float SVGFEMorphology::radiusX() const
+{
+ return m_radiusX;
+}
+
+void SVGFEMorphology::setRadiusX(float radiusX)
+{
+ m_radiusX = radiusX;
+}
+
+float SVGFEMorphology::radiusY() const
+{
+ return m_radiusY;
+}
+
+void SVGFEMorphology::setRadiusY(float radiusY)
+{
+ m_radiusY = radiusY;
+}
+
+static TextStream& operator<<(TextStream& ts, SVGMorphologyOperatorType t)
+{
+ switch (t)
+ {
+ case SVG_MORPHOLOGY_OPERATOR_UNKNOWN:
+ ts << "UNKNOWN"; break;
+ case SVG_MORPHOLOGY_OPERATOR_ERODE:
+ ts << "ERODE"; break;
+ case SVG_MORPHOLOGY_OPERATOR_DIALATE:
+ ts << "DIALATE"; break;
+ }
+ return ts;
+}
+
+TextStream& SVGFEMorphology::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=MORPHOLOGY-OPERATOR] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ ts << " [operator type=" << morphologyOperator() << "]"
+ << " [radius x=" << radiusX() << " y=" << radiusY() << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEMorphology.h b/WebCore/svg/graphics/filters/SVGFEMorphology.h
new file mode 100644
index 0000000..4ba7131
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEMorphology.h
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEMorphology_h
+#define SVGFEMorphology_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+enum SVGMorphologyOperatorType {
+ SVG_MORPHOLOGY_OPERATOR_UNKNOWN = 0,
+ SVG_MORPHOLOGY_OPERATOR_ERODE = 1,
+ SVG_MORPHOLOGY_OPERATOR_DIALATE = 2
+};
+
+class SVGFEMorphology : public SVGFilterEffect {
+public:
+ SVGFEMorphology(SVGResourceFilter*);
+
+ SVGMorphologyOperatorType morphologyOperator() const;
+ void setMorphologyOperator(SVGMorphologyOperatorType);
+
+ float radiusX() const;
+ void setRadiusX(float);
+
+ float radiusY() const;
+ void setRadiusY(float);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+private:
+ SVGMorphologyOperatorType m_operator;
+ float m_radiusX;
+ float m_radiusY;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFEMorphology_h
diff --git a/WebCore/svg/graphics/filters/SVGFEOffset.cpp b/WebCore/svg/graphics/filters/SVGFEOffset.cpp
new file mode 100644
index 0000000..6ac0d17
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEOffset.cpp
@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEOffset.h"
+
+namespace WebCore {
+
+SVGFEOffset::SVGFEOffset(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+ , m_dx(0.0f)
+ , m_dy(0.0f)
+{
+}
+
+float SVGFEOffset::dx() const
+{
+ return m_dx;
+}
+
+void SVGFEOffset::setDx(float dx)
+{
+ m_dx = dx;
+}
+
+float SVGFEOffset::dy() const
+{
+ return m_dy;
+}
+
+void SVGFEOffset::setDy(float dy)
+{
+ m_dy = dy;
+}
+
+TextStream& SVGFEOffset::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=OFFSET] "; SVGFilterEffect::externalRepresentation(ts)
+ << " [dx=" << dx() << " dy=" << dy() << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEOffset.h b/WebCore/svg/graphics/filters/SVGFEOffset.h
new file mode 100644
index 0000000..05b427d
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEOffset.h
@@ -0,0 +1,55 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFEOffset_h
+#define SVGFEOffset_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+class SVGFEOffset : public SVGFilterEffect {
+public:
+ SVGFEOffset(SVGResourceFilter*);
+
+ float dx() const;
+ void setDx(float);
+
+ float dy() const;
+ void setDy(float);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+#endif
+
+private:
+ float m_dx;
+ float m_dy;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFEOffset_h
diff --git a/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp b/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp
new file mode 100644
index 0000000..a68c31d
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp
@@ -0,0 +1,131 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFESpecularLighting.h"
+
+namespace WebCore {
+
+SVGFESpecularLighting::SVGFESpecularLighting(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+ , m_lightingColor()
+ , m_surfaceScale(0.0f)
+ , m_specularConstant(0.0f)
+ , m_specularExponent(0.0f)
+ , m_kernelUnitLengthX(0.0f)
+ , m_kernelUnitLengthY(0.0f)
+ , m_lightSource(0)
+{
+}
+
+SVGFESpecularLighting::~SVGFESpecularLighting()
+{
+ delete m_lightSource;
+}
+
+Color SVGFESpecularLighting::lightingColor() const
+{
+ return m_lightingColor;
+}
+
+void SVGFESpecularLighting::setLightingColor(const Color& lightingColor)
+{
+ m_lightingColor = lightingColor;
+}
+
+float SVGFESpecularLighting::surfaceScale() const
+{
+ return m_surfaceScale;
+}
+
+void SVGFESpecularLighting::setSurfaceScale(float surfaceScale)
+{
+ m_surfaceScale = surfaceScale;
+}
+
+float SVGFESpecularLighting::specularConstant() const
+{
+ return m_specularConstant;
+}
+
+void SVGFESpecularLighting::setSpecularConstant(float specularConstant)
+{
+ m_specularConstant = specularConstant;
+}
+
+float SVGFESpecularLighting::specularExponent() const
+{
+ return m_specularExponent;
+}
+
+void SVGFESpecularLighting::setSpecularExponent(float specularExponent)
+{
+ m_specularExponent = specularExponent;
+}
+
+float SVGFESpecularLighting::kernelUnitLengthX() const
+{
+ return m_kernelUnitLengthX;
+}
+
+void SVGFESpecularLighting::setKernelUnitLengthX(float kernelUnitLengthX)
+{
+ m_kernelUnitLengthX = kernelUnitLengthX;
+}
+
+float SVGFESpecularLighting::kernelUnitLengthY() const
+{
+ return m_kernelUnitLengthY;
+}
+
+void SVGFESpecularLighting::setKernelUnitLengthY(float kernelUnitLengthY)
+{
+ m_kernelUnitLengthY = kernelUnitLengthY;
+}
+
+const SVGLightSource* SVGFESpecularLighting::lightSource() const
+{
+ return m_lightSource;
+}
+
+void SVGFESpecularLighting::setLightSource(SVGLightSource* lightSource)
+{
+ if (m_lightSource != lightSource) {
+ delete m_lightSource;
+ m_lightSource = lightSource;
+ }
+}
+
+TextStream& SVGFESpecularLighting::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=SPECULAR-LIGHTING] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ ts << " [surface scale=" << m_surfaceScale << "]"
+ << " [specual constant=" << m_specularConstant << "]"
+ << " [specular exponent=" << m_specularExponent << "]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFESpecularLighting.h b/WebCore/svg/graphics/filters/SVGFESpecularLighting.h
new file mode 100644
index 0000000..66e1561
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFESpecularLighting.h
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFESpecularLighting_h
+#define SVGFESpecularLighting_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "Color.h"
+#include "SVGLightSource.h"
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+class SVGFESpecularLighting : public SVGFilterEffect {
+public:
+ SVGFESpecularLighting(SVGResourceFilter*);
+ virtual ~SVGFESpecularLighting();
+
+ Color lightingColor() const;
+ void setLightingColor(const Color&);
+
+ float surfaceScale() const;
+ void setSurfaceScale(float);
+
+ float specularConstant() const;
+ void setSpecularConstant(float);
+
+ float specularExponent() const;
+ void setSpecularExponent(float);
+
+ float kernelUnitLengthX() const;
+ void setKernelUnitLengthX(float);
+
+ float kernelUnitLengthY() const;
+ void setKernelUnitLengthY(float);
+
+ const SVGLightSource* lightSource() const;
+ void setLightSource(SVGLightSource*);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+#endif
+
+private:
+ Color m_lightingColor;
+ float m_surfaceScale;
+ float m_specularConstant;
+ float m_specularExponent;
+ float m_kernelUnitLengthX;
+ float m_kernelUnitLengthY;
+ SVGLightSource* m_lightSource;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFESpecularLighting_h
diff --git a/WebCore/svg/graphics/filters/SVGFETile.h b/WebCore/svg/graphics/filters/SVGFETile.h
new file mode 100644
index 0000000..1c3922f
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFETile.h
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFETile_h
+#define SVGFETile_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+class SVGFETile : public SVGFilterEffect
+{
+public:
+ SVGFETile(SVGResourceFilter* filter) : SVGFilterEffect(filter) { }
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+#endif
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFETile_h
diff --git a/WebCore/svg/graphics/filters/SVGFETurbulence.cpp b/WebCore/svg/graphics/filters/SVGFETurbulence.cpp
new file mode 100644
index 0000000..9432a0a
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFETurbulence.cpp
@@ -0,0 +1,129 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFETurbulence.h"
+
+namespace WebCore {
+
+SVGFETurbulence::SVGFETurbulence(SVGResourceFilter* filter)
+ : SVGFilterEffect(filter)
+ , m_baseFrequencyX(0.0f)
+ , m_baseFrequencyY(0.0f)
+ , m_numOctaves(0)
+ , m_seed(0)
+ , m_stitchTiles(false)
+ , m_type(SVG_TURBULENCE_TYPE_UNKNOWN)
+{
+}
+
+SVGTurbulanceType SVGFETurbulence::type() const
+{
+ return m_type;
+}
+
+void SVGFETurbulence::setType(SVGTurbulanceType type)
+{
+ m_type = type;
+}
+
+float SVGFETurbulence::baseFrequencyY() const
+{
+ return m_baseFrequencyY;
+}
+
+void SVGFETurbulence::setBaseFrequencyY(float baseFrequencyY)
+{
+ m_baseFrequencyY = baseFrequencyY;
+}
+
+float SVGFETurbulence::baseFrequencyX() const
+{
+ return m_baseFrequencyX;
+}
+
+void SVGFETurbulence::setBaseFrequencyX(float baseFrequencyX)
+{
+ m_baseFrequencyX = baseFrequencyX;
+}
+
+float SVGFETurbulence::seed() const
+{
+ return m_seed;
+}
+
+void SVGFETurbulence::setSeed(float seed)
+{
+ m_seed = seed;
+}
+
+int SVGFETurbulence::numOctaves() const
+{
+ return m_numOctaves;
+}
+
+void SVGFETurbulence::setNumOctaves(bool numOctaves)
+{
+ m_numOctaves = numOctaves;
+}
+
+bool SVGFETurbulence::stitchTiles() const
+{
+ return m_stitchTiles;
+}
+
+void SVGFETurbulence::setStitchTiles(bool stitch)
+{
+ m_stitchTiles = stitch;
+}
+
+static TextStream& operator<<(TextStream& ts, SVGTurbulanceType t)
+{
+ switch (t)
+ {
+ case SVG_TURBULENCE_TYPE_UNKNOWN:
+ ts << "UNKNOWN"; break;
+ case SVG_TURBULENCE_TYPE_TURBULENCE:
+ ts << "TURBULANCE"; break;
+ case SVG_TURBULENCE_TYPE_FRACTALNOISE:
+ ts << "NOISE"; break;
+ }
+ return ts;
+}
+
+TextStream& SVGFETurbulence::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=TURBULENCE] ";
+ SVGFilterEffect::externalRepresentation(ts);
+ ts << " [turbulence type=" << type() << "]"
+ << " [base frequency x=" << baseFrequencyX() << " y=" << baseFrequencyY() << "]"
+ << " [seed=" << seed() << "]"
+ << " [num octaves=" << numOctaves() << "]"
+ << " [stitch tiles=" << stitchTiles() << "]";
+ return ts;
+
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFETurbulence.h b/WebCore/svg/graphics/filters/SVGFETurbulence.h
new file mode 100644
index 0000000..b871416
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFETurbulence.h
@@ -0,0 +1,73 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFETurbulence_h
+#define SVGFETurbulence_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+enum SVGTurbulanceType {
+ SVG_TURBULENCE_TYPE_UNKNOWN = 0,
+ SVG_TURBULENCE_TYPE_FRACTALNOISE = 1,
+ SVG_TURBULENCE_TYPE_TURBULENCE = 2
+};
+
+class SVGFETurbulence : public SVGFilterEffect {
+public:
+ SVGFETurbulence(SVGResourceFilter*);
+
+ SVGTurbulanceType type() const;
+ void setType(SVGTurbulanceType);
+
+ float baseFrequencyY() const;
+ void setBaseFrequencyY(float);
+
+ float baseFrequencyX() const;
+ void setBaseFrequencyX(float);
+
+ float seed() const;
+ void setSeed(float);
+
+ int numOctaves() const;
+ void setNumOctaves(bool);
+
+ bool stitchTiles() const;
+ void setStitchTiles(bool);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+private:
+ float m_baseFrequencyX;
+ float m_baseFrequencyY;
+ int m_numOctaves;
+ float m_seed;
+ bool m_stitchTiles;
+ SVGTurbulanceType m_type;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFETurbulence_h
diff --git a/WebCore/svg/graphics/filters/SVGFilterEffect.cpp b/WebCore/svg/graphics/filters/SVGFilterEffect.cpp
new file mode 100644
index 0000000..f8e246f
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFilterEffect.cpp
@@ -0,0 +1,133 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFilterEffect.h"
+
+#include "SVGRenderTreeAsText.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGFilterEffect::SVGFilterEffect(SVGResourceFilter* filter)
+ : m_filter(filter)
+ , m_xBBoxMode(false)
+ , m_yBBoxMode(false)
+ , m_widthBBoxMode(false)
+ , m_heightBBoxMode(false)
+{
+}
+
+FloatRect SVGFilterEffect::primitiveBBoxForFilterBBox(const FloatRect& filterBBox, const FloatRect& itemBBox) const
+{
+ FloatRect subRegionBBox = subRegion();
+ FloatRect useBBox = filterBBox;
+
+ ASSERT(m_filter);
+ if (!m_filter)
+ return FloatRect();
+
+ if (m_filter->effectBoundingBoxMode()) {
+ if (!m_filter->filterBoundingBoxMode())
+ useBBox = itemBBox;
+
+ subRegionBBox = FloatRect(useBBox.x() + subRegionBBox.x() * useBBox.width(),
+ useBBox.y() + subRegionBBox.y() * useBBox.height(),
+ subRegionBBox.width() * useBBox.width(),
+ subRegionBBox.height() * useBBox.height());
+ } else {
+ if (xBoundingBoxMode())
+ subRegionBBox.setX(useBBox.x() + subRegionBBox.x() * useBBox.width());
+
+ if (yBoundingBoxMode())
+ subRegionBBox.setY(useBBox.y() + subRegionBBox.y() * useBBox.height());
+
+ if (widthBoundingBoxMode())
+ subRegionBBox.setWidth(subRegionBBox.width() * useBBox.width());
+
+ if (heightBoundingBoxMode())
+ subRegionBBox.setHeight(subRegionBBox.height() * useBBox.height());
+ }
+
+ return subRegionBBox;
+}
+
+FloatRect SVGFilterEffect::subRegion() const
+{
+ return m_subRegion;
+}
+
+void SVGFilterEffect::setSubRegion(const FloatRect& subRegion)
+{
+ m_subRegion = subRegion;
+}
+
+String SVGFilterEffect::in() const
+{
+ return m_in;
+}
+
+void SVGFilterEffect::setIn(const String& in)
+{
+ m_in = in;
+}
+
+String SVGFilterEffect::result() const
+{
+ return m_result;
+}
+
+void SVGFilterEffect::setResult(const String& result)
+{
+ m_result = result;
+}
+
+SVGResourceFilter* SVGFilterEffect::filter() const
+{
+ return m_filter;
+}
+
+void SVGFilterEffect::setFilter(SVGResourceFilter* filter)
+{
+ m_filter = filter;
+}
+
+TextStream& SVGFilterEffect::externalRepresentation(TextStream& ts) const
+{
+ if (!in().isEmpty())
+ ts << "[in=\"" << in() << "\"]";
+ if (!result().isEmpty())
+ ts << " [result=\"" << result() << "\"]";
+ if (!subRegion().isEmpty())
+ ts << " [subregion=\"" << subRegion() << "\"]";
+ return ts;
+}
+
+TextStream& operator<<(TextStream& ts, const SVGFilterEffect& e)
+{
+ return e.externalRepresentation(ts);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFilterEffect.h b/WebCore/svg/graphics/filters/SVGFilterEffect.h
new file mode 100644
index 0000000..f7128fc
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFilterEffect.h
@@ -0,0 +1,99 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGFilterEffect_h
+#define SVGFilterEffect_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "FloatRect.h"
+#include "PlatformString.h"
+
+#if PLATFORM(CI)
+#ifdef __OBJC__
+@class CIFilter;
+#else
+class CIFilter;
+#endif
+#endif
+
+namespace WebCore {
+
+class SVGResourceFilter;
+class TextStream;
+
+class SVGFilterEffect {
+public:
+ SVGFilterEffect(SVGResourceFilter*);
+ virtual ~SVGFilterEffect() { }
+
+ bool xBoundingBoxMode() const { return m_xBBoxMode; }
+ void setXBoundingBoxMode(bool bboxMode) { m_xBBoxMode = bboxMode; }
+
+ bool yBoundingBoxMode() const { return m_yBBoxMode; }
+ void setYBoundingBoxMode(bool bboxMode) { m_yBBoxMode = bboxMode; }
+
+ bool widthBoundingBoxMode() const { return m_widthBBoxMode; }
+ void setWidthBoundingBoxMode(bool bboxMode) { m_widthBBoxMode = bboxMode; }
+
+ bool heightBoundingBoxMode() const { return m_heightBBoxMode; }
+ void setHeightBoundingBoxMode(bool bboxMode) { m_heightBBoxMode = bboxMode; }
+
+ FloatRect primitiveBBoxForFilterBBox(const FloatRect& filterBBox, const FloatRect& itemBBox) const;
+
+ FloatRect subRegion() const;
+ void setSubRegion(const FloatRect&);
+
+ String in() const;
+ void setIn(const String&);
+
+ String result() const;
+ void setResult(const String&);
+
+ SVGResourceFilter* filter() const;
+ void setFilter(SVGResourceFilter*);
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+#if PLATFORM(CI)
+ virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
+#endif
+
+private:
+ SVGResourceFilter* m_filter;
+
+ bool m_xBBoxMode : 1;
+ bool m_yBBoxMode : 1;
+ bool m_widthBBoxMode : 1;
+ bool m_heightBBoxMode : 1;
+
+ FloatRect m_subRegion;
+
+ String m_in;
+ String m_result;
+};
+
+TextStream& operator<<(TextStream&, const SVGFilterEffect&);
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFilterEffect_h
diff --git a/WebCore/svg/graphics/filters/SVGLightSource.cpp b/WebCore/svg/graphics/filters/SVGLightSource.cpp
new file mode 100644
index 0000000..517ed50
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGLightSource.cpp
@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGPointLightSource.h"
+#include "SVGRenderTreeAsText.h"
+#include "SVGSpotLightSource.h"
+#include "SVGDistantLightSource.h"
+
+namespace WebCore {
+
+static TextStream& operator<<(TextStream& ts, const FloatPoint3D& p)
+{
+ ts << "x=" << p.x() << " y=" << p.y() << " z=" << p.z();
+ return ts;
+}
+
+TextStream& SVGPointLightSource::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=POINT-LIGHT] ";
+ ts << "[position=\"" << position() << "\"]";
+ return ts;
+}
+
+TextStream& SVGSpotLightSource::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=SPOT-LIGHT] ";
+ ts << "[position=\"" << position() << "\"]";
+ ts << "[direction=\"" << direction() << "\"]";
+ ts << "[specularExponent=\"" << specularExponent() << "\"]";
+ ts << "[limitingConeAngle=\"" << limitingConeAngle() << "\"]";
+ return ts;
+}
+
+TextStream& SVGDistantLightSource::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=DISTANT-LIGHT] ";
+ ts << "[azimuth=\"" << azimuth() << "\"]";
+ ts << "[elevation=\"" << elevation() << "\"]";
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGLightSource.h b/WebCore/svg/graphics/filters/SVGLightSource.h
new file mode 100644
index 0000000..12cf3d0
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGLightSource.h
@@ -0,0 +1,57 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGLightSource_h
+#define SVGLightSource_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+namespace WebCore {
+
+enum SVGLightType {
+ LS_DISTANT,
+ LS_POINT,
+ LS_SPOT
+};
+
+class TextStream;
+
+class SVGLightSource {
+public:
+ SVGLightSource(SVGLightType type)
+ : m_type(type)
+ { }
+
+ virtual ~SVGLightSource() { }
+
+ SVGLightType type() const { return m_type; }
+ virtual TextStream& externalRepresentation(TextStream&) const = 0;
+
+private:
+ SVGLightType m_type;
+};
+
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGLightSource_h
diff --git a/WebCore/svg/graphics/filters/SVGPointLightSource.h b/WebCore/svg/graphics/filters/SVGPointLightSource.h
new file mode 100644
index 0000000..71b8f70
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGPointLightSource.h
@@ -0,0 +1,50 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGPointLightSource_h
+#define SVGPointLightSource_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "FloatPoint3D.h"
+#include "SVGLightSource.h"
+
+namespace WebCore {
+
+class SVGPointLightSource : public SVGLightSource {
+public:
+ SVGPointLightSource(const FloatPoint3D& position)
+ : SVGLightSource(LS_POINT)
+ , m_position(position)
+ { }
+
+ const FloatPoint3D& position() const { return m_position; }
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+private:
+ FloatPoint3D m_position;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGPointLightSource_h
diff --git a/WebCore/svg/graphics/filters/SVGSpotLightSource.h b/WebCore/svg/graphics/filters/SVGSpotLightSource.h
new file mode 100644
index 0000000..850a5fa
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGSpotLightSource.h
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric@webkit.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SVGSpotLightSource_h
+#define SVGSpotLightSource_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "FloatPoint3D.h"
+#include "SVGLightSource.h"
+
+namespace WebCore {
+
+class SVGSpotLightSource : public SVGLightSource {
+public:
+ SVGSpotLightSource(const FloatPoint3D& position, const FloatPoint3D& direction, float specularExponent, float limitingConeAngle)
+ : SVGLightSource(LS_SPOT)
+ , m_position(position)
+ , m_direction(direction)
+ , m_specularExponent(specularExponent)
+ , m_limitingConeAngle(limitingConeAngle)
+ { }
+
+ const FloatPoint3D& position() const { return m_position; }
+ const FloatPoint3D& direction() const { return m_direction; }
+
+ float specularExponent() const { return m_specularExponent; }
+ float limitingConeAngle() const { return m_limitingConeAngle; }
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+
+private:
+ FloatPoint3D m_position;
+ FloatPoint3D m_direction;
+
+ float m_specularExponent;
+ float m_limitingConeAngle;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGSpotLightSource_h
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEBlendCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEBlendCg.mm
new file mode 100644
index 0000000..29caaa0
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFEBlendCg.mm
@@ -0,0 +1,77 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEBlend.h"
+#include "SVGFEHelpersCg.h"
+
+namespace WebCore {
+
+CIFilter* SVGFEBlend::getCIFilter(const FloatRect& bbox) const
+{
+ SVGResourceFilter* svgFilter = filter();
+ SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
+ CIFilter* filter = nil;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
+ switch (blendMode()) {
+ case SVG_FEBLEND_MODE_UNKNOWN:
+ return nil;
+ case SVG_FEBLEND_MODE_NORMAL:
+ // FIXME: I think this is correct....
+ filter = [CIFilter filterWithName:@"CISourceOverCompositing"];
+ break;
+ case SVG_FEBLEND_MODE_MULTIPLY:
+ filter = [CIFilter filterWithName:@"CIMultiplyBlendMode"];
+ break;
+ case SVG_FEBLEND_MODE_SCREEN:
+ filter = [CIFilter filterWithName:@"CIScreenBlendMode"];
+ break;
+ case SVG_FEBLEND_MODE_DARKEN:
+ filter = [CIFilter filterWithName:@"CIDarkenBlendMode"];
+ break;
+ case SVG_FEBLEND_MODE_LIGHTEN:
+ filter = [CIFilter filterWithName:@"CILightenBlendMode"];
+ break;
+ default:
+ LOG_ERROR("Unhandled blend mode: %i", blendMode());
+ return nil;
+ }
+
+ [filter setDefaults];
+
+ CIImage* inputImage = filterPlatformData->inputImage(this);
+ FE_QUARTZ_CHECK_INPUT(inputImage);
+ [filter setValue:inputImage forKey:@"inputImage"];
+
+ CIImage* backgroundImage = filterPlatformData->imageForName(in2());
+ FE_QUARTZ_CHECK_INPUT(backgroundImage);
+ [filter setValue:backgroundImage forKey:@"inputBackgroundImage"];
+
+ FE_QUARTZ_MAP_TO_SUBREGION(bbox);
+ FE_QUARTZ_OUTPUT_RETURN;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEColorMatrixCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEColorMatrixCg.mm
new file mode 100644
index 0000000..ae6e4aa
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFEColorMatrixCg.mm
@@ -0,0 +1,111 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEColorMatrix.h"
+#include "SVGFEHelpersCg.h"
+
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+#define CMValuesCheck(expected, type) \
+ if (values().size() != expected) { \
+ NSLog(@"Error, incorrect number of values in ColorMatrix for type \"%s\", expected: %i actual: %i, ignoring filter. Values:", type, expected, values().size()); \
+ for (unsigned x=0; x < values().size(); x++) fprintf(stderr, " %f", values()[x]); \
+ fprintf(stderr, "\n"); \
+ return nil; \
+ }
+
+CIFilter* SVGFEColorMatrix::getCIFilter(const FloatRect& bbox) const
+{
+ SVGResourceFilter* svgFilter = filter();
+ SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
+ CIFilter* filter = nil;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ switch (type()) {
+ case SVG_FECOLORMATRIX_TYPE_UNKNOWN:
+ return nil;
+ case SVG_FECOLORMATRIX_TYPE_MATRIX:
+ {
+ CMValuesCheck(20, "matrix");
+ filter = [CIFilter filterWithName:@"CIColorMatrix"];
+ [filter setDefaults];
+ const Vector<float>& v = values();
+ [filter setValue:[CIVector vectorWithX:v[0] Y:v[1] Z:v[2] W:v[3]] forKey:@"inputRVector"];
+ [filter setValue:[CIVector vectorWithX:v[5] Y:v[6] Z:v[7] W:v[8]] forKey:@"inputGVector"];
+ [filter setValue:[CIVector vectorWithX:v[10] Y:v[11] Z:v[12] W:v[13]] forKey:@"inputBVector"];
+ [filter setValue:[CIVector vectorWithX:v[15] Y:v[16] Z:v[17] W:v[18]] forKey:@"inputAVector"];
+ [filter setValue:[CIVector vectorWithX:v[4] Y:v[9] Z:v[14] W:v[19]] forKey:@"inputBiasVector"];
+ break;
+ }
+ case SVG_FECOLORMATRIX_TYPE_SATURATE:
+ {
+ CMValuesCheck(1, "saturate");
+ filter = [CIFilter filterWithName:@"CIColorControls"];
+ [filter setDefaults];
+ float saturation = values()[0];
+ if ((saturation < 0.0) || (saturation > 3.0))
+ NSLog(@"WARNING: Saturation adjustment: %f outside supported range.");
+ [filter setValue:[NSNumber numberWithFloat:saturation] forKey:@"inputSaturation"];
+ break;
+ }
+ case SVG_FECOLORMATRIX_TYPE_HUEROTATE:
+ {
+ CMValuesCheck(1, "hueRotate");
+ filter = [CIFilter filterWithName:@"CIHueAdjust"];
+ [filter setDefaults];
+ float radians = deg2rad(values()[0]);
+ [filter setValue:[NSNumber numberWithFloat:radians] forKey:@"inputAngle"];
+ break;
+ }
+ case SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
+ {
+ CMValuesCheck(0, "luminanceToAlpha");
+ // FIXME: I bet there is an easy filter to do this.
+ filter = [CIFilter filterWithName:@"CIColorMatrix"];
+ [filter setDefaults];
+ CGFloat zero[4] = {0, 0, 0, 0};
+ CGFloat alpha[4] = {0.2125f, 0.7154f, 0.0721f, 0};
+ [filter setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputRVector"];
+ [filter setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputGVector"];
+ [filter setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBVector"];
+ [filter setValue:[CIVector vectorWithValues:alpha count:4] forKey:@"inputAVector"];
+ [filter setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBiasVector"];
+ break;
+ }
+ default:
+ LOG_ERROR("Unhandled ColorMatrix type: %i", type());
+ return nil;
+ }
+ CIImage *inputImage = filterPlatformData->inputImage(this);
+ FE_QUARTZ_CHECK_INPUT(inputImage);
+ [filter setValue:inputImage forKey:@"inputImage"];
+
+ FE_QUARTZ_MAP_TO_SUBREGION(bbox);
+ FE_QUARTZ_OUTPUT_RETURN;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEComponentTransferCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEComponentTransferCg.mm
new file mode 100644
index 0000000..61515db
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFEComponentTransferCg.mm
@@ -0,0 +1,167 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEComponentTransfer.h"
+#include "SVGFEHelpersCg.h"
+
+#import "WKComponentMergeFilter.h"
+#import "WKIdentityTransferFilter.h"
+#import "WKTableTransferFilter.h"
+#import "WKDiscreteTransferFilter.h"
+#import "WKLinearTransferFilter.h"
+#import "WKGammaTransferFilter.h"
+
+namespace WebCore {
+
+static CIImage* genImageFromTable(const Vector<float>& table)
+{
+ int length = table.size();
+ int nBytes = length * 4 * sizeof(float);
+ float* tableStore = (float *) malloc(nBytes);
+ NSData* bitmapData = [NSData dataWithBytesNoCopy:tableStore length:nBytes];
+ for (Vector<float>::const_iterator it = table.begin(); it != table.end(); it++) {
+ const float value = *it;
+ *tableStore++ = value;
+ *tableStore++ = value;
+ *tableStore++ = value;
+ *tableStore++ = value;
+ }
+ return [CIImage imageWithBitmapData:bitmapData bytesPerRow:nBytes size:CGSizeMake(length, 1) format:kCIFormatRGBAf colorSpace:nil];
+}
+
+static void setParametersForComponentFunc(CIFilter* filter, const SVGComponentTransferFunction& func, CIVector* channelSelector)
+{
+ switch (func.type) {
+ case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
+ return;
+ case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
+ [filter setValue:genImageFromTable(func.tableValues) forKey:@"inputTable"];
+ [filter setValue:channelSelector forKey:@"inputSelector"];
+ break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
+ [filter setValue:genImageFromTable(func.tableValues) forKey:@"inputTable"];
+ [filter setValue:channelSelector forKey:@"inputSelector"];
+ break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
+ [filter setValue:[NSNumber numberWithFloat:func.slope] forKey:@"inputSlope"];
+ [filter setValue:[NSNumber numberWithFloat:func.intercept] forKey:@"inputIntercept"];
+ break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
+ [filter setValue:[NSNumber numberWithFloat:func.amplitude] forKey:@"inputAmplitude"];
+ [filter setValue:[NSNumber numberWithFloat:func.exponent] forKey:@"inputExponent"];
+ [filter setValue:[NSNumber numberWithFloat:func.offset] forKey:@"inputOffset"];
+ break;
+ default:
+ // identity has no args
+ break;
+ }
+}
+
+static CIFilter* filterForComponentFunc(const SVGComponentTransferFunction& func)
+{
+ CIFilter *filter;
+ switch (func.type) {
+ case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
+ case SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY:
+ filter = [CIFilter filterWithName:@"WKIdentityTransfer"];
+ break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
+ filter = [CIFilter filterWithName:@"WKTableTransferFilter"];
+ break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
+ filter = [CIFilter filterWithName:@"WKDiscreteTransferFilter"];
+ break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
+ filter = [CIFilter filterWithName:@"WKLinearTransfer"];
+ break;
+ case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
+ filter = [CIFilter filterWithName:@"WKGammaTransfer"];
+ break;
+ default:
+ NSLog(@"WARNING: Unknown function type for feComponentTransfer");
+ //and to prevent the entire svg from failing as a result
+ filter = [CIFilter filterWithName:@"WKIdentityTransfer"];
+ break;
+ }
+ return filter;
+}
+
+static CIFilter* getFilterForFunc(const SVGComponentTransferFunction& func, CIImage* inputImage, CIVector* channelSelector)
+{
+ CIFilter* filter = filterForComponentFunc(func);
+ [filter setDefaults];
+
+ setParametersForComponentFunc(filter, func, channelSelector);
+ [filter setValue:inputImage forKey:@"inputImage"];
+ return filter;
+}
+
+CIFilter* SVGFEComponentTransfer::getFunctionFilter(SVGChannelSelectorType channel, CIImage* inputImage) const
+{
+ switch (channel) {
+ case SVG_CHANNEL_R:
+ return [getFilterForFunc(redFunction(), inputImage, getVectorForChannel(channel)) valueForKey:@"outputImage"];
+ case SVG_CHANNEL_G:
+ return [getFilterForFunc(greenFunction(), inputImage, getVectorForChannel(channel)) valueForKey:@"outputImage"];
+ case SVG_CHANNEL_B:
+ return [getFilterForFunc(blueFunction(), inputImage, getVectorForChannel(channel)) valueForKey:@"outputImage"];
+ case SVG_CHANNEL_A:
+ return [getFilterForFunc(alphaFunction(), inputImage, getVectorForChannel(channel)) valueForKey:@"outputImage"];
+ default:
+ return nil;
+ }
+}
+
+CIFilter* SVGFEComponentTransfer::getCIFilter(const FloatRect& bbox) const
+{
+ [WKComponentMergeFilter class];
+ [WKIdentityTransferFilter class];
+ [WKTableTransferFilter class];
+ [WKDiscreteTransferFilter class];
+ [WKLinearTransferFilter class];
+ [WKGammaTransferFilter class];
+
+ SVGResourceFilter* svgFilter = filter();
+ SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
+ CIFilter* filter = nil;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ filter = [CIFilter filterWithName:@"WKComponentMerge"];
+ if (!filter)
+ return nil;
+ [filter setDefaults];
+ CIImage* inputImage = filterPlatformData->inputImage(this);
+ FE_QUARTZ_CHECK_INPUT(inputImage);
+
+ [filter setValue:getFunctionFilter(SVG_CHANNEL_R, inputImage) forKey:@"inputFuncR"];
+ [filter setValue:getFunctionFilter(SVG_CHANNEL_G, inputImage) forKey:@"inputFuncG"];
+ [filter setValue:getFunctionFilter(SVG_CHANNEL_B, inputImage) forKey:@"inputFuncB"];
+ [filter setValue:getFunctionFilter(SVG_CHANNEL_A, inputImage) forKey:@"inputFuncA"];
+
+ FE_QUARTZ_MAP_TO_SUBREGION(bbox);
+ FE_QUARTZ_OUTPUT_RETURN;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFECompositeCg.mm b/WebCore/svg/graphics/filters/cg/SVGFECompositeCg.mm
new file mode 100644
index 0000000..624612c
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFECompositeCg.mm
@@ -0,0 +1,85 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEComposite.h"
+#include "SVGFEHelpersCg.h"
+
+#import "WKArithmeticFilter.h"
+
+namespace WebCore {
+
+CIFilter* SVGFEComposite::getCIFilter(const FloatRect& bbox) const
+{
+ SVGResourceFilter* svgFilter = filter();
+ SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
+ CIFilter* filter = nil;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
+ switch (operation()) {
+ case SVG_FECOMPOSITE_OPERATOR_UNKNOWN:
+ return nil;
+ case SVG_FECOMPOSITE_OPERATOR_OVER:
+ filter = [CIFilter filterWithName:@"CISourceOverCompositing"];
+ break;
+ case SVG_FECOMPOSITE_OPERATOR_IN:
+ filter = [CIFilter filterWithName:@"CISourceInCompositing"];
+ break;
+ case SVG_FECOMPOSITE_OPERATOR_OUT:
+ filter = [CIFilter filterWithName:@"CISourceOutCompositing"];
+ break;
+ case SVG_FECOMPOSITE_OPERATOR_ATOP:
+ filter = [CIFilter filterWithName:@"CISourceAtopCompositing"];
+ break;
+ case SVG_FECOMPOSITE_OPERATOR_XOR:
+ //FIXME: I'm not sure this is right...
+ filter = [CIFilter filterWithName:@"CIExclusionBlendMode"];
+ break;
+ case SVG_FECOMPOSITE_OPERATOR_ARITHMETIC:
+ [WKArithmeticFilter class];
+ filter = [CIFilter filterWithName:@"WKArithmeticFilter"];
+ break;
+ }
+
+ [filter setDefaults];
+ CIImage* inputImage = filterPlatformData->inputImage(this);
+ CIImage* backgroundImage = filterPlatformData->imageForName(in2());
+ FE_QUARTZ_CHECK_INPUT(inputImage);
+ FE_QUARTZ_CHECK_INPUT(backgroundImage);
+ [filter setValue:inputImage forKey:@"inputImage"];
+ [filter setValue:backgroundImage forKey:@"inputBackgroundImage"];
+ //FIXME: this seems ugly
+ if (operation() == SVG_FECOMPOSITE_OPERATOR_ARITHMETIC) {
+ [filter setValue:[NSNumber numberWithFloat:k1()] forKey:@"inputK1"];
+ [filter setValue:[NSNumber numberWithFloat:k2()] forKey:@"inputK2"];
+ [filter setValue:[NSNumber numberWithFloat:k3()] forKey:@"inputK3"];
+ [filter setValue:[NSNumber numberWithFloat:k4()] forKey:@"inputK4"];
+ }
+
+ FE_QUARTZ_MAP_TO_SUBREGION(bbox);
+ FE_QUARTZ_OUTPUT_RETURN;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEDiffuseLightingCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEDiffuseLightingCg.mm
new file mode 100644
index 0000000..981b88b
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFEDiffuseLightingCg.mm
@@ -0,0 +1,74 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEDiffuseLighting.h"
+#include "SVGFEHelpersCg.h"
+
+#import "WKDiffuseLightingFilter.h"
+
+namespace WebCore {
+
+CIFilter* SVGFEDiffuseLighting::getCIFilter(const FloatRect& bbox) const
+{
+ const SVGLightSource* light = lightSource();
+ if (!light)
+ return nil;
+
+ [WKDiffuseLightingFilter class];
+
+ SVGResourceFilter* svgFilter = filter();
+ SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
+
+ CIFilter* filter;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ filter = [CIFilter filterWithName:@"WKDiffuseLighting"];
+ if (!filter)
+ return nil;
+
+ [filter setDefaults];
+ CIImage* inputImage = filterPlatformData->inputImage(this);
+ FE_QUARTZ_CHECK_INPUT(inputImage);
+ CIFilter* normals = getNormalMap(inputImage, surfaceScale());
+ if (!normals)
+ return nil;
+
+ CIFilter* lightVectors = getLightVectors(normals, light, surfaceScale());
+ if (!lightVectors)
+ return nil;
+
+ [filter setValue:[normals valueForKey:@"outputImage"] forKey:@"inputNormalMap"];
+ [filter setValue:[lightVectors valueForKey:@"outputImage"] forKey:@"inputLightVectors"];
+ [filter setValue:ciColor(lightingColor()) forKey:@"inputLightingColor"];
+ [filter setValue:[NSNumber numberWithFloat:surfaceScale()] forKey:@"inputSurfaceScale"];
+ [filter setValue:[NSNumber numberWithFloat:diffuseConstant()] forKey:@"inputDiffuseConstant"];
+ [filter setValue:[NSNumber numberWithFloat:kernelUnitLengthX()] forKey:@"inputKernelUnitLengthX"];
+ [filter setValue:[NSNumber numberWithFloat:kernelUnitLengthY()] forKey:@"inputKernelUnitLengthY"];
+
+ FE_QUARTZ_MAP_TO_SUBREGION(bbox);
+ FE_QUARTZ_OUTPUT_RETURN;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEDisplacementMapCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEDisplacementMapCg.mm
new file mode 100644
index 0000000..9d482e2
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFEDisplacementMapCg.mm
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEDisplacementMap.h"
+#include "SVGFEHelpersCg.h"
+
+#import "WKDisplacementMapFilter.h"
+
+namespace WebCore {
+
+CIFilter* SVGFEDisplacementMap::getCIFilter(const FloatRect& bbox) const
+{
+ SVGResourceFilter* svgFilter = filter();
+ SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
+
+ CIFilter* filter = nil;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ [WKDisplacementMapFilter class];
+ filter = [CIFilter filterWithName:@"WKDisplacementMapFilter"];
+ [filter setDefaults];
+ CIImage* inputImage = filterPlatformData->inputImage(this);
+ CIImage* displacementMap = filterPlatformData->imageForName(in2());
+ FE_QUARTZ_CHECK_INPUT(inputImage);
+ FE_QUARTZ_CHECK_INPUT(displacementMap);
+ [filter setValue:inputImage forKey:@"inputImage"];
+ [filter setValue:displacementMap forKey:@"inputDisplacementMap"];
+ [filter setValue:getVectorForChannel(xChannelSelector()) forKey:@"inputXChannelSelector"];
+ [filter setValue:getVectorForChannel(yChannelSelector()) forKey:@"inputYChannelSelector"];
+ [filter setValue:[NSNumber numberWithFloat:scale()] forKey:@"inputScale"];
+
+ FE_QUARTZ_MAP_TO_SUBREGION(bbox);
+ FE_QUARTZ_OUTPUT_RETURN;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEFloodCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEFloodCg.mm
new file mode 100644
index 0000000..db46f5b
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFEFloodCg.mm
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEFlood.h"
+
+#include "AffineTransform.h"
+#include "SVGFEHelpersCg.h"
+#include "CgSupport.h"
+
+namespace WebCore {
+
+CIFilter* SVGFEFlood::getCIFilter(const FloatRect& bbox) const
+{
+ SVGResourceFilter* svgFilter = filter();
+ SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
+ CIFilter* filter;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ filter = [CIFilter filterWithName:@"CIConstantColorGenerator"];
+ [filter setDefaults];
+ CGColorRef color = cgColor(floodColor());
+ CGColorRef withAlpha = CGColorCreateCopyWithAlpha(color, CGColorGetAlpha(color) * floodOpacity());
+ CIColor* inputColor = [CIColor colorWithCGColor:withAlpha];
+ CGColorRelease(color);
+ CGColorRelease(withAlpha);
+ [filter setValue:inputColor forKey:@"inputColor"];
+
+ FE_QUARTZ_MAP_TO_SUBREGION(bbox);
+ FE_QUARTZ_OUTPUT_RETURN;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEGaussianBlurCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEGaussianBlurCg.mm
new file mode 100644
index 0000000..13140b6
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFEGaussianBlurCg.mm
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEGaussianBlur.h"
+#include "SVGFEHelpersCg.h"
+
+namespace WebCore {
+
+CIFilter* SVGFEGaussianBlur::getCIFilter(const FloatRect& bbox) const
+{
+ SVGResourceFilter* svgFilter = filter();
+ FE_QUARTZ_SETUP_INPUT(@"CIGaussianPyramid");
+
+ float inputRadius = stdDeviationX();
+ if (inputRadius != stdDeviationY()) {
+ float inputAspectRatio = stdDeviationX()/stdDeviationY();
+ // FIXME: inputAspectRatio only support the range .5 to 2.0!
+ [filter setValue:[NSNumber numberWithFloat:inputAspectRatio] forKey:@"inputAspectRatio"];
+ }
+ [filter setValue:[NSNumber numberWithFloat:inputRadius] forKey:@"inputRadius"];
+
+ FE_QUARTZ_MAP_TO_SUBREGION(bbox);
+ FE_QUARTZ_OUTPUT_RETURN;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.h b/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.h
new file mode 100644
index 0000000..176abb5
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.h
@@ -0,0 +1,88 @@
+/*
+ Copyright (C) 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#include "BlockExceptions.h"
+#include "SVGFEDisplacementMap.h"
+#include "SVGResourceFilter.h"
+#include "SVGResourceFilterPlatformDataMac.h"
+#include <QuartzCore/CoreImage.h>
+#include <wtf/MathExtras.h>
+
+class Color;
+class SVGLightSource;
+
+namespace WebCore {
+
+CIVector* getVectorForChannel(SVGChannelSelectorType channel);
+CIColor* ciColor(const Color& c);
+
+// Lighting
+CIFilter* getPointLightVectors(CIFilter* normals, CIVector* lightPosition, float surfaceScale);
+CIFilter* getLightVectors(CIFilter* normals, const SVGLightSource* light, float surfaceScale);
+CIFilter* getNormalMap(CIImage* bumpMap, float scale);
+
+};
+
+// Macros used by the SVGFE*Cg classes
+#define FE_QUARTZ_SETUP_INPUT(name) \
+ SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData()); \
+ CIImage* inputImage = filterPlatformData->inputImage(this); \
+ FE_QUARTZ_CHECK_INPUT(inputImage) \
+ CIFilter* filter; \
+ BEGIN_BLOCK_OBJC_EXCEPTIONS; \
+ filter = [CIFilter filterWithName:name]; \
+ [filter setDefaults]; \
+ [filter setValue:inputImage forKey:@"inputImage"];
+
+#define FE_QUARTZ_CHECK_INPUT(input) \
+ if (!input) \
+ return nil;
+
+#define FE_QUARTZ_OUTPUT_RETURN \
+ filterPlatformData->setOutputImage(this, [filter valueForKey:@"outputImage"]); \
+ return filter; \
+ END_BLOCK_OBJC_EXCEPTIONS; \
+ return nil;
+
+#define FE_QUARTZ_MAP_TO_SUBREGION_PREPARE(bbox) \
+ FloatRect filterRect = svgFilter->filterBBoxForItemBBox(bbox); \
+ FloatRect cropRect = primitiveBBoxForFilterBBox(filterRect, bbox); \
+ cropRect.intersect(filterRect); \
+ cropRect.move(-filterRect.x(), -filterRect.y());
+
+#define FE_QUARTZ_MAP_TO_SUBREGION_APPLY(cropRect) \
+ { \
+ CIFilter* crop = [CIFilter filterWithName:@"CICrop"]; \
+ [crop setDefaults]; \
+ if (CIImage* currentFilterOutputImage = [filter valueForKey:@"outputImage"]) { \
+ [crop setValue:currentFilterOutputImage forKey:@"inputImage"]; \
+ [crop setValue:[CIVector vectorWithX:cropRect.x() Y:cropRect.y() Z:cropRect.width() W:cropRect.height()] forKey:@"inputRectangle"]; \
+ filter = crop; \
+ } \
+ }
+
+#define FE_QUARTZ_MAP_TO_SUBREGION(bbox) \
+ FE_QUARTZ_MAP_TO_SUBREGION_PREPARE(bbox); \
+ FE_QUARTZ_MAP_TO_SUBREGION_APPLY(cropRect);
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm
new file mode 100644
index 0000000..5c7fc31
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm
@@ -0,0 +1,162 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEHelpersCg.h"
+
+#include "Color.h"
+#include "SVGDistantLightSource.h"
+#include "SVGLightSource.h"
+#include "SVGPointLightSource.h"
+#include "SVGSpotLightSource.h"
+
+#import "WKDistantLightFilter.h"
+#import "WKNormalMapFilter.h"
+#import "WKPointLightFilter.h"
+#import "WKSpotLightFilter.h"
+
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+CIVector* getVectorForChannel(SVGChannelSelectorType channel)
+{
+ switch (channel) {
+ case SVG_CHANNEL_UNKNOWN:
+ return nil;
+ case SVG_CHANNEL_R:
+ return [CIVector vectorWithX:1.0f Y:0.0f Z:0.0f W:0.0f];
+ case SVG_CHANNEL_G:
+ return [CIVector vectorWithX:0.0f Y:1.0f Z:0.0f W:0.0f];
+ case SVG_CHANNEL_B:
+ return [CIVector vectorWithX:0.0f Y:0.0f Z:1.0f W:0.0f];
+ case SVG_CHANNEL_A:
+ return [CIVector vectorWithX:0.0f Y:0.0f Z:0.0f W:1.0f];
+ default:
+ return [CIVector vectorWithX:0.0f Y:0.0f Z:0.0f W:0.0f];
+ }
+}
+
+CIColor* ciColor(const Color& c)
+{
+ CGColorRef colorCG = cgColor(c);
+ CIColor* colorCI = [CIColor colorWithCGColor:colorCG];
+ CGColorRelease(colorCG);
+ return colorCI;
+}
+
+// Lighting
+CIFilter* getPointLightVectors(CIFilter* normals, CIVector* lightPosition, float surfaceScale)
+{
+ CIFilter* filter;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ filter = [CIFilter filterWithName:@"WKPointLight"];
+ if (!filter)
+ return nil;
+ [filter setDefaults];
+ [filter setValue:[normals valueForKey:@"outputImage"] forKey:@"inputNormalMap"];
+ [filter setValue:lightPosition forKey:@"inputLightPosition"];
+ [filter setValue:[NSNumber numberWithFloat:surfaceScale] forKey:@"inputSurfaceScale"];
+ return filter;
+ END_BLOCK_OBJC_EXCEPTIONS;
+ return nil;
+}
+
+CIFilter* getLightVectors(CIFilter* normals, const SVGLightSource* light, float surfaceScale)
+{
+ [WKDistantLightFilter class];
+ [WKPointLightFilter class];
+ [WKSpotLightFilter class];
+
+ CIFilter* filter = nil;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
+ switch (light->type()) {
+ case LS_DISTANT:
+ {
+ const SVGDistantLightSource* dlight = static_cast<const SVGDistantLightSource*>(light);
+
+ filter = [CIFilter filterWithName:@"WKDistantLight"];
+ if (!filter)
+ return nil;
+ [filter setDefaults];
+
+ float azimuth = dlight->azimuth();
+ float elevation = dlight->elevation();
+ azimuth = deg2rad(azimuth);
+ elevation = deg2rad(elevation);
+ float Lx = cosf(azimuth)*cosf(elevation);
+ float Ly = sinf(azimuth)*cosf(elevation);
+ float Lz = sinf(elevation);
+
+ [filter setValue:[normals valueForKey:@"outputImage"] forKey:@"inputNormalMap"];
+ [filter setValue:[CIVector vectorWithX:Lx Y:Ly Z:Lz] forKey:@"inputLightDirection"];
+ return filter;
+ }
+ case LS_POINT:
+ {
+ const SVGPointLightSource* plight = static_cast<const SVGPointLightSource*>(light);
+ return getPointLightVectors(normals, [CIVector vectorWithX:plight->position().x() Y:plight->position().y() Z:plight->position().z()], surfaceScale);
+ }
+ case LS_SPOT:
+ {
+ const SVGSpotLightSource* slight = static_cast<const SVGSpotLightSource*>(light);
+ filter = [CIFilter filterWithName:@"WKSpotLight"];
+ if (!filter)
+ return nil;
+
+ CIFilter* pointLightFilter = getPointLightVectors(normals, [CIVector vectorWithX:slight->position().x() Y:slight->position().y() Z:slight->position().z()], surfaceScale);
+ if (!pointLightFilter)
+ return nil;
+ [filter setDefaults];
+
+ [filter setValue:[pointLightFilter valueForKey:@"outputImage"] forKey:@"inputLightVectors"];
+ [filter setValue:[CIVector vectorWithX:slight->direction().x() Y:slight->direction().y() Z:slight->direction().z()] forKey:@"inputLightDirection"];
+ [filter setValue:[NSNumber numberWithFloat:slight->specularExponent()] forKey:@"inputSpecularExponent"];
+ [filter setValue:[NSNumber numberWithFloat:deg2rad(slight->limitingConeAngle())] forKey:@"inputLimitingConeAngle"];
+ return filter;
+ }
+ }
+
+ END_BLOCK_OBJC_EXCEPTIONS;
+ return nil;
+}
+
+CIFilter* getNormalMap(CIImage* bumpMap, float scale)
+{
+ [WKNormalMapFilter class];
+ CIFilter* filter;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ filter = [CIFilter filterWithName:@"WKNormalMap"];
+ [filter setDefaults];
+
+ [filter setValue:bumpMap forKey:@"inputImage"];
+ [filter setValue:[NSNumber numberWithFloat:scale] forKey:@"inputSurfaceScale"];
+ return filter;
+ END_BLOCK_OBJC_EXCEPTIONS;
+ return nil;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEImageCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEImageCg.mm
new file mode 100644
index 0000000..2f12274
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFEImageCg.mm
@@ -0,0 +1,80 @@
+/*
+ Copyright (C) 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEImage.h"
+
+#include "Image.h"
+#include "SVGFEHelpersCg.h"
+#include "CgSupport.h"
+
+namespace WebCore {
+
+CIFilter* SVGFEImage::getCIFilter(const FloatRect& bbox) const
+{
+ if (!cachedImage())
+ return nil;
+
+ SVGResourceFilter* svgFilter = filter();
+ SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
+
+ CIFilter* filter;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ CIImage* ciImage = [CIImage imageWithCGImage:cachedImage()->image()->getCGImageRef()];
+
+ filter = [CIFilter filterWithName:@"CIAffineTransform"];
+ [filter setDefaults];
+ [filter setValue:ciImage forKey:@"inputImage"];
+
+ FloatRect imageRect = cachedImage()->image()->rect();
+
+ // Flip image into right origin
+ CGAffineTransform cgTransform = CGAffineTransformMake(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, imageRect.bottom());
+ NSAffineTransform* nsTransform = [NSAffineTransform transform];
+ [nsTransform setTransformStruct:*((NSAffineTransformStruct *)&cgTransform)];
+ [filter setValue:nsTransform forKey:@"inputTransform"];
+
+ // Calculate crop rect
+ FE_QUARTZ_MAP_TO_SUBREGION_PREPARE(bbox);
+
+ // Map between the image rectangle and the crop rect
+ if (!cropRect.isEmpty()) {
+ CIFilter* scaleImage = [CIFilter filterWithName:@"CIAffineTransform"];
+ [scaleImage setDefaults];
+ [scaleImage setValue:[filter valueForKey:@"outputImage"] forKey:@"inputImage"];
+
+ cgTransform = CGAffineTransformMakeMapBetweenRects(CGRect(imageRect), CGRect(cropRect));
+ [nsTransform setTransformStruct:*((NSAffineTransformStruct *)&cgTransform)];
+ [scaleImage setValue:nsTransform forKey:@"inputTransform"];
+
+ filter = scaleImage;
+ }
+
+ // Actually apply cropping
+ FE_QUARTZ_MAP_TO_SUBREGION_APPLY(cropRect);
+ FE_QUARTZ_OUTPUT_RETURN;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEMergeCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEMergeCg.mm
new file mode 100644
index 0000000..30a981a
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFEMergeCg.mm
@@ -0,0 +1,57 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEMerge.h"
+#include "SVGFEHelpersCg.h"
+
+namespace WebCore {
+
+CIFilter* SVGFEMerge::getCIFilter(const FloatRect& bbox) const
+{
+ SVGResourceFilter* svgFilter = filter();
+ SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
+
+ CIFilter* filter = nil;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ const Vector<String>& inputs = mergeInputs();
+
+ CIImage* previousOutput = filterPlatformData->inputImage(this);
+ for (unsigned x = 0; x < inputs.size(); x++) {
+ CIImage* inputImage = filterPlatformData->imageForName(inputs[x]);
+ FE_QUARTZ_CHECK_INPUT(inputImage);
+ FE_QUARTZ_CHECK_INPUT(previousOutput);
+ filter = [CIFilter filterWithName:@"CISourceOverCompositing"];
+ [filter setDefaults];
+ [filter setValue:inputImage forKey:@"inputImage"];
+ [filter setValue:previousOutput forKey:@"inputBackgroundImage"];
+ previousOutput = [filter valueForKey:@"outputImage"];
+ }
+
+ FE_QUARTZ_MAP_TO_SUBREGION(bbox);
+ FE_QUARTZ_OUTPUT_RETURN;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEOffsetCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEOffsetCg.mm
new file mode 100644
index 0000000..46fb045
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFEOffsetCg.mm
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEOffset.h"
+#include "SVGFEHelpersCg.h"
+
+namespace WebCore {
+
+CIFilter* SVGFEOffset::getCIFilter(const FloatRect& bbox) const
+{
+ SVGResourceFilter* svgFilter = filter();
+ FE_QUARTZ_SETUP_INPUT(@"CIAffineTransform");
+ NSAffineTransform* offsetTransform = [NSAffineTransform transform];
+ [offsetTransform translateXBy:dx() yBy:dy()];
+ [filter setValue:offsetTransform forKey:@"inputTransform"];
+
+ FE_QUARTZ_MAP_TO_SUBREGION(bbox);
+ FE_QUARTZ_OUTPUT_RETURN;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFESpecularLightingCg.mm b/WebCore/svg/graphics/filters/cg/SVGFESpecularLightingCg.mm
new file mode 100644
index 0000000..e872c6a
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFESpecularLightingCg.mm
@@ -0,0 +1,69 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFESpecularLighting.h"
+#include "SVGFEHelpersCg.h"
+
+#import "WKSpecularLightingFilter.h"
+
+namespace WebCore {
+
+CIFilter* SVGFESpecularLighting::getCIFilter(const FloatRect& bbox) const
+{
+ const SVGLightSource* light = lightSource();
+ if (!light)
+ return nil;
+
+ [WKSpecularLightingFilter class];
+
+ SVGResourceFilter* svgFilter = filter();
+ SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
+ CIFilter* filter;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ filter = [CIFilter filterWithName:@"WKSpecularLighting"];
+ [filter setDefaults];
+ CIImage* inputImage = filterPlatformData->inputImage(this);
+ FE_QUARTZ_CHECK_INPUT(inputImage);
+ CIFilter* normals = getNormalMap(inputImage, surfaceScale());
+ if (!normals)
+ return nil;
+ CIFilter* lightVectors = getLightVectors(normals, light, surfaceScale());
+ if (!lightVectors)
+ return nil;
+ [filter setValue:[normals valueForKey:@"outputImage"] forKey:@"inputNormalMap"];
+ [filter setValue:[lightVectors valueForKey:@"outputImage"] forKey:@"inputLightVectors"];
+ [filter setValue:ciColor(lightingColor()) forKey:@"inputLightingColor"];
+ [filter setValue:[NSNumber numberWithFloat:surfaceScale()] forKey:@"inputSurfaceScale"];
+ [filter setValue:[NSNumber numberWithFloat:specularConstant()] forKey:@"inputSpecularConstant"];
+ [filter setValue:[NSNumber numberWithFloat:specularExponent()] forKey:@"inputSpecularExponent"];
+ [filter setValue:[NSNumber numberWithFloat:kernelUnitLengthX()] forKey:@"inputKernelUnitLengthX"];
+ [filter setValue:[NSNumber numberWithFloat:kernelUnitLengthY()] forKey:@"inputKernelUnitLengthY"];
+
+ FE_QUARTZ_MAP_TO_SUBREGION(bbox);
+ FE_QUARTZ_OUTPUT_RETURN;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFETileCg.mm b/WebCore/svg/graphics/filters/cg/SVGFETileCg.mm
new file mode 100644
index 0000000..dea9854
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFETileCg.mm
@@ -0,0 +1,41 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFETile.h"
+#include "SVGFEHelpersCg.h"
+
+namespace WebCore {
+
+CIFilter* SVGFETile::getCIFilter(const FloatRect& bbox) const
+{
+ SVGResourceFilter* svgFilter = filter();
+ FE_QUARTZ_SETUP_INPUT(@"CIAffineTile");
+
+ FE_QUARTZ_MAP_TO_SUBREGION(bbox);
+ FE_QUARTZ_OUTPUT_RETURN;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFilterEffectCg.mm b/WebCore/svg/graphics/filters/cg/SVGFilterEffectCg.mm
new file mode 100644
index 0000000..4b0a233
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/SVGFilterEffectCg.mm
@@ -0,0 +1,37 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#include "SVGFilterEffect.h"
+
+namespace WebCore {
+
+CIFilter* SVGFilterEffect::getCIFilter(const FloatRect& bbox) const
+{
+ return nil;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.cikernel
new file mode 100644
index 0000000..3c32c3a
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.cikernel
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+kernel vec4 arithmeticComposite(sampler in1, sampler in2, float k1, float k2, float k3, float k4)
+{
+ vec4 vin1 = sample(in1, samplerCoord(in1));
+ vec4 vin2 = sample(in2, samplerCoord(in2));
+ vec4 res = k1*vin1*vin2 + k2*vin1 + k3*vin2 + vec4(k4);
+ return res;
+}
diff --git a/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.h b/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.h
new file mode 100644
index 0000000..4693853
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKArithmeticFilter : CIFilter {
+ CIImage *inputImage;
+ CIImage *inputBackgroundImage;
+ NSNumber *inputK1;
+ NSNumber *inputK2;
+ NSNumber *inputK3;
+ NSNumber *inputK4;
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.m b/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.m
new file mode 100644
index 0000000..389f25d
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.m
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKArithmeticFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+static CIKernel *arithmeticFilter = nil;
+
+@implementation WKArithmeticFilter
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKArithmeticFilter"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Arithmetic Filter", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories,
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeMin,
+ [NSNumber numberWithDouble:0.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputK1",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeMin,
+ [NSNumber numberWithDouble:0.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputK2",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeMin,
+ [NSNumber numberWithDouble:0.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputK3",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeMin,
+ [NSNumber numberWithDouble:0.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputK4",
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ if (!arithmeticFilter) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *kernelFile = [bundle pathForResource:@"WKArithmeticFilter" ofType:@"cikernel"];
+ NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0];
+ NSArray *kernels = [CIKernel kernelsWithString:code];
+ arithmeticFilter = [[kernels objectAtIndex:0] retain];
+ }
+ return [super init];
+}
+
+- (CIImage *)outputImage
+{
+ return [self apply:arithmeticFilter, inputImage, inputBackgroundImage, inputK1, inputK2, inputK3,
+ inputK4, nil];
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.cikernel
new file mode 100644
index 0000000..f33f20c
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.cikernel
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+kernel vec4 mergeComponents(sampler funcR, sampler funcG, sampler funcB, sampler funcA)
+{
+ float r = sample(funcR, samplerCoord(funcR)).r;
+ float g = sample(funcG, samplerCoord(funcG)).g;
+ float b = sample(funcB, samplerCoord(funcB)).b;
+ float a = sample(funcA, samplerCoord(funcA)).a;
+ return vec4(r, g, b, a);
+}
diff --git a/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.h b/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.h
new file mode 100644
index 0000000..778e326
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKComponentMergeFilter : CIFilter {
+ CIImage *inputFuncR;
+ CIImage *inputFuncG;
+ CIImage *inputFuncB;
+ CIImage *inputFuncA;
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.m b/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.m
new file mode 100644
index 0000000..4f2045a
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.m
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKComponentMergeFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+static CIKernel *componentMergeFilter = nil;
+
+@implementation WKComponentMergeFilter
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKComponentMerge"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Component Merge", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories,
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ if (!componentMergeFilter) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *kernelFile = [bundle pathForResource:@"WKComponentMergeFilter" ofType:@"cikernel"];
+ NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0];
+ NSArray *kernels = [CIKernel kernelsWithString:code];
+ componentMergeFilter = [[kernels objectAtIndex:0] retain];
+ }
+ return [super init];
+}
+
+- (CIImage *)outputImage
+{
+ return [self apply:componentMergeFilter, [CISampler samplerWithImage: inputFuncR],
+ [CISampler samplerWithImage: inputFuncG], [CISampler samplerWithImage: inputFuncB], [CISampler samplerWithImage: inputFuncA], @"definition", [inputFuncR definition], nil];
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.cikernel
new file mode 100644
index 0000000..870956a
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.cikernel
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+kernel vec4 diffuseLighting(sampler normalVectors, sampler lightVectors, __color lightingColor,
+ float surfaceScale, float diffuseConstant, float kernelLengthX, float kernelLengthY)
+{
+ vec2 pos = samplerCoord(lightVectors);
+ vec2 posn = samplerCoord(normalVectors);
+ vec4 l4 = sample(lightVectors, pos);
+ vec3 l = l4.xyz;
+ l = normalize(l);
+ vec3 n = sample(normalVectors, posn).xyz;
+ float nl = dot(l, n) * diffuseConstant;
+ vec4 res = vec4(lightingColor.r * nl, lightingColor.g * nl, lightingColor.b * nl, 1.0);
+ res.xyz *= l4.w;
+ return res;
+}
diff --git a/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.h b/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.h
new file mode 100644
index 0000000..2731986
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKDiffuseLightingFilter : CIFilter {
+ CISampler *inputNormalMap;
+ CISampler *inputLightVectors;
+ CIColor *inputLightingColor;
+ NSNumber *inputSurfaceScale;
+ NSNumber *inputDiffuseConstant;
+ NSNumber *inputKernelUnitLengthX;
+ NSNumber *inputKernelUnitLengthY;
+}
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.m b/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.m
new file mode 100644
index 0000000..3675af8
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.m
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKDiffuseLightingFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+static CIKernel *diffuseLightingFilter = nil;
+@implementation WKDiffuseLightingFilter
+
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKDiffuseLighting"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Diffuse Lighting", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories,
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [CIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f],
+ kCIAttributeDefault, nil], @"inputLightingColor",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeMin,
+ [NSNumber numberWithDouble:1.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputSurfaceScale",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeMin,
+ [NSNumber numberWithDouble:1.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputDiffuseConstant",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeMin,
+ [NSNumber numberWithDouble:1.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputKernelUnitLengthX",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeMin,
+ [NSNumber numberWithDouble:1.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputKernelUnitLengthY",
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ if (!diffuseLightingFilter) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *kernelFile = [bundle pathForResource:@"WKDiffuseLightingFilter" ofType:@"cikernel"];
+ NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0];
+ NSArray *kernels = [CIKernel kernelsWithString:code];
+ diffuseLightingFilter = [[kernels objectAtIndex:0] retain];
+ }
+ return [super init];
+}
+
+- (CIImage *)outputImage
+{
+ return [self apply:diffuseLightingFilter, inputNormalMap, inputLightVectors, inputLightingColor, inputSurfaceScale, inputDiffuseConstant,
+ inputKernelUnitLengthX, inputKernelUnitLengthY, nil];
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.cikernel
new file mode 100644
index 0000000..db3cefd
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.cikernel
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+kernel vec4 discreteTransfer(sampler image, sampler table, vec4 rgbaSelector, float maxIndex)
+{
+ vec4 C = sample(image, samplerCoord(image));
+ float k = floor(dot(rgbaSelector, C) * maxIndex);
+ vec4 res = sample(table, vec2(k+0.0, 0.0));
+ return res;
+}
diff --git a/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.h b/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.h
new file mode 100644
index 0000000..d444c75
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKDiscreteTransferFilter : CIFilter {
+ CIImage *inputImage;
+ CIImage *inputTable;
+ CIVector *inputSelector;
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.m b/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.m
new file mode 100644
index 0000000..dc6ca76
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.m
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKDiscreteTransferFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+static CIKernel *discreteTransferFilter = nil;
+
+@implementation WKDiscreteTransferFilter
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKDiscreteTransfer"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Discrete Transfer", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories,
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ if (!discreteTransferFilter) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *kernelFile = [bundle pathForResource:@"WKDiscreteTransferFilter" ofType:@"cikernel"];
+ NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0];
+ NSArray *kernels = [CIKernel kernelsWithString:code];
+ discreteTransferFilter = [[kernels objectAtIndex:0] retain];
+ }
+ return [super init];
+}
+
+- (CIImage *)outputImage
+{
+ CISampler *inputSampler = [CISampler samplerWithImage: inputImage];
+ CISampler *tableSampler = [CISampler samplerWithImage: inputTable keysAndValues:kCISamplerFilterMode, kCISamplerFilterNearest, kCISamplerWrapMode, kCISamplerWrapClamp, nil];
+ NSArray *args = [NSArray arrayWithObjects:inputSampler, tableSampler, inputSelector,
+ [NSNumber numberWithDouble:[inputTable extent].size.width - 1.0f], @"definition", [inputSampler definition], nil];
+ return [self apply:discreteTransferFilter arguments:args options:nil];
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.cikernel
new file mode 100644
index 0000000..95b19c6
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.cikernel
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Performs the transformation:
+ * P'(x,y) <- P( x + scale * (XC(x,y) - .5), y + scale * (YC(x,y) - .5))
+ *
+ * x/ychannel arguments are used to select the appropriate channel for x and
+ * y displacement. Hence each vector should have only one non-zero element,
+ * which should have the value 1.0.
+ *
+ */
+
+kernel vec4 displacementMap(sampler image, sampler map, vec4 xchannel, vec4 ychannel, float scale)
+{
+ vec2 samplePos = samplerCoord(image);
+ vec4 XCYC = sample(map, samplerCoord(map));
+ float xc = dot(XCYC, xchannel);
+ float yc = dot(XCYC, ychannel);
+ samplePos.x += scale*(xc-0.5);
+ samplePos.y += scale*(yc-0.5);
+ return sample(image, samplePos);
+}
diff --git a/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.h b/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.h
new file mode 100644
index 0000000..e594495
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKDisplacementMapFilter : CIFilter {
+ CIImage *inputImage;
+ CIImage *inputDisplacementMap;
+ CIVector *inputXChannelSelector;
+ CIVector *inputYChannelSelector;
+ NSNumber *inputScale;
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.m b/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.m
new file mode 100644
index 0000000..8ccd52c
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.m
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKDisplacementMapFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+static CIKernel *displacementMapFilter = nil;
+
+@implementation WKDisplacementMapFilter
+
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKDisplacementMapFilter"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Displacement Map Filter", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories,
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [CIVector vectorWithX:1.0f Y:0.0f Z:0.0f W:0.0f],
+ kCIAttributeDefault, nil], @"inputXChannelSelector",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [CIVector vectorWithX:0.0f Y:1.0f Z:0.0f W:0.0f],
+ kCIAttributeDefault, nil], @"inputYChannelSelector",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:0.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputScale",
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ if (!displacementMapFilter) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *kernelFile = [bundle pathForResource:@"WKDisplacementMapFilter" ofType:@"cikernel"];
+ NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0];
+ NSArray *kernels = [CIKernel kernelsWithString:code];
+ displacementMapFilter = [[kernels objectAtIndex:0] retain];
+ }
+ return [super init];
+}
+
+- (CIImage *)outputImage
+{
+ return [self apply:displacementMapFilter, inputImage, inputDisplacementMap, inputXChannelSelector, inputYChannelSelector, inputScale, nil];
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.cikernel
new file mode 100644
index 0000000..c14677c
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.cikernel
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+kernel vec4 distantLightGenerator(sampler image, vec3 direction)
+{
+ return vec4(direction.x, direction.y, direction.z, 1.0);
+}
diff --git a/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.h b/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.h
new file mode 100644
index 0000000..e5fe15a
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKDistantLightFilter : CIFilter {
+ CIImage * inputNormalMap;
+ CIVector * inputLightDirection;
+}
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.m b/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.m
new file mode 100644
index 0000000..29e3caf
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.m
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKDistantLightFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+static CIKernel *distantLightFilter = nil;
+
+@implementation WKDistantLightFilter
+
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKDistantLight"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Distant Light", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories,
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ kCIAttributeTypePosition3, kCIAttributeType,
+ nil], @"inputLightDirection",
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ if (!distantLightFilter) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *kernelFile = [bundle pathForResource:@"WKDistantLightFilter" ofType:@"cikernel"];
+ NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0];
+ NSArray *kernels = [CIKernel kernelsWithString:code];
+ distantLightFilter = [[kernels objectAtIndex:0] retain];
+ }
+ return [super init];
+}
+
+- (CIImage *)outputImage
+{
+ return [self apply:distantLightFilter, [CISampler samplerWithImage:inputNormalMap], inputLightDirection, nil];
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.cikernel
new file mode 100644
index 0000000..810edb6
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.cikernel
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+kernel vec4 gammaTransfer(sampler image, float amplitude, float exponent, float offset)
+{
+ vec4 C = sample(image, samplerCoord(image));
+ return amplitude * pow(C, vec4(exponent)) + offset;
+}
diff --git a/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.h b/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.h
new file mode 100644
index 0000000..7e0c1e4
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKGammaTransferFilter : CIFilter {
+ CIImage *inputImage;
+ NSNumber *inputAmplitude;
+ NSNumber *inputExponent;
+ NSNumber *inputOffset;
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.m b/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.m
new file mode 100644
index 0000000..8642931
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.m
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKGammaTransferFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+static CIKernel *gammaTransferFilter = nil;
+
+@implementation WKGammaTransferFilter
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKGammaTransfer"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Gamma Transfer", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories,
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:1.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputAmplitude",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:1.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputExponent",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:0.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputOffset",
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ if (!gammaTransferFilter) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *kernelFile = [bundle pathForResource:@"WKGammaTransferFilter" ofType:@"cikernel"];
+ NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0];
+ NSArray *kernels = [CIKernel kernelsWithString:code];
+ gammaTransferFilter = [[kernels objectAtIndex:0] retain];
+ }
+ return [super init];
+}
+
+- (CIImage *)outputImage
+{
+ CISampler *inputSampler = [CISampler samplerWithImage: inputImage];
+ return [self apply:gammaTransferFilter, inputSampler, inputAmplitude, inputExponent, inputOffset, @"definition", [inputSampler definition], nil];
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.h b/WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.h
new file mode 100644
index 0000000..0c36daa
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKIdentityTransferFilter : CIFilter {
+ CIImage *inputImage;
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.m b/WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.m
new file mode 100644
index 0000000..935c305
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.m
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKIdentityTransferFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@implementation WKIdentityTransferFilter
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKIdentityTransfer"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Identity Transfer", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories,
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ return [super init];
+}
+
+- (CIImage *)outputImage
+{
+ return inputImage;
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.cikernel
new file mode 100644
index 0000000..17d57e4
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.cikernel
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+kernel vec4 linearTransfer(sampler image, float slope, float intercept)
+{
+ vec4 C = sample(image, samplerCoord(image));
+ return slope * C + intercept;
+}
diff --git a/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.h b/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.h
new file mode 100644
index 0000000..91a99f5
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKLinearTransferFilter : CIFilter {
+ CIImage *inputImage;
+ NSNumber *inputSlope;
+ NSNumber *inputIntercept;
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m b/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m
new file mode 100644
index 0000000..ecfed53
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKLinearTransferFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+static CIKernel *linearTransferFilter = nil;
+
+@implementation WKLinearTransferFilter
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKLinearTransfer"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Linear Transfer", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories,
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:1.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputSlope",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:0.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputIntersection",
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ if (!linearTransferFilter) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *kernelFile = [bundle pathForResource:@"WKLinearTransferFilter" ofType:@"cikernel"];
+ NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0];
+ NSArray *kernels = [CIKernel kernelsWithString:code];
+ linearTransferFilter = [[kernels objectAtIndex:0] retain];
+ }
+ return [super init];
+}
+
+- (CIImage *)outputImage
+{
+ CISampler *inputSampler = [CISampler samplerWithImage: inputImage];
+ return [self apply:linearTransferFilter, inputSampler, inputSlope, inputIntercept, @"definition", [inputSampler definition], nil];
+}
+
+@end
+
+#endif ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.cikernel
new file mode 100644
index 0000000..589f475
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.cikernel
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+//TODO: We currently ignore the input kernel lengths
+kernel vec4 convolve3x3(sampler image, float divisor, float bias,
+ vec3 m0, vec3 m1, vec3 m2)
+{
+ vec4 colour = vec4(0.0, 0.0, 0.0, 0.0);
+ vec2 pos= samplerCoord(image);
+ colour = sample(image, pos + vec2(-1.0, -1.0)) *m0.x;
+ colour += sample(image, pos + vec2(-1.0, 0.0)) *m0.y;
+ colour += sample(image, pos + vec2(-1.0, 1.0)) *m0.z;
+ colour += sample(image, pos + vec2( 0.0, -1.0)) *m1.x;
+ colour += sample(image, pos) * m1.y;
+ colour += sample(image, pos + vec2( 0.0, 1.0))*m1.z;
+ colour += sample(image, pos + vec2( 1.0, -1.0))*m2.x;
+ colour += sample(image, pos + vec2( 1.0, 0.0))*m2.y;
+ colour += sample(image, pos + vec2( 1.0, 1.0))*m2.z;
+ return colour / divisor + bias;
+}
+
+kernel vec4 mergeNormals(sampler Nx, sampler Ny, sampler src, float surfaceScale)
+{
+ vec3 N = vec3(surfaceScale * sample(Nx, samplerCoord(Nx)).a, -surfaceScale * sample(Ny, samplerCoord(Ny)).a, 1.0);
+ N = normalize(N);
+ return vec4(N.x, N.y, N.z, sample(src, samplerCoord(src)).a);
+}
diff --git a/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.h b/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.h
new file mode 100644
index 0000000..fb27447
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKNormalMapFilter : CIFilter {
+ CIImage *inputImage;
+ NSNumber *inputSurfaceScale;
+}
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.m b/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.m
new file mode 100644
index 0000000..b462008
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.m
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKNormalMapFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+static CIKernel *convolveKernel = nil;
+static CIKernel *normalMapKernel = nil;
+
+@implementation WKNormalMapFilter
+
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKNormalMap"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Normal Map", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects: kCICategoryBlur, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels, nil], kCIAttributeFilterCategories,
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeMin,
+ [NSNumber numberWithDouble:1.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputSurfaceScale",
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ if (!normalMapKernel) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *kernelFile = [bundle pathForResource:@"WKNormalMapFilter" ofType:@"cikernel"];
+ NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0];
+ NSArray *kernels = [CIKernel kernelsWithString:code];
+ convolveKernel = [[kernels objectAtIndex:0] retain];
+ normalMapKernel = [[kernels objectAtIndex:1] retain];
+ }
+ return [super init];
+}
+
+- (NSArray *)xConvolveArgsWithBumpMap:(CISampler *)bumpMap {
+ return [NSArray arrayWithObjects:
+ bumpMap,
+ [NSNumber numberWithFloat:4],
+ [NSNumber numberWithFloat:0],
+ [CIVector vectorWithX:1 Y:2 Z:1],
+ [CIVector vectorWithX:0 Y:0 Z:0],
+ [CIVector vectorWithX:-1 Y:-2 Z:-1],
+ nil];
+}
+
+- (NSArray *)yConvolveArgsWithBumpMap:(CISampler *)bumpMap {
+ return [NSArray arrayWithObjects:
+ bumpMap,
+ [NSNumber numberWithFloat:4],
+ [NSNumber numberWithFloat:0],
+ [CIVector vectorWithX:1 Y:0 Z:-1],
+ [CIVector vectorWithX:2 Y:0 Z:-2],
+ [CIVector vectorWithX:1 Y:0 Z:-1],
+ nil];
+}
+
+- (CIImage *)outputImage
+{
+ CISampler *image = [CISampler samplerWithImage:inputImage];
+ NSDictionary *applyOptions = [NSDictionary dictionaryWithObjectsAndKeys:[image definition], kCIApplyOptionDefinition, nil];
+
+ CIImage *convolveX = [self apply:convolveKernel arguments:[self xConvolveArgsWithBumpMap:image] options:applyOptions];
+ CIImage *convolveY = [self apply:convolveKernel arguments:[self yConvolveArgsWithBumpMap:image] options:applyOptions];
+ CISampler *samplerX = [CISampler samplerWithImage:convolveX];
+ CISampler *samplerY = [CISampler samplerWithImage:convolveY];
+
+ NSArray *normalMapArgs = [NSArray arrayWithObjects:samplerX, samplerY, image, inputSurfaceScale, nil];
+ return [self apply:normalMapKernel arguments:normalMapArgs options:applyOptions];
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKPointLightFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKPointLightFilter.cikernel
new file mode 100644
index 0000000..fd0a851
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKPointLightFilter.cikernel
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+kernel vec4 genPointLight(sampler normalMap, vec3 lightPos, float surfaceScale)
+{
+ vec2 pos = samplerCoord(normalMap);
+ vec3 P = vec3(pos.x, pos.y, surfaceScale * sample(normalMap, pos).a);
+ vec3 L = lightPos - P;
+ L = normalize(L);
+ return vec4(L.x, L.y, L.z, 1.0);
+}
diff --git a/WebCore/svg/graphics/filters/cg/WKPointLightFilter.h b/WebCore/svg/graphics/filters/cg/WKPointLightFilter.h
new file mode 100644
index 0000000..58ec689
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKPointLightFilter.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKPointLightFilter : CIFilter {
+ CIImage *inputNormalMap;
+ CIVector *inputLightPosition;
+ NSNumber *inputSurfaceScale;
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKPointLightFilter.m b/WebCore/svg/graphics/filters/cg/WKPointLightFilter.m
new file mode 100644
index 0000000..331207e
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKPointLightFilter.m
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKPointLightFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+static CIKernel *pointLightFilter = nil;
+
+@implementation WKPointLightFilter
+
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKPointLight"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Point Light", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories,
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ kCIAttributeTypePosition3, kCIAttributeType,
+ nil], @"inputLightPosition",
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ if (!pointLightFilter) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *kernelFile = [bundle pathForResource:@"WKPointLightFilter" ofType:@"cikernel"];
+ NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0];
+ NSArray *kernels = [CIKernel kernelsWithString:code];
+ pointLightFilter = [[kernels objectAtIndex:0] retain];
+ }
+ return [super init];
+}
+
+- (CIImage *)outputImage
+{
+ return [self apply:pointLightFilter, inputNormalMap, inputLightPosition, inputSurfaceScale, nil];
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.cikernel
new file mode 100644
index 0000000..64228f0
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.cikernel
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+kernel vec4 basic(sampler inputNormalVectors, sampler inputLightVectors, __color inputLightingColor, float inputSurfaceScale, float inputSpecularConstant,
+ float inputSpecularExponent, float inputKernelUnitLengthX, float inputKernelUnitLengthY)
+{
+ vec2 pos = samplerCoord(inputLightVectors);
+ vec2 posn = samplerCoord(inputNormalVectors);
+ vec3 l = sample(inputLightVectors, pos).xyz;
+ vec3 n = sample(inputNormalVectors, posn).xyz;
+ vec3 h = l+vec3(0.0, 0.0, 1.0);
+ h = normalize(h);
+ float nh = inputSpecularConstant*pow((dot(n, h)), inputSpecularExponent);
+ vec4 res = inputLightingColor * nh;
+ res.a = max(res.r, res.g);
+ res.a = max(res.a, res.b);
+ return res;
+}
diff --git a/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h b/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h
new file mode 100644
index 0000000..1b76f2b
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKSpecularLightingFilter : CIFilter {
+ CISampler *inputNormalMap;
+ CISampler *inputLightVectors;
+ CIColor *inputLightingColor;
+ NSNumber *inputSurfaceScale;
+ NSNumber *inputSpecularConstant;
+ NSNumber *inputSpecularExponent;
+ NSNumber *inputKernelUnitLengthX;
+ NSNumber *inputKernelUnitLengthY;
+}
+@end
+
+#endif ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.m b/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.m
new file mode 100644
index 0000000..22495ae
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.m
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKSpecularLightingFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+static CIKernel *specularLightingFilter = nil;
+
+@implementation WKSpecularLightingFilter
+
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKSpecularLighting"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Specular Lighting", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories,
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [CIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f],
+ kCIAttributeDefault, nil], @"inputLightingColor",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeMin,
+ [NSNumber numberWithDouble:1.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputSurfaceScale",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeMin,
+ [NSNumber numberWithDouble:1.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputSpecularConstant",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:0.0], kCIAttributeMin,
+ [NSNumber numberWithDouble:128.0], kCIAttributeMin,
+ [NSNumber numberWithDouble:1.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputSpecularExponent",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ kCIAttributeTypeOffset, kCIAttributeType,
+ nil], @"inputKernelUnitLength",
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ if (!specularLightingFilter) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *kernelFile = [bundle pathForResource:@"WKSpecularLightingFilter" ofType:@"cikernel"];
+ NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0];
+ NSArray *kernels = [CIKernel kernelsWithString:code];
+ specularLightingFilter = [[kernels objectAtIndex:0] retain];
+ }
+ return [super init];
+}
+
+- (CIImage *)outputImage
+{
+ return [self apply:specularLightingFilter, inputNormalMap, inputLightVectors, inputLightingColor, inputSurfaceScale, inputSpecularConstant,
+ inputSpecularExponent, inputKernelUnitLengthX, inputKernelUnitLengthY, nil];
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.cikernel
new file mode 100644
index 0000000..0fa83a8
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.cikernel
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+kernel vec4 spotLightFilter(sampler lightVectors, vec3 lightDirection, float specularExponent, float cosCutoffAngle)
+{
+ vec2 pos = samplerCoord(lightVectors);
+ vec3 l = sample(lightVectors, pos).xyz;
+ float sl = -dot(lightDirection, l);
+ sl = max(sl, 0.0);
+ sl = pow(sl, specularExponent) * sign(sl - cosCutoffAngle);
+ return vec4(l.x, l.y, l.z, sl);
+}
diff --git a/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.h b/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.h
new file mode 100644
index 0000000..d87beca
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKSpotLightFilter : CIFilter {
+ CIImage *inputLightVectors;
+ CIVector *inputLightDirection;
+ NSNumber *inputSpecularExponent;
+ NSNumber *inputLimitingConeAngle;
+}
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.m b/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.m
new file mode 100644
index 0000000..62973ef
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.m
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKSpotLightFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+static CIKernel *spotLightFilter = nil;
+
+@implementation WKSpotLightFilter
+
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKSpotLight"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Spot Light", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories,
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ kCIAttributeTypePosition3, kCIAttributeType,
+ nil], @"inputLightDirection",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithDouble:1.0], kCIAttributeDefault,
+ [NSNumber numberWithDouble:1.0], kCIAttributeIdentity,
+ kCIAttributeTypeScalar, kCIAttributeType,
+ nil], @"inputSpecularExponent",
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ kCIAttributeTypeAngle, kCIAttributeType,
+ nil], @"inputLimitingConeAngle",
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ if (!spotLightFilter) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *kernelFile = [bundle pathForResource:@"WKSpotLightFilter" ofType:@"cikernel"];
+ NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0];
+ NSArray *kernels = [CIKernel kernelsWithString:code];
+ spotLightFilter = [[kernels objectAtIndex:0] retain];
+ }
+ return [super init];
+}
+
+- (CIImage *)outputImage
+{
+ float coscutoff = cosf([inputLimitingConeAngle floatValue]);
+ if (coscutoff < 0)
+ coscutoff = -coscutoff;
+ return [self apply:spotLightFilter, inputLightVectors, inputLightDirection, inputSpecularExponent, [NSNumber numberWithFloat:coscutoff], nil];
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.cikernel
new file mode 100644
index 0000000..19dfcdf
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.cikernel
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* For some reason CI is ignoring the request to interpolate the colour returned
+ * when we sample the lookup table. Therefore it is necessary to implement the
+ * blend operation ourselves.
+ */
+kernel vec4 tableTransfer(sampler image, sampler table, vec4 rgbaSelector, float maxIndex)
+{
+ vec4 C = sample(image, samplerCoord(image));
+ float k = dot(rgbaSelector, C) * maxIndex;
+ float t = fract(k);
+ k = floor(k);
+ vec4 res = sample(table, vec2(k, 0.0))*(1.0-t)+sample(table, vec2(k+1.0, 0.0))*(t);
+ return res;
+}
diff --git a/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.h b/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.h
new file mode 100644
index 0000000..34adf00
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <QuartzCore/CoreImage.h>
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+@interface WKTableTransferFilter : CIFilter {
+ CIImage *inputImage;
+ CIImage *inputTable;
+ CIVector *inputSelector;
+}
+
+@end
+
+#endif
diff --git a/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.m b/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.m
new file mode 100644
index 0000000..55d7c9d
--- /dev/null
+++ b/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.m
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKTableTransferFilter.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+static CIKernel *tableTransferFilter = nil;
+
+@implementation WKTableTransferFilter
++ (void)initialize
+{
+ [CIFilter registerFilterName:@"WKTableTransfer"
+ constructor:self
+ classAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"WebKit Table Transfer", kCIAttributeFilterDisplayName,
+ [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo,
+ kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories,
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ kCIAttributeTypeGradient, kCIAttributeType,
+ nil], @"inputTable",
+ nil]];
+}
+
++ (CIFilter *)filterWithName:(NSString *)name
+{
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init
+{
+ if (!tableTransferFilter) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *kernelFile = [bundle pathForResource:@"WKTableTransferFilter" ofType:@"cikernel"];
+ NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0];
+ NSArray *kernels = [CIKernel kernelsWithString:code];
+ tableTransferFilter = [[kernels objectAtIndex:0] retain];
+ }
+ return [super init];
+}
+
+- (CIImage *)outputImage
+{
+ CISampler *inputSampler = [CISampler samplerWithImage: inputImage];
+ CISampler *tableSampler = [CISampler samplerWithImage: inputTable keysAndValues:kCISamplerFilterMode, kCISamplerFilterLinear, kCISamplerWrapMode, kCISamplerWrapClamp, nil];
+ NSArray *args = [NSArray arrayWithObjects:inputSampler, tableSampler, inputSelector,
+ [NSNumber numberWithDouble:[inputTable extent].size.width - 1.0f], @"definition", [inputSampler definition], nil];
+ return [self apply:tableTransferFilter arguments:args options:nil];
+}
+
+@end
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h
new file mode 100644
index 0000000..3236ee5
--- /dev/null
+++ b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGResourceFilterPlatformDataMac_h
+#define SVGResourceFilterPlatformDataMac_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#include "SVGResourceFilter.h"
+
+#include <ApplicationServices/ApplicationServices.h>
+#include <wtf/RetainPtr.h>
+
+@class CIImage;
+@class CIFilter;
+@class CIContext;
+@class NSArray;
+@class NSMutableDictionary;
+
+namespace WebCore {
+ class SVGResourceFilterPlatformDataMac : public SVGResourceFilterPlatformData {
+ public:
+ SVGResourceFilterPlatformDataMac(SVGResourceFilter*);
+ virtual ~SVGResourceFilterPlatformDataMac();
+
+ CIImage* imageForName(const String&) const;
+ void setImageForName(CIImage*, const String&);
+
+ void setOutputImage(const SVGFilterEffect*, CIImage*);
+ CIImage* inputImage(const SVGFilterEffect*);
+
+ NSArray* getCIFilterStack(CIImage* inputImage, const FloatRect& bbox);
+
+ CIContext* m_filterCIContext;
+ CGLayerRef m_filterCGLayer;
+ RetainPtr<NSMutableDictionary> m_imagesByName;
+ SVGResourceFilter* m_filter;
+ };
+}
+
+#endif // #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGResourceFilterPlatformDataMac_h
diff --git a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm
new file mode 100644
index 0000000..c031bbc
--- /dev/null
+++ b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#include "SVGResourceFilterPlatformDataMac.h"
+#include <QuartzCore/CoreImage.h>
+
+namespace WebCore {
+
+static const char* const SVGPreviousFilterOutputName = "__previousOutput__";
+
+SVGResourceFilterPlatformDataMac::SVGResourceFilterPlatformDataMac(SVGResourceFilter* filter)
+ : m_filterCIContext(0)
+ , m_filterCGLayer(0)
+ , m_imagesByName(AdoptNS, [[NSMutableDictionary alloc] init])
+ , m_filter(filter)
+{
+}
+
+SVGResourceFilterPlatformDataMac::~SVGResourceFilterPlatformDataMac()
+{
+ ASSERT(!m_filterCGLayer);
+ ASSERT(!m_filterCIContext);
+}
+
+
+NSArray* SVGResourceFilterPlatformDataMac::getCIFilterStack(CIImage* inputImage, const FloatRect& bbox)
+{
+ NSMutableArray* filterEffects = [NSMutableArray array];
+
+ setImageForName(inputImage, "SourceGraphic"); // input
+
+ for (unsigned int i = 0; i < m_filter->effects().size(); i++) {
+ CIFilter* filter = m_filter->effects()[i]->getCIFilter(bbox);
+ if (filter)
+ [filterEffects addObject:filter];
+ }
+
+ [m_imagesByName.get() removeAllObjects]; // clean up before next time.
+
+ return filterEffects;
+}
+
+static inline CIImage* alphaImageForImage(CIImage* image)
+{
+ CIFilter* onlyAlpha = [CIFilter filterWithName:@"CIColorMatrix"];
+ CGFloat zero[4] = {0, 0, 0, 0};
+ [onlyAlpha setDefaults];
+ [onlyAlpha setValue:image forKey:@"inputImage"];
+ [onlyAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputRVector"];
+ [onlyAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputGVector"];
+ [onlyAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBVector"];
+ return [onlyAlpha valueForKey:@"outputImage"];
+}
+
+CIImage* SVGResourceFilterPlatformDataMac::imageForName(const String& name) const
+{
+ return [m_imagesByName.get() objectForKey:name];
+}
+
+void SVGResourceFilterPlatformDataMac::setImageForName(CIImage* image, const String& name)
+{
+ [m_imagesByName.get() setValue:image forKey:name];
+}
+
+void SVGResourceFilterPlatformDataMac::setOutputImage(const SVGFilterEffect* filterEffect, CIImage* output)
+{
+ if (!filterEffect->result().isEmpty())
+ setImageForName(output, filterEffect->result());
+
+ setImageForName(output, SVGPreviousFilterOutputName);
+}
+
+CIImage* SVGResourceFilterPlatformDataMac::inputImage(const SVGFilterEffect* filterEffect)
+{
+ if (filterEffect->in().isEmpty()) {
+ CIImage* inImage = imageForName(SVGPreviousFilterOutputName);
+
+ if (!inImage)
+ inImage = imageForName("SourceGraphic");
+
+ return inImage;
+ } else if (filterEffect->in() == "SourceAlpha") {
+ CIImage* sourceAlpha = imageForName(filterEffect->in());
+
+ if (!sourceAlpha) {
+ CIImage* sourceGraphic = imageForName("SourceGraphic");
+
+ if (!sourceGraphic)
+ return nil;
+
+ sourceAlpha = alphaImageForImage(sourceGraphic);
+ setImageForName(sourceAlpha, "SourceAlpha");
+ }
+
+ return sourceAlpha;
+ }
+
+ return imageForName(filterEffect->in());
+}
+
+
+}
+
+#endif // #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/qt/RenderPathQt.cpp b/WebCore/svg/graphics/qt/RenderPathQt.cpp
new file mode 100644
index 0000000..8bee8b8
--- /dev/null
+++ b/WebCore/svg/graphics/qt/RenderPathQt.cpp
@@ -0,0 +1,89 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ 2005 Eric Seidel <eric.seidel@kdemail.net>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "RenderPath.h"
+#include "SVGRenderStyle.h"
+#include "SVGPaintServer.h"
+
+#include <QDebug>
+#include <QPainterPathStroker>
+
+namespace WebCore {
+
+bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const
+{
+ if (path().isEmpty())
+ return false;
+
+ if (requiresStroke && !SVGPaintServer::strokePaintServer(style(), this))
+ return false;
+
+ return false;
+}
+
+static QPainterPath getPathStroke(const QPainterPath &path, const RenderObject* object, const RenderStyle* style)
+{
+ QPainterPathStroker s;
+ s.setWidth(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0));
+
+ if (style->svgStyle()->capStyle() == ButtCap)
+ s.setCapStyle(Qt::FlatCap);
+ else if (style->svgStyle()->capStyle() == RoundCap)
+ s.setCapStyle(Qt::RoundCap);
+
+ if (style->svgStyle()->joinStyle() == MiterJoin) {
+ s.setJoinStyle(Qt::MiterJoin);
+ s.setMiterLimit((qreal) style->svgStyle()->strokeMiterLimit());
+ } else if(style->svgStyle()->joinStyle() == RoundJoin)
+ s.setJoinStyle(Qt::RoundJoin);
+
+ const DashArray& dashes = WebCore::dashArrayFromRenderingStyle(style);
+ double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0);
+
+ unsigned int dashLength = !dashes.isEmpty() ? dashes.size() : 0;
+ if(dashLength) {
+ QVector<qreal> pattern;
+ unsigned int count = (dashLength % 2) == 0 ? dashLength : dashLength * 2;
+
+ for(unsigned int i = 0; i < count; i++)
+ pattern.append(dashes[i % dashLength] / (float)s.width());
+
+ s.setDashPattern(pattern);
+
+ Q_UNUSED(dashOffset);
+ // TODO: dash-offset, does/will qt4 API allow it? (Rob)
+ }
+
+ return s.createStroke(path);
+}
+
+FloatRect RenderPath::strokeBBox() const
+{
+ QPainterPath outline = getPathStroke(*(path().platformPath()), this, style());
+ return outline.boundingRect();
+}
+
+}
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp
new file mode 100644
index 0000000..7240c49
--- /dev/null
+++ b/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp
@@ -0,0 +1,110 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerGradient.h"
+
+#include "GraphicsContext.h"
+#include "RenderObject.h"
+#include "RenderStyle.h"
+#include "SVGGradientElement.h"
+
+#include <QPainter>
+#include <QPainterPath>
+#include <QColor>
+#include <QGradient>
+
+namespace WebCore {
+
+// Helper function used by linear & radial gradient
+void SVGPaintServerGradient::fillColorArray(QGradient& gradient, const Vector<SVGGradientStop>& stops,
+ float opacity) const
+{
+ for (unsigned i = 0; i < stops.size(); ++i) {
+ float offset = stops[i].first;
+ Color color = stops[i].second;
+
+ QColor c(color.red(), color.green(), color.blue());
+ c.setAlpha(int(color.alpha() * opacity));
+
+ gradient.setColorAt(offset, c);
+ }
+}
+
+bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object,
+ SVGPaintTargetType type, bool isPaintingText) const
+{
+ m_ownerElement->buildGradient();
+
+ QPainter* painter(context ? context->platformContext() : 0);
+ Q_ASSERT(painter);
+
+ QPainterPath* path(context ? context->currentPath() : 0);
+ Q_ASSERT(path);
+
+ RenderStyle* renderStyle = object->style();
+
+ QGradient gradient = setupGradient(context, object);
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(Qt::NoBrush);
+
+ if (spreadMethod() == SPREADMETHOD_REPEAT)
+ gradient.setSpread(QGradient::RepeatSpread);
+ else if (spreadMethod() == SPREADMETHOD_REFLECT)
+ gradient.setSpread(QGradient::ReflectSpread);
+ else
+ gradient.setSpread(QGradient::PadSpread);
+ double opacity = 1.0;
+
+ if ((type & ApplyToFillTargetType) && renderStyle->svgStyle()->hasFill()) {
+ fillColorArray(gradient, gradientStops(), opacity);
+
+ QBrush brush(gradient);
+ brush.setMatrix(gradientTransform());
+
+ painter->setBrush(brush);
+ context->setFillRule(renderStyle->svgStyle()->fillRule());
+ }
+
+ if ((type & ApplyToStrokeTargetType) && renderStyle->svgStyle()->hasStroke()) {
+ fillColorArray(gradient, gradientStops(), opacity);
+
+ QPen pen;
+ QBrush brush(gradient);
+ brush.setMatrix(gradientTransform());
+
+ setPenProperties(object, renderStyle, pen);
+ pen.setBrush(brush);
+
+ painter->setPen(pen);
+ }
+
+ return true;
+}
+
+} // namespace WebCore
+
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerLinearGradientQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerLinearGradientQt.cpp
new file mode 100644
index 0000000..69934ab
--- /dev/null
+++ b/WebCore/svg/graphics/qt/SVGPaintServerLinearGradientQt.cpp
@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerLinearGradient.h"
+#include "SVGGradientElement.h"
+
+#include "GraphicsContext.h"
+#include "RenderPath.h"
+
+#include <QLinearGradient>
+#include <QPainter>
+#include <QPainterPath>
+
+namespace WebCore {
+
+QGradient SVGPaintServerLinearGradient::setupGradient(GraphicsContext*& context, const RenderObject* object) const
+{
+ QPainterPath* path(context ? context->currentPath() : 0);
+ Q_ASSERT(path);
+
+ double x1, x2, y1, y2;
+ if (boundingBoxMode()) {
+ QRectF bbox = path->boundingRect();
+ x1 = bbox.x();
+ y1 = bbox.y();
+ x2 = bbox.x() + bbox.width();
+ y2 = bbox.y() + bbox.height();
+ } else {
+ x1 = gradientStart().x();
+ y1 = gradientStart().y();
+ x2 = gradientEnd().x();
+ y2 = gradientEnd().y();
+ }
+
+ QLinearGradient gradient(QPointF(x1, y1), QPointF(x2, y2));
+
+ return gradient;
+}
+
+} // namespace WebCore
+
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp
new file mode 100644
index 0000000..119e0b0
--- /dev/null
+++ b/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerPattern.h"
+
+namespace WebCore {
+
+bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ // FIXME: Reactivate old pattern code
+
+/*
+ QPainter* painter(context ? context->platformContext() : 0);
+ Q_ASSERT(painter);
+
+ QPainterPath* _path = static_cast<QPainterPath*>(qtContext->path());
+ Q_ASSERT(_path != 0);
+
+ RenderStyle* renderStyle = object->style();
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(Qt::NoBrush);
+ QImage* patternimage = new QImage(tile()->bits(), tile()->width(), tile()->height(), QImage::Format_ARGB32_Premultiplied);
+ patternimage->setAlphaBuffer(true);
+ if (type & APPLY_TO_FILL) {
+ //QColor c = color();
+ //c.setAlphaF(style->fillPainter()->opacity() * style->opacity() * opacity());
+ KRenderingFillPainter fillPainter = KSVGPainterFactory::fillPainter(renderStyle, object);
+ QBrush brush(QPixmap::fromImage(*patternimage));
+ _path->setFillRule(fillPainter.fillRule() == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
+ painter->setBrush(brush);
+ }
+ if (type & APPLY_TO_STROKE) {
+ //QColor c = color();
+ //c.setAlphaF(style->strokePainter()->opacity() * style->opacity() * opacity());
+ KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(renderStyle, object);
+
+ QPen pen;
+ QBrush brush(QPixmap::fromImage(*patternimage));
+
+ setPenProperties(strokePainter, pen);
+ pen.setBrush(brush);
+ painter->setPen(pen);
+ }
+
+ painter->drawPath(*_path);
+
+ delete patternimage;
+*/
+
+ return true;
+}
+
+} // namespace WebCore
+
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp
new file mode 100644
index 0000000..db20347
--- /dev/null
+++ b/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp
@@ -0,0 +1,104 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServer.h"
+
+#include "GraphicsContext.h"
+#include "SVGRenderStyle.h"
+#include "RenderObject.h"
+
+#include <QPainter>
+#include <QVector>
+
+namespace WebCore {
+
+void SVGPaintServer::setPenProperties(const RenderObject* object, const RenderStyle* style, QPen& pen) const
+{
+ pen.setWidthF(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0));
+
+ if (style->svgStyle()->capStyle() == ButtCap)
+ pen.setCapStyle(Qt::FlatCap);
+ else if (style->svgStyle()->capStyle() == RoundCap)
+ pen.setCapStyle(Qt::RoundCap);
+
+ if (style->svgStyle()->joinStyle() == MiterJoin) {
+ pen.setJoinStyle(Qt::MiterJoin);
+ pen.setMiterLimit((qreal) style->svgStyle()->strokeMiterLimit());
+ } else if(style->svgStyle()->joinStyle() == RoundJoin)
+ pen.setJoinStyle(Qt::RoundJoin);
+
+ const DashArray& dashes = WebCore::dashArrayFromRenderingStyle(style);
+ double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0);
+
+ unsigned int dashLength = !dashes.isEmpty() ? dashes.size() : 0;
+ if(dashLength) {
+ QVector<qreal> pattern;
+ unsigned int count = (dashLength % 2) == 0 ? dashLength : dashLength * 2;
+
+ for(unsigned int i = 0; i < count; i++)
+ pattern.append(dashes[i % dashLength] / (float)pen.widthF());
+
+ pen.setDashPattern(pattern);
+
+ Q_UNUSED(dashOffset);
+ // TODO: dash-offset, does/will qt4 API allow it? (Rob)
+ }
+}
+
+void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
+{
+ if (!setup(context, path, type))
+ return;
+
+ renderPath(context, path, type);
+ teardown(context, path, type);
+}
+
+void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const
+{
+ // no-op
+}
+
+void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
+{
+ RenderStyle* renderStyle = path->style();
+
+ QPainter* painter(context ? context->platformContext() : 0);
+ Q_ASSERT(painter);
+
+ QPainterPath* painterPath(context ? context->currentPath() : 0);
+ Q_ASSERT(painterPath);
+
+ if ((type & ApplyToFillTargetType) && renderStyle->svgStyle()->hasFill())
+ painter->fillPath(*painterPath, painter->brush());
+
+ if ((type & ApplyToStrokeTargetType) && renderStyle->svgStyle()->hasStroke())
+ painter->strokePath(*painterPath, painter->pen());
+}
+
+} // namespace WebCore
+
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp
new file mode 100644
index 0000000..95d71a3
--- /dev/null
+++ b/WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp
@@ -0,0 +1,98 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerRadialGradient.h"
+
+#include "GraphicsContext.h"
+#include "RenderPath.h"
+
+#include <math.h>
+#include <QPainter>
+#include <QPainterPath>
+#include <QRadialGradient>
+
+namespace WebCore {
+
+QGradient SVGPaintServerRadialGradient::setupGradient(GraphicsContext*& context, const RenderObject* object) const
+{
+ QPainter* painter(context ? context->platformContext() : 0);
+ Q_ASSERT(painter);
+
+ QPainterPath* path(context ? context->currentPath() : 0);
+ Q_ASSERT(path);
+
+ RenderStyle* renderStyle = object->style();
+
+ QMatrix mat = painter->matrix();
+
+ double cx, fx, cy, fy, r;
+ if (boundingBoxMode()) {
+ QRectF bbox = path->boundingRect();
+ cx = double(bbox.left()) + (double(gradientCenter().x() / 100.0) * double(bbox.width()));
+ cy = double(bbox.top()) + (double(gradientCenter().y() / 100.0) * double(bbox.height()));
+ fx = double(bbox.left()) + (double(gradientFocal().x() / 100.0) * double(bbox.width())) - cx;
+ fy = double(bbox.top()) + (double(gradientFocal().y() / 100.0) * double(bbox.height())) - cy;
+ r = double(gradientRadius() / 100.0) * (sqrt(pow(bbox.width(), 2) + pow(bbox.height(), 2)));
+
+ float width = bbox.width();
+ float height = bbox.height();
+
+ int diff = int(width - height); // allow slight tolerance
+ if (!(diff > -2 && diff < 2)) {
+ // make elliptical or circular depending on bbox aspect ratio
+ float ratioX = (width / height);
+ float ratioY = (height / width);
+ mat.scale((width > height) ? 1 : ratioX, (width > height) ? ratioY : 1);
+ }
+ } else {
+ cx = gradientCenter().x();
+ cy = gradientCenter().y();
+
+ fx = gradientFocal().x();
+ fy = gradientFocal().y();
+
+ fx -= cx;
+ fy -= cy;
+
+ r = gradientRadius();
+ }
+
+ if (sqrt(fx * fx + fy * fy) > r) {
+ // Spec: If (fx, fy) lies outside the circle defined by (cx, cy) and r, set (fx, fy)
+ // to the point of intersection of the line through (fx, fy) and the circle.
+ double angle = atan2(fy, fx);
+ fx = int(cos(angle) * r) - 1;
+ fy = int(sin(angle) * r) - 1;
+ }
+
+ QRadialGradient gradient(QPointF(cx, cy), gradientRadius(), QPointF(fx + cx, fy + cy));
+
+ return gradient;
+}
+
+} // namespace WebCore
+
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp
new file mode 100644
index 0000000..7b06a03
--- /dev/null
+++ b/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp
@@ -0,0 +1,71 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPaintServerSolid.h"
+
+#include "GraphicsContext.h"
+#include "RenderPath.h"
+
+#include <QPainter>
+
+namespace WebCore {
+
+bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ QPainter* painter(context ? context->platformContext() : 0);
+ Q_ASSERT(painter);
+
+ RenderStyle* renderStyle = object->style();
+ // TODO? painter->setOpacity(renderStyle->opacity());
+
+ QColor c = color();
+
+ if ((type & ApplyToFillTargetType) && renderStyle->svgStyle()->hasFill()) {
+ c.setAlphaF(renderStyle->svgStyle()->fillOpacity());
+
+ QBrush brush(c);
+ painter->setBrush(brush);
+ context->setFillRule(renderStyle->svgStyle()->fillRule());
+
+ /* if(isPaintingText()) ... */
+ }
+
+ if ((type & ApplyToStrokeTargetType) && renderStyle->svgStyle()->hasStroke()) {
+ c.setAlphaF(renderStyle->svgStyle()->strokeOpacity());
+
+ QPen pen(c);
+ setPenProperties(object, renderStyle, pen);
+ painter->setPen(pen);
+
+ /* if(isPaintingText()) ... */
+ }
+
+ return true;
+}
+
+} // namespace WebCore
+
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp b/WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp
new file mode 100644
index 0000000..42d3855
--- /dev/null
+++ b/WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp
@@ -0,0 +1,127 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ 2005 Apple Computer, Inc.
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGResourceClipper.h"
+
+#include "GraphicsContext.h"
+
+#include <QPainter>
+#include <QPainterPath>
+
+namespace WebCore {
+
+void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
+{
+ if (m_clipData.clipData().size() < 1)
+ return;
+
+ context->beginPath();
+
+ QPainterPath newPath;
+
+ bool heterogenousClipRules = false;
+ WindRule clipRule = m_clipData.clipData()[0].windRule;
+
+ unsigned int clipDataCount = m_clipData.clipData().size();
+ for (unsigned int x = 0; x < clipDataCount; x++) {
+ ClipData clipData = m_clipData.clipData()[x];
+ if (clipData.windRule != clipRule)
+ heterogenousClipRules = true;
+
+ QPainterPath path = *(clipData.path.platformPath());
+ if (path.isEmpty())
+ continue;
+
+ if (!newPath.isEmpty())
+ newPath.closeSubpath();
+
+ // Respect clipping units...
+ QMatrix transform;
+
+ if (clipData.bboxUnits) {
+ transform.translate(boundingBox.x(), boundingBox.y());
+ transform.scale(boundingBox.width(), boundingBox.height());
+ }
+
+ // TODO: support heterogenous clip rules!
+ //clipRule = (clipData.windRule() == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
+
+ for (int i = 0; i < path.elementCount(); ++i) {
+ const QPainterPath::Element &cur = path.elementAt(i);
+
+ switch (cur.type) {
+ case QPainterPath::MoveToElement:
+ newPath.moveTo(QPointF(cur.x, cur.y) * transform);
+ break;
+ case QPainterPath::LineToElement:
+ newPath.lineTo(QPointF(cur.x, cur.y) * transform);
+ break;
+ case QPainterPath::CurveToElement:
+ {
+ const QPainterPath::Element &c1 = path.elementAt(i + 1);
+ const QPainterPath::Element &c2 = path.elementAt(i + 2);
+
+ Q_ASSERT(c1.type == QPainterPath::CurveToDataElement);
+ Q_ASSERT(c2.type == QPainterPath::CurveToDataElement);
+
+ newPath.cubicTo(QPointF(cur.x, cur.y) * transform,
+ QPointF(c1.x, c1.y) * transform,
+ QPointF(c2.x, c2.y) * transform);
+
+ i += 2;
+ break;
+ }
+ case QPainterPath::CurveToDataElement:
+ Q_ASSERT(false);
+ break;
+ }
+ }
+ }
+
+ if (m_clipData.clipData().size()) {
+ // FIXME!
+ // We don't currently allow for heterogenous clip rules.
+ // we would have to detect such, draw to a mask, and then clip
+ // to that mask
+ // if (!CGContextIsPathEmpty(cgContext)) {
+ if (clipRule == RULE_EVENODD)
+ newPath.setFillRule(Qt::OddEvenFill);
+ else
+ newPath.setFillRule(Qt::WindingFill);
+ // }
+ }
+
+ QPainter* painter(context ? context->platformContext() : 0);
+ Q_ASSERT(painter);
+
+ painter->setClipPath(newPath);
+}
+
+} // namespace WebCore
+
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp b/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp
new file mode 100644
index 0000000..557f3dd
--- /dev/null
+++ b/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_EXPERIMENTAL_FEATURES)
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGResourceFilterPlatformData* SVGResourceFilter::createPlatformData()
+{
+ return 0;
+}
+
+void SVGResourceFilter::prepareFilter(GraphicsContext*&, const FloatRect&)
+{
+ // FIXME: implement me :-)
+}
+
+void SVGResourceFilter::applyFilter(GraphicsContext*&, const FloatRect&)
+{
+ // FIXME: implement me :-)
+}
+
+} // namespace WebCore
+
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGResourceMaskerQt.cpp b/WebCore/svg/graphics/qt/SVGResourceMaskerQt.cpp
new file mode 100644
index 0000000..2b89bac
--- /dev/null
+++ b/WebCore/svg/graphics/qt/SVGResourceMaskerQt.cpp
@@ -0,0 +1,38 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+
+ This file is part of the KDE project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ aint with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGResourceMasker.h"
+
+namespace WebCore {
+
+void SVGResourceMasker::applyMask(GraphicsContext*, const FloatRect&)
+{
+ // FIXME: implement me :-)
+}
+
+} // namespace WebCore
+
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/svgattrs.in b/WebCore/svg/svgattrs.in
new file mode 100644
index 0000000..8388133
--- /dev/null
+++ b/WebCore/svg/svgattrs.in
@@ -0,0 +1,247 @@
+accent-height
+accumulate
+additive
+alignment-baseline
+alphabetic
+amplitude
+animate
+arabic-form
+ascent
+attributeName
+attributeType
+azimuth
+baseFrequency
+baseline-shift
+baseProfile
+bbox
+begin
+bias
+by
+calcMode
+cap-height
+clip
+clip-path
+clip-rule
+clipPathUnits
+color
+color-interpolation
+color-interpolation-filters
+color-profile
+color-rendering
+contentScriptType
+contentStyleType
+cursor
+cx
+cy
+d
+descent
+diffuseConstant
+direction
+display
+divisor
+dominant-baseline
+dur
+dx
+dy
+edgeMode
+elevation
+enable-background
+end
+exponent
+externalResourcesRequired
+feColorMatrix
+feComposite
+feGaussianBlur
+feMorphology
+feTile
+fill
+fill-opacity
+fill-rule
+filter
+filterRes
+filterUnits
+flood-color
+flood-opacity
+font-family
+font-size
+font-size-adjust
+font-stretch
+font-style
+font-variant
+font-weight
+format
+from
+fx
+fy
+g1
+g2
+glyph-name
+glyph-orientation-horizontal
+glyph-orientation-vertical
+glyphRef
+gradientTransform
+gradientUnits
+hanging
+height
+horiz-adv-x
+horiz-origin-x
+horiz-origin-y
+ideographic
+image-rendering
+in
+in2
+intercept
+k
+k1
+k2
+k3
+k4
+kernelMatrix
+kernelUnitLength
+kerning
+keyPoints
+keySplines
+keyTimes
+lang
+lengthAdjust
+letter-spacing
+lighting-color
+limitingConeAngle
+local
+marker-end
+marker-mid
+marker-start
+markerHeight
+markerUnits
+markerWidth
+mask
+maskContentUnits
+maskUnits
+mathematical
+max
+media
+method
+min
+mode
+name
+numOctaves
+offset
+onactivate
+onbegin
+onend
+onfocusin
+onfocusout
+onrepeat
+onzoom
+opacity
+operator
+order
+orient
+orientation
+origin
+overflow
+overline-position
+overline-thickness
+panose-1
+path
+pathLength
+patternContentUnits
+patternTransform
+patternUnits
+pointer-events
+points
+pointsAtX
+pointsAtY
+pointsAtZ
+preserveAlpha
+preserveAspectRatio
+primitiveUnits
+r
+radius
+refX
+refY
+rendering-intent
+repeatCount
+repeatDur
+requiredExtensions
+requiredFeatures
+restart
+result
+rotate
+rx
+ry
+scale
+seed
+shape-rendering
+slope
+spacing
+specularConstant
+specularExponent
+spreadMethod
+startOffset
+stdDeviation
+stemh
+stemv
+stitchTiles
+stop-color
+stop-opacity
+strikethrough-position
+strikethrough-thickness
+stroke
+stroke-dasharray
+stroke-dashoffset
+stroke-linecap
+stroke-linejoin
+stroke-miterlimit
+stroke-opacity
+stroke-width
+style
+surfaceScale
+systemLanguage
+tableValues
+target
+targetX
+targetY
+text-anchor
+text-decoration
+text-rendering
+textLength
+title
+to
+transform
+type
+u1
+u2
+underline-position
+underline-thickness
+unicode
+unicode-bidi
+unicode-range
+units-per-em
+v-alphabetic
+v-hanging
+v-ideographic
+v-mathematical
+values
+version
+vert-adv-y
+vert-origin-x
+vert-origin-y
+viewBox
+viewTarget
+visibility
+width
+widths
+word-spacing
+writing-mode
+x
+x-height
+x1
+x2
+xChannelSelector
+y
+y1
+y2
+yChannelSelector
+z
+zoomAndPan
diff --git a/WebCore/svg/svgtags.in b/WebCore/svg/svgtags.in
new file mode 100644
index 0000000..0aa34e5
--- /dev/null
+++ b/WebCore/svg/svgtags.in
@@ -0,0 +1,107 @@
+a
+#if 0
+altGlyph
+altGlyphDef
+altGlyphItem
+#endif
+#ifdef ENABLE_SVG_ANIMATION
+animate
+animateColor
+animateMotion
+animateTransform
+#endif
+circle
+clipPath
+#if 0
+color_profile
+#endif
+cursor
+#if ENABLE_SVG_FONTS
+definition_src
+#endif
+defs
+desc
+ellipse
+#ifdef ENABLE_SVG_FILTERS
+feBlend
+feColorMatrix
+feComponentTransfer
+feComposite
+#if 0
+feConvolveMatrix
+#endif
+feDiffuseLighting
+feDisplacementMap
+feDistantLight
+feFlood
+feFuncA
+feFuncB
+feFuncG
+feFuncR
+feGaussianBlur
+feImage
+feMerge
+feMergeNode
+#if 0
+feMorphology
+#endif
+feOffset
+fePointLight
+feSpecularLighting
+feSpotLight
+feTile
+feTurbulence
+filter
+#endif
+#ifdef ENABLE_SVG_FONTS
+font
+font_face
+font_face_format
+font_face_name
+font_face_src
+font_face_uri
+#endif
+#ifdef ENABLE_SVG_FOREIGN_OBJECT
+foreignObject
+#endif
+g
+#ifdef ENABLE_SVG_FONTS
+glyph
+#endif
+#if 0
+glyphRef
+hkern
+#endif
+image
+line
+linearGradient
+marker
+mask
+metadata
+#ifdef ENABLE_SVG_FONTS
+missing_glyph
+#endif
+mpath
+path
+pattern
+polygon
+polyline
+radialGradient
+rect
+script
+set
+stop
+style
+svg
+switch
+symbol
+text
+textPath
+title
+tref
+tspan
+use
+view
+#if 0
+vkern
+#endif
diff --git a/WebCore/svg/xlinkattrs.in b/WebCore/svg/xlinkattrs.in
new file mode 100644
index 0000000..851af1a
--- /dev/null
+++ b/WebCore/svg/xlinkattrs.in
@@ -0,0 +1,7 @@
+actuate
+arcrole
+href
+role
+show
+title
+type