summaryrefslogtreecommitdiffstats
path: root/WebCore/svg
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:30:52 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:30:52 -0800
commit8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (patch)
tree11425ea0b299d6fb89c6d3618a22d97d5bf68d0f /WebCore/svg
parent648161bb0edfc3d43db63caed5cc5213bc6cb78f (diff)
downloadexternal_webkit-8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2.zip
external_webkit-8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2.tar.gz
external_webkit-8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2.tar.bz2
auto import from //depot/cupcake/@135843
Diffstat (limited to 'WebCore/svg')
-rw-r--r--WebCore/svg/ColorDistance.cpp94
-rw-r--r--WebCore/svg/ColorDistance.h53
-rw-r--r--WebCore/svg/ElementTimeControl.h48
-rw-r--r--WebCore/svg/ElementTimeControl.idl39
-rw-r--r--WebCore/svg/Filter.cpp39
-rw-r--r--WebCore/svg/Filter.h46
-rw-r--r--WebCore/svg/FilterBuilder.h51
-rw-r--r--WebCore/svg/FilterEffect.cpp42
-rw-r--r--WebCore/svg/FilterEffect.h48
-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.cpp213
-rw-r--r--WebCore/svg/SVGAElement.h73
-rw-r--r--WebCore/svg/SVGAElement.idl38
-rw-r--r--WebCore/svg/SVGAltGlyphElement.cpp89
-rw-r--r--WebCore/svg/SVGAltGlyphElement.h57
-rw-r--r--WebCore/svg/SVGAltGlyphElement.idl35
-rw-r--r--WebCore/svg/SVGAngle.cpp150
-rw-r--r--WebCore/svg/SVGAngle.h79
-rw-r--r--WebCore/svg/SVGAngle.idl45
-rw-r--r--WebCore/svg/SVGAnimateColorElement.cpp39
-rw-r--r--WebCore/svg/SVGAnimateColorElement.h43
-rw-r--r--WebCore/svg/SVGAnimateColorElement.idl31
-rw-r--r--WebCore/svg/SVGAnimateElement.cpp289
-rw-r--r--WebCore/svg/SVGAnimateElement.h73
-rw-r--r--WebCore/svg/SVGAnimateElement.idl32
-rw-r--r--WebCore/svg/SVGAnimateMotionElement.cpp244
-rw-r--r--WebCore/svg/SVGAnimateMotionElement.h79
-rw-r--r--WebCore/svg/SVGAnimateTransformElement.cpp207
-rw-r--r--WebCore/svg/SVGAnimateTransformElement.h69
-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/SVGAnimatedProperty.h460
-rw-r--r--WebCore/svg/SVGAnimatedRect.idl33
-rw-r--r--WebCore/svg/SVGAnimatedString.idl34
-rw-r--r--WebCore/svg/SVGAnimatedTemplate.h258
-rw-r--r--WebCore/svg/SVGAnimatedTransformList.idl33
-rw-r--r--WebCore/svg/SVGAnimationElement.cpp533
-rw-r--r--WebCore/svg/SVGAnimationElement.h125
-rw-r--r--WebCore/svg/SVGAnimationElement.idl40
-rw-r--r--WebCore/svg/SVGCircleElement.cpp99
-rw-r--r--WebCore/svg/SVGCircleElement.h62
-rw-r--r--WebCore/svg/SVGCircleElement.idl40
-rw-r--r--WebCore/svg/SVGClipPathElement.cpp123
-rw-r--r--WebCore/svg/SVGClipPathElement.h65
-rw-r--r--WebCore/svg/SVGClipPathElement.idl39
-rw-r--r--WebCore/svg/SVGColor.cpp119
-rw-r--r--WebCore/svg/SVGColor.h93
-rw-r--r--WebCore/svg/SVGColor.idl48
-rw-r--r--WebCore/svg/SVGComponentTransferFunctionElement.cpp106
-rw-r--r--WebCore/svg/SVGComponentTransferFunctionElement.h57
-rw-r--r--WebCore/svg/SVGComponentTransferFunctionElement.idl46
-rw-r--r--WebCore/svg/SVGCursorElement.cpp99
-rw-r--r--WebCore/svg/SVGCursorElement.h66
-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.h53
-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.cpp105
-rw-r--r--WebCore/svg/SVGDocument.h66
-rw-r--r--WebCore/svg/SVGDocument.idl34
-rw-r--r--WebCore/svg/SVGDocumentExtensions.cpp137
-rw-r--r--WebCore/svg/SVGDocumentExtensions.h131
-rw-r--r--WebCore/svg/SVGElement.cpp286
-rw-r--r--WebCore/svg/SVGElement.h137
-rw-r--r--WebCore/svg/SVGElement.idl36
-rw-r--r--WebCore/svg/SVGElementInstance.cpp572
-rw-r--r--WebCore/svg/SVGElementInstance.h211
-rw-r--r--WebCore/svg/SVGElementInstance.idl103
-rw-r--r--WebCore/svg/SVGElementInstanceList.cpp62
-rw-r--r--WebCore/svg/SVGElementInstanceList.h50
-rw-r--r--WebCore/svg/SVGElementInstanceList.idl32
-rw-r--r--WebCore/svg/SVGEllipseElement.cpp106
-rw-r--r--WebCore/svg/SVGEllipseElement.h63
-rw-r--r--WebCore/svg/SVGEllipseElement.idl40
-rw-r--r--WebCore/svg/SVGException.h58
-rw-r--r--WebCore/svg/SVGException.idl42
-rw-r--r--WebCore/svg/SVGExternalResourcesRequired.cpp62
-rw-r--r--WebCore/svg/SVGExternalResourcesRequired.h63
-rw-r--r--WebCore/svg/SVGExternalResourcesRequired.idl33
-rw-r--r--WebCore/svg/SVGFEBlendElement.cpp90
-rw-r--r--WebCore/svg/SVGFEBlendElement.h55
-rw-r--r--WebCore/svg/SVGFEBlendElement.idl43
-rw-r--r--WebCore/svg/SVGFEColorMatrixElement.cpp96
-rw-r--r--WebCore/svg/SVGFEColorMatrixElement.h53
-rw-r--r--WebCore/svg/SVGFEColorMatrixElement.idl42
-rw-r--r--WebCore/svg/SVGFEComponentTransferElement.cpp97
-rw-r--r--WebCore/svg/SVGFEComponentTransferElement.h50
-rw-r--r--WebCore/svg/SVGFEComponentTransferElement.idl33
-rw-r--r--WebCore/svg/SVGFECompositeElement.cpp106
-rw-r--r--WebCore/svg/SVGFECompositeElement.h56
-rw-r--r--WebCore/svg/SVGFECompositeElement.idl48
-rw-r--r--WebCore/svg/SVGFEDiffuseLightingElement.cpp115
-rw-r--r--WebCore/svg/SVGFEDiffuseLightingElement.h61
-rw-r--r--WebCore/svg/SVGFEDiffuseLightingElement.idl37
-rw-r--r--WebCore/svg/SVGFEDisplacementMapElement.cpp102
-rw-r--r--WebCore/svg/SVGFEDisplacementMapElement.h53
-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.cpp74
-rw-r--r--WebCore/svg/SVGFEFloodElement.h49
-rw-r--r--WebCore/svg/SVGFEFloodElement.idl32
-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.cpp89
-rw-r--r--WebCore/svg/SVGFEGaussianBlurElement.h57
-rw-r--r--WebCore/svg/SVGFEGaussianBlurElement.idl37
-rw-r--r--WebCore/svg/SVGFEImageElement.cpp113
-rw-r--r--WebCore/svg/SVGFEImageElement.h66
-rw-r--r--WebCore/svg/SVGFEImageElement.idl35
-rw-r--r--WebCore/svg/SVGFELightElement.cpp82
-rw-r--r--WebCore/svg/SVGFELightElement.h60
-rw-r--r--WebCore/svg/SVGFEMergeElement.cpp71
-rw-r--r--WebCore/svg/SVGFEMergeElement.h47
-rw-r--r--WebCore/svg/SVGFEMergeElement.idl32
-rw-r--r--WebCore/svg/SVGFEMergeNodeElement.cpp51
-rw-r--r--WebCore/svg/SVGFEMergeNodeElement.h48
-rw-r--r--WebCore/svg/SVGFEMergeNodeElement.idl32
-rw-r--r--WebCore/svg/SVGFEOffsetElement.cpp79
-rw-r--r--WebCore/svg/SVGFEOffsetElement.h52
-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.cpp115
-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.cpp74
-rw-r--r--WebCore/svg/SVGFETileElement.h50
-rw-r--r--WebCore/svg/SVGFETileElement.idl33
-rw-r--r--WebCore/svg/SVGFETurbulenceElement.cpp96
-rw-r--r--WebCore/svg/SVGFETurbulenceElement.h64
-rw-r--r--WebCore/svg/SVGFETurbulenceElement.idl48
-rw-r--r--WebCore/svg/SVGFilterElement.cpp156
-rw-r--r--WebCore/svg/SVGFilterElement.h73
-rw-r--r--WebCore/svg/SVGFilterElement.idl47
-rw-r--r--WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp128
-rw-r--r--WebCore/svg/SVGFilterPrimitiveStandardAttributes.h64
-rw-r--r--WebCore/svg/SVGFilterPrimitiveStandardAttributes.idl37
-rw-r--r--WebCore/svg/SVGFitToViewBox.cpp121
-rw-r--r--WebCore/svg/SVGFitToViewBox.h57
-rw-r--r--WebCore/svg/SVGFitToViewBox.idl34
-rw-r--r--WebCore/svg/SVGFont.cpp594
-rw-r--r--WebCore/svg/SVGFontData.cpp45
-rw-r--r--WebCore/svg/SVGFontData.h65
-rw-r--r--WebCore/svg/SVGFontElement.cpp243
-rw-r--r--WebCore/svg/SVGFontElement.h66
-rw-r--r--WebCore/svg/SVGFontElement.idl31
-rw-r--r--WebCore/svg/SVGFontFaceElement.cpp367
-rw-r--r--WebCore/svg/SVGFontFaceElement.h73
-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.cpp167
-rw-r--r--WebCore/svg/SVGForeignObjectElement.h64
-rw-r--r--WebCore/svg/SVGForeignObjectElement.idl40
-rw-r--r--WebCore/svg/SVGGElement.cpp85
-rw-r--r--WebCore/svg/SVGGElement.h61
-rw-r--r--WebCore/svg/SVGGElement.idl36
-rw-r--r--WebCore/svg/SVGGlyphElement.cpp178
-rw-r--r--WebCore/svg/SVGGlyphElement.h131
-rw-r--r--WebCore/svg/SVGGlyphElement.idl31
-rw-r--r--WebCore/svg/SVGGlyphMap.h109
-rw-r--r--WebCore/svg/SVGGradientElement.cpp169
-rw-r--r--WebCore/svg/SVGGradientElement.h74
-rw-r--r--WebCore/svg/SVGGradientElement.idl44
-rw-r--r--WebCore/svg/SVGHKernElement.cpp81
-rw-r--r--WebCore/svg/SVGHKernElement.h66
-rw-r--r--WebCore/svg/SVGHKernElement.idl27
-rw-r--r--WebCore/svg/SVGImageElement.cpp164
-rw-r--r--WebCore/svg/SVGImageElement.h79
-rw-r--r--WebCore/svg/SVGImageElement.idl42
-rw-r--r--WebCore/svg/SVGImageLoader.cpp65
-rw-r--r--WebCore/svg/SVGImageLoader.h44
-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.cpp323
-rw-r--r--WebCore/svg/SVGLength.h105
-rw-r--r--WebCore/svg/SVGLength.idl52
-rw-r--r--WebCore/svg/SVGLengthList.cpp80
-rw-r--r--WebCore/svg/SVGLengthList.h48
-rw-r--r--WebCore/svg/SVGLengthList.idl48
-rw-r--r--WebCore/svg/SVGLineElement.cpp103
-rw-r--r--WebCore/svg/SVGLineElement.h67
-rw-r--r--WebCore/svg/SVGLineElement.idl40
-rw-r--r--WebCore/svg/SVGLinearGradientElement.cpp159
-rw-r--r--WebCore/svg/SVGLinearGradientElement.h58
-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.cpp159
-rw-r--r--WebCore/svg/SVGLocatable.h64
-rw-r--r--WebCore/svg/SVGLocatable.idl40
-rw-r--r--WebCore/svg/SVGMPathElement.cpp58
-rw-r--r--WebCore/svg/SVGMPathElement.h54
-rw-r--r--WebCore/svg/SVGMarkerElement.cpp195
-rw-r--r--WebCore/svg/SVGMarkerElement.h89
-rw-r--r--WebCore/svg/SVGMarkerElement.idl55
-rw-r--r--WebCore/svg/SVGMaskElement.cpp214
-rw-r--r--WebCore/svg/SVGMaskElement.h73
-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.cpp75
-rw-r--r--WebCore/svg/SVGNumberList.h50
-rw-r--r--WebCore/svg/SVGNumberList.idl48
-rw-r--r--WebCore/svg/SVGPaint.cpp117
-rw-r--r--WebCore/svg/SVGPaint.h100
-rw-r--r--WebCore/svg/SVGPaint.idl52
-rw-r--r--WebCore/svg/SVGParserUtilities.cpp873
-rw-r--r--WebCore/svg/SVGParserUtilities.h71
-rw-r--r--WebCore/svg/SVGPathElement.cpp242
-rw-r--r--WebCore/svg/SVGPathElement.h115
-rw-r--r--WebCore/svg/SVGPathElement.idl112
-rw-r--r--WebCore/svg/SVGPathSeg.h95
-rw-r--r--WebCore/svg/SVGPathSeg.idl56
-rw-r--r--WebCore/svg/SVGPathSegArc.cpp44
-rw-r--r--WebCore/svg/SVGPathSegArc.h104
-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.cpp44
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubic.h98
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubicAbs.idl44
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubicRel.idl44
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubicSmooth.cpp43
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubicSmooth.h85
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubicSmoothAbs.idl40
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubicSmoothRel.idl40
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadratic.cpp44
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadratic.h85
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadraticAbs.idl40
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadraticRel.idl40
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.cpp44
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h59
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadraticSmoothAbs.idl36
-rw-r--r--WebCore/svg/SVGPathSegCurvetoQuadraticSmoothRel.idl36
-rw-r--r--WebCore/svg/SVGPathSegLineto.cpp44
-rw-r--r--WebCore/svg/SVGPathSegLineto.h59
-rw-r--r--WebCore/svg/SVGPathSegLinetoAbs.idl36
-rw-r--r--WebCore/svg/SVGPathSegLinetoHorizontal.cpp44
-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.cpp43
-rw-r--r--WebCore/svg/SVGPathSegLinetoVertical.h72
-rw-r--r--WebCore/svg/SVGPathSegLinetoVerticalAbs.idl34
-rw-r--r--WebCore/svg/SVGPathSegLinetoVerticalRel.idl34
-rw-r--r--WebCore/svg/SVGPathSegList.cpp260
-rw-r--r--WebCore/svg/SVGPathSegList.h51
-rw-r--r--WebCore/svg/SVGPathSegList.idl48
-rw-r--r--WebCore/svg/SVGPathSegMoveto.cpp43
-rw-r--r--WebCore/svg/SVGPathSegMoveto.h58
-rw-r--r--WebCore/svg/SVGPathSegMovetoAbs.idl36
-rw-r--r--WebCore/svg/SVGPathSegMovetoRel.idl36
-rw-r--r--WebCore/svg/SVGPatternElement.cpp322
-rw-r--r--WebCore/svg/SVGPatternElement.h85
-rw-r--r--WebCore/svg/SVGPatternElement.idl45
-rw-r--r--WebCore/svg/SVGPoint.idl36
-rw-r--r--WebCore/svg/SVGPointList.cpp60
-rw-r--r--WebCore/svg/SVGPointList.h49
-rw-r--r--WebCore/svg/SVGPointList.idl47
-rw-r--r--WebCore/svg/SVGPolyElement.cpp130
-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.cpp261
-rw-r--r--WebCore/svg/SVGPreserveAspectRatio.h92
-rw-r--r--WebCore/svg/SVGPreserveAspectRatio.idl52
-rw-r--r--WebCore/svg/SVGRadialGradientElement.cpp177
-rw-r--r--WebCore/svg/SVGRadialGradientElement.h59
-rw-r--r--WebCore/svg/SVGRadialGradientElement.idl36
-rw-r--r--WebCore/svg/SVGRect.idl38
-rw-r--r--WebCore/svg/SVGRectElement.cpp126
-rw-r--r--WebCore/svg/SVGRectElement.h65
-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.cpp541
-rw-r--r--WebCore/svg/SVGSVGElement.h167
-rw-r--r--WebCore/svg/SVGSVGElement.idl88
-rw-r--r--WebCore/svg/SVGScriptElement.cpp212
-rw-r--r--WebCore/svg/SVGScriptElement.h81
-rw-r--r--WebCore/svg/SVGScriptElement.idl35
-rw-r--r--WebCore/svg/SVGSetElement.cpp37
-rw-r--r--WebCore/svg/SVGSetElement.h43
-rw-r--r--WebCore/svg/SVGSetElement.idl31
-rw-r--r--WebCore/svg/SVGStopElement.cpp66
-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.cpp139
-rw-r--r--WebCore/svg/SVGStyleElement.h71
-rw-r--r--WebCore/svg/SVGStyleElement.idl40
-rw-r--r--WebCore/svg/SVGStyledElement.cpp281
-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.cpp126
-rw-r--r--WebCore/svg/SVGStyledTransformableElement.h75
-rw-r--r--WebCore/svg/SVGSwitchElement.cpp66
-rw-r--r--WebCore/svg/SVGSwitchElement.h61
-rw-r--r--WebCore/svg/SVGSwitchElement.idl36
-rw-r--r--WebCore/svg/SVGSymbolElement.cpp60
-rw-r--r--WebCore/svg/SVGSymbolElement.h54
-rw-r--r--WebCore/svg/SVGSymbolElement.idl35
-rw-r--r--WebCore/svg/SVGTRefElement.cpp82
-rw-r--r--WebCore/svg/SVGTRefElement.h53
-rw-r--r--WebCore/svg/SVGTRefElement.idl32
-rw-r--r--WebCore/svg/SVGTSpanElement.cpp64
-rw-r--r--WebCore/svg/SVGTSpanElement.h43
-rw-r--r--WebCore/svg/SVGTSpanElement.idl31
-rw-r--r--WebCore/svg/SVGTests.cpp120
-rw-r--r--WebCore/svg/SVGTests.h61
-rw-r--r--WebCore/svg/SVGTests.idl37
-rw-r--r--WebCore/svg/SVGTextContentElement.cpp529
-rw-r--r--WebCore/svg/SVGTextContentElement.h80
-rw-r--r--WebCore/svg/SVGTextContentElement.idl60
-rw-r--r--WebCore/svg/SVGTextElement.cpp134
-rw-r--r--WebCore/svg/SVGTextElement.h64
-rw-r--r--WebCore/svg/SVGTextElement.idl32
-rw-r--r--WebCore/svg/SVGTextPathElement.cpp107
-rw-r--r--WebCore/svg/SVGTextPathElement.h81
-rw-r--r--WebCore/svg/SVGTextPathElement.idl45
-rw-r--r--WebCore/svg/SVGTextPositioningElement.cpp78
-rw-r--r--WebCore/svg/SVGTextPositioningElement.h55
-rw-r--r--WebCore/svg/SVGTextPositioningElement.idl36
-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.h99
-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.cpp97
-rw-r--r--WebCore/svg/SVGTransformList.h56
-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.cpp70
-rw-r--r--WebCore/svg/SVGURIReference.h54
-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.cpp879
-rw-r--r--WebCore/svg/SVGUseElement.h112
-rw-r--r--WebCore/svg/SVGUseElement.idl44
-rw-r--r--WebCore/svg/SVGViewElement.cpp73
-rw-r--r--WebCore/svg/SVGViewElement.h59
-rw-r--r--WebCore/svg/SVGViewElement.idl35
-rw-r--r--WebCore/svg/SVGViewSpec.cpp179
-rw-r--r--WebCore/svg/SVGViewSpec.h67
-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/SynchronizableTypeWrapper.h180
-rw-r--r--WebCore/svg/animation/SMILTime.cpp64
-rw-r--r--WebCore/svg/animation/SMILTime.h74
-rw-r--r--WebCore/svg/animation/SMILTimeContainer.cpp286
-rw-r--r--WebCore/svg/animation/SMILTimeContainer.h95
-rw-r--r--WebCore/svg/animation/SVGSMILElement.cpp929
-rw-r--r--WebCore/svg/animation/SVGSMILElement.h197
-rw-r--r--WebCore/svg/graphics/SVGImage.cpp221
-rw-r--r--WebCore/svg/graphics/SVGImage.h84
-rw-r--r--WebCore/svg/graphics/SVGPaintServer.cpp183
-rw-r--r--WebCore/svg/graphics/SVGPaintServer.h101
-rw-r--r--WebCore/svg/graphics/SVGPaintServerGradient.cpp143
-rw-r--r--WebCore/svg/graphics/SVGPaintServerGradient.h142
-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.h88
-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.h60
-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.cpp160
-rw-r--r--WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp82
-rw-r--r--WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp59
-rw-r--r--WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp68
-rw-r--r--WebCore/svg/graphics/cairo/SVGResourceFilterCairo.cpp47
-rw-r--r--WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp48
-rw-r--r--WebCore/svg/graphics/cg/CgSupport.cpp100
-rw-r--r--WebCore/svg/graphics/cg/CgSupport.h50
-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.cpp336
-rw-r--r--WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp130
-rw-r--r--WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp77
-rw-r--r--WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp82
-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.mm129
-rw-r--r--WebCore/svg/graphics/filters/SVGDistantLightSource.h53
-rw-r--r--WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp177
-rw-r--r--WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h95
-rw-r--r--WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp135
-rw-r--r--WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h78
-rw-r--r--WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp116
-rw-r--r--WebCore/svg/graphics/filters/SVGFEDisplacementMap.h72
-rw-r--r--WebCore/svg/graphics/filters/SVGFEFlood.cpp81
-rw-r--r--WebCore/svg/graphics/filters/SVGFEFlood.h56
-rw-r--r--WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp81
-rw-r--r--WebCore/svg/graphics/filters/SVGFEGaussianBlur.h56
-rw-r--r--WebCore/svg/graphics/filters/SVGFEImage.cpp84
-rw-r--r--WebCore/svg/graphics/filters/SVGFEImage.h58
-rw-r--r--WebCore/svg/graphics/filters/SVGFEMerge.cpp78
-rw-r--r--WebCore/svg/graphics/filters/SVGFEMerge.h53
-rw-r--r--WebCore/svg/graphics/filters/SVGFEMorphology.cpp107
-rw-r--r--WebCore/svg/graphics/filters/SVGFEMorphology.h65
-rw-r--r--WebCore/svg/graphics/filters/SVGFEOffset.cpp81
-rw-r--r--WebCore/svg/graphics/filters/SVGFEOffset.h56
-rw-r--r--WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp147
-rw-r--r--WebCore/svg/graphics/filters/SVGFESpecularLighting.h81
-rw-r--r--WebCore/svg/graphics/filters/SVGFETile.cpp57
-rw-r--r--WebCore/svg/graphics/filters/SVGFETile.h48
-rw-r--r--WebCore/svg/graphics/filters/SVGFETurbulence.cpp145
-rw-r--r--WebCore/svg/graphics/filters/SVGFETurbulence.h79
-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.h58
-rw-r--r--WebCore/svg/graphics/filters/SVGPointLightSource.h51
-rw-r--r--WebCore/svg/graphics/filters/SVGSpotLightSource.h62
-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/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.cpp90
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerQt.cpp72
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp98
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp78
-rw-r--r--WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp127
-rw-r--r--WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp50
-rw-r--r--WebCore/svg/graphics/qt/SVGResourceMaskerQt.cpp38
-rw-r--r--WebCore/svg/svgattrs.in253
-rw-r--r--WebCore/svg/svgtags.in116
-rw-r--r--WebCore/svg/xlinkattrs.in11
569 files changed, 47152 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/ElementTimeControl.h b/WebCore/svg/ElementTimeControl.h
new file mode 100644
index 0000000..4c185b9
--- /dev/null
+++ b/WebCore/svg/ElementTimeControl.h
@@ -0,0 +1,48 @@
+/*
+ * 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 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 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 ElementTimeControl_h
+#define ElementTimeControl_h
+
+#if ENABLE(SVG)
+
+#include "ExceptionCode.h"
+
+namespace WebCore {
+
+ class ElementTimeControl {
+ public:
+ virtual ~ElementTimeControl() {}
+ virtual bool beginElement(ExceptionCode&) = 0;
+ virtual bool beginElementAt(float offset, ExceptionCode&) = 0;
+ virtual bool endElement(ExceptionCode&) = 0;
+ virtual bool endElementAt(float offset, ExceptionCode&) = 0;
+ };
+
+}
+
+#endif
+
+#endif
diff --git a/WebCore/svg/ElementTimeControl.idl b/WebCore/svg/ElementTimeControl.idl
new file mode 100644
index 0000000..569fefa
--- /dev/null
+++ b/WebCore/svg/ElementTimeControl.idl
@@ -0,0 +1,39 @@
+/*
+ * 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 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 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] ElementTimeControl {
+ boolean beginElement()
+ raises(DOMException);
+ boolean beginElementAt(in float offset)
+ raises(DOMException);
+ boolean endElement()
+ raises(DOMException);
+ boolean endElementAt(in float offset)
+ raises(DOMException);
+ };
+
+}
diff --git a/WebCore/svg/Filter.cpp b/WebCore/svg/Filter.cpp
new file mode 100644
index 0000000..24a9fb8
--- /dev/null
+++ b/WebCore/svg/Filter.cpp
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.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 "Filter.h"
+
+namespace WebCore {
+
+Filter::Filter(FilterEffect* effect)
+ : m_effect(effect)
+{
+}
+
+PassRefPtr<Filter> Filter::create(FilterEffect* effect)
+{
+ return adoptRef(new Filter(effect));
+}
+
+} //namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/Filter.h b/WebCore/svg/Filter.h
new file mode 100644
index 0000000..f3a110e
--- /dev/null
+++ b/WebCore/svg/Filter.h
@@ -0,0 +1,46 @@
+/*
+ Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.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 Filter_h
+#define Filter_h
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "FilterEffect.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+ class Filter : public RefCounted<Filter> {
+ public:
+ static PassRefPtr<Filter> create(FilterEffect*);
+
+ private:
+ Filter(FilterEffect* effect);
+
+ RefPtr<FilterEffect> m_effect;
+ };
+
+} //namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#endif
diff --git a/WebCore/svg/FilterBuilder.h b/WebCore/svg/FilterBuilder.h
new file mode 100644
index 0000000..630537c
--- /dev/null
+++ b/WebCore/svg/FilterBuilder.h
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.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 FilterBuilder_h
+#define FilterBuilder_h
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "PlatformString.h"
+#include "FilterEffect.h"
+#include "Filter.h"
+
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+ class FilterBuilder : public RefCounted<FilterBuilder> {
+ public:
+ void add(const String& id, PassRefPtr<FilterEffect> effect) { m_namedEffects.set(id.impl(), effect); }
+ FilterEffect* getEffectById(const String& id) const { return m_namedEffects.get(id.impl()).get(); }
+
+ PassRefPtr<Filter> filter() const { return m_filter; }
+
+ private:
+ HashMap<StringImpl*, RefPtr<FilterEffect> > m_namedEffects;
+
+ RefPtr<Filter> m_filter;
+ };
+
+} //namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#endif
diff --git a/WebCore/svg/FilterEffect.cpp b/WebCore/svg/FilterEffect.cpp
new file mode 100644
index 0000000..24c187c
--- /dev/null
+++ b/WebCore/svg/FilterEffect.cpp
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) Alex Mathews <possessedpenguinbob@gmail.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
+ 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 "FilterEffect.h"
+
+namespace WebCore {
+
+FilterEffect::FilterEffect()
+{
+}
+
+FilterEffect::~FilterEffect()
+{
+}
+
+TextStream& FilterEffect::externalRepresentation(TextStream& ts) const
+{
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/FilterEffect.h b/WebCore/svg/FilterEffect.h
new file mode 100644
index 0000000..8f53ae1
--- /dev/null
+++ b/WebCore/svg/FilterEffect.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.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
+ 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 FilterEffect_h
+#define FilterEffect_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "TextStream.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+ class FilterEffect : public RefCounted<FilterEffect> {
+ public:
+ virtual ~FilterEffect();
+
+ virtual void apply() = 0;
+ virtual void dump() = 0;
+
+ virtual TextStream& externalRepresentation(TextStream&) const;
+ protected:
+ FilterEffect();
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // FilterEffect_h
diff --git a/WebCore/svg/GradientAttributes.h b/WebCore/svg/GradientAttributes.h
new file mode 100644
index 0000000..a5f0f37
--- /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(SpreadMethodPad)
+ , m_boundingBoxMode(true)
+ , m_spreadMethodSet(false)
+ , m_boundingBoxModeSet(false)
+ , m_gradientTransformSet(false)
+ , m_stopsSet(false)
+ {
+ }
+
+ GradientSpreadMethod 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(GradientSpreadMethod 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
+ GradientSpreadMethod 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..9236af4
--- /dev/null
+++ b/WebCore/svg/SVGAElement.cpp
@@ -0,0 +1,213 @@
+/*
+ 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 "SVGSMILElement.h"
+#include "SVGNames.h"
+#include "XLinkNames.h"
+
+namespace WebCore {
+
+SVGAElement::SVGAElement(const QualifiedName& tagName, Document *doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGURIReference()
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_target(this, SVGNames::targetAttr)
+{
+}
+
+SVGAElement::~SVGAElement()
+{
+}
+
+String SVGAElement::title() const
+{
+ return getAttribute(XLinkNames::titleAttr);
+}
+
+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 = isLink();
+ setIsLink(!href().isNull());
+
+ if (wasLink != 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 (isLink() && (evt->type() == eventNames().clickEvent || (evt->type() == eventNames().keydownEvent && focused()))) {
+ MouseEvent* e = 0;
+ if (evt->type() == eventNames().clickEvent && evt->isMouseEvent())
+ e = static_cast<MouseEvent*>(evt);
+
+ KeyboardEvent* k = 0;
+ if (evt->type() == eventNames().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";
+
+ if (!evt->defaultPrevented()) {
+ String url = parseURL(href());
+#if ENABLE(SVG_ANIMATION)
+ if (url.startsWith("#")) {
+ Element* targetElement = document()->getElementById(url.substring(1));
+ if (SVGSMILElement::isSMILElement(targetElement)) {
+ SVGSMILElement* timed = static_cast<SVGSMILElement*>(targetElement);
+ timed->beginByLinkActivation();
+ evt->setDefaultHandled();
+ SVGStyledTransformableElement::defaultEventHandler(evt);
+ return;
+ }
+ }
+#endif
+ 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
+{
+ // http://www.w3.org/2003/01/REC-SVG11-20030114-errata#linking-text-environment
+ // The 'a' element may contain any element that its parent may contain, except itself.
+ if (child->hasTagName(SVGNames::aTag))
+ return false;
+ if (parent() && parent()->isSVGElement())
+ return static_cast<SVGElement*>(parent())->childShouldCreateRenderer(child);
+
+ 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..8890ca4
--- /dev/null
+++ b/WebCore/svg/SVGAElement.h
@@ -0,0 +1,73 @@
+/*
+ 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_DECLARATIONS(SVGAElement, SVGNames::aTagString, SVGNames::targetAttrString, 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/SVGAltGlyphElement.cpp b/WebCore/svg/SVGAltGlyphElement.cpp
new file mode 100644
index 0000000..e88e9b9
--- /dev/null
+++ b/WebCore/svg/SVGAltGlyphElement.cpp
@@ -0,0 +1,89 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ Copyright (C) 2008 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.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG_FONTS)
+#include "SVGAltGlyphElement.h"
+
+#include "ExceptionCode.h"
+#include "RenderInline.h"
+#include "RenderSVGTSpan.h"
+#include "SVGGlyphElement.h"
+#include "SVGNames.h"
+#include "XLinkNames.h"
+
+namespace WebCore {
+
+SVGAltGlyphElement::SVGAltGlyphElement(const QualifiedName& tagName, Document* doc)
+ : SVGTextPositioningElement(tagName, doc)
+{
+}
+
+SVGAltGlyphElement::~SVGAltGlyphElement()
+{
+}
+
+void SVGAltGlyphElement::setGlyphRef(const AtomicString& type, ExceptionCode& ec)
+{
+ ec = NO_MODIFICATION_ALLOWED_ERR;
+}
+
+const AtomicString& SVGAltGlyphElement::glyphRef() const
+{
+ return getAttribute(SVGNames::glyphRefAttr);
+}
+
+void SVGAltGlyphElement::setFormat(const AtomicString& type, ExceptionCode& ec)
+{
+ ec = NO_MODIFICATION_ALLOWED_ERR;
+}
+
+const AtomicString& SVGAltGlyphElement::format() const
+{
+ return getAttribute(SVGNames::formatAttr);
+}
+
+bool SVGAltGlyphElement::childShouldCreateRenderer(Node* child) const
+{
+ if (child->isTextNode())
+ return true;
+ return false;
+}
+
+RenderObject* SVGAltGlyphElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+ return new (arena) RenderSVGTSpan(this);
+}
+
+SVGGlyphElement* SVGAltGlyphElement::glyphElement() const
+{
+ Element* elt = document()->getElementById(getTarget(getAttribute(XLinkNames::hrefAttr)));
+ if (!elt || !elt->hasTagName(SVGNames::glyphTag))
+ return 0;
+ return static_cast<SVGGlyphElement*>(elt);
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGAltGlyphElement.h b/WebCore/svg/SVGAltGlyphElement.h
new file mode 100644
index 0000000..91c99e3
--- /dev/null
+++ b/WebCore/svg/SVGAltGlyphElement.h
@@ -0,0 +1,57 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ Copyright (C) 2008 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 SVGAltGlyphElement_h
+#define SVGAltGlyphElement_h
+
+#if ENABLE(SVG_FONTS)
+#include "AtomicString.h"
+#include "SVGTextPositioningElement.h"
+#include "SVGURIReference.h"
+
+namespace WebCore {
+
+ class SVGGlyphElement;
+
+ class SVGAltGlyphElement : public SVGTextPositioningElement,
+ public SVGURIReference {
+ public:
+ SVGAltGlyphElement(const QualifiedName&, Document*);
+ virtual ~SVGAltGlyphElement();
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+ bool childShouldCreateRenderer(Node*) const;
+
+ const AtomicString& glyphRef() const;
+ void setGlyphRef(const AtomicString&, ExceptionCode&);
+ const AtomicString& format() const;
+ void setFormat(const AtomicString&, ExceptionCode&);
+
+ SVGGlyphElement* glyphElement() const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGAltGlyphElement.idl b/WebCore/svg/SVGAltGlyphElement.idl
new file mode 100644
index 0000000..a00e346
--- /dev/null
+++ b/WebCore/svg/SVGAltGlyphElement.idl
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2008 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_FONTS] SVGAltGlyphElement : SVGTextPositioningElement, SVGURIReference {
+ attribute DOMString glyphRef
+ setter raises(DOMException);
+ attribute DOMString format
+ setter raises(DOMException);
+ };
+
+}
diff --git a/WebCore/svg/SVGAngle.cpp b/WebCore/svg/SVGAngle.cpp
new file mode 100644
index 0000000..a0cffa0
--- /dev/null
+++ b/WebCore/svg/SVGAngle.cpp
@@ -0,0 +1,150 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 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"
+#include "SVGAngle.h"
+
+#if ENABLE(SVG)
+
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+SVGAngle::SVGAngle()
+ : 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;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGAngle.h b/WebCore/svg/SVGAngle.h
new file mode 100644
index 0000000..13b9fd4
--- /dev/null
+++ b/WebCore/svg/SVGAngle.h
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 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.
+*/
+
+#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:
+ static PassRefPtr<SVGAngle> create()
+ {
+ return adoptRef(new 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);
+
+ // Throughout SVG 1.1 'SVGAngle' is only used for 'SVGMarkerElement' (orient-angle)
+ const QualifiedName& associatedAttributeName() const { return SVGNames::orientAttr; }
+
+ private:
+ SVGAngle();
+
+ 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..1555f5e
--- /dev/null
+++ b/WebCore/svg/SVGAnimateColorElement.cpp
@@ -0,0 +1,39 @@
+/*
+ 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_ANIMATION)
+#include "SVGAnimateColorElement.h"
+
+namespace WebCore {
+
+SVGAnimateColorElement::SVGAnimateColorElement(const QualifiedName& tagName, Document* doc)
+ : SVGAnimateElement(tagName, doc)
+{
+}
+
+}
+
+// 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..595f0a9
--- /dev/null
+++ b/WebCore/svg/SVGAnimateColorElement.h
@@ -0,0 +1,43 @@
+/*
+ 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_ANIMATION)
+
+#include "SVGAnimateElement.h"
+
+namespace WebCore {
+
+ // SVGAnimateElement implements superset of the functionality.
+ class SVGAnimateColorElement : public SVGAnimateElement {
+ public:
+ SVGAnimateColorElement(const QualifiedName&, Document*);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_ANIMATION)
+#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..4df1847
--- /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_ANIMATION] SVGAnimateColorElement : SVGAnimationElement {
+ }
+
+};
diff --git a/WebCore/svg/SVGAnimateElement.cpp b/WebCore/svg/SVGAnimateElement.cpp
new file mode 100644
index 0000000..c2a83c0
--- /dev/null
+++ b/WebCore/svg/SVGAnimateElement.cpp
@@ -0,0 +1,289 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ Copyright (C) 2008 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) && ENABLE(SVG_ANIMATION)
+#include "SVGAnimateElement.h"
+
+#include "ColorDistance.h"
+#include "FloatConversion.h"
+#include "SVGColor.h"
+#include "SVGParserUtilities.h"
+#include "SVGPathSegList.h"
+#include <math.h>
+
+using namespace std;
+
+namespace WebCore {
+
+SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName, Document* doc)
+ : SVGAnimationElement(tagName, doc)
+ , m_propertyType(StringProperty)
+ , m_fromNumber(0)
+ , m_toNumber(0)
+ , m_animatedNumber(numeric_limits<double>::infinity())
+{
+}
+
+SVGAnimateElement::~SVGAnimateElement()
+{
+}
+
+static bool parseNumberValueAndUnit(const String& in, double& value, String& unit)
+{
+ // FIXME: These are from top of my head, figure out all property types that can be animated as numbers.
+ unsigned unitLength = 0;
+ String parse = in.stripWhiteSpace();
+ if (parse.endsWith("%"))
+ unitLength = 1;
+ else if (parse.endsWith("px") || parse.endsWith("pt") || parse.endsWith("em"))
+ unitLength = 2;
+ else if (parse.endsWith("deg") || parse.endsWith("rad"))
+ unitLength = 3;
+ else if (parse.endsWith("grad"))
+ unitLength = 4;
+ String newUnit = parse.right(unitLength);
+ String number = parse.left(parse.length() - unitLength);
+ if (!unit.isEmpty() && newUnit != unit || number.isEmpty())
+ return false;
+ UChar last = number[number.length() - 1];
+ if (last < '0' || last > '9')
+ return false;
+ unit = newUnit;
+ bool ok;
+ value = number.toDouble(&ok);
+ return ok;
+}
+
+SVGAnimateElement::PropertyType SVGAnimateElement::determinePropertyType(const String& attribute) const
+{
+ // FIXME: We need a full property table for figuring this out reliably.
+ if (hasTagName(SVGNames::animateColorTag))
+ return ColorProperty;
+ if (attribute == "d")
+ return PathProperty;
+ if (attribute == "color" || attribute == "fill" || attribute == "stroke")
+ return ColorProperty;
+ return NumberProperty;
+}
+
+void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement* resultElement)
+{
+ ASSERT(percentage >= 0.f && percentage <= 1.f);
+ ASSERT(resultElement);
+ if (hasTagName(SVGNames::setTag))
+ percentage = 1.f;
+ if (!resultElement->hasTagName(SVGNames::animateTag) && !resultElement->hasTagName(SVGNames::animateColorTag)
+ && !resultElement->hasTagName(SVGNames::setTag))
+ return;
+ SVGAnimateElement* results = static_cast<SVGAnimateElement*>(resultElement);
+ // Can't accumulate over a string property.
+ if (results->m_propertyType == StringProperty && m_propertyType != StringProperty)
+ return;
+ if (m_propertyType == NumberProperty) {
+ // To animation uses contributions from the lower priority animations as the base value.
+ if (animationMode() == ToAnimation)
+ m_fromNumber = results->m_animatedNumber;
+
+ double number = (m_toNumber - m_fromNumber) * percentage + m_fromNumber;
+
+ // FIXME: This is not correct for values animation.
+ if (isAccumulated() && repeat)
+ number += m_toNumber * repeat;
+ if (isAdditive() && animationMode() != ToAnimation)
+ results->m_animatedNumber += number;
+ else
+ results->m_animatedNumber = number;
+ return;
+ }
+ if (m_propertyType == ColorProperty) {
+ if (animationMode() == ToAnimation)
+ m_fromColor = results->m_animatedColor;
+ Color color = ColorDistance(m_fromColor, m_toColor).scaledDistance(percentage).addToColorAndClamp(m_fromColor);
+ // FIXME: Accumulate colors.
+ if (isAdditive() && animationMode() != ToAnimation)
+ results->m_animatedColor = ColorDistance::addColorsAndClamp(results->m_animatedColor, color);
+ else
+ results->m_animatedColor = color;
+ return;
+ }
+ AnimationMode animationMode = this->animationMode();
+ if (m_propertyType == PathProperty) {
+ if (percentage == 0)
+ results->m_animatedPath = m_fromPath;
+ else if (percentage == 1.f)
+ results->m_animatedPath = m_toPath;
+ else {
+ if (m_fromPath && m_toPath)
+ results->m_animatedPath = SVGPathSegList::createAnimated(m_fromPath.get(), m_toPath.get(), percentage);
+ else
+ results->m_animatedPath.clear();
+ // Fall back to discrete animation if the paths are not compatible
+ if (!results->m_animatedPath)
+ results->m_animatedPath = ((animationMode == FromToAnimation && percentage > 0.5f) || animationMode == ToAnimation || percentage == 1.0f)
+ ? m_toPath : m_fromPath;
+ }
+ return;
+ }
+ ASSERT(animationMode == FromToAnimation || animationMode == ToAnimation || animationMode == ValuesAnimation);
+ if ((animationMode == FromToAnimation && percentage > 0.5f) || animationMode == ToAnimation || percentage == 1.0f)
+ results->m_animatedString = m_toString;
+ else
+ results->m_animatedString = m_fromString;
+ // Higher priority replace animation overrides any additive results so far.
+ results->m_propertyType = StringProperty;
+}
+
+bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const String& toString)
+{
+ // FIXME: Needs more solid way determine target attribute type.
+ m_propertyType = determinePropertyType(attributeName());
+ if (m_propertyType == ColorProperty) {
+ m_fromColor = SVGColor::colorFromRGBColorString(fromString);
+ m_toColor = SVGColor::colorFromRGBColorString(toString);
+ if (m_fromColor.isValid() && m_toColor.isValid())
+ return true;
+ } else if (m_propertyType == NumberProperty) {
+ m_numberUnit = String();
+ if (parseNumberValueAndUnit(toString, m_toNumber, m_numberUnit)) {
+ // For to-animations the from number is calculated later
+ if (animationMode() == ToAnimation || parseNumberValueAndUnit(fromString, m_fromNumber, m_numberUnit))
+ return true;
+ }
+ } else if (m_propertyType == PathProperty) {
+ m_fromPath = SVGPathSegList::create(SVGNames::dAttr);
+ if (pathSegListFromSVGData(m_fromPath.get(), fromString)) {
+ m_toPath = SVGPathSegList::create(SVGNames::dAttr);
+ if (pathSegListFromSVGData(m_toPath.get(), toString))
+ return true;
+ }
+ m_fromPath.clear();
+ m_toPath.clear();
+ }
+ m_fromString = fromString;
+ m_toString = toString;
+ m_propertyType = StringProperty;
+ return true;
+}
+
+bool SVGAnimateElement::calculateFromAndByValues(const String& fromString, const String& byString)
+{
+ ASSERT(!hasTagName(SVGNames::setTag));
+ m_propertyType = determinePropertyType(attributeName());
+ if (m_propertyType == ColorProperty) {
+ m_fromColor = fromString.isEmpty() ? Color() : SVGColor::colorFromRGBColorString(fromString);
+ m_toColor = ColorDistance::addColorsAndClamp(m_fromColor, SVGColor::colorFromRGBColorString(byString));
+ if (!m_fromColor.isValid() || !m_toColor.isValid())
+ return false;
+ } else {
+ m_numberUnit = String();
+ m_fromNumber = 0;
+ if (!fromString.isEmpty() && !parseNumberValueAndUnit(fromString, m_fromNumber, m_numberUnit))
+ return false;
+ if (!parseNumberValueAndUnit(byString, m_toNumber, m_numberUnit))
+ return false;
+ m_toNumber += m_fromNumber;
+ }
+ return true;
+}
+
+void SVGAnimateElement::resetToBaseValue(const String& baseString)
+{
+ m_animatedString = baseString;
+ m_propertyType = determinePropertyType(attributeName());
+ if (m_propertyType == ColorProperty) {
+ m_animatedColor = baseString.isEmpty() ? Color() : SVGColor::colorFromRGBColorString(baseString);
+ if (m_animatedColor.isValid())
+ return;
+ } else if (m_propertyType == NumberProperty) {
+ if (baseString.isEmpty()) {
+ m_animatedNumber = 0;
+ m_numberUnit = String();
+ return;
+ }
+ if (parseNumberValueAndUnit(baseString, m_animatedNumber, m_numberUnit))
+ return;
+ } else if (m_propertyType == PathProperty) {
+ m_animatedPath.clear();
+ return;
+ }
+ m_propertyType = StringProperty;
+}
+
+void SVGAnimateElement::applyResultsToTarget()
+{
+ String valueToApply;
+ if (m_propertyType == ColorProperty)
+ valueToApply = m_animatedColor.name();
+ else if (m_propertyType == NumberProperty)
+ valueToApply = String::number(m_animatedNumber) + m_numberUnit;
+ else if (m_propertyType == PathProperty) {
+ if (!m_animatedPath || !m_animatedPath->numberOfItems())
+ valueToApply = m_animatedString;
+ else {
+ // We need to keep going to string and back because we are currently only able to paint
+ // "processed" paths where complex shapes are replaced with simpler ones. Path
+ // morphing needs to be done with unprocessed paths.
+ // FIXME: This could be optimized if paths were not processed at parse time.
+ unsigned itemCount = m_animatedPath->numberOfItems();
+ ExceptionCode ec;
+ for (unsigned n = 0; n < itemCount; ++n) {
+ RefPtr<SVGPathSeg> segment = m_animatedPath->getItem(n, ec);
+ valueToApply.append(segment->toString() + " ");
+ }
+ }
+ } else
+ valueToApply = m_animatedString;
+
+ setTargetAttributeAnimatedValue(valueToApply);
+}
+
+float SVGAnimateElement::calculateDistance(const String& fromString, const String& toString)
+{
+ m_propertyType = determinePropertyType(attributeName());
+ if (m_propertyType == NumberProperty) {
+ double from;
+ double to;
+ String unit;
+ if (!parseNumberValueAndUnit(fromString, from, unit))
+ return -1.f;
+ if (!parseNumberValueAndUnit(toString, to, unit))
+ return -1.f;
+ return narrowPrecisionToFloat(fabs(to - from));
+ } else if (m_propertyType == ColorProperty) {
+ Color from = SVGColor::colorFromRGBColorString(fromString);
+ if (!from.isValid())
+ return -1.f;
+ Color to = SVGColor::colorFromRGBColorString(toString);
+ if (!to.isValid())
+ return -1.f;
+ return ColorDistance(from, to).distance();
+ }
+ return -1.f;
+}
+
+}
+
+// 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..b90e5c8
--- /dev/null
+++ b/WebCore/svg/SVGAnimateElement.h
@@ -0,0 +1,73 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005 Rob Buis <buis@kde.org>
+ Copyright (C) 2008 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.
+*/
+
+#ifndef SVGAnimateElement_h
+#define SVGAnimateElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
+
+#include "Color.h"
+#include "SVGAnimationElement.h"
+
+namespace WebCore {
+ class SVGPathSegList;
+
+ class SVGAnimateElement : public SVGAnimationElement {
+ public:
+ SVGAnimateElement(const QualifiedName&, Document*);
+ virtual ~SVGAnimateElement();
+
+ protected:
+ virtual void resetToBaseValue(const String&);
+ virtual bool calculateFromAndToValues(const String& fromString, const String& toString);
+ virtual bool calculateFromAndByValues(const String& fromString, const String& byString);
+ virtual void calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement* resultElement);
+ virtual void applyResultsToTarget();
+ virtual float calculateDistance(const String& fromString, const String& toString);
+
+ private:
+ enum PropertyType { NumberProperty, ColorProperty, StringProperty, PathProperty };
+ PropertyType determinePropertyType(const String& attribute) const;
+ PropertyType m_propertyType;
+
+ double m_fromNumber;
+ double m_toNumber;
+ double m_animatedNumber;
+ String m_numberUnit;
+ Color m_fromColor;
+ Color m_toColor;
+ Color m_animatedColor;
+ String m_fromString;
+ String m_toString;
+ String m_animatedString;
+ RefPtr<SVGPathSegList> m_fromPath;
+ RefPtr<SVGPathSegList> m_toPath;
+ RefPtr<SVGPathSegList> m_animatedPath;
+ };
+
+} // 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..60ffc47
--- /dev/null
+++ b/WebCore/svg/SVGAnimateMotionElement.cpp
@@ -0,0 +1,244 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ (C) 2007 Rob Buis <buis@kde.org>
+ Copyright (C) 2008 Apple Inc. All Rights Reserved.
+
+ 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 "SVGElementInstance.h"
+#include "SVGMPathElement.h"
+#include "SVGParserUtilities.h"
+#include "SVGPathElement.h"
+#include "SVGTransformList.h"
+#include <math.h>
+
+namespace WebCore {
+
+using namespace SVGNames;
+
+SVGAnimateMotionElement::SVGAnimateMotionElement(const QualifiedName& tagName, Document* doc)
+ : SVGAnimationElement(tagName, doc)
+ , m_baseIndexInTransformList(0)
+ , m_angle(0)
+{
+}
+
+SVGAnimateMotionElement::~SVGAnimateMotionElement()
+{
+}
+
+bool SVGAnimateMotionElement::hasValidTarget() const
+{
+ if (!SVGAnimationElement::hasValidTarget())
+ return false;
+ SVGElement* targetElement = this->targetElement();
+ if (!targetElement->isStyledTransformable() && !targetElement->hasTagName(SVGNames::textTag))
+ 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)
+#if ENABLE(SVG_FOREIGN_OBJECT)
+ || targetElement->hasTagName(foreignObjectTag)
+#endif
+ )
+ return true;
+ return false;
+}
+
+void SVGAnimateMotionElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::pathAttr) {
+ m_path = Path();
+ pathFromSVGData(m_path, attr->value());
+ } else
+ SVGAnimationElement::parseMappedAttribute(attr);
+}
+
+SVGAnimateMotionElement::RotateMode SVGAnimateMotionElement::rotateMode() const
+{
+ static const AtomicString autoVal("auto");
+ static const AtomicString autoReverse("auto-reverse");
+ String rotate = getAttribute(SVGNames::rotateAttr);
+ if (rotate == autoVal)
+ return RotateAuto;
+ if (rotate == autoReverse)
+ return RotateAutoReverse;
+ return RotateAngle;
+}
+
+Path SVGAnimateMotionElement::animationPath() const
+{
+ for (Node* child = firstChild(); child; child = child->nextSibling()) {
+ if (child->hasTagName(SVGNames::mpathTag)) {
+ SVGMPathElement* mPath = static_cast<SVGMPathElement*>(child);
+ SVGPathElement* pathElement = mPath->pathElement();
+ if (pathElement)
+ return pathElement->toPathData();
+ return Path();
+ }
+ }
+ if (hasAttribute(SVGNames::pathAttr))
+ return m_path;
+ return Path();
+}
+
+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 anything except spaces at the end
+ return !skipOptionalSpaces(cur, end);
+}
+
+void SVGAnimateMotionElement::resetToBaseValue(const String&)
+{
+ if (!hasValidTarget())
+ return;
+ SVGElement* target = targetElement();
+ AffineTransform* transform = target->supplementalTransform();
+ if (!transform)
+ return;
+ transform->reset();
+}
+
+bool SVGAnimateMotionElement::calculateFromAndToValues(const String& fromString, const String& toString)
+{
+ parsePoint(fromString, m_fromPoint);
+ parsePoint(toString, m_toPoint);
+ return true;
+}
+
+bool SVGAnimateMotionElement::calculateFromAndByValues(const String& fromString, const String& byString)
+{
+ parsePoint(fromString, m_fromPoint);
+ FloatPoint byPoint;
+ parsePoint(byString, byPoint);
+ m_toPoint = FloatPoint(m_fromPoint.x() + byPoint.x(), m_fromPoint.y() + byPoint.y());
+ return true;
+}
+
+void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement*)
+{
+ SVGElement* target = targetElement();
+ if (!target)
+ return;
+ AffineTransform* transform = target->supplementalTransform();
+ if (!transform)
+ return;
+
+ if (!isAdditive())
+ transform->reset();
+
+ // FIXME: Implement accumulate.
+
+ if (animationMode() == PathAnimation) {
+ ASSERT(!animationPath().isEmpty());
+ Path path = animationPath();
+ float positionOnPath = path.length() * percentage;
+ bool ok;
+ FloatPoint position = path.pointAtLength(positionOnPath, ok);
+ if (ok) {
+ transform->translate(position.x(), position.y());
+ RotateMode rotateMode = this->rotateMode();
+ if (rotateMode == RotateAuto || rotateMode == RotateAutoReverse) {
+ float angle = path.normalAngleAtLength(positionOnPath, ok);
+ if (rotateMode == RotateAutoReverse)
+ angle += 180.f;
+ transform->rotate(angle);
+ }
+ }
+ return;
+ }
+ FloatSize diff = m_toPoint - m_fromPoint;
+ transform->translate(diff.width() * percentage + m_fromPoint.x(), diff.height() * percentage + m_fromPoint.y());
+}
+
+void SVGAnimateMotionElement::applyResultsToTarget()
+{
+ // We accumulate to the target element transform list so there is not much to do here.
+ SVGElement* targetElement = this->targetElement();
+ if (targetElement && targetElement->renderer())
+ targetElement->renderer()->setNeedsLayout(true);
+
+ // ...except in case where we have additional instances in <use> trees.
+ HashSet<SVGElementInstance*> instances = targetElement->instancesForElement();
+ HashSet<SVGElementInstance*>::iterator end = instances.end();
+ for (HashSet<SVGElementInstance*>::iterator it = instances.begin(); it != end; ++it) {
+ SVGElement* shadowTreeElement = (*it)->shadowTreeElement();
+ ASSERT(shadowTreeElement);
+ AffineTransform* transform = shadowTreeElement->supplementalTransform();
+ AffineTransform* t = targetElement->supplementalTransform();
+ transform->setMatrix(t->a(), t->b(), t->c(), t->d(), t->e(), t->f());
+ if (shadowTreeElement->renderer())
+ shadowTreeElement->renderer()->setNeedsLayout(true);
+ }
+}
+
+float SVGAnimateMotionElement::calculateDistance(const String& fromString, const String& toString)
+{
+ FloatPoint from;
+ FloatPoint to;
+ if (!parsePoint(fromString, from))
+ return -1.f;
+ if (!parsePoint(toString, to))
+ return -1.f;
+ FloatSize diff = to - from;
+ return sqrtf(diff.width() * diff.width() + diff.height() * diff.height());
+}
+
+}
+
+#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..ff58264
--- /dev/null
+++ b/WebCore/svg/SVGAnimateMotionElement.h
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2008 Apple Inc. All Rights Reserved.
+
+ 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_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 void parseMappedAttribute(MappedAttribute*);
+
+ private:
+ virtual void resetToBaseValue(const String&);
+ virtual bool calculateFromAndToValues(const String& fromString, const String& toString);
+ virtual bool calculateFromAndByValues(const String& fromString, const String& byString);
+ virtual void calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement* resultElement);
+ virtual void applyResultsToTarget();
+ virtual float calculateDistance(const String& fromString, const String& toString);
+ virtual Path animationPath() const;
+
+ enum RotateMode {
+ RotateAngle,
+ RotateAuto,
+ RotateAutoReverse
+ };
+ RotateMode rotateMode() const;
+
+ 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;
+
+ unsigned m_baseIndexInTransformList;
+
+ Path m_path;
+ Vector<float> m_keyPoints;
+ float m_angle;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_ANIMATION)
+#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..c5b4e9d
--- /dev/null
+++ b/WebCore/svg/SVGAnimateTransformElement.cpp
@@ -0,0 +1,207 @@
+/*
+ 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>
+ Copyright (C) 2008 Apple Inc. All Rights Reserved.
+
+ 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 "SVGElementInstance.h"
+#include "SVGParserUtilities.h"
+#include "SVGSVGElement.h"
+#include "SVGStyledTransformableElement.h"
+#include "SVGTextElement.h"
+#include "SVGTransform.h"
+#include "SVGTransformList.h"
+#include "SVGUseElement.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)
+ , m_baseIndexInTransformList(0)
+{
+}
+
+SVGAnimateTransformElement::~SVGAnimateTransformElement()
+{
+}
+
+bool SVGAnimateTransformElement::hasValidTarget() const
+{
+ SVGElement* targetElement = this->targetElement();
+ return SVGAnimationElement::hasValidTarget() && (targetElement->isStyledTransformable() || targetElement->hasTagName(SVGNames::textTag));
+}
+
+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);
+}
+
+
+static PassRefPtr<SVGTransformList> transformListFor(SVGElement* element)
+{
+ ASSERT(element);
+ if (element->isStyledTransformable())
+ return static_cast<SVGStyledTransformableElement*>(element)->transform();
+ if (element->hasTagName(SVGNames::textTag))
+ return static_cast<SVGTextElement*>(element)->transform();
+ return 0;
+}
+
+void SVGAnimateTransformElement::resetToBaseValue(const String& baseValue)
+{
+ if (!hasValidTarget())
+ return;
+ if (baseValue.isEmpty()) {
+ ExceptionCode ec;
+ RefPtr<SVGTransformList> list = transformListFor(targetElement());
+ list->clear(ec);
+ } else
+ targetElement()->setAttribute(SVGNames::transformAttr, baseValue);
+}
+
+void SVGAnimateTransformElement::calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement* resultElement)
+{
+ if (!hasValidTarget())
+ return;
+ SVGElement* targetElement = resultElement->targetElement();
+ RefPtr<SVGTransformList> transformList = transformListFor(targetElement);
+ ASSERT(transformList);
+
+ ExceptionCode ec;
+ if (!isAdditive())
+ transformList->clear(ec);
+ if (isAccumulated() && repeat) {
+ SVGTransform accumulatedTransform = SVGTransformDistance(m_fromTransform, m_toTransform).scaledDistance(repeat).addToSVGTransform(SVGTransform());
+ transformList->appendItem(accumulatedTransform, ec);
+ }
+ SVGTransform transform = SVGTransformDistance(m_fromTransform, m_toTransform).scaledDistance(percentage).addToSVGTransform(m_fromTransform);
+ transformList->appendItem(transform, ec);
+}
+
+bool SVGAnimateTransformElement::calculateFromAndToValues(const String& fromString, const String& toString)
+{
+ m_fromTransform = parseTransformValue(fromString);
+ if (!m_fromTransform.isValid())
+ return false;
+ m_toTransform = parseTransformValue(toString);
+ return m_toTransform.isValid();
+}
+
+bool SVGAnimateTransformElement::calculateFromAndByValues(const String& fromString, const String& byString)
+{
+
+ m_fromTransform = parseTransformValue(fromString);
+ if (!m_fromTransform.isValid())
+ return false;
+ m_toTransform = SVGTransformDistance::addSVGTransforms(m_fromTransform, parseTransformValue(byString));
+ return m_toTransform.isValid();
+}
+
+SVGTransform SVGAnimateTransformElement::parseTransformValue(const String& value) const
+{
+ if (value.isEmpty())
+ return SVGTransform(m_type);
+ SVGTransform result;
+ // FIXME: This is pretty dumb but parseTransformValue() wants those parenthesis.
+ String parseString("(" + value + ")");
+ const UChar* ptr = parseString.characters();
+ SVGTransformable::parseTransformValue(m_type, ptr, ptr + parseString.length(), result); // ignoring return value
+ return result;
+}
+
+void SVGAnimateTransformElement::applyResultsToTarget()
+{
+ if (!hasValidTarget())
+ return;
+ // We accumulate to the target element transform list so there is not much to do here.
+ SVGElement* targetElement = this->targetElement();
+ if (targetElement->renderer())
+ targetElement->renderer()->setNeedsLayout(true);
+
+ // ...except in case where we have additional instances in <use> trees.
+ HashSet<SVGElementInstance*> instances = targetElement->instancesForElement();
+ RefPtr<SVGTransformList> transformList = transformListFor(targetElement);
+ HashSet<SVGElementInstance*>::iterator end = instances.end();
+ for (HashSet<SVGElementInstance*>::iterator it = instances.begin(); it != end; ++it) {
+ SVGElement* shadowTreeElement = (*it)->shadowTreeElement();
+ ASSERT(shadowTreeElement);
+ if (shadowTreeElement->isStyledTransformable())
+ static_cast<SVGStyledTransformableElement*>(shadowTreeElement)->setTransform(transformList.get());
+ else if (shadowTreeElement->hasTagName(SVGNames::textTag))
+ static_cast<SVGTextElement*>(shadowTreeElement)->setTransform(transformList.get());
+ if (shadowTreeElement->renderer())
+ shadowTreeElement->renderer()->setNeedsLayout(true);
+ }
+}
+
+float SVGAnimateTransformElement::calculateDistance(const String& fromString, const String& toString)
+{
+ // FIXME: This is not correct in all cases. The spec demands that each component (translate x and y for example)
+ // is paced separately. To implement this we need to treat each component as individual animation everywhere.
+ SVGTransform from = parseTransformValue(fromString);
+ if (!from.isValid())
+ return -1.f;
+ SVGTransform to = parseTransformValue(toString);
+ if (!to.isValid() || from.type() != to.type())
+ return -1.f;
+ if (to.type() == SVGTransform::SVG_TRANSFORM_TRANSLATE) {
+ FloatSize diff = to.translate() - from.translate();
+ return sqrtf(diff.width() * diff.width() + diff.height() * diff.height());
+ }
+ if (to.type() == SVGTransform::SVG_TRANSFORM_ROTATE)
+ return fabsf(to.angle() - from.angle());
+ if (to.type() == SVGTransform::SVG_TRANSFORM_SCALE) {
+ FloatSize diff = to.scale() - from.scale();
+ return sqrtf(diff.width() * diff.width() + diff.height() * diff.height());
+ }
+ return -1.f;
+}
+
+}
+
+// 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..3c31d17
--- /dev/null
+++ b/WebCore/svg/SVGAnimateTransformElement.h
@@ -0,0 +1,69 @@
+/*
+ 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>
+ Copyright (C) 2008 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.
+*/
+
+#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*);
+
+ private:
+ virtual void resetToBaseValue(const String&);
+ virtual bool calculateFromAndToValues(const String& fromString, const String& toString);
+ virtual bool calculateFromAndByValues(const String& fromString, const String& byString);
+ virtual void calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement* resultElement);
+ virtual void applyResultsToTarget();
+ virtual float calculateDistance(const String& fromString, const String& toString);
+
+ SVGTransform parseTransformValue(const String&) const;
+
+ SVGTransform::SVGTransformType m_type;
+
+ unsigned m_baseIndexInTransformList;
+
+ SVGTransform m_toTransform;
+ SVGTransform m_fromTransform;
+ };
+
+} // 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/SVGAnimatedProperty.h b/WebCore/svg/SVGAnimatedProperty.h
new file mode 100644
index 0000000..e7439a4
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedProperty.h
@@ -0,0 +1,460 @@
+/*
+ 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 SVGAnimatedProperty_h
+#define SVGAnimatedProperty_h
+
+#if ENABLE(SVG)
+#include "SVGAnimatedTemplate.h"
+#include "SVGDocumentExtensions.h"
+#include "SynchronizableTypeWrapper.h"
+
+namespace WebCore {
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ class SVGAnimatedProperty;
+
+ template<typename OwnerType, typename OwnerElement, typename AnimatedType, typename DecoratedType, const char* TagName, const char* PropertyName>
+ class SVGAnimatedPropertyTearOff : public SVGAnimatedTemplate<DecoratedType> {
+ public:
+ typedef SVGAnimatedPropertyTearOff<OwnerType, OwnerElement, AnimatedType, DecoratedType, TagName, PropertyName> Self;
+ typedef SVGAnimatedProperty<OwnerType, AnimatedType, TagName, PropertyName> Creator;
+
+ static PassRefPtr<Self> create(const Creator& creator, const OwnerElement* owner, const QualifiedName& attributeName)
+ {
+ return adoptRef(new Self(creator, owner, attributeName));
+ }
+
+ virtual DecoratedType baseVal() const;
+ virtual void setBaseVal(DecoratedType);
+
+ virtual DecoratedType animVal() const;
+ virtual void setAnimVal(DecoratedType);
+
+ private:
+ SVGAnimatedPropertyTearOff(const Creator&, const OwnerElement*, const QualifiedName& attributeName);
+
+ Creator& m_creator;
+ RefPtr<OwnerElement> m_ownerElement;
+ };
+
+ // Helper templates mapping owner types to owner elements (for SVG*Element OwnerType is equal to OwnerElement, for non-SVG*Element derived types, they're different)
+ template<typename OwnerType, bool isDerivedFromSVGElement>
+ struct GetOwnerElementForType;
+
+ template<typename OwnerType>
+ struct IsDerivedFromSVGElement;
+
+ // Helper template used for synchronizing SVG <-> XML properties
+ template<typename OwnerElement, typename DecoratedType>
+ void synchronizeProperty(const OwnerElement* ownerElement, const QualifiedName& attributeName, DecoratedType baseValue);
+
+ // Abstract base class
+ class SVGAnimatedPropertyBase : Noncopyable {
+ public:
+ virtual ~SVGAnimatedPropertyBase() { }
+ virtual void synchronize() const = 0;
+ };
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ class SVGAnimatedProperty : public SVGAnimatedPropertyBase {
+ public:
+ typedef OwnerTypeArg OwnerType;
+ typedef AnimatedTypeArg AnimatedType;
+
+ typedef typename SVGAnimatedTypeValue<AnimatedType>::StorableType StorableType;
+ typedef typename SVGAnimatedTypeValue<AnimatedType>::DecoratedType DecoratedType;
+
+ typedef GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value> OwnerElementForType;
+ typedef typename OwnerElementForType::OwnerElement OwnerElement;
+ typedef SVGAnimatedPropertyTearOff<OwnerType, OwnerElement, AnimatedType, DecoratedType, TagName, PropertyName> TearOff;
+
+ // attributeName & attributeIdentifier may differ. For SVGMarkerElement, there are two exposed SVG animatable
+ // properties: orientType & orientAngle, though only one DOM attribute "orient", handle these cases!
+ SVGAnimatedProperty(const OwnerType*, const QualifiedName& attributeName);
+ SVGAnimatedProperty(const OwnerType*, const QualifiedName& attributeName, const AtomicString& attributeIdentifier);
+
+ // "Forwarding constructors" for primitive type assignment with more than one argument
+ template<typename T1>
+ SVGAnimatedProperty(const OwnerType*, const QualifiedName& attributeName,
+ const T1&);
+
+ template<typename T1>
+ SVGAnimatedProperty(const OwnerType*, const QualifiedName& attributeName, const AtomicString& attributeIdentifier,
+ const T1&);
+
+ template<typename T1, typename T2>
+ SVGAnimatedProperty(const OwnerType*, const QualifiedName& attributeName,
+ const T1&, const T2&);
+
+ template<typename T1, typename T2>
+ SVGAnimatedProperty(const OwnerType*, const QualifiedName& attributeName, const AtomicString& attributeIdentifier,
+ const T1&, const T2&);
+
+ template<typename T1, typename T2, typename T3>
+ SVGAnimatedProperty(const OwnerType*, const QualifiedName& attributeName,
+ const T1&, const T2&, const T3&);
+
+ template<typename T1, typename T2, typename T3>
+ SVGAnimatedProperty(const OwnerType*, const QualifiedName& attributeName, const AtomicString& attributeIdentifier,
+ const T1&, const T2&, const T3&);
+
+ DecoratedType value() const;
+ void setValue(DecoratedType);
+
+ DecoratedType baseValue() const;
+ void setBaseValue(DecoratedType);
+
+ // Tear offs only used by bindings, never in internal code
+ PassRefPtr<TearOff> animatedTearOff() const;
+
+ virtual void synchronize() const;
+
+ void startAnimation() const;
+ void stopAnimation();
+
+ private:
+ const OwnerElement* ownerElement() const;
+
+ private:
+ // We're a member variable on stack, living in OwnerType, NO need to ref here.
+ const OwnerType* m_ownerType;
+
+ const QualifiedName& m_attributeName;
+ const AtomicString& m_attributeIdentifier;
+
+ mutable SynchronizableTypeWrapper<StorableType> m_value;
+ };
+
+ // SVGAnimatedPropertyTearOff implementation
+ template<typename OwnerType, typename OwnerElement, typename AnimatedType, typename DecoratedType, const char* TagName, const char* PropertyName>
+ SVGAnimatedPropertyTearOff<OwnerType, OwnerElement, AnimatedType, DecoratedType, TagName, PropertyName>::SVGAnimatedPropertyTearOff(const Creator& creator,
+ const OwnerElement* owner,
+ const QualifiedName& attributeName)
+ : SVGAnimatedTemplate<DecoratedType>(attributeName)
+ , m_creator(const_cast<Creator&>(creator))
+ , m_ownerElement(const_cast<OwnerElement*>(owner))
+ {
+ ASSERT(m_ownerElement);
+ }
+
+ template<typename OwnerType, typename OwnerElement, typename AnimatedType, typename DecoratedType, const char* TagName, const char* PropertyName>
+ DecoratedType SVGAnimatedPropertyTearOff<OwnerType, OwnerElement, AnimatedType, DecoratedType, TagName, PropertyName>::baseVal() const
+ {
+ return m_creator.baseValue();
+ }
+
+ template<typename OwnerType, typename OwnerElement, typename AnimatedType, typename DecoratedType, const char* TagName, const char* PropertyName>
+ void SVGAnimatedPropertyTearOff<OwnerType, OwnerElement, AnimatedType, DecoratedType, TagName, PropertyName>::setBaseVal(DecoratedType newBaseVal)
+ {
+ m_creator.setBaseValue(newBaseVal);
+ }
+
+ template<typename OwnerType, typename OwnerElement, typename AnimatedType, typename DecoratedType, const char* TagName, const char* PropertyName>
+ DecoratedType SVGAnimatedPropertyTearOff<OwnerType, OwnerElement, AnimatedType, DecoratedType, TagName, PropertyName>::animVal() const
+ {
+ return m_creator.value();
+ }
+
+ template<typename OwnerType, typename OwnerElement, typename AnimatedType, typename DecoratedType, const char* TagName, const char* PropertyName>
+ void SVGAnimatedPropertyTearOff<OwnerType, OwnerElement, AnimatedType, DecoratedType, TagName, PropertyName>::setAnimVal(DecoratedType newAnimVal)
+ {
+ m_creator.setValue(newAnimVal);
+ }
+
+ // SVGAnimatedProperty implementation
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::SVGAnimatedProperty(const OwnerType* owner,
+ const QualifiedName& attributeName)
+ : m_ownerType(owner)
+ , m_attributeName(attributeName)
+ , m_attributeIdentifier(attributeName.localName())
+ , m_value()
+ {
+ ASSERT(m_ownerType);
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::SVGAnimatedProperty(const OwnerType* owner,
+ const QualifiedName& attributeName,
+ const AtomicString& attributeIdentifier)
+ : m_ownerType(owner)
+ , m_attributeName(attributeName)
+ , m_attributeIdentifier(attributeIdentifier)
+ , m_value()
+ {
+ ASSERT(m_ownerType);
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ template<typename T1>
+ SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::SVGAnimatedProperty(const OwnerType* owner,
+ const QualifiedName& attributeName,
+ const T1& arg1)
+ : m_ownerType(owner)
+ , m_attributeName(attributeName)
+ , m_attributeIdentifier(attributeName.localName())
+ , m_value(arg1)
+ {
+ ASSERT(m_ownerType);
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ template<typename T1>
+ SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::SVGAnimatedProperty(const OwnerType* owner,
+ const QualifiedName& attributeName,
+ const AtomicString& attributeIdentifier,
+ const T1& arg1)
+ : m_ownerType(owner)
+ , m_attributeName(attributeName)
+ , m_attributeIdentifier(attributeIdentifier)
+ , m_value(arg1)
+ {
+ ASSERT(m_ownerType);
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ template<typename T1, typename T2>
+ SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::SVGAnimatedProperty(const OwnerType* owner,
+ const QualifiedName& attributeName,
+ const T1& arg1,
+ const T2& arg2)
+ : m_ownerType(owner)
+ , m_attributeName(attributeName)
+ , m_attributeIdentifier(attributeName.localName())
+ , m_value(arg1, arg2)
+ {
+ ASSERT(m_ownerType);
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ template<typename T1, typename T2>
+ SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::SVGAnimatedProperty(const OwnerType* owner,
+ const QualifiedName& attributeName,
+ const AtomicString& attributeIdentifier,
+ const T1& arg1,
+ const T2& arg2)
+ : m_ownerType(owner)
+ , m_attributeName(attributeName)
+ , m_attributeIdentifier(attributeIdentifier)
+ , m_value(arg1, arg2)
+ {
+ ASSERT(m_ownerType);
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ template<typename T1, typename T2, typename T3>
+ SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::SVGAnimatedProperty(const OwnerType* owner,
+ const QualifiedName& attributeName,
+ const T1& arg1,
+ const T2& arg2,
+ const T3& arg3)
+ : m_ownerType(owner)
+ , m_attributeName(attributeName)
+ , m_attributeIdentifier(attributeName.localName())
+ , m_value(arg1, arg2, arg3)
+ {
+ ASSERT(m_ownerType);
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ template<typename T1, typename T2, typename T3>
+ SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::SVGAnimatedProperty(const OwnerType* owner,
+ const QualifiedName& attributeName,
+ const AtomicString& attributeIdentifier,
+ const T1& arg1,
+ const T2& arg2,
+ const T3& arg3)
+ : m_ownerType(owner)
+ , m_attributeName(attributeName)
+ , m_attributeIdentifier(attributeIdentifier)
+ , m_value(arg1, arg2, arg3)
+ {
+ ASSERT(m_ownerType);
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ typename SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::DecoratedType
+ SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::value() const
+ {
+ return m_value;
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ void SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::setValue(typename SVGAnimatedProperty::DecoratedType newValue)
+ {
+ m_value = newValue;
+ ownerElement()->setSynchronizedSVGAttributes(false);
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ typename SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::DecoratedType
+ SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::baseValue() const
+ {
+ const OwnerElement* ownerElement = this->ownerElement();
+ SVGDocumentExtensions* extensions = ownerElement->accessDocumentSVGExtensions();
+ if (extensions && extensions->hasBaseValue<DecoratedType>(ownerElement, m_attributeIdentifier))
+ return extensions->baseValue<DecoratedType>(ownerElement, m_attributeIdentifier);
+
+ return m_value;
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ void SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::setBaseValue(typename SVGAnimatedProperty::DecoratedType newValue)
+ {
+ const OwnerElement* ownerElement = this->ownerElement();
+ SVGDocumentExtensions* extensions = ownerElement->accessDocumentSVGExtensions();
+ if (extensions && extensions->hasBaseValue<DecoratedType>(ownerElement, m_attributeIdentifier)) {
+ extensions->setBaseValue<DecoratedType>(ownerElement, m_attributeIdentifier, newValue);
+ return;
+ }
+
+ // Only update stored property, if not animating
+ m_value = newValue;
+ ownerElement->setSynchronizedSVGAttributes(false);
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ PassRefPtr<typename SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::TearOff>
+ SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::animatedTearOff() const
+ {
+ return lookupOrCreateWrapper<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName, TearOff, OwnerElement>(*this, ownerElement(), m_attributeName, m_attributeIdentifier);
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ void SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::synchronize() const
+ {
+ if (!m_value.needsSynchronization())
+ return;
+
+ synchronizeProperty<OwnerElement, DecoratedType>(ownerElement(), m_attributeName, baseValue());
+ m_value.setSynchronized();
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ void SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::startAnimation() const
+ {
+ const OwnerElement* ownerElement = this->ownerElement();
+ SVGDocumentExtensions* extensions = ownerElement->accessDocumentSVGExtensions();
+ if (extensions) {
+ ASSERT(!extensions->hasBaseValue<DecoratedType>(ownerElement, m_attributeIdentifier));
+ extensions->setBaseValue<DecoratedType>(ownerElement, m_attributeIdentifier, m_value);
+ }
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ void SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::stopAnimation()
+ {
+ const OwnerElement* ownerElement = this->ownerElement();
+ SVGDocumentExtensions* extensions = ownerElement->accessDocumentSVGExtensions();
+ if (extensions) {
+ ASSERT(extensions->hasBaseValue<DecoratedType>(ownerElement, m_attributeIdentifier));
+ setValue(extensions->baseValue<DecoratedType>(ownerElement, m_attributeIdentifier));
+ extensions->removeBaseValue<AnimatedType>(ownerElement, m_attributeIdentifier);
+ }
+ }
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ const typename SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::OwnerElement*
+ SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::ownerElement() const
+ {
+ return OwnerElementForType::ownerElement(m_ownerType);
+ }
+
+ // GetOwnerElementForType implementation
+ template<typename OwnerType>
+ struct GetOwnerElementForType<OwnerType, true> : Noncopyable {
+ typedef OwnerType OwnerElement;
+
+ static const OwnerElement* ownerElement(const OwnerType* type)
+ {
+ return type;
+ }
+ };
+
+ template<typename OwnerType>
+ struct GetOwnerElementForType<OwnerType, false> : Noncopyable {
+ typedef SVGElement OwnerElement;
+
+ static const OwnerElement* ownerElement(const OwnerType* type)
+ {
+ const OwnerElement* context = type->contextElement();
+ ASSERT(context);
+ return context;
+ }
+ };
+
+ // IsDerivedFromSVGElement implementation
+ template<typename OwnerType>
+ struct IsDerivedFromSVGElement : Noncopyable {
+ static const bool value = true;
+ };
+
+ class SVGExternalResourcesRequired;
+ template<>
+ struct IsDerivedFromSVGElement<SVGExternalResourcesRequired> : Noncopyable {
+ static const bool value = false;
+ };
+
+ class SVGFitToViewBox;
+ template<>
+ struct IsDerivedFromSVGElement<SVGFitToViewBox> : Noncopyable {
+ static const bool value = false;
+ };
+
+ class SVGURIReference;
+ template<>
+ struct IsDerivedFromSVGElement<SVGURIReference> : Noncopyable {
+ static const bool value = false;
+ };
+
+ // Central function handling the main SVG<->XML synchronization part.
+ template<typename OwnerElement, typename DecoratedType>
+ void synchronizeProperty(const OwnerElement* ownerElement, const QualifiedName& attributeName, DecoratedType baseValue)
+ {
+ AtomicString value(SVGAnimatedTypeValue<DecoratedType>::toString(baseValue));
+
+ NamedAttrMap* namedAttrMap = ownerElement->attributes(false);
+ Attribute* old = namedAttrMap->getAttributeItem(attributeName);
+ if (old && value.isNull())
+ namedAttrMap->removeAttribute(old->name());
+ else if (!old && !value.isNull())
+ namedAttrMap->addAttribute(const_cast<OwnerElement*>(ownerElement)->createAttribute(QualifiedName(nullAtom, attributeName.localName(), nullAtom), value));
+ else if (old && !value.isNull())
+ old->setValue(value);
+ }
+
+ // Helper macro used to register animated properties within SVG* classes
+ #define ANIMATED_PROPERTY_DECLARATIONS(OwnerType, ElementTag, AttributeTag, AnimatedType, UpperProperty, LowerProperty) \
+ private: \
+ typedef SVGAnimatedProperty<OwnerType, AnimatedType, ElementTag, AttributeTag> SVGAnimatedProperty##UpperProperty; \
+ typedef SVGAnimatedTypeValue<AnimatedType>::DecoratedType DecoratedTypeFor##UpperProperty; \
+ SVGAnimatedProperty##UpperProperty m_##LowerProperty; \
+ public: \
+ DecoratedTypeFor##UpperProperty LowerProperty() const { return m_##LowerProperty.value(); } \
+ void set##UpperProperty(DecoratedTypeFor##UpperProperty type) { m_##LowerProperty.setValue(type); } \
+ DecoratedTypeFor##UpperProperty LowerProperty##BaseValue() const { return m_##LowerProperty.baseValue(); } \
+ void set##UpperProperty##BaseValue(DecoratedTypeFor##UpperProperty type) { m_##LowerProperty.setBaseValue(type); } \
+ PassRefPtr<SVGAnimatedProperty##UpperProperty::TearOff> LowerProperty##Animated() const { return m_##LowerProperty.animatedTearOff(); } \
+ void synchronize##UpperProperty() const { m_##LowerProperty.synchronize(); }
+
+};
+
+#endif
+#endif
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..3f04c5b
--- /dev/null
+++ b/WebCore/svg/SVGAnimatedTemplate.h
@@ -0,0 +1,258 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005 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 SVGAnimatedTemplate_h
+#define SVGAnimatedTemplate_h
+
+#if ENABLE(SVG)
+#include "AtomicString.h"
+#include "FloatRect.h"
+#include "SVGLength.h"
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+
+ class SVGAngle;
+ class SVGElement;
+ class SVGLengthList;
+ class SVGNumberList;
+ class SVGPreserveAspectRatio;
+ class SVGTransformList;
+ class String;
+ class QualifiedName;
+
+ struct SVGAnimatedTypeWrapperKey {
+ // Empty value
+ SVGAnimatedTypeWrapperKey()
+ : element(0)
+ , attributeName(0)
+ { }
+
+ // Deleted value
+ SVGAnimatedTypeWrapperKey(WTF::HashTableDeletedValueType)
+ : element(reinterpret_cast<SVGElement*>(-1))
+ {
+ }
+
+ bool isHashTableDeletedValue() const
+ {
+ return element == reinterpret_cast<SVGElement*>(-1);
+ }
+
+ 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(reinterpret_cast<const 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 void constructDeletedValue(SVGAnimatedTypeWrapperKey& slot)
+ {
+ new (&slot) SVGAnimatedTypeWrapperKey(WTF::HashTableDeletedValue);
+ }
+
+ static bool isDeletedValue(const SVGAnimatedTypeWrapperKey& value)
+ {
+ return value.isHashTableDeletedValue();
+ }
+ };
+
+ template<typename BareType>
+ class SVGAnimatedTemplate : public RefCounted<SVGAnimatedTemplate<BareType> > {
+ public:
+ virtual ~SVGAnimatedTemplate() { forgetWrapper(this); }
+
+ virtual BareType baseVal() const = 0;
+ virtual void setBaseVal(BareType) = 0;
+
+ virtual BareType animVal() const = 0;
+ virtual void setAnimVal(BareType) = 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; }
+
+ protected:
+ SVGAnimatedTemplate(const QualifiedName& attributeName)
+ : m_associatedAttributeName(attributeName)
+ {
+ }
+
+ private:
+ const QualifiedName& m_associatedAttributeName;
+ };
+
+ template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName>
+ class SVGAnimatedProperty;
+
+ template<typename OwnerType, typename AnimatedType, const char* TagName, const char* PropertyName, typename Type, typename OwnerElement>
+ PassRefPtr<Type> lookupOrCreateWrapper(const SVGAnimatedProperty<OwnerType, AnimatedType, TagName, PropertyName>& creator,
+ const OwnerElement* element, const QualifiedName& attrName, const AtomicString& attrIdentifier)
+ {
+ SVGAnimatedTypeWrapperKey key(element, attrIdentifier);
+ RefPtr<Type> wrapper = static_cast<Type*>(Type::wrapperCache()->get(key));
+
+ if (!wrapper) {
+ wrapper = Type::create(creator, element, attrName);
+ element->addSVGPropertySynchronizer(attrName, creator);
+ Type::wrapperCache()->set(key, wrapper.get());
+ }
+
+ return wrapper.release();
+ }
+
+ // Default implementation for pointer types
+ template<typename Type>
+ struct SVGAnimatedTypeValue : Noncopyable {
+ typedef RefPtr<Type> StorableType;
+ typedef Type* DecoratedType;
+
+ static Type null() { return 0; }
+ static AtomicString toString(Type type) { return type ? AtomicString(type->valueAsString()) : nullAtom; }
+ };
+
+ template<>
+ struct SVGAnimatedTypeValue<bool> : Noncopyable {
+ typedef bool StorableType;
+ typedef bool DecoratedType;
+
+ static bool null() { return false; }
+ static AtomicString toString(bool type) { return type ? "true" : "false"; }
+ };
+
+ template<>
+ struct SVGAnimatedTypeValue<int> : Noncopyable {
+ typedef int StorableType;
+ typedef int DecoratedType;
+
+ static int null() { return 0; }
+ static AtomicString toString(int type) { return String::number(type); }
+ };
+
+ template<>
+ struct SVGAnimatedTypeValue<long> : Noncopyable {
+ typedef long StorableType;
+ typedef long DecoratedType;
+
+ static long null() { return 0l; }
+ static AtomicString toString(long type) { return String::number(type); }
+ };
+
+ template<>
+ struct SVGAnimatedTypeValue<SVGLength> : Noncopyable {
+ typedef SVGLength StorableType;
+ typedef SVGLength DecoratedType;
+
+ static SVGLength null() { return SVGLength(); }
+ static AtomicString toString(const SVGLength& type) { return type.valueAsString(); }
+ };
+
+ template<>
+ struct SVGAnimatedTypeValue<float> : Noncopyable {
+ typedef float StorableType;
+ typedef float DecoratedType;
+
+ static float null() { return 0.0f; }
+ static AtomicString toString(float type) { return String::number(type); }
+ };
+
+ template<>
+ struct SVGAnimatedTypeValue<FloatRect> : Noncopyable {
+ typedef FloatRect StorableType;
+ typedef FloatRect DecoratedType;
+
+ static FloatRect null() { return FloatRect(); }
+ static AtomicString toString(const FloatRect& type) { return String::format("%f %f %f %f", type.x(), type.y(), type.width(), type.height()); }
+ };
+
+ template<>
+ struct SVGAnimatedTypeValue<String> : Noncopyable {
+ typedef String StorableType;
+ typedef String DecoratedType;
+
+ static String null() { return String(); }
+ static AtomicString toString(const String& type) { return type; }
+ };
+
+ // 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..5910ac8
--- /dev/null
+++ b/WebCore/svg/SVGAnimationElement.cpp
@@ -0,0 +1,533 @@
+/*
+ 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>
+ Copyright (C) 2008 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_ANIMATION)
+#include "SVGAnimationElement.h"
+
+#include "CSSComputedStyleDeclaration.h"
+#include "CSSParser.h"
+#include "CSSPropertyNames.h"
+#include "Document.h"
+#include "Event.h"
+#include "EventListener.h"
+#include "FloatConversion.h"
+#include "HTMLNames.h"
+#include "SVGElementInstance.h"
+#include "SVGNames.h"
+#include "SVGURIReference.h"
+#include "SVGUseElement.h"
+#include "XLinkNames.h"
+#include <math.h>
+
+using namespace std;
+
+namespace WebCore {
+
+SVGAnimationElement::SVGAnimationElement(const QualifiedName& tagName, Document* doc)
+ : SVGSMILElement(tagName, doc)
+ , SVGTests()
+ , SVGExternalResourcesRequired()
+ , m_animationValid(false)
+{
+}
+
+SVGAnimationElement::~SVGAnimationElement()
+{
+}
+
+static void parseKeyTimes(const String& parse, Vector<float>& result, bool verifyOrder)
+{
+ result.clear();
+ Vector<String> parseList;
+ parse.split(';', parseList);
+ for (unsigned n = 0; n < parseList.size(); ++n) {
+ String timeString = parseList[n];
+ bool ok;
+ float time = timeString.toFloat(&ok);
+ if (!ok || time < 0 || time > 1.f)
+ goto fail;
+ if (verifyOrder) {
+ if (!n) {
+ if (time != 0)
+ goto fail;
+ } else if (time < result.last())
+ goto fail;
+ }
+ result.append(time);
+ }
+ return;
+fail:
+ result.clear();
+}
+
+static void parseKeySplines(const String& parse, Vector<UnitBezier>& result)
+{
+ result.clear();
+ Vector<String> parseList;
+ parse.split(';', parseList);
+ for (unsigned n = 0; n < parseList.size(); ++n) {
+ Vector<String> parseSpline;
+ parseList[n].split(',', parseSpline);
+ // The spec says the sepator is a space, all tests use commas. Weird.
+ if (parseSpline.size() == 1)
+ parseList[n].split(' ', parseSpline);
+ if (parseSpline.size() != 4)
+ goto fail;
+ double curveValues[4];
+ for (unsigned i = 0; i < 4; ++i) {
+ String parseNumber = parseSpline[i];
+ bool ok;
+ curveValues[i] = parseNumber.toDouble(&ok);
+ if (!ok || curveValues[i] < 0.0 || curveValues[i] > 1.0)
+ goto fail;
+ }
+ result.append(UnitBezier(curveValues[0], curveValues[1], curveValues[2], curveValues[3]));
+ }
+ return;
+fail:
+ result.clear();
+}
+
+void SVGAnimationElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::valuesAttr)
+ attr->value().string().split(';', m_values);
+ else if (attr->name() == SVGNames::keyTimesAttr)
+ parseKeyTimes(attr->value(), m_keyTimes, true);
+ else if (attr->name() == SVGNames::keyPointsAttr && hasTagName(SVGNames::animateMotionTag)) {
+ // This is specified to be an animateMotion attribute only but it is simpler to put it here
+ // where the other timing calculatations are.
+ parseKeyTimes(attr->value(), m_keyPoints, false);
+ } else if (attr->name() == SVGNames::keySplinesAttr)
+ parseKeySplines(attr->value(), m_keySplines);
+ else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ SVGSMILElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGAnimationElement::attributeChanged(Attribute* attr, bool preserveDecls)
+{
+ // Assumptions may not hold after an attribute change.
+ m_animationValid = false;
+ SVGSMILElement::attributeChanged(attr, preserveDecls);
+}
+
+float SVGAnimationElement::getStartTime() const
+{
+ return narrowPrecisionToFloat(intervalBegin().value());
+}
+
+float SVGAnimationElement::getCurrentTime() const
+{
+ return narrowPrecisionToFloat(elapsed().value());
+}
+
+float SVGAnimationElement::getSimpleDuration(ExceptionCode&) const
+{
+ return narrowPrecisionToFloat(simpleDuration().value());
+}
+
+bool SVGAnimationElement::beginElement(ExceptionCode& ec)
+{
+ return beginElementAt(0, ec);
+}
+
+bool SVGAnimationElement::beginElementAt(float offset, ExceptionCode& ec)
+{
+ addBeginTime(elapsed() + offset);
+ return true;
+}
+
+bool SVGAnimationElement::endElement(ExceptionCode& ec)
+{
+ return endElementAt(0, ec);
+}
+
+bool SVGAnimationElement::endElementAt(float offset, ExceptionCode& ec)
+{
+ if (offset < 0)
+ return false;
+
+ addEndTime(elapsed() + offset);
+ return true;
+}
+
+SVGAnimationElement::AnimationMode SVGAnimationElement::animationMode() const
+{
+ // http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
+ if (hasTagName(SVGNames::setTag))
+ return ToAnimation;
+ if (!animationPath().isEmpty())
+ return PathAnimation;
+ if (hasAttribute(SVGNames::valuesAttr))
+ return ValuesAnimation;
+ if (!toValue().isEmpty())
+ return fromValue().isEmpty() ? ToAnimation : FromToAnimation;
+ if (!byValue().isEmpty())
+ return fromValue().isEmpty() ? ByAnimation : FromByAnimation;
+ return NoAnimation;
+}
+
+SVGAnimationElement::CalcMode SVGAnimationElement::calcMode() const
+{
+ static const AtomicString discrete("discrete");
+ static const AtomicString linear("linear");
+ static const AtomicString paced("paced");
+ static const AtomicString spline("spline");
+ const AtomicString& value = getAttribute(SVGNames::calcModeAttr);
+ if (value == discrete)
+ return CalcModeDiscrete;
+ if (value == linear)
+ return CalcModeLinear;
+ if (value == paced)
+ return CalcModePaced;
+ if (value == spline)
+ return CalcModeSpline;
+ return hasTagName(SVGNames::animateMotionTag) ? CalcModePaced : CalcModeLinear;
+}
+
+SVGAnimationElement::AttributeType SVGAnimationElement::attributeType() const
+{
+ static const AtomicString css("CSS");
+ static const AtomicString xml("XML");
+ const AtomicString& value = getAttribute(SVGNames::attributeTypeAttr);
+ if (value == css)
+ return AttributeTypeCSS;
+ if (value == xml)
+ return AttributeTypeXML;
+ return AttributeTypeAuto;
+}
+
+String SVGAnimationElement::toValue() const
+{
+ return getAttribute(SVGNames::toAttr);
+}
+
+String SVGAnimationElement::byValue() const
+{
+ return getAttribute(SVGNames::byAttr);
+}
+
+String SVGAnimationElement::fromValue() const
+{
+ return getAttribute(SVGNames::fromAttr);
+}
+
+bool SVGAnimationElement::isAdditive() const
+{
+ static const AtomicString sum("sum");
+ const AtomicString& value = getAttribute(SVGNames::additiveAttr);
+ return value == sum || animationMode() == ByAnimation;
+}
+
+bool SVGAnimationElement::isAccumulated() const
+{
+ static const AtomicString sum("sum");
+ const AtomicString& value = getAttribute(SVGNames::accumulateAttr);
+ return value == sum && animationMode() != ToAnimation;
+}
+
+bool SVGAnimationElement::hasValidTarget() const
+{
+ return targetElement();
+}
+
+bool SVGAnimationElement::attributeIsCSS(const String& attributeName)
+{
+ // FIXME: We should have a map of all SVG properties and their attribute types so we
+ // could validate animations better. The spec is very vague about this.
+ unsigned id = cssPropertyID(attributeName);
+ // SVG range
+ if (id >= CSSPropertyClipPath && id <= CSSPropertyWritingMode)
+ return true;
+ // Regular CSS properties also in SVG
+ return id == CSSPropertyColor || id == CSSPropertyDisplay || id == CSSPropertyOpacity
+ || (id >= CSSPropertyFont && id <= CSSPropertyFontWeight)
+ || id == CSSPropertyOverflow || id == CSSPropertyVisibility;
+}
+
+bool SVGAnimationElement::targetAttributeIsCSS() const
+{
+ AttributeType type = attributeType();
+ if (type == AttributeTypeCSS)
+ return true;
+ if (type == AttributeTypeXML)
+ return false;
+ return attributeIsCSS(attributeName());
+}
+
+void SVGAnimationElement::setTargetAttributeAnimatedValue(const String& value)
+{
+ if (!hasValidTarget())
+ return;
+ SVGElement* target = targetElement();
+ String attributeName = this->attributeName();
+ if (!target || attributeName.isEmpty() || value.isNull())
+ return;
+
+ // We don't want the instance tree to get rebuild. Instances are updated in the loop below.
+ if (target->isStyled())
+ static_cast<SVGStyledElement*>(target)->setInstanceUpdatesBlocked(true);
+
+ ExceptionCode ec;
+ bool isCSS = targetAttributeIsCSS();
+ if (isCSS) {
+ // FIXME: This should set the override style, not the inline style.
+ // Sadly override styles are not yet implemented.
+ target->style()->setProperty(attributeName, value, "", ec);
+ } else {
+ // FIXME: This should set the 'presentation' value, not the actual
+ // attribute value. Whatever that means in practice.
+ target->setAttribute(attributeName, value, ec);
+ }
+
+ if (target->isStyled())
+ static_cast<SVGStyledElement*>(target)->setInstanceUpdatesBlocked(false);
+
+ // If the target element is used in an <use> instance tree, update that as well.
+ HashSet<SVGElementInstance*> instances = target->instancesForElement();
+ HashSet<SVGElementInstance*>::iterator end = instances.end();
+ for (HashSet<SVGElementInstance*>::iterator it = instances.begin(); it != end; ++it) {
+ SVGElement* shadowTreeElement = (*it)->shadowTreeElement();
+ ASSERT(shadowTreeElement);
+ if (isCSS)
+ shadowTreeElement->style()->setProperty(attributeName, value, "", ec);
+ else
+ shadowTreeElement->setAttribute(attributeName, value, ec);
+ (*it)->correspondingUseElement()->setChanged();
+ }
+}
+
+void SVGAnimationElement::calculateKeyTimesForCalcModePaced()
+{
+ ASSERT(calcMode() == CalcModePaced);
+ ASSERT(animationMode() == ValuesAnimation);
+
+ unsigned valuesCount = m_values.size();
+ ASSERT(valuesCount > 1);
+ Vector<float> keyTimesForPaced;
+ float totalDistance = 0;
+ keyTimesForPaced.append(0);
+ for (unsigned n = 0; n < valuesCount - 1; ++n) {
+ // Distance in any units
+ float distance = calculateDistance(m_values[n], m_values[n + 1]);
+ if (distance < 0)
+ return;
+ totalDistance += distance;
+ keyTimesForPaced.append(distance);
+ }
+ if (!totalDistance)
+ return;
+
+ // Normalize.
+ for (unsigned n = 1; n < keyTimesForPaced.size() - 1; ++n)
+ keyTimesForPaced[n] = keyTimesForPaced[n - 1] + keyTimesForPaced[n] / totalDistance;
+ keyTimesForPaced[keyTimesForPaced.size() - 1] = 1.f;
+
+ // Use key times calculated based on pacing instead of the user provided ones.
+ m_keyTimes.swap(keyTimesForPaced);
+}
+
+static inline double solveEpsilon(double duration) { return 1. / (200. * duration); }
+
+float SVGAnimationElement::calculatePercentForSpline(float percent, unsigned splineIndex) const
+{
+ ASSERT(calcMode() == CalcModeSpline);
+ ASSERT(splineIndex < m_keySplines.size());
+ UnitBezier bezier = m_keySplines[splineIndex];
+ SMILTime duration = simpleDuration();
+ if (!duration.isFinite())
+ duration = 100.0;
+ return narrowPrecisionToFloat(bezier.solve(percent, solveEpsilon(duration.value())));
+}
+
+float SVGAnimationElement::calculatePercentFromKeyPoints(float percent) const
+{
+ ASSERT(!m_keyPoints.isEmpty());
+ ASSERT(calcMode() != CalcModePaced);
+ unsigned keyTimesCount = m_keyTimes.size();
+ ASSERT(keyTimesCount > 1);
+ ASSERT(m_keyPoints.size() == keyTimesCount);
+
+ unsigned index;
+ for (index = 1; index < keyTimesCount; ++index) {
+ if (m_keyTimes[index] >= percent)
+ break;
+ }
+ --index;
+
+ float fromPercent = m_keyTimes[index];
+ float toPercent = m_keyTimes[index + 1];
+ float fromKeyPoint = m_keyPoints[index];
+ float toKeyPoint = m_keyPoints[index + 1];
+
+ if (calcMode() == CalcModeDiscrete)
+ return percent == 1.0f ? toKeyPoint : fromKeyPoint;
+
+ float keyPointPercent = percent == 1.0f ? 1.0f : (percent - fromPercent) / (toPercent - fromPercent);
+
+ if (calcMode() == CalcModeSpline) {
+ ASSERT(m_keySplines.size() == m_keyPoints.size() - 1);
+ keyPointPercent = calculatePercentForSpline(keyPointPercent, index);
+ }
+ return (toKeyPoint - fromKeyPoint) * keyPointPercent + fromKeyPoint;
+}
+
+void SVGAnimationElement::currentValuesFromKeyPoints(float percent, float& effectivePercent, String& from, String& to) const
+{
+ ASSERT(!m_keyPoints.isEmpty());
+ ASSERT(m_keyPoints.size() == m_keyTimes.size());
+ ASSERT(calcMode() != CalcModePaced);
+ effectivePercent = calculatePercentFromKeyPoints(percent);
+ unsigned index = effectivePercent == 1.0f ? m_values.size() - 2 : static_cast<unsigned>(effectivePercent * (m_values.size() - 1));
+ from = m_values[index];
+ to = m_values[index + 1];
+}
+
+void SVGAnimationElement::currentValuesForValuesAnimation(float percent, float& effectivePercent, String& from, String& to) const
+{
+ unsigned valuesCount = m_values.size();
+ ASSERT(m_animationValid);
+ ASSERT(valuesCount > 1);
+
+ CalcMode calcMode = this->calcMode();
+ if (!m_keyPoints.isEmpty() && calcMode != CalcModePaced)
+ return currentValuesFromKeyPoints(percent, effectivePercent, from, to);
+
+ unsigned keyTimesCount = m_keyTimes.size();
+ ASSERT(!keyTimesCount || valuesCount == keyTimesCount);
+ ASSERT(!keyTimesCount || (keyTimesCount > 1 && m_keyTimes[0] == 0));
+
+ unsigned index;
+ for (index = 1; index < keyTimesCount; ++index) {
+ if (m_keyTimes[index] >= percent)
+ break;
+ }
+ --index;
+
+ if (calcMode == CalcModeDiscrete) {
+ if (!keyTimesCount)
+ index = percent == 1.0f ? valuesCount - 1 : static_cast<unsigned>(percent * valuesCount);
+ from = m_values[index];
+ to = m_values[index];
+ effectivePercent = 0.0f;
+ return;
+ }
+
+ float fromPercent;
+ float toPercent;
+ if (keyTimesCount) {
+ fromPercent = m_keyTimes[index];
+ toPercent = m_keyTimes[index + 1];
+ } else {
+ index = static_cast<unsigned>(percent * (valuesCount - 1));
+ fromPercent = static_cast<float>(index) / (valuesCount - 1);
+ toPercent = static_cast<float>(index + 1) / (valuesCount - 1);
+ }
+
+ if (index == valuesCount - 1)
+ --index;
+ from = m_values[index];
+ to = m_values[index + 1];
+ ASSERT(toPercent > fromPercent);
+ effectivePercent = percent == 1.0f ? 1.0f : (percent - fromPercent) / (toPercent - fromPercent);
+
+ if (calcMode == CalcModeSpline) {
+ ASSERT(m_keySplines.size() == m_values.size() - 1);
+ effectivePercent = calculatePercentForSpline(effectivePercent, index);
+ }
+}
+
+void SVGAnimationElement::startedActiveInterval()
+{
+ m_animationValid = false;
+
+ if (!hasValidTarget())
+ return;
+
+ AnimationMode animationMode = this->animationMode();
+ if (animationMode == NoAnimation)
+ return;
+ if (animationMode == FromToAnimation)
+ m_animationValid = calculateFromAndToValues(fromValue(), toValue());
+ else if (animationMode == ToAnimation) {
+ // For to-animations the from value is the current accumulated value from lower priority animations.
+ // The value is not static and is determined during the animation.
+ m_animationValid = calculateFromAndToValues(String(), toValue());
+ } else if (animationMode == FromByAnimation)
+ m_animationValid = calculateFromAndByValues(fromValue(), byValue());
+ else if (animationMode == ByAnimation)
+ m_animationValid = calculateFromAndByValues(String(), byValue());
+ else if (animationMode == ValuesAnimation) {
+ CalcMode calcMode = this->calcMode();
+ m_animationValid = m_values.size() > 1
+ && (calcMode == CalcModePaced || !hasAttribute(SVGNames::keyTimesAttr) || hasAttribute(SVGNames::keyPointsAttr) || (m_values.size() == m_keyTimes.size()))
+ && (calcMode == CalcModeDiscrete || !m_keyTimes.size() || m_keyTimes.last() == 1.0)
+ && (calcMode != CalcModeSpline || (m_keySplines.size() && (m_keySplines.size() == m_values.size() - 1) || m_keySplines.size() == m_keyPoints.size() - 1))
+ && (!hasAttribute(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size()));
+ if (calcMode == CalcModePaced && m_animationValid)
+ calculateKeyTimesForCalcModePaced();
+ } else if (animationMode == PathAnimation)
+ m_animationValid = calcMode() == CalcModePaced || !hasAttribute(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size());
+}
+
+void SVGAnimationElement::updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement)
+{
+ if (!m_animationValid)
+ return;
+
+ float effectivePercent;
+ if (animationMode() == ValuesAnimation) {
+ String from;
+ String to;
+ currentValuesForValuesAnimation(percent, effectivePercent, from, to);
+ if (from != m_lastValuesAnimationFrom || to != m_lastValuesAnimationTo ) {
+ m_animationValid = calculateFromAndToValues(from, to);
+ if (!m_animationValid)
+ return;
+ m_lastValuesAnimationFrom = from;
+ m_lastValuesAnimationTo = to;
+ }
+ } else if (!m_keyPoints.isEmpty() && calcMode() != CalcModePaced)
+ effectivePercent = calculatePercentFromKeyPoints(percent);
+ else
+ effectivePercent = percent;
+
+ calculateAnimatedValue(effectivePercent, repeat, resultElement);
+}
+
+void SVGAnimationElement::endedActiveInterval()
+{
+}
+
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG_ANIMATION)
+
diff --git a/WebCore/svg/SVGAnimationElement.h b/WebCore/svg/SVGAnimationElement.h
new file mode 100644
index 0000000..b4d4b78
--- /dev/null
+++ b/WebCore/svg/SVGAnimationElement.h
@@ -0,0 +1,125 @@
+/*
+ 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>
+ Copyright (C) 2008 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.
+*/
+
+#ifndef SVGAnimationElement_h
+#define SVGAnimationElement_h
+#if ENABLE(SVG_ANIMATION)
+
+#include "ElementTimeControl.h"
+#include "Path.h"
+#include "SMILTime.h"
+#include "SVGSMILElement.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGStringList.h"
+#include "SVGTests.h"
+#include "UnitBezier.h"
+
+namespace WebCore {
+
+ class ConditionEventListener;
+ class TimeContainer;
+
+ class SVGAnimationElement : public SVGSMILElement,
+ public SVGTests,
+ public SVGExternalResourcesRequired,
+ public ElementTimeControl
+ {
+ public:
+ SVGAnimationElement(const QualifiedName&, Document*);
+ virtual ~SVGAnimationElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void attributeChanged(Attribute*, bool preserveDecls);
+
+ // SVGAnimationElement
+ float getStartTime() const;
+ float getCurrentTime() const;
+ float getSimpleDuration(ExceptionCode&) const;
+
+ // ElementTimeControl
+ virtual bool beginElement(ExceptionCode&);
+ virtual bool beginElementAt(float offset, ExceptionCode&);
+ virtual bool endElement(ExceptionCode&);
+ virtual bool endElementAt(float offset, ExceptionCode&);
+
+ static bool attributeIsCSS(const String& attributeName);
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ enum CalcMode { CalcModeDiscrete, CalcModeLinear, CalcModePaced, CalcModeSpline };
+ CalcMode calcMode() const;
+
+ enum AttributeType { AttributeTypeCSS, AttributeTypeXML, AttributeTypeAuto };
+ AttributeType attributeType() const;
+
+ String toValue() const;
+ String byValue() const;
+ String fromValue() const;
+
+ enum AnimationMode { NoAnimation, ToAnimation, ByAnimation, ValuesAnimation, FromToAnimation, FromByAnimation, PathAnimation };
+ AnimationMode animationMode() const;
+
+ virtual bool hasValidTarget() const;
+
+ String targetAttributeBaseValue() const;
+ void setTargetAttributeAnimatedValue(const String&);
+ bool targetAttributeIsCSS() const;
+
+ bool isAdditive() const;
+ bool isAccumulated() const;
+
+ // from SVGSMILElement
+ virtual void startedActiveInterval();
+ virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement);
+ virtual void endedActiveInterval();
+
+ private:
+ virtual bool calculateFromAndToValues(const String& fromString, const String& toString) = 0;
+ virtual bool calculateFromAndByValues(const String& fromString, const String& byString) = 0;
+ virtual void calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement* resultElement) = 0;
+ virtual float calculateDistance(const String& fromString, const String& toString) { return -1.f; }
+ virtual Path animationPath() const { return Path(); }
+
+ void currentValuesForValuesAnimation(float percent, float& effectivePercent, String& from, String& to) const;
+ void calculateKeyTimesForCalcModePaced();
+ float calculatePercentFromKeyPoints(float percent) const;
+ void currentValuesFromKeyPoints(float percent, float& effectivePercent, String& from, String& to) const;
+ float calculatePercentForSpline(float percent, unsigned splineIndex) const;
+
+ protected:
+ bool m_animationValid;
+
+ Vector<String> m_values;
+ Vector<float> m_keyTimes;
+ Vector<float> m_keyPoints;
+ Vector<UnitBezier> m_keySplines;
+ String m_lastValuesAnimationFrom;
+ String m_lastValuesAnimationTo;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGAnimationElement_h
diff --git a/WebCore/svg/SVGAnimationElement.idl b/WebCore/svg/SVGAnimationElement.idl
new file mode 100644
index 0000000..afa3cbb
--- /dev/null
+++ b/WebCore/svg/SVGAnimationElement.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_ANIMATION] SVGAnimationElement : SVGElement,
+ SVGTests,
+ SVGExternalResourcesRequired,
+ ElementTimeControl {
+ 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..8817506
--- /dev/null
+++ b/WebCore/svg/SVGCircleElement.cpp
@@ -0,0 +1,99 @@
+/*
+ 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 "SVGLength.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+SVGCircleElement::SVGCircleElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_cx(this, SVGNames::cxAttr, LengthModeWidth)
+ , m_cy(this, SVGNames::cyAttr, LengthModeHeight)
+ , m_r(this, SVGNames::rAttr, LengthModeOther)
+{
+}
+
+SVGCircleElement::~SVGCircleElement()
+{
+}
+
+void SVGCircleElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::cxAttr)
+ setCxBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::cyAttr)
+ setCyBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::rAttr) {
+ setRBaseValue(SVGLength(LengthModeOther, attr->value()));
+ if (rBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for circle <r> is not allowed");
+ } else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ SVGStyledTransformableElement::parseMappedAttribute(attr);
+ }
+}
+
+void 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(this), cy().value(this)), r().value(this));
+}
+
+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..598e51f
--- /dev/null
+++ b/WebCore/svg/SVGCircleElement.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 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_DECLARATIONS(SVGCircleElement, SVGNames::circleTagString, SVGNames::cxAttrString, SVGLength, Cx, cx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGCircleElement, SVGNames::circleTagString, SVGNames::cyAttrString, SVGLength, Cy, cy)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGCircleElement, SVGNames::circleTagString, SVGNames::rAttrString, 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..a41bb45
--- /dev/null
+++ b/WebCore/svg/SVGClipPathElement.cpp
@@ -0,0 +1,123 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007, 2008 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(this, SVGNames::clipPathUnitsAttr, SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
+{
+}
+
+SVGClipPathElement::~SVGClipPathElement()
+{
+}
+
+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;
+
+ RefPtr<RenderStyle> clipPathStyle = styleForRenderer(); // 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);
+ RefPtr<RenderStyle> pathStyle = document()->styleSelector()->styleForElement(styled, clipPathStyle.get());
+ if (pathStyle->display() != NONE) {
+ Path pathData = styled->toClipPath();
+ if (!pathData.isEmpty())
+ m_clipper->addClipData(pathData, pathStyle->svgStyle()->clipRule(), bbox);
+ }
+ }
+ }
+ if (m_clipper->clipData().isEmpty()) {
+ Path pathData;
+ pathData.addRect(FloatRect());
+ m_clipper->addClipData(pathData, RULE_EVENODD, bbox);
+ }
+ 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..ab7ea68
--- /dev/null
+++ b/WebCore/svg/SVGClipPathElement.h
@@ -0,0 +1,65 @@
+/*
+ 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 "SVGExternalResourcesRequired.h"
+#include "SVGLangSpace.h"
+#include "SVGResourceClipper.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_DECLARATIONS(SVGClipPathElement, SVGNames::clipPathTagString, SVGNames::clipPathUnitsAttrString, 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..b56a80e
--- /dev/null
+++ b/WebCore/svg/SVGColor.cpp
@@ -0,0 +1,119 @@
+/*
+ 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()
+ : m_colorType(SVG_COLORTYPE_UNKNOWN)
+{
+}
+
+SVGColor::SVGColor(const String& rgbColor)
+ : m_colorType(SVG_COLORTYPE_RGBCOLOR)
+{
+ setRGBColor(rgbColor);
+}
+
+SVGColor::SVGColor(SVGColorType colorType)
+ : m_colorType(colorType)
+{
+}
+
+SVGColor::SVGColor(const Color& c)
+ : 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..e3a4b19
--- /dev/null
+++ b/WebCore/svg/SVGColor.h
@@ -0,0 +1,93 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 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 SVGColor_h
+#define SVGColor_h
+#if ENABLE(SVG)
+
+#include "CSSValue.h"
+#include "Color.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+ class SVGColor : public CSSValue {
+ public:
+ static PassRefPtr<SVGColor> create(const String& color)
+ {
+ return adoptRef(new SVGColor(color));
+ }
+ static PassRefPtr<SVGColor> create(const Color& color)
+ {
+ return adoptRef(new SVGColor(color));
+ }
+ static PassRefPtr<SVGColor> createCurrentColor()
+ {
+ return adoptRef(new SVGColor(SVG_COLORTYPE_CURRENTCOLOR));
+ }
+
+ 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;
+
+ protected:
+ SVGColor();
+ SVGColor(const String& color);
+ SVGColor(const Color&);
+
+ private:
+ SVGColor(SVGColorType);
+
+ static void create(int); // compile-time guard
+
+ virtual bool isSVGColor() const { return true; }
+
+ 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..f2be038
--- /dev/null
+++ b/WebCore/svg/SVGComponentTransferFunctionElement.cpp
@@ -0,0 +1,106 @@
+/*
+ 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 {
+
+char SVGComponentTransferFunctionElementIdentifier[] = "SVGComponentTransferFunctionElement";
+
+SVGComponentTransferFunctionElement::SVGComponentTransferFunctionElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+ , m_type(this, SVGNames::typeAttr, FECOMPONENTTRANSFER_TYPE_UNKNOWN)
+ , m_tableValues(this, SVGNames::tableValuesAttr, SVGNumberList::create(SVGNames::tableValuesAttr))
+ , m_slope(this, SVGNames::slopeAttr, 1.0f)
+ , m_intercept(this, SVGNames::interceptAttr)
+ , m_amplitude(this, SVGNames::amplitudeAttr, 1.0f)
+ , m_exponent(this, SVGNames::exponentAttr, 1.0f)
+ , m_offset(this, SVGNames::offsetAttr)
+{
+}
+
+SVGComponentTransferFunctionElement::~SVGComponentTransferFunctionElement()
+{
+}
+
+void SVGComponentTransferFunctionElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::typeAttr)
+ {
+ if (value == "identity")
+ setTypeBaseValue(FECOMPONENTTRANSFER_TYPE_IDENTITY);
+ else if (value == "table")
+ setTypeBaseValue(FECOMPONENTTRANSFER_TYPE_TABLE);
+ else if (value == "discrete")
+ setTypeBaseValue(FECOMPONENTTRANSFER_TYPE_DISCRETE);
+ else if (value == "linear")
+ setTypeBaseValue(FECOMPONENTTRANSFER_TYPE_LINEAR);
+ else if (value == "gamma")
+ setTypeBaseValue(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);
+}
+
+ComponentTransferFunction SVGComponentTransferFunctionElement::transferFunction() const
+{
+ ComponentTransferFunction func;
+ func.type = (ComponentTransferType) 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..5e20e37f
--- /dev/null
+++ b/WebCore/svg/SVGComponentTransferFunctionElement.h
@@ -0,0 +1,57 @@
+/*
+ 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 SVGComponentTransferFunctionElement_h
+#define SVGComponentTransferFunctionElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGElement.h"
+#include "SVGNumberList.h"
+#include "FEComponentTransfer.h"
+
+namespace WebCore {
+
+ extern char SVGComponentTransferFunctionElementIdentifier[];
+
+ class SVGComponentTransferFunctionElement : public SVGElement {
+ public:
+ SVGComponentTransferFunctionElement(const QualifiedName&, Document*);
+ virtual ~SVGComponentTransferFunctionElement();
+
+ virtual void parseMappedAttribute(MappedAttribute* attr);
+
+ ComponentTransferFunction transferFunction() const;
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, SVGComponentTransferFunctionElementIdentifier, SVGNames::typeAttrString, int, Type, type)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, SVGComponentTransferFunctionElementIdentifier, SVGNames::tableValuesAttrString, SVGNumberList, TableValues, tableValues)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, SVGComponentTransferFunctionElementIdentifier, SVGNames::slopeAttrString, float, Slope, slope)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, SVGComponentTransferFunctionElementIdentifier, SVGNames::interceptAttrString, float, Intercept, intercept)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, SVGComponentTransferFunctionElementIdentifier, SVGNames::amplitudeAttrString, float, Amplitude, amplitude)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, SVGComponentTransferFunctionElementIdentifier, SVGNames::exponentAttrString, float, Exponent, exponent)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, SVGComponentTransferFunctionElementIdentifier, SVGNames::offsetAttrString, float, Offset, offset)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#endif
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..161a061
--- /dev/null
+++ b/WebCore/svg/SVGCursorElement.cpp
@@ -0,0 +1,99 @@
+/*
+ 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(this, SVGNames::xAttr, LengthModeWidth)
+ , m_y(this, SVGNames::yAttr, LengthModeHeight)
+{
+}
+
+SVGCursorElement::~SVGCursorElement()
+{
+}
+
+void SVGCursorElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::xAttr)
+ setXBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else {
+ if (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();
+ }
+}
+
+void SVGCursorElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+ urls.append(href());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGCursorElement.h b/WebCore/svg/SVGCursorElement.h
new file mode 100644
index 0000000..d8d7eba
--- /dev/null
+++ b/WebCore/svg/SVGCursorElement.h
@@ -0,0 +1,66 @@
+/*
+ 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&);
+
+ virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGCursorElement, SVGNames::cursorTagString, SVGNames::xAttrString, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGCursorElement, SVGNames::cursorTagString, SVGNames::yAttrString, 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..c4cac62
--- /dev/null
+++ b/WebCore/svg/SVGDefsElement.h
@@ -0,0 +1,53 @@
+/*
+ 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; }
+ };
+
+} // 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..9244873
--- /dev/null
+++ b/WebCore/svg/SVGDocument.cpp
@@ -0,0 +1,105 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 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.
+*/
+
+#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(Frame* frame)
+ : Document(frame, false)
+{
+}
+
+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..1411017
--- /dev/null
+++ b/WebCore/svg/SVGDocument.h
@@ -0,0 +1,66 @@
+/*
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
+ 2004, 2005, 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 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:
+ static PassRefPtr<SVGDocument> create(Frame* frame)
+ {
+ return new SVGDocument(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:
+ SVGDocument(Frame*);
+
+ 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..d7169e1
--- /dev/null
+++ b/WebCore/svg/SVGDocumentExtensions.cpp
@@ -0,0 +1,137 @@
+/*
+ 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 "Console.h"
+#include "DOMWindow.h"
+#include "Document.h"
+#include "EventListener.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "Page.h"
+#include "SVGSVGElement.h"
+#include "SMILTimeContainer.h"
+#include "XMLTokenizer.h"
+#include "ScriptController.h"
+
+namespace WebCore {
+
+SVGDocumentExtensions::SVGDocumentExtensions(Document* doc)
+ : m_doc(doc)
+{
+}
+
+SVGDocumentExtensions::~SVGDocumentExtensions()
+{
+ deleteAllValues(m_pendingResources);
+}
+
+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)->timeContainer()->begin();
+#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())
+ frame->domWindow()->console()->addMessage(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())
+ frame->domWindow()->console()->addMessage(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;
+}
+
+}
+
+#endif
diff --git a/WebCore/svg/SVGDocumentExtensions.h b/WebCore/svg/SVGDocumentExtensions.h
new file mode 100644
index 0000000..cd20a30
--- /dev/null
+++ b/WebCore/svg/SVGDocumentExtensions.h
@@ -0,0 +1,131 @@
+/*
+ Copyright (C) 2006 Apple Computer, Inc.
+ 2006, 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.
+*/
+
+#ifndef SVGDocumentExtensions_h
+#define SVGDocumentExtensions_h
+
+#if ENABLE(SVG)
+#include <memory>
+
+#include <wtf/HashSet.h>
+#include <wtf/HashMap.h>
+
+#include "StringHash.h"
+#include "StringImpl.h"
+#include "SVGAnimatedTemplate.h"
+
+namespace WebCore {
+
+class Document;
+class EventListener;
+class Node;
+class String;
+class SVGElementInstance;
+class SVGStyledElement;
+class SVGSVGElement;
+
+class SVGDocumentExtensions {
+public:
+ SVGDocumentExtensions(Document*);
+ ~SVGDocumentExtensions();
+
+ 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;
+
+ 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);
+
+ // 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 SVGAnimatedTypeValue<ValueType>::null();
+ }
+
+ 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;
+ }
+};
+
+}
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGElement.cpp b/WebCore/svg/SVGElement.cpp
new file mode 100644
index 0000000..9ecfe7d
--- /dev/null
+++ b/WebCore/svg/SVGElement.cpp
@@ -0,0 +1,286 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org>
+ Copyright (C) 2008 Apple Inc. All rights reserved.
+ Copyright (C) 2008 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 "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 "SVGResource.h"
+#include "SVGSVGElement.h"
+#include "SVGURIReference.h"
+#include "SVGUseElement.h"
+#include "XMLNames.h"
+#include "RegisteredEventListener.h"
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+SVGElement::SVGElement(const QualifiedName& tagName, Document* doc)
+ : StyledElement(tagName, doc)
+ , m_shadowParent(0)
+{
+}
+
+SVGElement::~SVGElement()
+{
+}
+
+bool SVGElement::isSupported(StringImpl* feature, StringImpl* version) const
+{
+ return DOMImplementation::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 = isShadowNode() ? const_cast<SVGElement*>(this)->shadowParentNode() : parentNode();
+ while (n) {
+ if (n->hasTagName(SVGNames::svgTag))
+ return static_cast<SVGSVGElement*>(n);
+
+ n = n->isShadowNode() ? n->shadowParentNode() : 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;
+}
+
+SVGDocumentExtensions* SVGElement::accessDocumentSVGExtensions() const
+{
+
+ // This function is provided for use by SVGAnimatedProperty to avoid
+ // global inclusion of Document.h in SVG code.
+ return document() ? document()->accessSVGExtensions() : 0;
+}
+
+void SVGElement::mapInstanceToElement(SVGElementInstance* instance)
+{
+ ASSERT(instance);
+ ASSERT(!m_elementInstances.contains(instance));
+ m_elementInstances.add(instance);
+}
+
+void SVGElement::removeInstanceMapping(SVGElementInstance* instance)
+{
+ ASSERT(instance);
+ ASSERT(m_elementInstances.contains(instance));
+ m_elementInstances.remove(instance);
+}
+
+HashSet<SVGElementInstance*> SVGElement::instancesForElement() const
+{
+ return m_elementInstances;
+}
+
+void SVGElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ // standard events
+ if (attr->name() == onloadAttr)
+ setInlineEventListenerForTypeAndAttribute(eventNames().loadEvent, attr);
+ else if (attr->name() == onclickAttr)
+ setInlineEventListenerForTypeAndAttribute(eventNames().clickEvent, attr);
+ else if (attr->name() == onmousedownAttr)
+ setInlineEventListenerForTypeAndAttribute(eventNames().mousedownEvent, attr);
+ else if (attr->name() == onmousemoveAttr)
+ setInlineEventListenerForTypeAndAttribute(eventNames().mousemoveEvent, attr);
+ else if (attr->name() == onmouseoutAttr)
+ setInlineEventListenerForTypeAndAttribute(eventNames().mouseoutEvent, attr);
+ else if (attr->name() == onmouseoverAttr)
+ setInlineEventListenerForTypeAndAttribute(eventNames().mouseoverEvent, attr);
+ else if (attr->name() == onmouseupAttr)
+ setInlineEventListenerForTypeAndAttribute(eventNames().mouseupEvent, attr);
+ else if (attr->name() == SVGNames::onfocusinAttr)
+ setInlineEventListenerForTypeAndAttribute(eventNames().DOMFocusInEvent, attr);
+ else if (attr->name() == SVGNames::onfocusoutAttr)
+ setInlineEventListenerForTypeAndAttribute(eventNames().DOMFocusOutEvent, attr);
+ else if (attr->name() == SVGNames::onactivateAttr)
+ setInlineEventListenerForTypeAndAttribute(eventNames().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;
+}
+
+static bool hasLoadListener(SVGElement* node)
+{
+ Node* currentNode = node;
+ while (currentNode && currentNode->isElementNode()) {
+ RegisteredEventListenerList *list = static_cast<Element*>(currentNode)->localEventListeners();
+ if (list) {
+ RegisteredEventListenerList::Iterator end = list->end();
+ for (RegisteredEventListenerList::Iterator it = list->begin(); it != end; ++it)
+ if ((*it)->eventType() == eventNames().loadEvent &&
+ (*it)->useCapture() == true || currentNode == node)
+ return true;
+ }
+ currentNode = currentNode->parentNode();
+ }
+
+ return false;
+}
+
+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
+ if (hasLoadListener(currentTarget.get())) {
+ RefPtr<Event> event = Event::create(eventNames().loadEvent, false, false);
+ event->setTarget(currentTarget);
+ ExceptionCode ignored = 0;
+ currentTarget->dispatchGenericEvent(event.release(), ignored);
+ }
+ currentTarget = (parent && parent->isSVGElement()) ? static_pointer_cast<SVGElement>(parent) : 0;
+ }
+}
+
+void SVGElement::finishParsingChildren()
+{
+ StyledElement::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);
+ }
+}
+
+void SVGElement::attributeChanged(Attribute* attr, bool preserveDecls)
+{
+ ASSERT(attr);
+ if (!attr)
+ return;
+
+ StyledElement::attributeChanged(attr, preserveDecls);
+ svgAttributeChanged(attr->name());
+}
+
+void SVGElement::updateAnimatedSVGAttribute(const String& name) const
+{
+ ASSERT(!m_areSVGAttributesValid);
+
+ if (m_synchronizingSVGAttributes)
+ return;
+
+ m_synchronizingSVGAttributes = true;
+
+ if (name.isEmpty()) {
+ invokeAllSVGPropertySynchronizers();
+ setSynchronizedSVGAttributes(true);
+ } else
+ invokeSVGPropertySynchronizer(name);
+
+ m_synchronizingSVGAttributes = false;
+}
+
+void SVGElement::setSynchronizedSVGAttributes(bool value) const
+{
+ m_areSVGAttributesValid = value;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGElement.h b/WebCore/svg/SVGElement.h
new file mode 100644
index 0000000..0223bf7
--- /dev/null
+++ b/WebCore/svg/SVGElement.h
@@ -0,0 +1,137 @@
+/*
+ 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 "StyledElement.h"
+#include "SVGAnimatedProperty.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+ class AffineTransform;
+ class Document;
+ class SVGElementInstance;
+ class SVGDocumentExtensions;
+ 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;
+ SVGDocumentExtensions* accessDocumentSVGExtensions() 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);
+
+ virtual AffineTransform* supplementalTransform() { return 0; }
+
+ virtual void updateAnimatedSVGAttribute(const String&) const;
+ virtual void setSynchronizedSVGAttributes(bool) const;
+
+ HashSet<SVGElementInstance*> instancesForElement() const;
+
+ // Inlined methods handling SVG property synchronization
+ void invokeSVGPropertySynchronizer(const String& name) const
+ {
+ if (m_svgPropertyMap.contains(name)) {
+ const SVGAnimatedPropertyBase* property = m_svgPropertyMap.get(name);
+ ASSERT(property);
+
+ property->synchronize();
+ }
+ }
+
+ void invokeAllSVGPropertySynchronizers() const
+ {
+ HashMap<String, const SVGAnimatedPropertyBase*>::const_iterator it = m_svgPropertyMap.begin();
+ const HashMap<String, const SVGAnimatedPropertyBase*>::const_iterator end = m_svgPropertyMap.end();
+ for (; it != end; ++it) {
+ const SVGAnimatedPropertyBase* property = it->second;
+ ASSERT(property);
+
+ property->synchronize();
+ }
+ }
+
+ void addSVGPropertySynchronizer(const QualifiedName& attrName, const SVGAnimatedPropertyBase& base) const
+ {
+ m_svgPropertyMap.set(attrName.localName(), &base);
+ }
+
+ private:
+ friend class SVGElementInstance;
+
+ void mapInstanceToElement(SVGElementInstance*);
+ void removeInstanceMapping(SVGElementInstance*);
+
+ virtual bool haveLoadedRequiredResources();
+
+ Node* m_shadowParent;
+ mutable HashMap<String, const SVGAnimatedPropertyBase*> m_svgPropertyMap;
+
+ HashSet<SVGElementInstance*> m_elementInstances;
+ };
+
+} // 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..e548900
--- /dev/null
+++ b/WebCore/svg/SVGElementInstance.cpp
@@ -0,0 +1,572 @@
+/*
+ Copyright (C) 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
+ along with this library; 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 "ContainerNodeAlgorithms.h"
+#include "Document.h"
+#include "Event.h"
+#include "EventException.h"
+#include "EventListener.h"
+#include "EventNames.h"
+#include "FrameView.h"
+#include "GCController.h"
+#include "SVGElementInstanceList.h"
+#include "SVGUseElement.h"
+
+#include <wtf/RefCountedLeakCounter.h>
+
+namespace WebCore {
+
+#ifndef NDEBUG
+static WTF::RefCountedLeakCounter instanceCounter("WebCoreSVGElementInstance");
+#endif
+
+SVGElementInstance::SVGElementInstance(SVGUseElement* useElement, SVGElement* originalElement)
+ : m_needsUpdate(false)
+ , m_useElement(useElement)
+ , m_element(originalElement)
+ , 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->mapInstanceToElement(this);
+
+#ifndef NDEBUG
+ instanceCounter.increment();
+#endif
+}
+
+SVGElementInstance::~SVGElementInstance()
+{
+#ifndef NDEBUG
+ instanceCounter.decrement();
+#endif
+
+ // Deregister as instance for passed element.
+ m_element->removeInstanceMapping(this);
+
+ removeAllChildrenInContainer<SVGElementInstance, SVGElementInstance>(this);
+}
+
+PassRefPtr<SVGElementInstanceList> SVGElementInstance::childNodes()
+{
+ return SVGElementInstanceList::create(this);
+}
+
+void SVGElementInstance::setShadowTreeElement(SVGElement* element)
+{
+ ASSERT(element);
+ m_shadowTreeElement = element;
+}
+
+void SVGElementInstance::forgetWrapper()
+{
+ // FIXME: This is fragile, as discussed with Sam. Need to find a better solution.
+ // Think about the case where JS explicitely holds "var root = useElement.instanceRoot;".
+ // We still have to recreate this wrapper somehow. The gc collection below, won't catch it.
+
+ // If the use shadow tree has been rebuilt, just the JSSVGElementInstance objects
+ // are still holding RefPtrs of SVGElementInstance objects, which prevent us to
+ // be deleted (and the shadow tree is not destructed as well). Force JS GC.
+ gcController().garbageCollectNow();
+}
+
+void SVGElementInstance::appendChild(PassRefPtr<SVGElementInstance> child)
+{
+ appendChildToContainer<SVGElementInstance, SVGElementInstance>(child.get(), this);
+}
+
+void SVGElementInstance::invalidateAllInstancesOfElement(SVGElement* element)
+{
+ if (!element)
+ return;
+
+ HashSet<SVGElementInstance*> set = element->instancesForElement();
+ if (set.isEmpty())
+ return;
+
+ // Find all use elements referencing the instances - ask them _once_ to rebuild.
+ HashSet<SVGElementInstance*>::const_iterator it = set.begin();
+ const HashSet<SVGElementInstance*>::const_iterator end = set.end();
+
+ for (; it != end; ++it)
+ (*it)->setNeedsUpdate(true);
+}
+
+void SVGElementInstance::setNeedsUpdate(bool value)
+{
+ m_needsUpdate = value;
+
+ if (m_needsUpdate)
+ correspondingUseElement()->setChanged();
+}
+
+ScriptExecutionContext* SVGElementInstance::scriptExecutionContext() const
+{
+ if (SVGElement* element = correspondingElement())
+ return element->scriptExecutionContext();
+ return 0;
+}
+
+void SVGElementInstance::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
+{
+ if (SVGElement* element = correspondingElement())
+ element->addEventListener(eventType, listener, useCapture);
+}
+
+void SVGElementInstance::removeEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture)
+{
+ if (SVGElement* element = correspondingElement())
+ element->removeEventListener(eventType, listener, useCapture);
+}
+
+bool SVGElementInstance::dispatchEvent(PassRefPtr<Event> e, ExceptionCode& ec)
+{
+ RefPtr<Event> evt(e);
+ ASSERT(!eventDispatchForbidden());
+ if (!evt || evt->type().isEmpty()) {
+ ec = EventException::UNSPECIFIED_EVENT_TYPE_ERR;
+ return false;
+ }
+
+ // The event has to be dispatched to the shadowTreeElement(), not the correspondingElement()!
+ SVGElement* element = shadowTreeElement();
+ if (!element)
+ return false;
+
+ evt->setTarget(this);
+
+ RefPtr<FrameView> view = element->document()->view();
+ return element->dispatchGenericEvent(evt.release(), ec);
+}
+
+EventListener* SVGElementInstance::onabort() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().abortEvent);
+}
+
+void SVGElementInstance::setOnabort(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().abortEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onblur() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().blurEvent);
+}
+
+void SVGElementInstance::setOnblur(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().blurEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onchange() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().changeEvent);
+}
+
+void SVGElementInstance::setOnchange(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().changeEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onclick() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().clickEvent);
+}
+
+void SVGElementInstance::setOnclick(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().clickEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::oncontextmenu() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().contextmenuEvent);
+}
+
+void SVGElementInstance::setOncontextmenu(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().contextmenuEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::ondblclick() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().dblclickEvent);
+}
+
+void SVGElementInstance::setOndblclick(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().dblclickEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onerror() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().errorEvent);
+}
+
+void SVGElementInstance::setOnerror(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().errorEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onfocus() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().focusEvent);
+}
+
+void SVGElementInstance::setOnfocus(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().focusEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::oninput() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().inputEvent);
+}
+
+void SVGElementInstance::setOninput(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().inputEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onkeydown() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().keydownEvent);
+}
+
+void SVGElementInstance::setOnkeydown(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().keydownEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onkeypress() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().keypressEvent);
+}
+
+void SVGElementInstance::setOnkeypress(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().keypressEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onkeyup() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().keyupEvent);
+}
+
+void SVGElementInstance::setOnkeyup(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().keyupEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onload() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().loadEvent);
+}
+
+void SVGElementInstance::setOnload(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().loadEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onmousedown() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().mousedownEvent);
+}
+
+void SVGElementInstance::setOnmousedown(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().mousedownEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onmousemove() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().mousemoveEvent);
+}
+
+void SVGElementInstance::setOnmousemove(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().mousemoveEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onmouseout() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().mouseoutEvent);
+}
+
+void SVGElementInstance::setOnmouseout(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().mouseoutEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onmouseover() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().mouseoverEvent);
+}
+
+void SVGElementInstance::setOnmouseover(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().mouseoverEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onmouseup() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().mouseupEvent);
+}
+
+void SVGElementInstance::setOnmouseup(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().mouseupEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onmousewheel() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().mousewheelEvent);
+}
+
+void SVGElementInstance::setOnmousewheel(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().mousewheelEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onbeforecut() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().beforecutEvent);
+}
+
+void SVGElementInstance::setOnbeforecut(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().beforecutEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::oncut() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().cutEvent);
+}
+
+void SVGElementInstance::setOncut(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().cutEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onbeforecopy() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().beforecopyEvent);
+}
+
+void SVGElementInstance::setOnbeforecopy(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().beforecopyEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::oncopy() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().copyEvent);
+}
+
+void SVGElementInstance::setOncopy(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().copyEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onbeforepaste() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().beforepasteEvent);
+}
+
+void SVGElementInstance::setOnbeforepaste(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().beforepasteEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onpaste() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().pasteEvent);
+}
+
+void SVGElementInstance::setOnpaste(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().pasteEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::ondragenter() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().dragenterEvent);
+}
+
+void SVGElementInstance::setOndragenter(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().dragenterEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::ondragover() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().dragoverEvent);
+}
+
+void SVGElementInstance::setOndragover(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().dragoverEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::ondragleave() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().dragleaveEvent);
+}
+
+void SVGElementInstance::setOndragleave(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().dragleaveEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::ondrop() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().dropEvent);
+}
+
+void SVGElementInstance::setOndrop(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().dropEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::ondragstart() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().dragstartEvent);
+}
+
+void SVGElementInstance::setOndragstart(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().dragstartEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::ondrag() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().dragEvent);
+}
+
+void SVGElementInstance::setOndrag(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().dragEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::ondragend() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().dragendEvent);
+}
+
+void SVGElementInstance::setOndragend(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().dragendEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onreset() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().resetEvent);
+}
+
+void SVGElementInstance::setOnreset(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().resetEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onresize() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().resizeEvent);
+}
+
+void SVGElementInstance::setOnresize(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().resizeEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onscroll() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().scrollEvent);
+}
+
+void SVGElementInstance::setOnscroll(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().scrollEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onsearch() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().searchEvent);
+}
+
+void SVGElementInstance::setOnsearch(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().searchEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onselect() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().selectEvent);
+}
+
+void SVGElementInstance::setOnselect(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().selectEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onselectstart() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().selectstartEvent);
+}
+
+void SVGElementInstance::setOnselectstart(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().selectstartEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onsubmit() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().submitEvent);
+}
+
+void SVGElementInstance::setOnsubmit(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().submitEvent, eventListener);
+}
+
+EventListener* SVGElementInstance::onunload() const
+{
+ return correspondingElement()->inlineEventListenerForType(eventNames().unloadEvent);
+}
+
+void SVGElementInstance::setOnunload(PassRefPtr<EventListener> eventListener)
+{
+ correspondingElement()->setInlineEventListenerForType(eventNames().unloadEvent, eventListener);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGElementInstance.h b/WebCore/svg/SVGElementInstance.h
new file mode 100644
index 0000000..261d34a
--- /dev/null
+++ b/WebCore/svg/SVGElementInstance.h
@@ -0,0 +1,211 @@
+/*
+ Copyright (C) 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
+ along with this library; 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 "SVGElement.h"
+#include "TreeShared.h"
+
+#include <wtf/RefPtr.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+ namespace Private {
+ template<class GenericNode, class GenericNodeContainer>
+ void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer* container);
+ };
+
+ class EventListener;
+ class Frame;
+ class SVGUseElement;
+ class SVGElementInstanceList;
+
+ // SVGElementInstance mimics Node, but without providing all its functionality
+ class SVGElementInstance : public TreeShared<SVGElementInstance>,
+ public EventTarget
+ {
+ public:
+ SVGElementInstance(SVGUseElement*, SVGElement* originalElement);
+ virtual ~SVGElementInstance();
+
+ bool needsUpdate() const { return m_needsUpdate; }
+ void setNeedsUpdate(bool);
+
+ virtual ScriptExecutionContext* scriptExecutionContext() const;
+
+ virtual EventTargetNode* toNode() { return shadowTreeElement(); }
+ virtual SVGElementInstance* toSVGElementInstance() { return this; }
+
+ 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&);
+
+ SVGElement* correspondingElement() const { return m_element.get(); }
+ SVGUseElement* correspondingUseElement() const { return m_useElement; }
+ SVGElement* shadowTreeElement() const { return m_shadowTreeElement.get(); }
+
+ SVGElementInstance* parentNode() const { return parent(); }
+ PassRefPtr<SVGElementInstanceList> childNodes();
+
+ SVGElementInstance* previousSibling() const { return m_previousSibling; }
+ SVGElementInstance* nextSibling() const { return m_nextSibling; }
+
+ SVGElementInstance* firstChild() const { return m_firstChild; }
+ SVGElementInstance* lastChild() const { return m_lastChild; }
+
+ Document* ownerDocument() const { return m_element ? m_element->ownerDocument() : 0; }
+
+ static void invalidateAllInstancesOfElement(SVGElement*);
+
+ using TreeShared<SVGElementInstance>::ref;
+ using TreeShared<SVGElementInstance>::deref;
+
+ // EventTarget API
+ EventListener* onabort() const;
+ void setOnabort(PassRefPtr<EventListener>);
+ EventListener* onblur() const;
+ void setOnblur(PassRefPtr<EventListener>);
+ EventListener* onchange() const;
+ void setOnchange(PassRefPtr<EventListener>);
+ EventListener* onclick() const;
+ void setOnclick(PassRefPtr<EventListener>);
+ EventListener* oncontextmenu() const;
+ void setOncontextmenu(PassRefPtr<EventListener>);
+ EventListener* ondblclick() const;
+ void setOndblclick(PassRefPtr<EventListener>);
+ EventListener* onerror() const;
+ void setOnerror(PassRefPtr<EventListener>);
+ EventListener* onfocus() const;
+ void setOnfocus(PassRefPtr<EventListener>);
+ EventListener* oninput() const;
+ void setOninput(PassRefPtr<EventListener>);
+ EventListener* onkeydown() const;
+ void setOnkeydown(PassRefPtr<EventListener>);
+ EventListener* onkeypress() const;
+ void setOnkeypress(PassRefPtr<EventListener>);
+ EventListener* onkeyup() const;
+ void setOnkeyup(PassRefPtr<EventListener>);
+ EventListener* onload() const;
+ void setOnload(PassRefPtr<EventListener>);
+ EventListener* onmousedown() const;
+ void setOnmousedown(PassRefPtr<EventListener>);
+ EventListener* onmousemove() const;
+ void setOnmousemove(PassRefPtr<EventListener>);
+ EventListener* onmouseout() const;
+ void setOnmouseout(PassRefPtr<EventListener>);
+ EventListener* onmouseover() const;
+ void setOnmouseover(PassRefPtr<EventListener>);
+ EventListener* onmouseup() const;
+ void setOnmouseup(PassRefPtr<EventListener>);
+ EventListener* onmousewheel() const;
+ void setOnmousewheel(PassRefPtr<EventListener>);
+ EventListener* onbeforecut() const;
+ void setOnbeforecut(PassRefPtr<EventListener>);
+ EventListener* oncut() const;
+ void setOncut(PassRefPtr<EventListener>);
+ EventListener* onbeforecopy() const;
+ void setOnbeforecopy(PassRefPtr<EventListener>);
+ EventListener* oncopy() const;
+ void setOncopy(PassRefPtr<EventListener>);
+ EventListener* onbeforepaste() const;
+ void setOnbeforepaste(PassRefPtr<EventListener>);
+ EventListener* onpaste() const;
+ void setOnpaste(PassRefPtr<EventListener>);
+ EventListener* ondragenter() const;
+ void setOndragenter(PassRefPtr<EventListener>);
+ EventListener* ondragover() const;
+ void setOndragover(PassRefPtr<EventListener>);
+ EventListener* ondragleave() const;
+ void setOndragleave(PassRefPtr<EventListener>);
+ EventListener* ondrop() const;
+ void setOndrop(PassRefPtr<EventListener>);
+ EventListener* ondragstart() const;
+ void setOndragstart(PassRefPtr<EventListener>);
+ EventListener* ondrag() const;
+ void setOndrag(PassRefPtr<EventListener>);
+ EventListener* ondragend() const;
+ void setOndragend(PassRefPtr<EventListener>);
+ EventListener* onreset() const;
+ void setOnreset(PassRefPtr<EventListener>);
+ EventListener* onresize() const;
+ void setOnresize(PassRefPtr<EventListener>);
+ EventListener* onscroll() const;
+ void setOnscroll(PassRefPtr<EventListener>);
+ EventListener* onsearch() const;
+ void setOnsearch(PassRefPtr<EventListener>);
+ EventListener* onselect() const;
+ void setOnselect(PassRefPtr<EventListener>);
+ EventListener* onselectstart() const;
+ void setOnselectstart(PassRefPtr<EventListener>);
+ EventListener* onsubmit() const;
+ void setOnsubmit(PassRefPtr<EventListener>);
+ EventListener* onunload() const;
+ void setOnunload(PassRefPtr<EventListener>);
+
+ private:
+ friend class SVGUseElement;
+
+ void appendChild(PassRefPtr<SVGElementInstance> child);
+ void setShadowTreeElement(SVGElement*);
+ void forgetWrapper();
+
+ template<class GenericNode, class GenericNodeContainer>
+ friend void appendChildToContainer(GenericNode* child, GenericNodeContainer* container);
+
+ template<class GenericNode, class GenericNodeContainer>
+ friend void removeAllChildrenInContainer(GenericNodeContainer* container);
+
+ template<class GenericNode, class GenericNodeContainer>
+ friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer* container);
+
+ bool hasChildNodes() const { return m_firstChild; }
+
+ void setFirstChild(SVGElementInstance* child) { m_firstChild = child; }
+ void setLastChild(SVGElementInstance* child) { m_lastChild = child; }
+
+ void setNextSibling(SVGElementInstance* sibling) { m_nextSibling = sibling; }
+ void setPreviousSibling(SVGElementInstance* sibling) { m_previousSibling = sibling; }
+
+ virtual void refEventTarget() { ref(); }
+ virtual void derefEventTarget() { deref(); }
+
+ private:
+ bool m_needsUpdate : 1;
+
+ SVGUseElement* m_useElement;
+ RefPtr<SVGElement> m_element;
+ RefPtr<SVGElement> m_shadowTreeElement;
+
+ SVGElementInstance* m_previousSibling;
+ SVGElementInstance* m_nextSibling;
+
+ SVGElementInstance* m_firstChild;
+ SVGElementInstance* m_lastChild;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGElementInstance.idl b/WebCore/svg/SVGElementInstance.idl
new file mode 100644
index 0000000..92da5a6
--- /dev/null
+++ b/WebCore/svg/SVGElementInstance.idl
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.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.
+ */
+
+module svg {
+
+ interface [
+ Conditional=SVG,
+ ObjCCustomInternalImpl,
+ CustomListeners,
+ CustomPushEventHandlerScope,
+ GenerateToJS,
+ GenerateNativeConverter
+ ] SVGElementInstance
+#if defined(LANGUAGE_OBJECTIVE_C)
+ : Object, EventTarget
+#endif /* defined(LANGUAGE_OBJECTIVE_C) */
+ {
+ 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;
+
+ // EventTarget
+#if !defined(LANGUAGE_OBJECTIVE_C)
+ attribute [DontEnum, ProtectedListener] EventListener onabort;
+ attribute [DontEnum, ProtectedListener] EventListener onblur;
+ attribute [DontEnum, ProtectedListener] EventListener onchange;
+ attribute [DontEnum, ProtectedListener] EventListener onclick;
+ attribute [DontEnum, ProtectedListener] EventListener oncontextmenu;
+ attribute [DontEnum, ProtectedListener] EventListener ondblclick;
+ attribute [DontEnum, ProtectedListener] EventListener onerror;
+ attribute [DontEnum, ProtectedListener] EventListener onfocus;
+ attribute [DontEnum, ProtectedListener] EventListener oninput;
+ attribute [DontEnum, ProtectedListener] EventListener onkeydown;
+ attribute [DontEnum, ProtectedListener] EventListener onkeypress;
+ attribute [DontEnum, ProtectedListener] EventListener onkeyup;
+ attribute [DontEnum, ProtectedListener] EventListener onload;
+ attribute [DontEnum, ProtectedListener] EventListener onmousedown;
+ attribute [DontEnum, ProtectedListener] EventListener onmousemove;
+ attribute [DontEnum, ProtectedListener] EventListener onmouseout;
+ attribute [DontEnum, ProtectedListener] EventListener onmouseover;
+ attribute [DontEnum, ProtectedListener] EventListener onmouseup;
+ attribute [DontEnum, ProtectedListener] EventListener onmousewheel;
+ attribute [DontEnum, ProtectedListener] EventListener onbeforecut;
+ attribute [DontEnum, ProtectedListener] EventListener oncut;
+ attribute [DontEnum, ProtectedListener] EventListener onbeforecopy;
+ attribute [DontEnum, ProtectedListener] EventListener oncopy;
+ attribute [DontEnum, ProtectedListener] EventListener onbeforepaste;
+ attribute [DontEnum, ProtectedListener] EventListener onpaste;
+ attribute [DontEnum, ProtectedListener] EventListener ondragenter;
+ attribute [DontEnum, ProtectedListener] EventListener ondragover;
+ attribute [DontEnum, ProtectedListener] EventListener ondragleave;
+ attribute [DontEnum, ProtectedListener] EventListener ondrop;
+ attribute [DontEnum, ProtectedListener] EventListener ondragstart;
+ attribute [DontEnum, ProtectedListener] EventListener ondrag;
+ attribute [DontEnum, ProtectedListener] EventListener ondragend;
+ attribute [DontEnum, ProtectedListener] EventListener onreset;
+ attribute [DontEnum, ProtectedListener] EventListener onresize;
+ attribute [DontEnum, ProtectedListener] EventListener onscroll;
+ attribute [DontEnum, ProtectedListener] EventListener onsearch;
+ attribute [DontEnum, ProtectedListener] EventListener onselect;
+ attribute [DontEnum, ProtectedListener] EventListener onselectstart;
+ attribute [DontEnum, ProtectedListener] EventListener onsubmit;
+ attribute [DontEnum, ProtectedListener] EventListener onunload;
+
+ [Custom] void addEventListener(in DOMString type,
+ in EventListener listener,
+ in boolean useCapture);
+ [Custom] void removeEventListener(in DOMString type,
+ in EventListener listener,
+ in boolean useCapture);
+ boolean dispatchEvent(in Event event)
+ raises(EventException);
+#endif /* defined(LANGUAGE_OBJECTIVE_C) */
+ };
+}
diff --git a/WebCore/svg/SVGElementInstanceList.cpp b/WebCore/svg/SVGElementInstanceList.cpp
new file mode 100644
index 0000000..f039d44
--- /dev/null
+++ b/WebCore/svg/SVGElementInstanceList.cpp
@@ -0,0 +1,62 @@
+/*
+ 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 SVGElementInstanceList::length() const
+{
+ // NOTE: We could use the same caching facilities, like the ones "ChildNodeList" uses.
+ unsigned length = 0;
+ for (SVGElementInstance* instance = m_rootInstance->firstChild(); instance; instance = instance->nextSibling())
+ length++;
+ return length;
+}
+
+SVGElementInstance* SVGElementInstanceList::item(unsigned index)
+{
+ unsigned 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..ef4c73c
--- /dev/null
+++ b/WebCore/svg/SVGElementInstanceList.h
@@ -0,0 +1,50 @@
+/*
+ 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 length() const;
+ SVGElementInstance* item(unsigned 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..a07a9a7
--- /dev/null
+++ b/WebCore/svg/SVGEllipseElement.cpp
@@ -0,0 +1,106 @@
+/*
+ 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, SVGNames::cxAttr, LengthModeWidth)
+ , m_cy(this, SVGNames::cyAttr, LengthModeHeight)
+ , m_rx(this, SVGNames::rxAttr, LengthModeWidth)
+ , m_ry(this, SVGNames::ryAttr, LengthModeHeight)
+{
+}
+
+SVGEllipseElement::~SVGEllipseElement()
+{
+}
+
+void SVGEllipseElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::cxAttr)
+ setCxBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::cyAttr)
+ setCyBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::rxAttr) {
+ setRxBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ if (rxBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for ellipse <rx> is not allowed");
+ } else if (attr->name() == SVGNames::ryAttr) {
+ setRyBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ if (ryBaseValue().value(this) < 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(this), cy().value(this)),
+ rx().value(this), ry().value(this));
+}
+
+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..8c7d3a1
--- /dev/null
+++ b/WebCore/svg/SVGEllipseElement.h
@@ -0,0 +1,63 @@
+/*
+ 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_DECLARATIONS(SVGEllipseElement, SVGNames::ellipseTagString, SVGNames::cxAttrString, SVGLength, Cx, cx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGEllipseElement, SVGNames::ellipseTagString, SVGNames::cyAttrString, SVGLength, Cy, cy)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGEllipseElement, SVGNames::ellipseTagString, SVGNames::rxAttrString, SVGLength, Rx, rx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGEllipseElement, SVGNames::ellipseTagString, SVGNames::ryAttrString, 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..b82adf7
--- /dev/null
+++ b/WebCore/svg/SVGException.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ * Copyright (C) 2006, 2008 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.
+ *
+ */
+
+#ifndef SVGException_h
+#define SVGException_h
+
+#include "ExceptionBase.h"
+
+#if ENABLE(SVG)
+
+namespace WebCore {
+
+ class SVGException : public ExceptionBase {
+ public:
+ static PassRefPtr<SVGException> create(const ExceptionCodeDescription& description)
+ {
+ return adoptRef(new SVGException(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
+ };
+
+ private:
+ SVGException(const ExceptionCodeDescription& description)
+ : ExceptionBase(description)
+ {
+ }
+ };
+
+} // 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..d087f64
--- /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 {
+
+char SVGExternalResourcesRequiredIdentifier[] = "SVGExternalResourcesRequired";
+
+SVGExternalResourcesRequired::SVGExternalResourcesRequired()
+ : m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
+{
+}
+
+SVGExternalResourcesRequired::~SVGExternalResourcesRequired()
+{
+}
+
+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..0ab6dc9
--- /dev/null
+++ b/WebCore/svg/SVGExternalResourcesRequired.h
@@ -0,0 +1,63 @@
+/*
+ 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 "SVGElement.h"
+
+namespace WebCore {
+
+ extern char SVGExternalResourcesRequiredIdentifier[];
+ 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&);
+
+ virtual const SVGElement* contextElement() const = 0;
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGExternalResourcesRequired, SVGExternalResourcesRequiredIdentifier,
+ SVGNames::externalResourcesRequiredAttrString, 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..3c8557e
--- /dev/null
+++ b/WebCore/svg/SVGFEBlendElement.cpp
@@ -0,0 +1,90 @@
+/*
+ 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_in1(this, SVGNames::inAttr)
+ , m_in2(this, SVGNames::in2Attr)
+ , m_mode(this, SVGNames::modeAttr, FEBLEND_MODE_NORMAL)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEBlendElement::~SVGFEBlendElement()
+{
+}
+
+void SVGFEBlendElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::modeAttr) {
+ if (value == "normal")
+ setModeBaseValue(FEBLEND_MODE_NORMAL);
+ else if (value == "multiply")
+ setModeBaseValue(FEBLEND_MODE_MULTIPLY);
+ else if (value == "screen")
+ setModeBaseValue(FEBLEND_MODE_SCREEN);
+ else if (value == "darken")
+ setModeBaseValue(FEBLEND_MODE_DARKEN);
+ else if (value == "lighten")
+ setModeBaseValue(FEBLEND_MODE_LIGHTEN);
+ } else if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else if (attr->name() == SVGNames::in2Attr)
+ setIn2BaseValue(value);
+ else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFilterEffect* SVGFEBlendElement::filterEffect(SVGResourceFilter* filter) const
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool SVGFEBlendElement::build(FilterBuilder* builder)
+{
+ FilterEffect* input1 = builder->getEffectById(in1());
+ FilterEffect* input2 = builder->getEffectById(in2());
+
+ if(!input1 || !input2)
+ return false;
+
+ builder->add(result(), FEBlend::create(input1, input2, static_cast<BlendModeType> (mode())));
+
+ return true;
+}
+
+}
+
+#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..a85d174
--- /dev/null
+++ b/WebCore/svg/SVGFEBlendElement.h
@@ -0,0 +1,55 @@
+/*
+ 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 "FEBlend.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore
+{
+ class SVGFEBlendElement : public SVGFilterPrimitiveStandardAttributes
+ {
+ public:
+ SVGFEBlendElement(const QualifiedName&, Document*);
+ virtual ~SVGFEBlendElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ bool build(FilterBuilder*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEBlendElement, SVGNames::feBlendTagString, SVGNames::inAttrString, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEBlendElement, SVGNames::feBlendTagString, SVGNames::in2AttrString, String, In2, in2)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEBlendElement, SVGNames::feBlendTagString, SVGNames::modeAttrString, int, Mode, mode)
+
+ mutable RefPtr<FEBlend> 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..c3a8f01
--- /dev/null
+++ b/WebCore/svg/SVGFEColorMatrixElement.cpp
@@ -0,0 +1,96 @@
+/*
+ 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_in1(this, SVGNames::inAttr)
+ , m_type(this, SVGNames::typeAttr, FECOLORMATRIX_TYPE_UNKNOWN)
+ , m_values(this, SVGNames::valuesAttr, SVGNumberList::create(SVGNames::valuesAttr))
+ , m_filterEffect(0)
+{
+}
+
+SVGFEColorMatrixElement::~SVGFEColorMatrixElement()
+{
+}
+
+void SVGFEColorMatrixElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::typeAttr) {
+ if (value == "matrix")
+ setTypeBaseValue(FECOLORMATRIX_TYPE_MATRIX);
+ else if (value == "saturate")
+ setTypeBaseValue(FECOLORMATRIX_TYPE_SATURATE);
+ else if (value == "hueRotate")
+ setTypeBaseValue(FECOLORMATRIX_TYPE_HUEROTATE);
+ else if (value == "luminanceToAlpha")
+ setTypeBaseValue(FECOLORMATRIX_TYPE_LUMINANCETOALPHA);
+ }
+ else if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else if (attr->name() == SVGNames::valuesAttr)
+ valuesBaseValue()->parse(value);
+ else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFilterEffect* SVGFEColorMatrixElement::filterEffect(SVGResourceFilter* filter) const
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool SVGFEColorMatrixElement::build(FilterBuilder* builder)
+{
+ FilterEffect* input1 = builder->getEffectById(in1());
+
+ if(!input1)
+ return false;
+
+ 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));
+
+ builder->add(result(), FEColorMatrix::create(input1, static_cast<ColorMatrixType> (type()), _values));
+
+ return true;
+}
+
+} //namespace WebCore
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFEColorMatrixElement.h b/WebCore/svg/SVGFEColorMatrixElement.h
new file mode 100644
index 0000000..f39db86
--- /dev/null
+++ b/WebCore/svg/SVGFEColorMatrixElement.h
@@ -0,0 +1,53 @@
+/*
+ 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 "FEColorMatrix.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+#include "SVGNumberList.h"
+
+namespace WebCore {
+
+ class SVGFEColorMatrixElement : public SVGFilterPrimitiveStandardAttributes {
+ public:
+ SVGFEColorMatrixElement(const QualifiedName&, Document*);
+ virtual ~SVGFEColorMatrixElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ bool build(FilterBuilder*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEColorMatrixElement, SVGNames::feColorMatrixTagString, SVGNames::inAttrString, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEColorMatrixElement, SVGNames::feColorMatrixTagString, SVGNames::typeAttrString, int, Type, type)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEColorMatrixElement, SVGNames::feColorMatrixTagString, SVGNames::valuesAttrString, SVGNumberList, Values, values)
+
+ mutable RefPtr<FEColorMatrix> m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..e1be6ae
--- /dev/null
+++ b/WebCore/svg/SVGFEComponentTransferElement.cpp
@@ -0,0 +1,97 @@
+/*
+ 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_in1(this, SVGNames::inAttr)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEComponentTransferElement::~SVGFEComponentTransferElement()
+{
+}
+
+void SVGFEComponentTransferElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFilterEffect* SVGFEComponentTransferElement::filterEffect(SVGResourceFilter* filter) const
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool SVGFEComponentTransferElement::build(FilterBuilder* builder)
+{
+ FilterEffect* input1 = builder->getEffectById(in1());
+
+ if(!input1)
+ return false;
+
+ ComponentTransferFunction red;
+ ComponentTransferFunction green;
+ ComponentTransferFunction blue;
+ ComponentTransferFunction alpha;
+
+ for (Node* n = firstChild(); n != 0; n = n->nextSibling()) {
+ if (n->hasTagName(SVGNames::feFuncRTag))
+ red = static_cast<SVGFEFuncRElement*>(n)->transferFunction();
+ else if (n->hasTagName(SVGNames::feFuncGTag))
+ green = static_cast<SVGFEFuncGElement*>(n)->transferFunction();
+ else if (n->hasTagName(SVGNames::feFuncBTag))
+ blue = static_cast<SVGFEFuncBElement*>(n)->transferFunction();
+ else if (n->hasTagName(SVGNames::feFuncATag))
+ alpha = static_cast<SVGFEFuncAElement*>(n)->transferFunction();
+ }
+
+ builder->add(result(), FEComponentTransfer::create(input1, red, green, blue, alpha));
+
+ return true;
+}
+
+}
+
+#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..e80ea94
--- /dev/null
+++ b/WebCore/svg/SVGFEComponentTransferElement.h
@@ -0,0 +1,50 @@
+/*
+ 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 "FEComponentTransfer.h"
+
+namespace WebCore {
+
+ class SVGFEComponentTransferElement : public SVGFilterPrimitiveStandardAttributes {
+ public:
+ SVGFEComponentTransferElement(const QualifiedName&, Document*);
+ virtual ~SVGFEComponentTransferElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ bool build(FilterBuilder*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEComponentTransferElement, SVGNames::feComponentTransferTagString, SVGNames::inAttrString, String, In1, in1)
+
+ mutable RefPtr<FEComponentTransfer> 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..f2fc4dc
--- /dev/null
+++ b/WebCore/svg/SVGFECompositeElement.cpp
@@ -0,0 +1,106 @@
+/*
+ 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_in1(this, SVGNames::inAttr)
+ , m_in2(this, SVGNames::in2Attr)
+ , m__operator(this, SVGNames::operatorAttr, FECOMPOSITE_OPERATOR_OVER)
+ , m_k1(this, SVGNames::k1Attr)
+ , m_k2(this, SVGNames::k2Attr)
+ , m_k3(this, SVGNames::k3Attr)
+ , m_k4(this, SVGNames::k4Attr)
+ , m_filterEffect(0)
+{
+}
+
+SVGFECompositeElement::~SVGFECompositeElement()
+{
+}
+
+void SVGFECompositeElement::parseMappedAttribute(MappedAttribute *attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::operatorAttr) {
+ if (value == "over")
+ set_operatorBaseValue(FECOMPOSITE_OPERATOR_OVER);
+ else if (value == "in")
+ set_operatorBaseValue(FECOMPOSITE_OPERATOR_IN);
+ else if (value == "out")
+ set_operatorBaseValue(FECOMPOSITE_OPERATOR_OUT);
+ else if (value == "atop")
+ set_operatorBaseValue(FECOMPOSITE_OPERATOR_ATOP);
+ else if (value == "xor")
+ set_operatorBaseValue(FECOMPOSITE_OPERATOR_XOR);
+ else if (value == "arithmetic")
+ set_operatorBaseValue(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);
+}
+
+SVGFilterEffect* SVGFECompositeElement::filterEffect(SVGResourceFilter* filter) const
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool SVGFECompositeElement::build(FilterBuilder* builder)
+{
+ FilterEffect* input1 = builder->getEffectById(in1());
+ FilterEffect* input2 = builder->getEffectById(in2());
+
+ if(!input1 || !input2)
+ return false;
+
+ RefPtr<FilterEffect> addedEffect = FEComposite::create(input1, input2, static_cast<CompositeOperationType> (_operator()),
+ k1(), k2(), k3(), k4());
+ builder->add(result(), addedEffect.release());
+
+ return true;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFECompositeElement.h b/WebCore/svg/SVGFECompositeElement.h
new file mode 100644
index 0000000..89ad7df
--- /dev/null
+++ b/WebCore/svg/SVGFECompositeElement.h
@@ -0,0 +1,56 @@
+/*
+ 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 "FEComposite.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore {
+
+ class SVGFECompositeElement : public SVGFilterPrimitiveStandardAttributes {
+ public:
+ SVGFECompositeElement(const QualifiedName&, Document*);
+ virtual ~SVGFECompositeElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ bool build(FilterBuilder*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, SVGNames::feCompositeTagString, SVGNames::inAttrString, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, SVGNames::feCompositeTagString, SVGNames::in2AttrString, String, In2, in2)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, SVGNames::feCompositeTagString, SVGNames::operatorAttrString, int, _operator, _operator)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, SVGNames::feCompositeTagString, SVGNames::k1AttrString, float, K1, k1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, SVGNames::feCompositeTagString, SVGNames::k2AttrString, float, K2, k2)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, SVGNames::feCompositeTagString, SVGNames::k3AttrString, float, K3, k3)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, SVGNames::feCompositeTagString, SVGNames::k4AttrString, float, K4, k4)
+
+ mutable RefPtr<FEComposite> m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..87fa33a
--- /dev/null
+++ b/WebCore/svg/SVGFEDiffuseLightingElement.cpp
@@ -0,0 +1,115 @@
+/*
+ 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 {
+
+char SVGKernelUnitLengthXIdentifier[] = "SVGKernelUnitLengthX";
+char SVGKernelUnitLengthYIdentifier[] = "SVGKernelUnitLengthY";
+
+SVGFEDiffuseLightingElement::SVGFEDiffuseLightingElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_in1(this, SVGNames::inAttr)
+ , m_diffuseConstant(this, SVGNames::diffuseConstantAttr, 1.0f)
+ , m_surfaceScale(this, SVGNames::surfaceScaleAttr, 1.0f)
+ , m_kernelUnitLengthX(this, SVGNames::kernelUnitLengthAttr)
+ , m_kernelUnitLengthY(this, SVGNames::kernelUnitLengthAttr)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEDiffuseLightingElement::~SVGFEDiffuseLightingElement()
+{
+}
+
+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
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool SVGFEDiffuseLightingElement::build(FilterBuilder* builder)
+{
+ FilterEffect* input1 = builder->getEffectById(in1());
+
+ if(!input1)
+ return false;
+
+ RefPtr<RenderStyle> filterStyle = styleForRenderer();
+ Color color = filterStyle->svgStyle()->lightingColor();
+
+ RefPtr<FilterEffect> addedEffect = FEDiffuseLighting::create(input1, color, surfaceScale(), diffuseConstant(),
+ kernelUnitLengthX(), kernelUnitLengthY(), findLights());
+ builder->add(result(), addedEffect.release());
+
+ return true;
+}
+
+LightSource* SVGFEDiffuseLightingElement::findLights() const
+{
+ LightSource* 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;
+ }
+ }
+
+ return light;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFEDiffuseLightingElement.h b/WebCore/svg/SVGFEDiffuseLightingElement.h
new file mode 100644
index 0000000..70c6777
--- /dev/null
+++ b/WebCore/svg/SVGFEDiffuseLightingElement.h
@@ -0,0 +1,61 @@
+/*
+ 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 "SVGFELightElement.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore {
+
+ extern char SVGKernelUnitLengthXIdentifier[];
+ extern char SVGKernelUnitLengthYIdentifier[];
+
+ class FEDiffuseLighting;
+ class SVGColor;
+
+ class SVGFEDiffuseLightingElement : public SVGFilterPrimitiveStandardAttributes {
+ public:
+ SVGFEDiffuseLightingElement(const QualifiedName&, Document*);
+ virtual ~SVGFEDiffuseLightingElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ bool build(FilterBuilder*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDiffuseLightingElement, SVGNames::feDiffuseLightingTagString, SVGNames::inAttrString, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDiffuseLightingElement, SVGNames::feDiffuseLightingTagString, SVGNames::diffuseConstantAttrString, float, DiffuseConstant, diffuseConstant)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDiffuseLightingElement, SVGNames::feDiffuseLightingTagString, SVGNames::surfaceScaleAttrString, float, SurfaceScale, surfaceScale)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDiffuseLightingElement, SVGNames::feDiffuseLightingTagString, SVGKernelUnitLengthXIdentifier, float, KernelUnitLengthX, kernelUnitLengthX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDiffuseLightingElement, SVGNames::feDiffuseLightingTagString, SVGKernelUnitLengthYIdentifier, float, KernelUnitLengthY, kernelUnitLengthY)
+
+ LightSource* findLights() const;
+
+ mutable RefPtr<FEDiffuseLighting> m_filterEffect;
+ };
+
+} // 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..3b6dfbf
--- /dev/null
+++ b/WebCore/svg/SVGFEDisplacementMapElement.cpp
@@ -0,0 +1,102 @@
+/*
+ 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_in1(this, SVGNames::inAttr)
+ , m_in2(this, SVGNames::in2Attr)
+ , m_xChannelSelector(this, SVGNames::xChannelSelectorAttr, CHANNEL_A)
+ , m_yChannelSelector(this, SVGNames::yChannelSelectorAttr, CHANNEL_A)
+ , m_scale(this, SVGNames::scaleAttr)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEDisplacementMapElement::~SVGFEDisplacementMapElement()
+{
+}
+
+ChannelSelectorType SVGFEDisplacementMapElement::stringToChannel(const String& key)
+{
+ if (key == "R")
+ return CHANNEL_R;
+ else if (key == "G")
+ return CHANNEL_G;
+ else if (key == "B")
+ return CHANNEL_B;
+ else if (key == "A")
+ return CHANNEL_A;
+
+ return 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);
+}
+
+SVGFilterEffect* SVGFEDisplacementMapElement::filterEffect(SVGResourceFilter* filter) const
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool SVGFEDisplacementMapElement::build(FilterBuilder* builder)
+{
+ FilterEffect* input1 = builder->getEffectById(in1());
+ FilterEffect* input2 = builder->getEffectById(in2());
+
+ if(!input1 || !input2)
+ return false;
+
+
+ RefPtr<FilterEffect> addedEffect = FEDisplacementMap::create(input1, input2, static_cast<ChannelSelectorType> (xChannelSelector()),
+ static_cast<ChannelSelectorType> (yChannelSelector()), scale());
+ builder->add(result(), addedEffect.release());
+
+ return true;
+}
+
+}
+
+#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..21b93f4
--- /dev/null
+++ b/WebCore/svg/SVGFEDisplacementMapElement.h
@@ -0,0 +1,53 @@
+/*
+ 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 ChannelSelectorType stringToChannel(const String&);
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ bool build(FilterBuilder*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDisplacementMapElement, SVGNames::feDisplacementMapTagString, SVGNames::inAttrString, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDisplacementMapElement, SVGNames::feDisplacementMapTagString, SVGNames::in2AttrString, String, In2, in2)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDisplacementMapElement, SVGNames::feDisplacementMapTagString, SVGNames::xChannelSelectorAttrString, int, XChannelSelector, xChannelSelector)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDisplacementMapElement, SVGNames::feDisplacementMapTagString, SVGNames::yChannelSelectorAttrString, int, YChannelSelector, yChannelSelector)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEDisplacementMapElement, SVGNames::feDisplacementMapTagString, SVGNames::scaleAttrString, float, Scale, scale)
+
+ mutable RefPtr<FEDisplacementMap> 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..e9ec48d
--- /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()
+{
+}
+
+LightSource* SVGFEDistantLightElement::lightSource() const
+{
+ return new DistantLightSource(azimuth(), elevation());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFEDistantLightElement.h b/WebCore/svg/SVGFEDistantLightElement.h
new file mode 100644
index 0000000..e43282f
--- /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 LightSource* 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..98e7d6f
--- /dev/null
+++ b/WebCore/svg/SVGFEFloodElement.cpp
@@ -0,0 +1,74 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2007, 2008 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 "Document.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()
+{
+}
+
+void SVGFEFloodElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFilterEffect* SVGFEFloodElement::filterEffect(SVGResourceFilter* filter) const
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool SVGFEFloodElement::build(FilterBuilder* builder)
+{
+ RefPtr<RenderStyle> filterStyle = styleForRenderer();
+
+ Color color = filterStyle->svgStyle()->floodColor();
+ float opacity = filterStyle->svgStyle()->floodOpacity();
+
+ builder->add(result(), FEFlood::create(color, opacity));
+
+ return true;
+}
+
+}
+
+#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..046f418
--- /dev/null
+++ b/WebCore/svg/SVGFEFloodElement.h
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2008 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 SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ bool build(FilterBuilder*);
+
+ private:
+ mutable RefPtr<FEFlood> 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..d2356bf
--- /dev/null
+++ b/WebCore/svg/SVGFEFloodElement.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] SVGFEFloodElement : SVGElement,
+ SVGFilterPrimitiveStandardAttributes {
+ };
+
+}
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..4fbabe3
--- /dev/null
+++ b/WebCore/svg/SVGFEGaussianBlurElement.cpp
@@ -0,0 +1,89 @@
+/*
+ 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 {
+
+char SVGStdDeviationXAttrIdentifier[] = "SVGStdDeviationXAttr";
+char SVGStdDeviationYAttrIdentifier[] = "SVGStdDeviationYAttr";
+
+SVGFEGaussianBlurElement::SVGFEGaussianBlurElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_in1(this, SVGNames::inAttr)
+ , m_stdDeviationX(this, SVGNames::stdDeviationAttr)
+ , m_stdDeviationY(this, SVGNames::stdDeviationAttr)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEGaussianBlurElement::~SVGFEGaussianBlurElement()
+{
+}
+
+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);
+}
+
+SVGFilterEffect* SVGFEGaussianBlurElement::filterEffect(SVGResourceFilter* filter) const
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool SVGFEGaussianBlurElement::build(FilterBuilder* builder)
+{
+ FilterEffect* input1 = builder->getEffectById(in1());
+
+ if(!input1)
+ return false;
+
+ builder->add(result(), FEGaussianBlur::create(input1, stdDeviationX(), stdDeviationY()));
+
+ return true;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFEGaussianBlurElement.h b/WebCore/svg/SVGFEGaussianBlurElement.h
new file mode 100644
index 0000000..9e1c15c
--- /dev/null
+++ b/WebCore/svg/SVGFEGaussianBlurElement.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 SVGFEGaussianBlurElement_h
+#define SVGFEGaussianBlurElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEGaussianBlur.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore {
+
+ extern char SVGStdDeviationXAttrIdentifier[];
+ extern char SVGStdDeviationYAttrIdentifier[];
+
+ class SVGFEGaussianBlurElement : public SVGFilterPrimitiveStandardAttributes {
+ public:
+ SVGFEGaussianBlurElement(const QualifiedName&, Document*);
+ virtual ~SVGFEGaussianBlurElement();
+
+ void setStdDeviation(float stdDeviationX, float stdDeviationY);
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ bool build(FilterBuilder*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEGaussianBlurElement, SVGNames::feGaussianBlurTagString, SVGNames::inAttrString, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEGaussianBlurElement, SVGNames::feGaussianBlurTagString, SVGStdDeviationXAttrIdentifier, float, StdDeviationX, stdDeviationX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEGaussianBlurElement, SVGNames::feGaussianBlurTagString, SVGStdDeviationYAttrIdentifier, float, StdDeviationY, stdDeviationY)
+
+ mutable RefPtr<FEGaussianBlur> m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..e19ee78
--- /dev/null
+++ b/WebCore/svg/SVGFEImageElement.cpp
@@ -0,0 +1,113 @@
+/*
+ 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(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
+ , m_cachedImage(0)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEImageElement::~SVGFEImageElement()
+{
+ if (m_cachedImage)
+ m_cachedImage->removeClient(this);
+}
+
+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->removeClient(this);
+ m_cachedImage = ownerDocument()->docLoader()->requestImage(href());
+ if (m_cachedImage)
+ m_cachedImage->addClient(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.get());
+}
+
+SVGFilterEffect* SVGFEImageElement::filterEffect(SVGResourceFilter* filter) const
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool SVGFEImageElement::build(FilterBuilder* builder)
+{
+ if(!m_cachedImage)
+ return false;
+
+ builder->add(result(), FEImage::create(m_cachedImage.get()));
+
+ return true;
+}
+
+void SVGFEImageElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+ urls.append(href());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFEImageElement.h b/WebCore/svg/SVGFEImageElement.h
new file mode 100644
index 0000000..dc88c0a
--- /dev/null
+++ b/WebCore/svg/SVGFEImageElement.h
@@ -0,0 +1,66 @@
+/*
+ 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 "CachedResourceHandle.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+#include "SVGURIReference.h"
+#include "SVGLangSpace.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGFEImage.h"
+#include "SVGPreserveAspectRatio.h"
+
+namespace WebCore {
+
+ 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*);
+
+ virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+ bool build(FilterBuilder*);
+
+ protected:
+ virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEImageElement, SVGNames::feImageTagString, SVGNames::preserveAspectRatioAttrString, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio)
+
+ CachedResourceHandle<CachedImage> m_cachedImage;
+ mutable RefPtr<FEImage> m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..73c088f
--- /dev/null
+++ b/WebCore/svg/SVGFELightElement.cpp
@@ -0,0 +1,82 @@
+/*
+ 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 {
+
+char SVGFELightElementIdentifier[] = "SVGFELightElement";
+
+SVGFELightElement::SVGFELightElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+ , m_azimuth(this, SVGNames::azimuthAttr)
+ , m_elevation(this, SVGNames::elevationAttr)
+ , m_x(this, SVGNames::xAttr)
+ , m_y(this, SVGNames::yAttr)
+ , m_z(this, SVGNames::zAttr)
+ , m_pointsAtX(this, SVGNames::pointsAtXAttr)
+ , m_pointsAtY(this, SVGNames::pointsAtYAttr)
+ , m_pointsAtZ(this, SVGNames::pointsAtZAttr)
+ , m_specularExponent(this, SVGNames::specularExponentAttr, 1.0f)
+ , m_limitingConeAngle(this, SVGNames::limitingConeAngleAttr)
+{
+}
+
+SVGFELightElement::~SVGFELightElement()
+{
+}
+
+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..5c4a785
--- /dev/null
+++ b/WebCore/svg/SVGFELightElement.h
@@ -0,0 +1,60 @@
+/*
+ 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 {
+
+ extern char SVGFELightElementIdentifier[];
+
+ class SVGFELightElement : public SVGElement {
+ public:
+ SVGFELightElement(const QualifiedName&, Document*);
+ virtual ~SVGFELightElement();
+
+ virtual LightSource* lightSource() const = 0;
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, SVGFELightElementIdentifier, SVGNames::azimuthAttrString, float, Azimuth, azimuth)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, SVGFELightElementIdentifier, SVGNames::elevationAttrString, float, Elevation, elevation)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, SVGFELightElementIdentifier, SVGNames::xAttrString, float, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, SVGFELightElementIdentifier, SVGNames::yAttrString, float, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, SVGFELightElementIdentifier, SVGNames::zAttrString, float, Z, z)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, SVGFELightElementIdentifier, SVGNames::pointsAtXAttrString, float, PointsAtX, pointsAtX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, SVGFELightElementIdentifier, SVGNames::pointsAtYAttrString, float, PointsAtY, pointsAtY)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, SVGFELightElementIdentifier, SVGNames::pointsAtZAttrString, float, PointsAtZ, pointsAtZ)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, SVGFELightElementIdentifier, SVGNames::specularExponentAttrString, float, SpecularExponent, specularExponent)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, SVGFELightElementIdentifier, SVGNames::limitingConeAngleAttrString, 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..5ccf403
--- /dev/null
+++ b/WebCore/svg/SVGFEMergeElement.cpp
@@ -0,0 +1,71 @@
+/*
+ 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()
+{
+}
+
+SVGFilterEffect* SVGFEMergeElement::filterEffect(SVGResourceFilter* filter) const
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool SVGFEMergeElement::build(FilterBuilder* builder)
+{
+ Vector<FilterEffect*> mergeInputs;
+ for (Node* n = firstChild(); n != 0; n = n->nextSibling()) {
+ if (n->hasTagName(SVGNames::feMergeNodeTag)) {
+ FilterEffect* mergeEffect = builder->getEffectById(static_cast<SVGFEMergeNodeElement*>(n)->in1());
+ mergeInputs.append(mergeEffect);
+ }
+ }
+
+ if(mergeInputs.isEmpty())
+ return false;
+
+ builder->add(result(), FEMerge::create(mergeInputs));
+
+ return true;
+}
+
+}
+
+#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..6449286
--- /dev/null
+++ b/WebCore/svg/SVGFEMergeElement.h
@@ -0,0 +1,47 @@
+/*
+ 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 SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ bool build(FilterBuilder*);
+
+ private:
+ mutable RefPtr<FEMerge> 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..e68f4d7
--- /dev/null
+++ b/WebCore/svg/SVGFEMergeNodeElement.cpp
@@ -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.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEMergeNodeElement.h"
+
+namespace WebCore {
+
+SVGFEMergeNodeElement::SVGFEMergeNodeElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+ , m_in1(this, SVGNames::inAttr)
+{
+}
+
+SVGFEMergeNodeElement::~SVGFEMergeNodeElement()
+{
+}
+
+void SVGFEMergeNodeElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else
+ SVGElement::parseMappedAttribute(attr);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFEMergeNodeElement.h b/WebCore/svg/SVGFEMergeNodeElement.h
new file mode 100644
index 0000000..c1abd2f
--- /dev/null
+++ b/WebCore/svg/SVGFEMergeNodeElement.h
@@ -0,0 +1,48 @@
+/*
+ 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, SVGNames::feMergeNodeTagString, SVGNames::inAttrString, String, In1, in1)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..4fa572f
--- /dev/null
+++ b/WebCore/svg/SVGFEOffsetElement.cpp
@@ -0,0 +1,79 @@
+/*
+ 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_in1(this, SVGNames::inAttr)
+ , m_dx(this, SVGNames::dxAttr)
+ , m_dy(this, SVGNames::dyAttr)
+ , m_filterEffect(0)
+{
+}
+
+SVGFEOffsetElement::~SVGFEOffsetElement()
+{
+}
+
+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);
+}
+
+SVGFilterEffect* SVGFEOffsetElement::filterEffect(SVGResourceFilter* filter) const
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool SVGFEOffsetElement::build(FilterBuilder* builder)
+{
+ FilterEffect* input1 = builder->getEffectById(in1());
+
+ if(!input1)
+ return false;
+
+ builder->add(result(), FEOffset::create(input1, dx(), dy()));
+
+ return true;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFEOffsetElement.h b/WebCore/svg/SVGFEOffsetElement.h
new file mode 100644
index 0000000..2d1b0ba
--- /dev/null
+++ b/WebCore/svg/SVGFEOffsetElement.h
@@ -0,0 +1,52 @@
+/*
+ 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 SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ bool build(FilterBuilder*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEOffsetElement, SVGNames::feOffsetTagString, SVGNames::inAttrString, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEOffsetElement, SVGNames::feOffsetTagString, SVGNames::dxAttrString, float, Dx, dx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFEOffsetElement, SVGNames::feOffsetTagString, SVGNames::dyAttrString, float, Dy, dy)
+
+ mutable RefPtr<FEOffset> m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..f30f6db
--- /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()
+{
+}
+
+LightSource* SVGFEPointLightElement::lightSource() const
+{
+ FloatPoint3D pos(x(), y(), z());
+ return new PointLightSource(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..5b72e09
--- /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 LightSource* 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..c7b7410
--- /dev/null
+++ b/WebCore/svg/SVGFESpecularLightingElement.cpp
@@ -0,0 +1,115 @@
+/*
+ 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_in1(this, SVGNames::inAttr)
+ , m_specularConstant(this, SVGNames::specularConstantAttr, 1.0f)
+ , m_specularExponent(this, SVGNames::specularExponentAttr, 1.0f)
+ , m_surfaceScale(this, SVGNames::surfaceScaleAttr, 1.0f)
+ , m_kernelUnitLengthX(this, SVGNames::kernelUnitLengthAttr)
+ , m_kernelUnitLengthY(this, SVGNames::kernelUnitLengthAttr)
+ , m_filterEffect(0)
+{
+}
+
+SVGFESpecularLightingElement::~SVGFESpecularLightingElement()
+{
+}
+
+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);
+}
+
+SVGFilterEffect* SVGFESpecularLightingElement::filterEffect(SVGResourceFilter* filter) const
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+LightSource* SVGFESpecularLightingElement::findLights() const
+{
+ LightSource* 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;
+ }
+ }
+
+ return light;
+}
+
+bool SVGFESpecularLightingElement::build(FilterBuilder* builder)
+{
+ FilterEffect* input1 = builder->getEffectById(in1());
+
+ if(!input1)
+ return false;
+
+ RefPtr<RenderStyle> filterStyle = styleForRenderer();
+
+ Color color = filterStyle->svgStyle()->lightingColor();
+
+ RefPtr<FilterEffect> addedEffect = FESpecularLighting::create(input1, color, surfaceScale(), specularConstant(),
+ specularExponent(), kernelUnitLengthX(), kernelUnitLengthY(), findLights());
+ builder->add(result(), addedEffect.release());
+
+ return true;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFESpecularLightingElement.h b/WebCore/svg/SVGFESpecularLightingElement.h
new file mode 100644
index 0000000..d76cb43
--- /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 {
+
+ extern char SVGKernelUnitLengthXIdentifier[];
+ extern char SVGKernelUnitLengthYIdentifier[];
+
+ class SVGColor;
+
+ class SVGFESpecularLightingElement : public SVGFilterPrimitiveStandardAttributes {
+ public:
+ SVGFESpecularLightingElement(const QualifiedName&, Document*);
+ virtual ~SVGFESpecularLightingElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ bool build(FilterBuilder*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, SVGNames::feSpecularLightingTagString, SVGNames::inAttrString, String, In1, in1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, SVGNames::feSpecularLightingTagString, SVGNames::specularConstantAttrString, float, SpecularConstant, specularConstant)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, SVGNames::feSpecularLightingTagString, SVGNames::specularExponentAttrString, float, SpecularExponent, specularExponent)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, SVGNames::feSpecularLightingTagString, SVGNames::surfaceScaleAttrString, float, SurfaceScale, surfaceScale)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, SVGNames::feSpecularLightingTagString, SVGKernelUnitLengthXIdentifier, float, KernelUnitLengthX, kernelUnitLengthX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, SVGNames::feSpecularLightingTagString, SVGKernelUnitLengthYIdentifier, float, KernelUnitLengthY, kernelUnitLengthY)
+
+ mutable RefPtr<FESpecularLighting> m_filterEffect;
+
+ LightSource* findLights() 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..5add579
--- /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()
+{
+}
+
+LightSource* 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 SpotLightSource(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..2989b14
--- /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 LightSource* 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..bf90c33
--- /dev/null
+++ b/WebCore/svg/SVGFETileElement.cpp
@@ -0,0 +1,74 @@
+/*
+ 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_in1(this, SVGNames::inAttr)
+ , m_filterEffect(0)
+{
+}
+
+SVGFETileElement::~SVGFETileElement()
+{
+}
+
+void SVGFETileElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::inAttr)
+ setIn1BaseValue(value);
+ else
+ SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
+}
+
+SVGFilterEffect* SVGFETileElement::filterEffect(SVGResourceFilter* filter) const
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool SVGFETileElement::build(FilterBuilder* builder)
+{
+ FilterEffect* input1 = builder->getEffectById(in1());
+
+ if(!input1)
+ return false;
+
+ builder->add(result(), FETile::create(input1));
+
+ return true;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFETileElement.h b/WebCore/svg/SVGFETileElement.h
new file mode 100644
index 0000000..ba68115
--- /dev/null
+++ b/WebCore/svg/SVGFETileElement.h
@@ -0,0 +1,50 @@
+/*
+ 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 SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ bool build(FilterBuilder*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETileElement, SVGNames::feTileTagString, SVGNames::inAttrString, String, In1, in1)
+
+ mutable RefPtr<FETile> 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..f51d835
--- /dev/null
+++ b/WebCore/svg/SVGFETurbulenceElement.cpp
@@ -0,0 +1,96 @@
+/*
+ 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 {
+
+char SVGBaseFrequencyXIdentifier[] = "SVGBaseFrequencyX";
+char SVGBaseFrequencyYIdentifier[] = "SVGBaseFrequencyY";
+
+SVGFETurbulenceElement::SVGFETurbulenceElement(const QualifiedName& tagName, Document* doc)
+ : SVGFilterPrimitiveStandardAttributes(tagName, doc)
+ , m_baseFrequencyX(this, SVGNames::baseFrequencyAttr)
+ , m_baseFrequencyY(this, SVGNames::baseFrequencyAttr)
+ , m_numOctaves(this, SVGNames::numOctavesAttr, 1)
+ , m_seed(this, SVGNames::seedAttr)
+ , m_stitchTiles(this, SVGNames::stitchTilesAttr, SVG_STITCHTYPE_NOSTITCH)
+ , m_type(this, SVGNames::typeAttr, FETURBULENCE_TYPE_TURBULENCE)
+ , m_filterEffect(0)
+{
+}
+
+SVGFETurbulenceElement::~SVGFETurbulenceElement()
+{
+}
+
+void SVGFETurbulenceElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+ if (attr->name() == SVGNames::typeAttr) {
+ if (value == "fractalNoise")
+ setTypeBaseValue(FETURBULENCE_TYPE_FRACTALNOISE);
+ else if (value == "turbulence")
+ setTypeBaseValue(FETURBULENCE_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);
+}
+
+SVGFilterEffect* SVGFETurbulenceElement::filterEffect(SVGResourceFilter* filter) const
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool SVGFETurbulenceElement::build(FilterBuilder* builder)
+{
+ RefPtr<FilterEffect> addedEffect = FETurbulence::create(static_cast<TurbulanceType> (type()), baseFrequencyX(),
+ baseFrequencyY(), numOctaves(), seed(), stitchTiles() == SVG_STITCHTYPE_STITCH);
+ builder->add(result(), addedEffect.release());
+
+ return true;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFETurbulenceElement.h b/WebCore/svg/SVGFETurbulenceElement.h
new file mode 100644
index 0000000..bae2d9b
--- /dev/null
+++ b/WebCore/svg/SVGFETurbulenceElement.h
@@ -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.
+*/
+
+#ifndef SVGFETurbulenceElement_h
+#define SVGFETurbulenceElement_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFETurbulence.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+
+namespace WebCore {
+
+ extern char SVGBaseFrequencyXIdentifier[];
+ extern char SVGBaseFrequencyYIdentifier[];
+
+ 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 SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+ bool build(FilterBuilder*);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETurbulenceElement, SVGNames::feTurbulenceTagString, SVGBaseFrequencyXIdentifier, float, BaseFrequencyX, baseFrequencyX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETurbulenceElement, SVGNames::feTurbulenceTagString, SVGBaseFrequencyYIdentifier, float, BaseFrequencyY, baseFrequencyY)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETurbulenceElement, SVGNames::feTurbulenceTagString, SVGNames::numOctavesAttrString, long, NumOctaves, numOctaves)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETurbulenceElement, SVGNames::feTurbulenceTagString, SVGNames::seedAttrString, float, Seed, seed)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETurbulenceElement, SVGNames::feTurbulenceTagString, SVGNames::stitchTilesAttrString, int, StitchTiles, stitchTiles)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFETurbulenceElement, SVGNames::feTurbulenceTagString, SVGNames::typeAttrString, int, Type, type)
+
+ mutable RefPtr<FETurbulence> m_filterEffect;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..774232f
--- /dev/null
+++ b/WebCore/svg/SVGFilterElement.cpp
@@ -0,0 +1,156 @@
+/*
+ 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 {
+
+char SVGFilterResXIdentifier[] = "SVGFilterResX";
+char SVGFilterResYIdentifier[] = "SVGFilterResY";
+
+SVGFilterElement::SVGFilterElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , SVGURIReference()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_filterUnits(this, SVGNames::filterUnitsAttr, SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
+ , m_primitiveUnits(this, SVGNames::primitiveUnitsAttr, SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
+ , m_x(this, SVGNames::xAttr, LengthModeWidth, "-10%")
+ , m_y(this, SVGNames::yAttr, LengthModeHeight, "-10%")
+ , m_width(this, SVGNames::widthAttr, LengthModeWidth, "120%")
+ , m_height(this, SVGNames::heightAttr, LengthModeHeight, "120%")
+ , m_filterResX(this, SVGNames::filterResAttr)
+ , m_filterResY(this, SVGNames::filterResAttr)
+{
+ // Spec: If the x/y attribute is not specified, the effect is as if a value of "-10%" were specified.
+ // Spec: If the width/height attribute is not specified, the effect is as if a value of "120%" were specified.
+}
+
+SVGFilterElement::~SVGFilterElement()
+{
+}
+
+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(LengthModeWidth, value));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(LengthModeHeight, value));
+ else if (attr->name() == SVGNames::widthAttr)
+ setWidthBaseValue(SVGLength(LengthModeWidth, value));
+ else if (attr->name() == SVGNames::heightAttr)
+ setHeightBaseValue(SVGLength(LengthModeHeight, value));
+ else {
+ if (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(this);
+ _y = y().value(this);
+ _width = width().value(this);
+ _height = height().value(this);
+ }
+
+ 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..c907b9c
--- /dev/null
+++ b/WebCore/svg/SVGFilterElement.h
@@ -0,0 +1,73 @@
+/*
+ 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 {
+
+ extern char SVGFilterResXIdentifier[];
+ extern char SVGFilterResYIdentifier[];
+
+ 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_DECLARATIONS(SVGFilterElement, SVGNames::filterTagString, SVGNames::filterUnitsAttrString, int, FilterUnits, filterUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGNames::filterTagString, SVGNames::primitiveUnitsAttrString, int, PrimitiveUnits, primitiveUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGNames::filterTagString, SVGNames::xAttrString, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGNames::filterTagString, SVGNames::yAttrString, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGNames::filterTagString, SVGNames::widthAttrString, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGNames::filterTagString, SVGNames::heightAttrString, SVGLength, Height, height)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGNames::filterTagString, SVGFilterResXIdentifier, long, FilterResX, filterResX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGNames::filterTagString, SVGFilterResYIdentifier, long, FilterResY, filterResY)
+
+ RefPtr<SVGResourceFilter> m_filter;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..eab7bdd
--- /dev/null
+++ b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp
@@ -0,0 +1,128 @@
+/*
+ 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 {
+
+char SVGFilterPrimitiveStandardAttributesIdentifierIdentifier[] = "SVGFilterPrimitiveStandardAttributesIdentifier";
+
+SVGFilterPrimitiveStandardAttributes::SVGFilterPrimitiveStandardAttributes(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , m_x(this, SVGNames::xAttr, LengthModeWidth, "0%")
+ , m_y(this, SVGNames::yAttr, LengthModeHeight, "0%")
+ , m_width(this, SVGNames::widthAttr, LengthModeWidth, "100%")
+ , m_height(this, SVGNames::heightAttr, LengthModeHeight, "100%")
+ , m_result(this, SVGNames::resultAttr)
+{
+ // Spec: If the x/y attribute is not specified, the effect is as if a value of "0%" were specified.
+ // Spec: If the width/height attribute is not specified, the effect is as if a value of "100%" were specified.
+}
+
+SVGFilterPrimitiveStandardAttributes::~SVGFilterPrimitiveStandardAttributes()
+{
+}
+
+void SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(MappedAttribute* attr)
+{
+ const AtomicString& value = attr->value();
+ if (attr->name() == SVGNames::xAttr)
+ setXBaseValue(SVGLength(LengthModeWidth, value));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(LengthModeHeight, value));
+ else if (attr->name() == SVGNames::widthAttr)
+ setWidthBaseValue(SVGLength(LengthModeWidth, value));
+ else if (attr->name() == SVGNames::heightAttr)
+ setHeightBaseValue(SVGLength(LengthModeHeight, value));
+ else if (attr->name() == SVGNames::resultAttr)
+ setResultBaseValue(value);
+ else
+ return SVGStyledElement::parseMappedAttribute(attr);
+}
+
+void 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(this);
+ }
+
+ if (y().unitType() == LengthTypePercentage) {
+ filterEffect->setYBoundingBoxMode(true);
+ _y = y().valueAsPercentage();
+ } else {
+ filterEffect->setYBoundingBoxMode(false);
+ _y = y().value(this);
+ }
+
+ if (width().unitType() == LengthTypePercentage) {
+ filterEffect->setWidthBoundingBoxMode(true);
+ _width = width().valueAsPercentage();
+ } else {
+ filterEffect->setWidthBoundingBoxMode(false);
+ _width = width().value(this);
+ }
+
+ if (height().unitType() == LengthTypePercentage) {
+ filterEffect->setHeightBoundingBoxMode(true);
+ _height = height().valueAsPercentage();
+ } else {
+ filterEffect->setHeightBoundingBoxMode(false);
+ _height = height().value(this);
+ }
+ }
+
+ filterEffect->setSubRegion(FloatRect(_x, _y, _width, _height));
+ filterEffect->setResult(result());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h
new file mode 100644
index 0000000..bbdeb00
--- /dev/null
+++ b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h
@@ -0,0 +1,64 @@
+/*
+ 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 "FilterBuilder.h"
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+ extern char SVGFilterPrimitiveStandardAttributesIdentifier[];
+
+ 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:
+ virtual const SVGElement* contextElement() const { return this; }
+ void setStandardAttributes(SVGFilterEffect*) const;
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterPrimitiveStandardAttributes, SVGFilterPrimitiveStandardAttributesIdentifier, SVGNames::xAttrString, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterPrimitiveStandardAttributes, SVGFilterPrimitiveStandardAttributesIdentifier, SVGNames::yAttrString, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterPrimitiveStandardAttributes, SVGFilterPrimitiveStandardAttributesIdentifier, SVGNames::widthAttrString, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterPrimitiveStandardAttributes, SVGFilterPrimitiveStandardAttributesIdentifier, SVGNames::heightAttrString, SVGLength, Height, height)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFilterPrimitiveStandardAttributes, SVGFilterPrimitiveStandardAttributesIdentifier, SVGNames::resultAttrString, String, Result, result)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..69e077e
--- /dev/null
+++ b/WebCore/svg/SVGFitToViewBox.cpp
@@ -0,0 +1,121 @@
+/*
+ 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 "Document.h"
+#include "FloatRect.h"
+#include "SVGNames.h"
+#include "SVGParserUtilities.h"
+#include "SVGPreserveAspectRatio.h"
+#include "StringImpl.h"
+
+namespace WebCore {
+
+char SVGFitToViewBoxIdentifier[] = "SVGFitToViewBox";
+
+SVGFitToViewBox::SVGFitToViewBox()
+ : m_viewBox(this, SVGNames::viewBoxAttr)
+ , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
+{
+}
+
+SVGFitToViewBox::~SVGFitToViewBox()
+{
+}
+
+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..cc612ec
--- /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"
+#include "SVGPreserveAspectRatio.h"
+
+namespace WebCore {
+
+ extern char SVGFitToViewBoxIdentifier[];
+
+ class AffineTransform;
+
+ class SVGFitToViewBox {
+ public:
+ SVGFitToViewBox();
+ virtual ~SVGFitToViewBox();
+
+ 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&);
+
+ virtual const SVGElement* contextElement() const = 0;
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFitToViewBox, SVGFitToViewBoxIdentifier, SVGNames::viewBoxAttrString, FloatRect, ViewBox, viewBox)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGFitToViewBox, SVGFitToViewBoxIdentifier, SVGNames::preserveAspectRatioAttrString, 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..ece667f
--- /dev/null
+++ b/WebCore/svg/SVGFont.cpp
@@ -0,0 +1,594 @@
+/**
+ * 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 "SVGAltGlyphElement.h"
+#include "SVGFontData.h"
+#include "SVGGlyphElement.h"
+#include "SVGGlyphMap.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 length = input.length();
+
+ bool containsArabic = false;
+ for (unsigned 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 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 startPosition, unsigned 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 != static_cast<SVGGlyphIdentifier::ArabicForm>(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 startPosition, unsigned 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) {
+ const 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());
+
+ Vector<SVGGlyphIdentifier::ArabicForm> chars(charactersWithArabicForm(String(run.data(from), run.length()), run.rtl()));
+
+ SVGGlyphIdentifier identifier;
+ bool foundGlyph = false;
+ int characterLookupRange;
+ int endOfScanRange = to + m_walkerData.extraCharsAvailable;
+
+ bool haveAltGlyph = false;
+ SVGGlyphIdentifier altGlyphIdentifier;
+ if (RenderObject* renderObject = run.referencingRenderObject()) {
+ if (renderObject->element() && renderObject->element()->hasTagName(SVGNames::altGlyphTag)) {
+ SVGGlyphElement* glyphElement = static_cast<SVGAltGlyphElement*>(renderObject->element())->glyphElement();
+ if (glyphElement) {
+ haveAltGlyph = true;
+ altGlyphIdentifier = glyphElement->buildGlyphIdentifier();
+ altGlyphIdentifier.isValid = true;
+ altGlyphIdentifier.nameLength = to - from;
+ }
+ }
+ }
+
+ 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 = endOfScanRange - i;
+
+ String lookupString(run.data(i), characterLookupRange);
+ Vector<SVGGlyphIdentifier> glyphs;
+ if (haveAltGlyph)
+ glyphs.append(altGlyphIdentifier);
+ else
+ m_fontElement->getGlyphIdentifiersForString(lookupString, glyphs);
+
+ Vector<SVGGlyphIdentifier>::iterator it = glyphs.begin();
+ Vector<SVGGlyphIdentifier>::iterator end = glyphs.end();
+
+ for (; it != end; ++it) {
+ identifier = *it;
+ if (identifier.isValid && isCompatibleGlyph(identifier, isVerticalText, language, chars, i, i + identifier.nameLength)) {
+ ASSERT(characterLookupRange > 0);
+ i += identifier.nameLength - 1;
+ m_walkerData.charsConsumed += identifier.nameLength;
+ m_walkerData.glyphName = identifier.glyphName;
+
+ foundGlyph = true;
+ SVGGlyphElement::inheritUnspecifiedAttributes(identifier, m_fontData);
+ break;
+ }
+ }
+
+ if (!foundGlyph) {
+ ++m_walkerData.charsConsumed;
+ if (SVGMissingGlyphElement* element = m_fontElement->firstMissingGlyphElement()) {
+ // <missing-glyph> element support
+ identifier = SVGGlyphElement::buildGenericGlyphIdentifier(element);
+ SVGGlyphElement::inheritUnspecifiedAttributes(identifier, m_fontData);
+ identifier.isValid = true;
+ } 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;
+ int extraCharsAvailable;
+ int charsConsumed;
+ String glyphName;
+
+ 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);
+}
+
+
+SVGFontElement* Font::svgFont() const
+{
+ if (!isSVGFont())
+ return 0;
+
+ SVGFontElement* fontElement = 0;
+ SVGFontFaceElement* fontFaceElement = 0;
+ if (svgFontAndFontFaceElementForFontData(primaryFont(), fontFaceElement, fontElement))
+ return fontElement;
+
+ return 0;
+}
+
+static float floatWidthOfSubStringUsingSVGFont(const Font* font, const TextRun& run, int extraCharsAvailable, int from, int to, int& charsConsumed, String& glyphName)
+{
+ 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.extraCharsAvailable = extraCharsAvailable;
+ data.charsConsumed = 0;
+ 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());
+ charsConsumed = data.charsConsumed;
+ glyphName = data.glyphName;
+ return data.length;
+ }
+
+ return 0.0f;
+}
+
+float Font::floatWidthUsingSVGFont(const TextRun& run) const
+{
+ int charsConsumed;
+ String glyphName;
+ return floatWidthOfSubStringUsingSVGFont(this, run, 0, 0, run.length(), charsConsumed, glyphName);
+}
+
+float Font::floatWidthUsingSVGFont(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const
+{
+ return floatWidthOfSubStringUsingSVGFont(this, run, extraCharsAvailable, 0, run.length(), charsConsumed, glyphName);
+}
+
+// Callback & data structures to draw text using SVG Fonts
+struct SVGTextRunWalkerDrawTextData {
+ int extraCharsAvailable;
+ int charsConsumed;
+ String glyphName;
+ Vector<SVGGlyphIdentifier> glyphIdentifiers;
+ Vector<UChar> fallbackCharacters;
+};
+
+bool drawTextUsingSVGFontCallback(const SVGGlyphIdentifier& identifier, SVGTextRunWalkerDrawTextData& data)
+{
+ data.glyphIdentifiers.append(identifier);
+ return true;
+}
+
+void drawTextMissingGlyphCallback(const TextRun& run, SVGTextRunWalkerDrawTextData& data)
+{
+ ASSERT(run.length() == 1);
+ data.glyphIdentifiers.append(SVGGlyphIdentifier());
+ data.fallbackCharacters.append(run[0]);
+}
+
+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;
+ FloatPoint currentPoint = point;
+ float scale = convertEmUnitToPixel(size(), fontFaceElement->unitsPerEm(), 1.0f);
+
+ SVGPaintServer* activePaintServer = run.activePaintServer();
+
+ // If renderObject is not set, we're dealing for HTML text rendered using SVG Fonts.
+ if (!run.referencingRenderObject()) {
+ ASSERT(!activePaintServer);
+
+ // TODO: We're only supporting simple filled HTML text so far.
+ SVGPaintServerSolid* solidPaintServer = SVGPaintServer::sharedSolidPaintServer();
+ solidPaintServer->setColor(context->fillColor());
+
+ activePaintServer = solidPaintServer;
+ }
+
+ ASSERT(activePaintServer);
+
+ int charsConsumed;
+ String glyphName;
+ bool isVerticalText = false;
+ float xStartOffset = floatWidthOfSubStringUsingSVGFont(this, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed, glyphName);
+ FloatPoint glyphOrigin;
+
+ String language;
+
+ // TODO: language matching & svg glyphs should be possible for HTML text, too.
+ if (run.referencingRenderObject()) {
+ isVerticalText = isVerticalWritingMode(run.referencingRenderObject()->style()->svgStyle());
+
+ if (SVGElement* element = static_cast<SVGElement*>(run.referencingRenderObject()->element()))
+ language = element->getAttribute(XMLNames::langAttr);
+ }
+
+ if (!isVerticalText) {
+ glyphOrigin.setX(fontData->horizontalOriginX() * scale);
+ glyphOrigin.setY(fontData->horizontalOriginY() * scale);
+ }
+
+ data.extraCharsAvailable = 0;
+
+ SVGTextRunWalker<SVGTextRunWalkerDrawTextData> runWalker(fontData, fontElement, data, drawTextUsingSVGFontCallback, drawTextMissingGlyphCallback);
+ runWalker.walk(run, isVerticalText, language, from, to);
+
+ SVGPaintTargetType targetType = context->textDrawingMode() == cTextStroke ? ApplyToStrokeTargetType : ApplyToFillTargetType;
+
+ unsigned numGlyphs = data.glyphIdentifiers.size();
+ unsigned fallbackCharacterIndex = 0;
+ for (unsigned i = 0; i < numGlyphs; ++i) {
+ const SVGGlyphIdentifier& identifier = data.glyphIdentifiers[run.rtl() ? numGlyphs - i - 1 : i];
+ if (identifier.isValid) {
+ // FIXME: Support arbitary SVG content as glyph (currently limited to <glyph d="..."> situations).
+ if (!identifier.pathData.isEmpty()) {
+ context->save();
+
+ if (isVerticalText) {
+ glyphOrigin.setX(identifier.verticalOriginX * scale);
+ glyphOrigin.setY(identifier.verticalOriginY * scale);
+ }
+
+ context->translate(xStartOffset + currentPoint.x() + glyphOrigin.x(), currentPoint.y() + glyphOrigin.y());
+ context->scale(FloatSize(scale, -scale));
+
+ context->beginPath();
+ context->addPath(identifier.pathData);
+
+ if (activePaintServer->setup(context, run.referencingRenderObject(), 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 && scale != 0.0f)
+ context->setStrokeThickness(context->strokeThickness() / scale);
+
+ activePaintServer->renderPath(context, run.referencingRenderObject(), targetType);
+ activePaintServer->teardown(context, run.referencingRenderObject(), targetType);
+ }
+
+ context->restore();
+ }
+
+ if (isVerticalText)
+ currentPoint.move(0.0f, identifier.verticalAdvanceY * scale);
+ else
+ currentPoint.move(identifier.horizontalAdvanceX * scale, 0.0f);
+ } else {
+ // Handle system font fallback
+ FontDescription fontDescription(context->font().fontDescription());
+ fontDescription.setFamily(FontFamily());
+ Font font(fontDescription, 0, 0); // spacing handled by SVG text code.
+ font.update(context->font().fontSelector());
+
+ TextRun fallbackCharacterRun(run);
+ fallbackCharacterRun.setText(&data.fallbackCharacters[run.rtl() ? data.fallbackCharacters.size() - fallbackCharacterIndex - 1 : fallbackCharacterIndex], 1);
+ font.drawText(context, fallbackCharacterRun, currentPoint);
+
+ if (isVerticalText)
+ currentPoint.move(0.0f, font.floatWidth(fallbackCharacterRun));
+ else
+ currentPoint.move(font.floatWidth(fallbackCharacterRun), 0.0f);
+
+ fallbackCharacterIndex++;
+ }
+ }
+ }
+}
+
+FloatRect Font::selectionRectForTextUsingSVGFont(const TextRun& run, const IntPoint& point, int height, int from, int to) const
+{
+ int charsConsumed;
+ String glyphName;
+
+ return FloatRect(point.x() + floatWidthOfSubStringUsingSVGFont(this, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed, glyphName),
+ point.y(), floatWidthOfSubStringUsingSVGFont(this, run, 0, from, to, charsConsumed, glyphName), 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..4df3db2
--- /dev/null
+++ b/WebCore/svg/SVGFontData.h
@@ -0,0 +1,65 @@
+/*
+ * 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; }
+
+ 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:
+ // Ths SVGFontFaceElement is kept alive --
+ // 1) in the external font case: by the CSSFontFaceSource, which holds a reference to the external SVG document
+ // containing the element;
+ // 2) in the in-document font case: by virtue of being in the document tree and making sure that when it is removed
+ // from the document, it removes the @font-face rule it owns from the document's mapped element sheet and forces
+ // a style update.
+ 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..98321f4
--- /dev/null
+++ b/WebCore/svg/SVGFontElement.cpp
@@ -0,0 +1,243 @@
+/*
+ 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 "Document.h"
+#include "Font.h"
+#include "GlyphPageTreeNode.h"
+#include "SVGGlyphElement.h"
+#include "SVGMissingGlyphElement.h"
+#include "SVGNames.h"
+#include "SVGParserUtilities.h"
+#include <wtf/ASCIICType.h>
+
+using namespace WTF;
+
+namespace WebCore {
+
+using namespace SVGNames;
+
+SVGFontElement::SVGFontElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , m_isGlyphCacheValid(false)
+{
+}
+
+SVGFontElement::~SVGFontElement()
+{
+}
+
+void SVGFontElement::invalidateGlyphCache()
+{
+ if (m_isGlyphCacheValid) {
+ m_glyphMap.clear();
+ m_kerningPairs.clear();
+ }
+ m_isGlyphCacheValid = false;
+}
+
+SVGMissingGlyphElement* SVGFontElement::firstMissingGlyphElement() const
+{
+ for (Node* child = firstChild(); child; child = child->nextSibling()) {
+ if (child->hasTagName(missing_glyphTag))
+ return static_cast<SVGMissingGlyphElement*>(child);
+ }
+
+ return 0;
+}
+
+void SVGFontElement::ensureGlyphCache() const
+{
+ if (m_isGlyphCacheValid)
+ return;
+
+ for (Node* child = firstChild(); child; child = child->nextSibling()) {
+ if (child->hasTagName(glyphTag)) {
+ SVGGlyphElement* glyph = static_cast<SVGGlyphElement*>(child);
+ String unicode = glyph->getAttribute(unicodeAttr);
+ if (unicode.length())
+ m_glyphMap.add(unicode, glyph->buildGlyphIdentifier());
+ } else if (child->hasTagName(hkernTag)) {
+ SVGHKernElement* hkern = static_cast<SVGHKernElement*>(child);
+ SVGHorizontalKerningPair kerningPair = hkern->buildHorizontalKerningPair();
+ m_kerningPairs.append(kerningPair);
+ }
+ }
+
+ m_isGlyphCacheValid = true;
+}
+
+// Returns the number of characters consumed or 0 if no range was found.
+static unsigned parseUnicodeRange(const UChar* characters, unsigned length, pair<unsigned, unsigned>& range)
+{
+ if (length < 2)
+ return 0;
+ if (characters[0] != 'U')
+ return 0;
+ if (characters[1] != '+')
+ return 0;
+
+ // Parse the starting hex number (or its prefix).
+ unsigned start = 0;
+ unsigned startLength = 0;
+ for (unsigned i = 2; i < length; ++i) {
+ if (!isASCIIHexDigit(characters[i]))
+ break;
+ if (++startLength > 6)
+ return 0;
+ start = (start << 4) | toASCIIHexValue(characters[i]);
+ }
+
+ // Handle the case of ranges separated by "-" sign.
+ if (2 + startLength < length && characters[2 + startLength] == '-') {
+ if (!startLength)
+ return 0;
+
+ // Parse the ending hex number (or its prefix).
+ unsigned end = 0;
+ unsigned endLength = 0;
+ for (unsigned i = 2 + startLength + 1; i < length; ++i) {
+ if (!isASCIIHexDigit(characters[i]))
+ break;
+ if (++endLength > 6)
+ return 0;
+ end = (end << 4) | toASCIIHexValue(characters[i]);
+ }
+
+ if (!endLength)
+ return 0;
+
+ range.first = start;
+ range.second = end;
+ return 2 + startLength + 1 + endLength;
+ }
+
+ // Handle the case of a number with some optional trailing question marks.
+ unsigned end = start;
+ for (unsigned i = 2 + startLength; i < length; ++i) {
+ if (characters[i] != '?')
+ break;
+ if (++startLength > 6)
+ return 0;
+ start <<= 4;
+ end = (end << 4) | 0xF;
+ }
+
+ if (!startLength)
+ return 0;
+
+ range.first = start;
+ range.second = end;
+ return 2 + startLength;
+}
+
+static bool parseUnicodeRangeList(const UChar* characters, unsigned length, Vector<pair<unsigned, unsigned> >& ranges)
+{
+ ranges.clear();
+ if (!length)
+ return true;
+
+ const UChar* remainingCharacters = characters;
+ unsigned remainingLength = length;
+
+ while (1) {
+ pair<unsigned, unsigned> range;
+ unsigned charactersConsumed = parseUnicodeRange(remainingCharacters, remainingLength, range);
+ if (charactersConsumed) {
+ ranges.append(range);
+ remainingCharacters += charactersConsumed;
+ remainingLength -= charactersConsumed;
+ } else {
+ if (!remainingLength)
+ return false;
+ UChar character = remainingCharacters[0];
+ if (character == ',')
+ return false;
+ ranges.append(make_pair(character, character));
+ ++remainingCharacters;
+ --remainingLength;
+ }
+ if (!remainingLength)
+ return true;
+ if (remainingCharacters[0] != ',')
+ return false;
+ ++remainingCharacters;
+ --remainingLength;
+ }
+}
+
+static bool stringMatchesUnicodeRange(const String& unicodeString, const String& unicodeRangeSpec)
+{
+ Vector<pair<unsigned, unsigned> > ranges;
+ if (!parseUnicodeRangeList(unicodeRangeSpec.characters(), unicodeRangeSpec.length(), ranges))
+ return false;
+
+ if (unicodeString.length() != ranges.size())
+ return false;
+
+ for (size_t i = 0; i < unicodeString.length(); ++i) {
+ UChar c = unicodeString[i];
+ if (c < ranges[i].first || c > ranges[i].second)
+ return false;
+ }
+
+ return true;
+}
+
+static bool matches(const String& u1, const String& g1, const String& u2, const String& g2, const SVGHorizontalKerningPair& kerningPair)
+{
+ if (kerningPair.unicode1.length() && !stringMatchesUnicodeRange(u1, kerningPair.unicode1))
+ return false;
+ if (kerningPair.glyphName1.length() && kerningPair.glyphName1 != g1)
+ return false;
+
+ if (kerningPair.unicode2.length() && !stringMatchesUnicodeRange(u2, kerningPair.unicode2))
+ return false;
+ if (kerningPair.glyphName2.length() && kerningPair.glyphName2 != g2)
+ return false;
+
+ return true;
+}
+
+bool SVGFontElement::getHorizontalKerningPairForStringsAndGlyphs(const String& u1, const String& g1, const String& u2, const String& g2, SVGHorizontalKerningPair& kerningPair) const
+{
+ for (size_t i = 0; i < m_kerningPairs.size(); ++i) {
+ if (matches(u1, g1, u2, g2, m_kerningPairs[i])) {
+ kerningPair = m_kerningPairs[i];
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void SVGFontElement::getGlyphIdentifiersForString(const String& string, Vector<SVGGlyphIdentifier>& glyphs) const
+{
+ ensureGlyphCache();
+ m_glyphMap.get(string, glyphs);
+}
+
+}
+
+#endif // ENABLE(SVG_FONTS)
diff --git a/WebCore/svg/SVGFontElement.h b/WebCore/svg/SVGFontElement.h
new file mode 100644
index 0000000..42468da
--- /dev/null
+++ b/WebCore/svg/SVGFontElement.h
@@ -0,0 +1,66 @@
+/*
+ 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 "SVGGlyphMap.h"
+#include "SVGHKernElement.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; }
+
+ void invalidateGlyphCache();
+
+ void getGlyphIdentifiersForString(const String&, Vector<SVGGlyphIdentifier>&) const;
+
+ bool getHorizontalKerningPairForStringsAndGlyphs(const String& u1, const String& g1, const String& u2, const String& g2, SVGHorizontalKerningPair& kerningPair) const;
+
+ SVGMissingGlyphElement* firstMissingGlyphElement() const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ void ensureGlyphCache() const;
+
+ typedef Vector<SVGHorizontalKerningPair> KerningPairVector;
+
+ mutable KerningPairVector m_kerningPairs;
+ mutable SVGGlyphMap m_glyphMap;
+ mutable bool m_isGlyphCacheValid;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_FONTS)
+#endif
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..21fd277
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceElement.cpp
@@ -0,0 +1,367 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ Copyright (C) 2008 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_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 "Document.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(CSSFontFaceRule::create())
+ , m_styleDeclaration(CSSMutableStyleDeclaration::create())
+{
+ m_styleDeclaration->setParent(document()->mappedElementSheet());
+ m_styleDeclaration->setStrictParsing(true);
+ m_fontFaceRule->setDeclaration(m_styleDeclaration.get());
+}
+
+SVGFontFaceElement::~SVGFontFaceElement()
+{
+ removeFromMappedElementSheet();
+}
+
+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);
+ if (inDocument())
+ rebuildFontFace();
+ return;
+ }
+
+ SVGElement::parseMappedAttribute(attr);
+}
+
+unsigned SVGFontFaceElement::unitsPerEm() const
+{
+ const AtomicString& value = getAttribute(units_per_emAttr);
+ if (value.isEmpty())
+ return 1000;
+
+ return static_cast<unsigned>(ceilf(value.toFloat()));
+}
+
+int SVGFontFaceElement::xHeight() const
+{
+ return static_cast<int>(ceilf(getAttribute(x_heightAttr).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.
+ return m_fontElement->getAttribute(horiz_origin_xAttr).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.
+ return m_fontElement->getAttribute(horiz_origin_yAttr).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.
+ return m_fontElement->getAttribute(horiz_adv_xAttr).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.
+ const 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.
+ const 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).
+ const AtomicString& value = m_fontElement->getAttribute(vert_adv_yAttr);
+ if (value.isEmpty())
+ return 1.0f;
+
+ return value.toFloat();
+}
+
+int SVGFontFaceElement::ascent() const
+{
+ // 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.
+ const AtomicString& ascentValue = getAttribute(ascentAttr);
+ if (!ascentValue.isEmpty())
+ return static_cast<int>(ceilf(ascentValue.toFloat()));
+
+ if (m_fontElement) {
+ const AtomicString& vertOriginY = m_fontElement->getAttribute(vert_origin_yAttr);
+ if (!vertOriginY.isEmpty())
+ return static_cast<int>(unitsPerEm()) - static_cast<int>(ceilf(vertOriginY.toFloat()));
+ }
+
+ // Match Batiks default value
+ return static_cast<int>(ceilf(unitsPerEm() * 0.8f));
+}
+
+int SVGFontFaceElement::descent() const
+{
+ // 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.
+ const AtomicString& descentValue = getAttribute(descentAttr);
+ if (!descentValue.isEmpty()) {
+ // 14 different W3C SVG 1.1 testcases use a negative descent value,
+ // where a positive was meant to be used Including:
+ // animate-elem-24-t.svg, fonts-elem-01-t.svg, fonts-elem-02-t.svg (and 11 others)
+ int descent = static_cast<int>(ceilf(descentValue.toFloat()));
+ return descent < 0 ? -descent : descent;
+ }
+
+ if (m_fontElement) {
+ const AtomicString& vertOriginY = m_fontElement->getAttribute(vert_origin_yAttr);
+ if (!vertOriginY.isEmpty())
+ return static_cast<int>(ceilf(vertOriginY.toFloat()));
+ }
+
+ // Match Batiks default value
+ return static_cast<int>(ceilf(unitsPerEm() * 0.2f));
+}
+
+String SVGFontFaceElement::fontFamily() const
+{
+ return m_styleDeclaration->getPropertyValue(CSSPropertyFontFamily);
+}
+
+void SVGFontFaceElement::rebuildFontFace()
+{
+ ASSERT(inDocument());
+
+ // 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(CSSPropertyDefinitionSrc, definitionSrc->getAttribute(XLinkNames::hrefAttr), false);
+#endif
+
+ bool describesParentFont = parentNode()->hasTagName(fontTag);
+ RefPtr<CSSValueList> list;
+
+ if (describesParentFont) {
+ m_fontElement = static_cast<SVGFontElement*>(parentNode());
+
+ list = CSSValueList::createCommaSeparated();
+ list->append(CSSFontFaceSrcValue::createLocal(fontFamily()));
+ } else {
+ m_fontElement = 0;
+ if (srcElement)
+ list = srcElement->srcValue();
+ }
+
+ if (!list)
+ return;
+
+ // Parse in-memory CSS rules
+ CSSProperty srcProperty(CSSPropertySrc, 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(CSSPropertySrc);
+ 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->itemWithoutBoundsCheck(i)))
+ item->setSVGFontFaceElement(this);
+ }
+ }
+
+ document()->updateStyleSelector();
+}
+
+void SVGFontFaceElement::insertedIntoDocument()
+{
+ SVGElement::insertedIntoDocument();
+ document()->mappedElementSheet()->append(m_fontFaceRule);
+ rebuildFontFace();
+}
+
+void SVGFontFaceElement::removedFromDocument()
+{
+ removeFromMappedElementSheet();
+ SVGElement::removedFromDocument();
+}
+
+void SVGFontFaceElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+ if (inDocument())
+ rebuildFontFace();
+}
+
+void SVGFontFaceElement::removeFromMappedElementSheet()
+{
+ CSSStyleSheet* mappedElementSheet = document()->mappedElementSheet();
+ if (!mappedElementSheet)
+ return;
+
+ for (unsigned i = 0; i < mappedElementSheet->length(); ++i) {
+ if (mappedElementSheet->item(i) == m_fontFaceRule) {
+ mappedElementSheet->remove(i);
+ break;
+ }
+ }
+ document()->updateStyleSelector();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_FONTS)
diff --git a/WebCore/svg/SVGFontFaceElement.h b/WebCore/svg/SVGFontFaceElement.h
new file mode 100644
index 0000000..3c28a89
--- /dev/null
+++ b/WebCore/svg/SVGFontFaceElement.h
@@ -0,0 +1,73 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ Copyright (C) 2008 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.
+*/
+
+#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();
+ virtual void removedFromDocument();
+
+ 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 { return m_fontElement; }
+ void rebuildFontFace();
+ void removeFromMappedElementSheet();
+
+ private:
+ RefPtr<CSSFontFaceRule> m_fontFaceRule;
+ RefPtr<CSSMutableStyleDeclaration> m_styleDeclaration;
+
+ 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..91002e1
--- /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 CSSFontFaceSrcValue::createLocal(getAttribute(SVGNames::nameAttr));
+}
+
+}
+
+#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..0d72c74
--- /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 = CSSValueList::createCommaSeparated();
+ 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..7f6c6d2
--- /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 = CSSFontFaceSrcValue::create(getAttribute(XLinkNames::hrefAttr));
+ 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..f7c4582
--- /dev/null
+++ b/WebCore/svg/SVGForeignObjectElement.cpp
@@ -0,0 +1,167 @@
+/*
+ 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, SVGNames::xAttr, LengthModeWidth)
+ , m_y(this, SVGNames::yAttr, LengthModeHeight)
+ , m_width(this, SVGNames::widthAttr, LengthModeWidth)
+ , m_height(this, SVGNames::heightAttr, LengthModeHeight)
+{
+}
+
+SVGForeignObjectElement::~SVGForeignObjectElement()
+{
+}
+
+void SVGForeignObjectElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const AtomicString& value = attr->value();
+ if (attr->name() == SVGNames::xAttr)
+ setXBaseValue(SVGLength(LengthModeWidth, value));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(LengthModeHeight, value));
+ else if (attr->name() == SVGNames::widthAttr)
+ setWidthBaseValue(SVGLength(LengthModeWidth, value));
+ else if (attr->name() == SVGNames::heightAttr)
+ setHeightBaseValue(SVGLength(LengthModeHeight, value));
+ else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ SVGStyledTransformableElement::parseMappedAttribute(attr);
+ }
+}
+
+// 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;
+
+ Attribute* attr = attrs->getAttributeItem(name);
+ if (!attr || !attr->isMappedAttribute())
+ return;
+
+ MappedAttribute* mappedAttr = static_cast<MappedAttribute*>(attr);
+
+ // 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, CSSPropertyWidth, width().valueAsString());
+ return;
+ } else if (attrName == SVGNames::heightAttr) {
+ addCSSPropertyAndNotifyAttributeMap(this, attrName, CSSPropertyHeight, 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..14dbe68
--- /dev/null
+++ b/WebCore/svg/SVGForeignObjectElement.h
@@ -0,0 +1,64 @@
+/*
+ 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_DECLARATIONS(SVGForeignObjectElement, SVGNames::foreignObjectTagString, SVGNames::xAttrString, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGForeignObjectElement, SVGNames::foreignObjectTagString, SVGNames::yAttrString, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGForeignObjectElement, SVGNames::foreignObjectTagString, SVGNames::widthAttrString, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGForeignObjectElement, SVGNames::foreignObjectTagString, SVGNames::heightAttrString, 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..fe52d05
--- /dev/null
+++ b/WebCore/svg/SVGGElement.h
@@ -0,0 +1,61 @@
+/*
+ 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:
+ 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..ebf5dd0
--- /dev/null
+++ b/WebCore/svg/SVGGlyphElement.cpp
@@ -0,0 +1,178 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ Copyright (C) 2008 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_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::invalidateGlyphCache()
+{
+ Node* fontNode = parentNode();
+ if (fontNode && fontNode->hasTagName(fontTag)) {
+ if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
+ element->invalidateGlyphCache();
+ }
+}
+
+void SVGGlyphElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::dAttr)
+ invalidateGlyphCache();
+ else
+ SVGStyledElement::parseMappedAttribute(attr);
+}
+
+void SVGGlyphElement::insertedIntoDocument()
+{
+ invalidateGlyphCache();
+ SVGStyledElement::insertedIntoDocument();
+}
+
+void SVGGlyphElement::removedFromDocument()
+{
+ invalidateGlyphCache();
+ SVGStyledElement::removedFromDocument();
+}
+
+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..62ae263
--- /dev/null
+++ b/WebCore/svg/SVGGlyphElement.h
@@ -0,0 +1,131 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ Copyright (C) 2008 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 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)
+ , priority(0)
+ , nameLength(0)
+ , 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;
+
+ unsigned orientation : 2; // Orientation
+ unsigned arabicForm : 3; // ArabicForm
+ int priority;
+ size_t nameLength;
+ 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 parseMappedAttribute(MappedAttribute*);
+
+ 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*);
+ private:
+ void invalidateGlyphCache();
+ };
+
+} // 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/SVGGlyphMap.h b/WebCore/svg/SVGGlyphMap.h
new file mode 100644
index 0000000..b58b155
--- /dev/null
+++ b/WebCore/svg/SVGGlyphMap.h
@@ -0,0 +1,109 @@
+/*
+ Copyright (C) 2008 Apple, 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 SVGGlyphMap_h
+#define SVGGlyphMap_h
+
+#if ENABLE(SVG_FONTS)
+#include "SVGGlyphElement.h"
+
+
+namespace WebCore {
+
+ struct GlyphMapNode;
+
+ typedef HashMap<UChar, RefPtr<GlyphMapNode> > GlyphMapLayer;
+
+ struct GlyphMapNode : public RefCounted<GlyphMapNode> {
+ private:
+ GlyphMapNode() { }
+ public:
+ static PassRefPtr<GlyphMapNode> create() { return adoptRef(new GlyphMapNode); }
+
+ Vector<SVGGlyphIdentifier> glyphs;
+
+ GlyphMapLayer children;
+ };
+
+ class SVGGlyphMap {
+
+ public:
+ SVGGlyphMap() : m_currentPriority(0) { }
+
+ void add(const String& string, const SVGGlyphIdentifier& glyph)
+ {
+ size_t len = string.length();
+ GlyphMapLayer* currentLayer = &m_rootLayer;
+
+ RefPtr<GlyphMapNode> node;
+ for (size_t i = 0; i < len; i++) {
+ UChar curChar = string[i];
+ node = currentLayer->get(curChar);
+ if (!node) {
+ node = GlyphMapNode::create();
+ currentLayer->set(curChar, node);
+ }
+ currentLayer = &node->children;
+ }
+
+ if (node) {
+ node->glyphs.append(glyph);
+ node->glyphs.last().priority = m_currentPriority++;
+ node->glyphs.last().nameLength = len;
+ node->glyphs.last().isValid = true;
+ }
+ }
+
+ static inline bool compareGlyphPriority(const SVGGlyphIdentifier& first, const SVGGlyphIdentifier& second)
+ {
+ return first.priority < second.priority;
+ }
+
+ void get(const String& string, Vector<SVGGlyphIdentifier>& glyphs)
+ {
+ GlyphMapLayer* currentLayer = &m_rootLayer;
+
+ for (size_t i = 0; i < string.length(); i++) {
+ UChar curChar = string[i];
+ RefPtr<GlyphMapNode> node = currentLayer->get(curChar);
+ if (!node)
+ break;
+ glyphs.append(node->glyphs);
+ currentLayer = &node->children;
+ }
+ std::sort(glyphs.begin(), glyphs.end(), compareGlyphPriority);
+ }
+
+ void clear()
+ {
+ m_rootLayer.clear();
+ m_currentPriority = 0;
+ }
+
+ private:
+ GlyphMapLayer m_rootLayer;
+ int m_currentPriority;
+ };
+
+}
+
+#endif // ENABLE(SVG_FONTS)
+
+
+#endif //SVGGlyphMap_h
diff --git a/WebCore/svg/SVGGradientElement.cpp b/WebCore/svg/SVGGradientElement.cpp
new file mode 100644
index 0000000..e4e3213
--- /dev/null
+++ b/WebCore/svg/SVGGradientElement.cpp
@@ -0,0 +1,169 @@
+/*
+ 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 {
+
+char SVGGradientElementIdentifier[] = "SVGGradientElement";
+
+SVGGradientElement::SVGGradientElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , SVGURIReference()
+ , SVGExternalResourcesRequired()
+ , m_spreadMethod(this, SVGNames::spreadMethodAttr)
+ , m_gradientUnits(this, SVGNames::gradientUnitsAttr, SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
+ , m_gradientTransform(this, SVGNames::gradientTransformAttr, SVGTransformList::create(SVGNames::gradientTransformAttr))
+{
+}
+
+SVGGradientElement::~SVGGradientElement()
+{
+}
+
+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(SpreadMethodReflect);
+ else if (attr->value() == "repeat")
+ setSpreadMethodBaseValue(SpreadMethodRepeat);
+ else if (attr->value() == "pad")
+ setSpreadMethodBaseValue(SpreadMethodPad);
+ } 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;
+ RefPtr<RenderStyle> gradientStyle;
+
+ 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();
+
+ RefPtr<RenderStyle> stopStyle = stop->resolveStyle(gradientStyle.get());
+
+ color = stopStyle->svgStyle()->stopColor();
+ opacity = stopStyle->svgStyle()->stopOpacity();
+ }
+
+ stops.append(makeGradientStop(stopOffset, makeRGBA(color.red(), color.green(), color.blue(), int(opacity * 255.))));
+ }
+ }
+
+ return stops;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGGradientElement.h b/WebCore/svg/SVGGradientElement.h
new file mode 100644
index 0000000..2027258
--- /dev/null
+++ b/WebCore/svg/SVGGradientElement.h
@@ -0,0 +1,74 @@
+/*
+ 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 "SVGTransformList.h"
+#include "SVGURIReference.h"
+
+namespace WebCore {
+
+ extern char SVGGradientElementIdentifier[];
+
+ class SVGGradientElement : public SVGStyledElement,
+ public SVGURIReference,
+ public SVGExternalResourcesRequired {
+ public:
+ 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;
+
+ virtual const SVGElement* contextElement() const { return this; }
+
+ protected:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGGradientElement, SVGGradientElementIdentifier, SVGNames::spreadMethodAttrString, int, SpreadMethod, spreadMethod)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGGradientElement, SVGGradientElementIdentifier, SVGNames::gradientUnitsAttrString, int, GradientUnits, gradientUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGGradientElement, SVGGradientElementIdentifier, SVGNames::gradientTransformAttrString, 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/SVGHKernElement.cpp b/WebCore/svg/SVGHKernElement.cpp
new file mode 100644
index 0000000..f232fdc
--- /dev/null
+++ b/WebCore/svg/SVGHKernElement.cpp
@@ -0,0 +1,81 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ Copyright (C) 2008 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 "SVGHKernElement.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;
+
+SVGHKernElement::SVGHKernElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+{
+}
+
+SVGHKernElement::~SVGHKernElement()
+{
+}
+
+void SVGHKernElement::insertedIntoDocument()
+{
+ Node* fontNode = parentNode();
+ if (fontNode && fontNode->hasTagName(fontTag)) {
+ if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
+ element->invalidateGlyphCache();
+ }
+}
+
+void SVGHKernElement::removedFromDocument()
+{
+ Node* fontNode = parentNode();
+ if (fontNode && fontNode->hasTagName(fontTag)) {
+ if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
+ element->invalidateGlyphCache();
+ }
+}
+
+SVGHorizontalKerningPair SVGHKernElement::buildHorizontalKerningPair() const
+{
+ SVGHorizontalKerningPair kerningPair;
+
+ kerningPair.unicode1 = getAttribute(u1Attr);
+ kerningPair.glyphName1 = getAttribute(g1Attr);
+ kerningPair.unicode2 = getAttribute(u2Attr);
+ kerningPair.glyphName2 = getAttribute(g2Attr);
+ kerningPair.kerning = getAttribute(kAttr).string().toDouble();
+
+ return kerningPair;
+}
+
+}
+
+#endif // ENABLE(SVG_FONTS)
diff --git a/WebCore/svg/SVGHKernElement.h b/WebCore/svg/SVGHKernElement.h
new file mode 100644
index 0000000..6fda779
--- /dev/null
+++ b/WebCore/svg/SVGHKernElement.h
@@ -0,0 +1,66 @@
+/*
+ Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ Copyright (C) 2008 Apple, 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 SVGHKernElement_h
+#define SVGHKernElement_h
+
+#if ENABLE(SVG_FONTS)
+#include "SVGStyledElement.h"
+
+#include <limits>
+#include "Path.h"
+
+namespace WebCore {
+
+ class AtomicString;
+ struct SVGFontData;
+
+ // Describe an SVG <hkern> element
+ struct SVGHorizontalKerningPair {
+ String unicode1;
+ String glyphName1;
+ String unicode2;
+ String glyphName2;
+ double kerning;
+
+ SVGHorizontalKerningPair()
+ : kerning(0)
+ {
+ }
+ };
+
+ class SVGHKernElement : public SVGElement {
+ public:
+ SVGHKernElement(const QualifiedName&, Document*);
+ virtual ~SVGHKernElement();
+
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
+
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+
+ SVGHorizontalKerningPair buildHorizontalKerningPair() const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_FONTS)
+#endif
diff --git a/WebCore/svg/SVGHKernElement.idl b/WebCore/svg/SVGHKernElement.idl
new file mode 100644
index 0000000..1971aef
--- /dev/null
+++ b/WebCore/svg/SVGHKernElement.idl
@@ -0,0 +1,27 @@
+/*
+ Copyright (C) 2008 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&SVG_FONTS] SVGHKernElement : SVGElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGImageElement.cpp b/WebCore/svg/SVGImageElement.cpp
new file mode 100644
index 0000000..d7daebc
--- /dev/null
+++ b/WebCore/svg/SVGImageElement.cpp
@@ -0,0 +1,164 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007, 2008 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 "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, SVGNames::xAttr, LengthModeWidth)
+ , m_y(this, SVGNames::yAttr, LengthModeHeight)
+ , m_width(this, SVGNames::widthAttr, LengthModeWidth)
+ , m_height(this, SVGNames::heightAttr, LengthModeHeight)
+ , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
+ , m_imageLoader(this)
+{
+}
+
+SVGImageElement::~SVGImageElement()
+{
+}
+
+void SVGImageElement::parseMappedAttribute(MappedAttribute *attr)
+{
+ if (attr->name() == SVGNames::xAttr)
+ setXBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::preserveAspectRatioAttr) {
+ const UChar* c = attr->value().characters();
+ const UChar* end = c + attr->value().length();
+ preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
+ } else if (attr->name() == SVGNames::widthAttr) {
+ setWidthBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ addCSSProperty(attr, CSSPropertyWidth, attr->value());
+ if (widthBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for image attribute <width> is not allowed");
+ } else if (attr->name() == SVGNames::heightAttr) {
+ setHeightBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ addCSSProperty(attr, CSSPropertyHeight, attr->value());
+ if (heightBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for image attribute <height> is not allowed");
+ } else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ if (SVGURIReference::parseMappedAttribute(attr))
+ return;
+ SVGStyledTransformableElement::parseMappedAttribute(attr);
+ }
+}
+
+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 ||
+ attrName == SVGNames::preserveAspectRatioAttr ||
+ 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.haveFiredLoadEvent();
+}
+
+void SVGImageElement::attach()
+{
+ SVGStyledTransformableElement::attach();
+
+ if (RenderSVGImage* imageObj = static_cast<RenderSVGImage*>(renderer())) {
+ if (imageObj->hasImage())
+ return;
+
+ imageObj->setCachedImage(m_imageLoader.image());
+ }
+}
+
+void SVGImageElement::insertedIntoDocument()
+{
+ SVGStyledTransformableElement::insertedIntoDocument();
+
+ // Update image loader, as soon as we're living in the tree.
+ // We can only resolve base URIs properly, after that!
+ m_imageLoader.updateFromElement();
+}
+
+const QualifiedName& SVGImageElement::imageSourceAttributeName() const
+{
+ return XLinkNames::hrefAttr;
+}
+
+void SVGImageElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+ urls.append(href());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGImageElement.h b/WebCore/svg/SVGImageElement.h
new file mode 100644
index 0000000..bddfddd
--- /dev/null
+++ b/WebCore/svg/SVGImageElement.h
@@ -0,0 +1,79 @@
+/*
+ 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"
+#include "SVGPreserveAspectRatio.h"
+
+namespace WebCore {
+
+ 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 void insertedIntoDocument();
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ virtual const QualifiedName& imageSourceAttributeName() const;
+ virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
+ protected:
+ virtual bool haveLoadedRequiredResources();
+ virtual bool hasRelativeValues() const;
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGNames::imageTagString, SVGNames::xAttrString, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGNames::imageTagString, SVGNames::yAttrString, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGNames::imageTagString, SVGNames::widthAttrString, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGNames::imageTagString, SVGNames::heightAttrString, SVGLength, Height, height)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGNames::imageTagString, SVGNames::preserveAspectRatioAttrString, 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..6e0915d
--- /dev/null
+++ b/WebCore/svg/SVGImageLoader.cpp
@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2005, 2005 Alexander Kellett <lypanov@kde.org>
+ 2008 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 "SVGImageLoader.h"
+
+#include "EventNames.h"
+#include "SVGImageElement.h"
+#include "RenderImage.h"
+
+namespace WebCore {
+
+SVGImageLoader::SVGImageLoader(SVGImageElement* node)
+ : ImageLoader(node)
+{
+}
+
+SVGImageLoader::~SVGImageLoader()
+{
+}
+
+void SVGImageLoader::dispatchLoadEvent()
+{
+ if (!haveFiredLoadEvent() && image()) {
+ setHaveFiredLoadEvent(true);
+
+ if (image()->errorOccurred())
+ element()->dispatchEventForType(eventNames().errorEvent, false, false);
+ else {
+ SVGImageElement* imageElement = static_cast<SVGImageElement*>(element());
+ if (imageElement->externalResourcesRequiredBaseValue())
+ imageElement->sendSVGLoadEventIfPossible(true);
+ }
+ }
+}
+
+String SVGImageLoader::sourceURI(const AtomicString& attr) const
+{
+ return parseURL(KURL(element()->baseURI(), attr).string());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGImageLoader.h b/WebCore/svg/SVGImageLoader.h
new file mode 100644
index 0000000..a838db8
--- /dev/null
+++ b/WebCore/svg/SVGImageLoader.h
@@ -0,0 +1,44 @@
+/*
+ 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 "ImageLoader.h"
+
+namespace WebCore {
+
+ class SVGImageElement;
+
+ class SVGImageLoader : public ImageLoader {
+ public:
+ SVGImageLoader(SVGImageElement*);
+ virtual ~SVGImageLoader();
+
+ virtual void dispatchLoadEvent();
+ virtual String sourceURI(const AtomicString&) const;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGImageLoader_h
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..86714f9
--- /dev/null
+++ b/WebCore/svg/SVGLength.cpp
@@ -0,0 +1,323 @@
+/*
+ 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 <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(SVGLengthMode mode, const String& valueAsString)
+ : m_valueInSpecifiedUnits(0.0f)
+ , m_unit(storeUnit(mode, LengthTypeNumber))
+{
+ setValueAsString(valueAsString);
+}
+
+SVGLengthType SVGLength::unitType() const
+{
+ return extractType(m_unit);
+}
+
+float SVGLength::value(const SVGElement* context) 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, context, extractMode(m_unit));
+ case LengthTypeEMS:
+ case LengthTypeEXS:
+ {
+ RenderStyle* style = 0;
+ if (context && context->renderer())
+ style = 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, const SVGElement* context)
+{
+ ASSERT(type <= LengthTypePC);
+
+ float valueInUserUnits = value(context);
+ m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type);
+ setValue(valueInUserUnits);
+}
+
+float SVGLength::PercentageOfViewport(float value, const SVGElement* 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(svg);
+ height = svg->height().value(svg);
+ }
+ } 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..7846b4a
--- /dev/null
+++ b/WebCore/svg/SVGLength.h
@@ -0,0 +1,105 @@
+/*
+ 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 SVGLength_h
+#define SVGLength_h
+
+#if ENABLE(SVG)
+#include "PlatformString.h"
+
+namespace WebCore {
+
+ 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 SVGElement;
+
+ 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(SVGLengthMode mode = LengthModeOther, const String& valueAsString = String());
+
+ SVGLengthType unitType() const;
+
+ float value(const SVGElement* context) 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, const SVGElement* context);
+
+ // Helper functions
+ static float PercentageOfViewport(float value, const SVGElement* context, SVGLengthMode);
+
+ inline bool isRelative() const
+ {
+ SVGLengthType type = unitType();
+ return (type == LengthTypePercentage || type == LengthTypeEMS || type == LengthTypeEXS);
+ }
+
+ private:
+ float m_valueInSpecifiedUnits;
+ unsigned int m_unit;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGLength_h
diff --git a/WebCore/svg/SVGLength.idl b/WebCore/svg/SVGLength.idl
new file mode 100644
index 0000000..20748b1
--- /dev/null
+++ b/WebCore/svg/SVGLength.idl
@@ -0,0 +1,52 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@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 [CustomGetter] float value;
+ attribute float valueInSpecifiedUnits;
+ attribute [ConvertNullToNullString] DOMString valueAsString;
+
+ void newValueSpecifiedUnits(in unsigned short unitType,
+ in float valueInSpecifiedUnits);
+
+ [Custom] void convertToSpecifiedUnits(in unsigned short unitType);
+ };
+
+}
diff --git a/WebCore/svg/SVGLengthList.cpp b/WebCore/svg/SVGLengthList.cpp
new file mode 100644
index 0000000..20b61d6
--- /dev/null
+++ b/WebCore/svg/SVGLengthList.cpp
@@ -0,0 +1,80 @@
+/*
+ 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, 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(mode);
+ if (!length.setValueAsString(String(start, ptr - start)))
+ return;
+ appendItem(length, ec);
+ skipOptionalSpacesOrDelimiter(ptr, end);
+ }
+}
+
+String SVGLengthList::valueAsString() const
+{
+ String result;
+
+ ExceptionCode ec = 0;
+ for (unsigned int i = 0; i < numberOfItems(); ++i) {
+ if (i > 0)
+ result += ", ";
+
+ result += getItem(i, ec).valueAsString();
+ ASSERT(ec == 0);
+ }
+
+ return result;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGLengthList.h b/WebCore/svg/SVGLengthList.h
new file mode 100644
index 0000000..e83fee8
--- /dev/null
+++ b/WebCore/svg/SVGLengthList.h
@@ -0,0 +1,48 @@
+/*
+ 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, SVGLengthMode mode);
+
+ String valueAsString() const;
+
+ 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..12f54e3
--- /dev/null
+++ b/WebCore/svg/SVGLineElement.cpp
@@ -0,0 +1,103 @@
+/*
+ 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, SVGNames::x1Attr, LengthModeWidth)
+ , m_y1(this, SVGNames::y1Attr, LengthModeHeight)
+ , m_x2(this, SVGNames::x2Attr, LengthModeWidth)
+ , m_y2(this, SVGNames::y2Attr, LengthModeHeight)
+{
+}
+
+SVGLineElement::~SVGLineElement()
+{
+}
+
+void SVGLineElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::x1Attr)
+ setX1BaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::y1Attr)
+ setY1BaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::x2Attr)
+ setX2BaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::y2Attr)
+ setY2BaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else
+ {
+ 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(this), y1().value(this)),
+ FloatPoint(x2().value(this), y2().value(this)));
+}
+
+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..2d89f5c
--- /dev/null
+++ b/WebCore/svg/SVGLineElement.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 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_DECLARATIONS(SVGLineElement, SVGNames::lineTagString, SVGNames::x1AttrString, SVGLength, X1, x1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLineElement, SVGNames::lineTagString, SVGNames::y1AttrString, SVGLength, Y1, y1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLineElement, SVGNames::lineTagString, SVGNames::x2AttrString, SVGLength, X2, x2)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLineElement, SVGNames::lineTagString, SVGNames::y2AttrString, 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..04469a9
--- /dev/null
+++ b/WebCore/svg/SVGLinearGradientElement.cpp
@@ -0,0 +1,159 @@
+/*
+ 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 "Document.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, SVGNames::x1Attr, LengthModeWidth)
+ , m_y1(this, SVGNames::y1Attr, LengthModeHeight)
+ , m_x2(this, SVGNames::x2Attr, LengthModeWidth, "100%")
+ , m_y2(this, SVGNames::y2Attr, LengthModeHeight)
+{
+ // Spec: If the x2 attribute is not specified, the effect is as if a value of "100%" were specified.
+}
+
+SVGLinearGradientElement::~SVGLinearGradientElement()
+{
+}
+
+void SVGLinearGradientElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::x1Attr)
+ setX1BaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::y1Attr)
+ setY1BaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::x2Attr)
+ setX2BaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::y2Attr)
+ setY2BaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else
+ SVGGradientElement::parseMappedAttribute(attr);
+}
+
+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((GradientSpreadMethod) current->spreadMethod());
+
+ if (!attributes.hasBoundingBoxMode() && current->hasAttribute(SVGNames::gradientUnitsAttr))
+ attributes.setBoundingBoxMode(current->gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_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..0e1efd4
--- /dev/null
+++ b/WebCore/svg/SVGLinearGradientElement.h
@@ -0,0 +1,58 @@
+/*
+ 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;
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLinearGradientElement, SVGNames::linearGradientTagString, SVGNames::x1AttrString, SVGLength, X1, x1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLinearGradientElement, SVGNames::linearGradientTagString, SVGNames::y1AttrString, SVGLength, Y1, y1)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLinearGradientElement, SVGNames::linearGradientTagString, SVGNames::x2AttrString, SVGLength, X2, x2)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGLinearGradientElement, SVGNames::linearGradientTagString, SVGNames::y2AttrString, 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..956a4f9
--- /dev/null
+++ b/WebCore/svg/SVGLocatable.cpp
@@ -0,0 +1,159 @@
+/*
+ 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 SVGElement* 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 SVGElement* 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 SVGElement* e)
+{
+ FloatRect bboxRect;
+
+ e->document()->updateLayoutIgnorePendingStylesheets();
+
+ if (e && e->renderer()) {
+ // Need this to make sure we have render object dimensions.
+ // See bug 11686.
+ 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..b1601ce
--- /dev/null
+++ b/WebCore/svg/SVGLocatable.h
@@ -0,0 +1,64 @@
+/*
+ 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 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 SVGElement*);
+ static SVGElement* farthestViewportElement(const SVGElement*);
+
+ protected:
+ static FloatRect getBBox(const SVGElement*);
+ 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..b3214ed
--- /dev/null
+++ b/WebCore/svg/SVGMPathElement.cpp
@@ -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.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGMPathElement.h"
+
+#include "Document.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..6145f7c
--- /dev/null
+++ b/WebCore/svg/SVGMarkerElement.cpp
@@ -0,0 +1,195 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 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.
+*/
+
+#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 {
+
+char SVGOrientTypeAttrIdentifier[] = "SVGOrientTypeAttr";
+char SVGOrientAngleAttrIdentifier[] = "SVGOrientAngleAttr";
+
+SVGMarkerElement::SVGMarkerElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , SVGFitToViewBox()
+ , m_refX(this, SVGNames::refXAttr, LengthModeWidth)
+ , m_refY(this, SVGNames::refYAttr, LengthModeHeight)
+ , m_markerWidth(this, SVGNames::markerWidthAttr, LengthModeWidth, "3")
+ , m_markerHeight(this, SVGNames::markerHeightAttr, LengthModeHeight, "3")
+ , m_markerUnits(this, SVGNames::markerUnitsAttr, SVG_MARKERUNITS_STROKEWIDTH)
+ , m_orientType(this, SVGNames::orientAttr, SVG_MARKER_ORIENT_ANGLE)
+ , m_orientAngle(this, SVGNames::orientAttr, SVGAngle::create())
+{
+ // Spec: If the markerWidth/markerHeight attribute is not specified, the effect is as if a value of "3" were specified.
+}
+
+SVGMarkerElement::~SVGMarkerElement()
+{
+ // Call detach() here because if we wait until ~Node() calls it, we crash during
+ // RenderSVGViewportContainer destruction, as the renderer assumes that the element
+ // is still fully constructed. See <https://bugs.webkit.org/show_bug.cgi?id=21293>.
+ if (renderer())
+ detach();
+}
+
+void SVGMarkerElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::markerUnitsAttr) {
+ if (attr->value() == "userSpaceOnUse")
+ setMarkerUnitsBaseValue(SVG_MARKERUNITS_USERSPACEONUSE);
+ else if (attr->value() == "strokeWidth")
+ setMarkerUnitsBaseValue(SVG_MARKERUNITS_STROKEWIDTH);
+ } else if (attr->name() == SVGNames::refXAttr)
+ setRefXBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::refYAttr)
+ setRefYBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::markerWidthAttr)
+ setMarkerWidthBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::markerHeightAttr)
+ setMarkerHeightBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::orientAttr) {
+ RefPtr<SVGAngle> angle = SVGAngle::create();
+
+ if (attr->value() == "auto")
+ setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO);
+ else {
+ angle->setValueAsString(attr->value());
+ setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE);
+ }
+
+ setOrientAngleBaseValue(angle.get());
+ } 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 (!m_marker)
+ return;
+
+ if (renderer())
+ renderer()->setNeedsLayout(true);
+
+ m_marker->invalidate();
+}
+
+void SVGMarkerElement::setOrientToAuto()
+{
+ setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO);
+
+ RefPtr<SVGAngle> angle = SVGAngle::create();
+ setOrientAngleBaseValue(angle.get());
+
+ if (!m_marker)
+ return;
+
+ if (renderer())
+ renderer()->setNeedsLayout(true);
+
+ m_marker->invalidate();
+}
+
+void SVGMarkerElement::setOrientToAngle(PassRefPtr<SVGAngle> angle)
+{
+ setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE);
+ setOrientAngleBaseValue(angle.get());
+
+ if (!m_marker)
+ return;
+
+ if (renderer())
+ renderer()->setNeedsLayout(true);
+
+ m_marker->invalidate();
+}
+
+SVGResource* SVGMarkerElement::canvasResource()
+{
+ if (!m_marker)
+ m_marker = SVGResourceMarker::create();
+
+ m_marker->setMarker(static_cast<RenderSVGViewportContainer*>(renderer()));
+
+ if (orientType() == SVG_MARKER_ORIENT_ANGLE) {
+ if (orientAngle())
+ m_marker->setAngle(orientAngle()->value());
+ } else
+ m_marker->setAutoAngle();
+
+ m_marker->setRef(refX().value(this), refY().value(this));
+ 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..e2e3493
--- /dev/null
+++ b/WebCore/svg/SVGMarkerElement.h
@@ -0,0 +1,89 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 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.
+*/
+
+#ifndef SVGMarkerElement_h
+#define SVGMarkerElement_h
+
+#if ENABLE(SVG)
+
+#include "SVGAngle.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGFitToViewBox.h"
+#include "SVGLangSpace.h"
+#include "SVGResourceMarker.h"
+#include "SVGStyledElement.h"
+
+namespace WebCore {
+
+ class Document;
+ class SVGAngle;
+
+ extern char SVGOrientTypeAttrIdentifier[];
+ extern char SVGOrientAngleAttrIdentifier[];
+
+ 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(PassRefPtr<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_DECLARATIONS(SVGMarkerElement, SVGNames::markerTagString, SVGNames::refXAttrString, SVGLength, RefX, refX)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGNames::markerTagString, SVGNames::refYAttrString, SVGLength, RefY, refY)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGNames::markerTagString, SVGNames::markerWidthAttrString, SVGLength, MarkerWidth, markerWidth)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGNames::markerTagString, SVGNames::markerHeightAttrString, SVGLength, MarkerHeight, markerHeight)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGNames::markerTagString, SVGNames::markerUnitsAttrString, int, MarkerUnits, markerUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGNames::markerTagString, SVGOrientTypeAttrIdentifier, int, OrientType, orientType)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGNames::markerTagString, SVGOrientAngleAttrIdentifier, 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..9f9ae34
--- /dev/null
+++ b/WebCore/svg/SVGMaskElement.cpp
@@ -0,0 +1,214 @@
+/*
+ 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(this, SVGNames::maskUnitsAttr, SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
+ , m_maskContentUnits(this, SVGNames::maskContentUnitsAttr, SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
+ , m_x(this, SVGNames::xAttr, LengthModeWidth, "-10%")
+ , m_y(this, SVGNames::yAttr, LengthModeHeight, "-10%")
+ , m_width(this, SVGNames::widthAttr, LengthModeWidth, "120%")
+ , m_height(this, SVGNames::heightAttr, LengthModeHeight, "120%")
+{
+ // Spec: If the x/y attribute is not specified, the effect is as if a value of "-10%" were specified.
+ // Spec: If the width/height attribute is not specified, the effect is as if a value of "120%" were specified.
+}
+
+SVGMaskElement::~SVGMaskElement()
+{
+}
+
+void SVGMaskElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::maskUnitsAttr) {
+ if (attr->value() == "userSpaceOnUse")
+ setMaskUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE);
+ else if (attr->value() == "objectBoundingBox")
+ setMaskUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
+ } else if (attr->name() == SVGNames::maskContentUnitsAttr) {
+ if (attr->value() == "userSpaceOnUse")
+ setMaskContentUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE);
+ else if (attr->value() == "objectBoundingBox")
+ setMaskContentUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
+ } else if (attr->name() == SVGNames::xAttr)
+ setXBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::widthAttr)
+ setWidthBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::heightAttr)
+ setHeightBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else {
+ if (SVGURIReference::parseMappedAttribute(attr))
+ return;
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ SVGStyledElement::parseMappedAttribute(attr);
+ }
+}
+
+void 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(this);
+ yValue = y().value(this);
+ widthValue = width().value(this);
+ heightValue = height().value(this);
+ }
+
+ 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..4bcf82f
--- /dev/null
+++ b/WebCore/svg/SVGMaskElement.h
@@ -0,0 +1,73 @@
+/*
+ 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:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGNames::maskTagString, SVGNames::maskUnitsAttrString, int, MaskUnits, maskUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGNames::maskTagString, SVGNames::maskContentUnitsAttrString, int, MaskContentUnits, maskContentUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGNames::maskTagString, SVGNames::xAttrString, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGNames::maskTagString, SVGNames::yAttrString, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGNames::maskTagString, SVGNames::widthAttrString, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGNames::maskTagString, SVGNames::heightAttrString, SVGLength, Height, height)
+
+ 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..be1e895
--- /dev/null
+++ b/WebCore/svg/SVGNumberList.cpp
@@ -0,0 +1,75 @@
+/*
+ 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);
+ }
+}
+
+String SVGNumberList::valueAsString() const
+{
+ String result;
+
+ ExceptionCode ec = 0;
+ for (unsigned int i = 0; i < numberOfItems(); ++i) {
+ if (i > 0)
+ result += ", ";
+
+ result += String::number(getItem(i, ec));
+ ASSERT(ec == 0);
+ }
+
+ return result;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGNumberList.h b/WebCore/svg/SVGNumberList.h
new file mode 100644
index 0000000..6cd43ff
--- /dev/null
+++ b/WebCore/svg/SVGNumberList.h
@@ -0,0 +1,50 @@
+/*
+ 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);
+
+ String valueAsString() const;
+
+ 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..45abe69
--- /dev/null
+++ b/WebCore/svg/SVGPaint.cpp
@@ -0,0 +1,117 @@
+/*
+ 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()
+ : m_paintType(SVG_PAINTTYPE_UNKNOWN)
+{
+}
+
+SVGPaint::SVGPaint(const String& uri)
+ : m_paintType(SVG_PAINTTYPE_URI_RGBCOLOR)
+{
+ setUri(uri);
+}
+
+SVGPaint::SVGPaint(SVGPaintType paintType)
+ : 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..032f715
--- /dev/null
+++ b/WebCore/svg/SVGPaint.h
@@ -0,0 +1,100 @@
+/*
+ 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 library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; 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"
+#include "PlatformString.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
+ };
+
+ static PassRefPtr<SVGPaint> create()
+ {
+ return adoptRef(new SVGPaint);
+ }
+ static PassRefPtr<SVGPaint> create(SVGPaintType type)
+ {
+ return adoptRef(new SVGPaint(type));
+ }
+ static PassRefPtr<SVGPaint> create(const Color& color)
+ {
+ return adoptRef(new SVGPaint(color));
+ }
+ static PassRefPtr<SVGPaint> create(SVGPaintType type, const String& uri)
+ {
+ return adoptRef(new SVGPaint(type, uri, String(), String()));
+ }
+ static PassRefPtr<SVGPaint> create(const String& uri, const Color& color)
+ {
+ return adoptRef(new SVGPaint(uri, color));
+ }
+
+ 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();
+
+ private:
+ SVGPaint();
+ SVGPaint(const String& uri);
+ SVGPaint(SVGPaintType);
+ SVGPaint(SVGPaintType, const String& uri, const String& rgbPaint, const String& iccPaint);
+ SVGPaint(const Color& c);
+ SVGPaint(const String& uri, const Color& c);
+
+ virtual bool isSVGPaint() const { return true; }
+
+ 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..8d3c9b2
--- /dev/null
+++ b/WebCore/svg/SVGParserUtilities.h
@@ -0,0 +1,71 @@
+/*
+ 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 "ParserUtilities.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
+ inline bool isWhitespace(const UChar& c)
+ {
+ return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
+ }
+
+ inline bool skipOptionalSpaces(const UChar*& ptr, const UChar* end)
+ {
+ while (ptr < end && isWhitespace(*ptr))
+ ptr++;
+ return ptr < end;
+ }
+
+ 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;
+ }
+
+ 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 // SVGParserUtilities_h
diff --git a/WebCore/svg/SVGPathElement.cpp b/WebCore/svg/SVGPathElement.cpp
new file mode 100644
index 0000000..bdd60e5
--- /dev/null
+++ b/WebCore/svg/SVGPathElement.cpp
@@ -0,0 +1,242 @@
+/*
+ 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(this, SVGNames::pathLengthAttr, 0.0f)
+{
+}
+
+SVGPathElement::~SVGPathElement()
+{
+}
+
+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) {
+ setPathLengthBaseValue(attr->value().toFloat());
+ if (pathLengthBaseValue() < 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..a39e628
--- /dev/null
+++ b/WebCore/svg/SVGPathElement.h
@@ -0,0 +1,115 @@
+/*
+ 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_DECLARATIONS(SVGPathElement, SVGNames::pathTagString, SVGNames::pathLengthAttrString, 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..84de92f
--- /dev/null
+++ b/WebCore/svg/SVGPathSeg.h
@@ -0,0 +1,95 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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() { }
+ };
+
+ class SVGPathSegSingleCoord : public SVGPathSeg {
+ public:
+ SVGPathSegSingleCoord(float x, float y)
+ : SVGPathSeg() , m_x(x) , m_y(y) {}
+
+ void setX(float x) { m_x = x; }
+ float x() const { return m_x; }
+
+ void setY(float y) { m_y = y; }
+ float y() const { return m_y; }
+
+ virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg", m_x, m_y); }
+
+ private:
+ float m_x;
+ float m_y;
+ };
+
+
+} // 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..a54f057
--- /dev/null
+++ b/WebCore/svg/SVGPathSegArc.cpp
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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"
+
+namespace WebCore {
+
+SVGPathSegArcAbs::SVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
+ : SVGPathSegArc(x, y, r1, r2, angle, largeArcFlag, sweepFlag)
+{
+}
+
+SVGPathSegArcRel::SVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
+ : SVGPathSegArc(x, y, r1, r2, angle, largeArcFlag, 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..8611e8a
--- /dev/null
+++ b/WebCore/svg/SVGPathSegArc.h
@@ -0,0 +1,104 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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 SVGPathSegArc : public SVGPathSeg {
+ public:
+ SVGPathSegArc(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
+ : m_x(x), m_y(y), m_r1(r1), m_r2(r2), m_angle(angle), m_largeArcFlag(largeArcFlag), m_sweepFlag(sweepFlag) {}
+
+ virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.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) { m_x = x; }
+ float x() const { return m_x; }
+
+ void setY(float y) { m_y = y; }
+ float y() const { return m_y; }
+
+ void setR1(float r1) { m_r1 = r1; }
+ float r1() const { return m_r1; }
+
+ void setR2(float r2) { m_r2 = r2; }
+ float r2() const { return m_r2; }
+
+ void setAngle(float angle) { m_angle = angle; }
+ float angle() const { return m_angle; }
+
+ void setLargeArcFlag(bool largeArcFlag) { m_largeArcFlag = largeArcFlag; }
+ bool largeArcFlag() const { return m_largeArcFlag; }
+
+ void setSweepFlag(bool sweepFlag) { m_sweepFlag = sweepFlag; }
+ bool sweepFlag() const { return m_sweepFlag; }
+
+ private:
+ float m_x;
+ float m_y;
+ float m_r1;
+ float m_r2;
+ float m_angle;
+
+ bool m_largeArcFlag : 1;
+ bool m_sweepFlag : 1;
+ };
+
+ class SVGPathSegArcAbs : public SVGPathSegArc {
+ 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 unsigned short pathSegType() const { return PATHSEG_ARC_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "A"; }
+
+ private:
+ SVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
+ };
+
+ class SVGPathSegArcRel : public SVGPathSegArc {
+ 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 unsigned short pathSegType() const { return PATHSEG_ARC_REL; }
+ virtual String pathSegTypeAsLetter() const { return "a"; }
+
+ private:
+ SVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
+ };
+
+} // 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..14359de
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoCubic.cpp
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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"
+
+namespace WebCore {
+
+SVGPathSegCurvetoCubicAbs::SVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2)
+ : SVGPathSegCurvetoCubic(x, y, x1, y1, x2, y2)
+{
+}
+
+SVGPathSegCurvetoCubicRel::SVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2)
+ : SVGPathSegCurvetoCubic(x, y, x1, y1, x2, 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..68e3311
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoCubic.h
@@ -0,0 +1,98 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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 SVGPathSegCurvetoCubic : public SVGPathSeg {
+ public:
+ SVGPathSegCurvetoCubic(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) {}
+
+ virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg %.6lg %.6lg %.6lg %.6lg", m_x1, m_y1, m_x2, m_y2, m_x, m_y); }
+
+ void setX(float x) { m_x = x; }
+ float x() const { return m_x; }
+
+ void setY(float y) { m_y = y; }
+ float y() const { return m_y; }
+
+ void setX1(float x1) { m_x1 = x1; }
+ float x1() const { return m_x1; }
+
+ void setY1(float y1) { m_y1 = y1; }
+ float y1() const { return m_y1; }
+
+ void setX2(float x2) { m_x2 = x2; }
+ float x2() const { return m_x2; }
+
+ void setY2(float y2) { m_y2 = y2; }
+ float y2() const { return m_y2; }
+
+ private:
+ float m_x;
+ float m_y;
+ float m_x1;
+ float m_y1;
+ float m_x2;
+ float m_y2;
+ };
+
+ class SVGPathSegCurvetoCubicAbs : public SVGPathSegCurvetoCubic {
+ 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 unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "C"; }
+
+ private:
+ SVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2);
+ };
+
+ class SVGPathSegCurvetoCubicRel : public SVGPathSegCurvetoCubic {
+ 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 unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_REL; }
+ virtual String pathSegTypeAsLetter() const { return "c"; }
+
+ private:
+ SVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float 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..26babdb
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.cpp
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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"
+
+namespace WebCore {
+
+SVGPathSegCurvetoCubicSmoothAbs::SVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2)
+ : SVGPathSegCurvetoCubicSmooth(x, y, x2, y2)
+{
+}
+
+SVGPathSegCurvetoCubicSmoothRel::SVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2)
+ : SVGPathSegCurvetoCubicSmooth(x, y, x2, 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..8b8998c
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h
@@ -0,0 +1,85 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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 SVGPathSegCurvetoCubicSmooth : public SVGPathSeg {
+ public:
+ SVGPathSegCurvetoCubicSmooth(float x, float y, float x2, float y2)
+ : SVGPathSeg(), m_x(x), m_y(y), m_x2(x2), m_y2(y) {}
+
+ virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg %.6lg %.6lg", m_x2, m_y2, m_x, m_y); }
+
+ void setX(float x) { m_x = x; }
+ float x() const { return m_x; }
+
+ void setY(float y) { m_y = y; }
+ float y() const { return m_y; }
+
+ void setX2(float x2) { m_x2 = x2; }
+ float x2() const { return m_x2; }
+
+ void setY2(float y2) { m_y2 = y2; }
+ float y2() const { return m_y2; }
+
+ private:
+ float m_x;
+ float m_y;
+ float m_x2;
+ float m_y2;
+ };
+
+ class SVGPathSegCurvetoCubicSmoothAbs : public SVGPathSegCurvetoCubicSmooth {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> create(float x, float y, float x2, float y2) { return adoptRef(new SVGPathSegCurvetoCubicSmoothAbs(x, y, x2, y2)); }
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "S"; }
+
+ private:
+ SVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2);
+ };
+
+ class SVGPathSegCurvetoCubicSmoothRel : public SVGPathSegCurvetoCubicSmooth {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> create(float x, float y, float x2, float y2) { return adoptRef(new SVGPathSegCurvetoCubicSmoothRel(x, y, x2, y2)); }
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_SMOOTH_REL; }
+ virtual String pathSegTypeAsLetter() const { return "s"; }
+
+ private:
+ SVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float 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..8594fde
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoQuadratic.cpp
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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"
+
+namespace WebCore {
+
+SVGPathSegCurvetoQuadraticAbs::SVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1)
+ : SVGPathSegCurvetoQuadratic(x, y, x1, y1)
+{
+}
+
+SVGPathSegCurvetoQuadraticRel::SVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1)
+ : SVGPathSegCurvetoQuadratic(x, y, x1, 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..1625f13
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoQuadratic.h
@@ -0,0 +1,85 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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 SVGPathSegCurvetoQuadratic : public SVGPathSeg {
+ public:
+ SVGPathSegCurvetoQuadratic(float x, float y, float x1, float y1)
+ : SVGPathSeg(), m_x(x), m_y(y), m_x1(x1), m_y1(y1) {}
+
+ virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg %.6lg %.6lg", m_x1, m_y1, m_x, m_y); }
+
+ void setX(float x) { m_x = x; }
+ float x() const { return m_x; }
+
+ void setY(float y) { m_y = y; }
+ float y() const { return m_y; }
+
+ void setX1(float x1) { m_x1 = x1; }
+ float x1() const { return m_x1; }
+
+ void setY1(float y1) { m_y1 = y1; }
+ float y1() const { return m_y1; }
+
+ private:
+ float m_x;
+ float m_y;
+ float m_x1;
+ float m_y1;
+ };
+
+ class SVGPathSegCurvetoQuadraticAbs : public SVGPathSegCurvetoQuadratic {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoQuadraticAbs> create(float x, float y, float x1, float y1) { return adoptRef(new SVGPathSegCurvetoQuadraticAbs(x, y, x1, y1)); }
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "Q"; }
+
+ private:
+ SVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1);
+ };
+
+ class SVGPathSegCurvetoQuadraticRel : public SVGPathSegCurvetoQuadratic {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoQuadraticRel> create(float x, float y, float x1, float y1) { return adoptRef(new SVGPathSegCurvetoQuadraticRel(x, y, x1, y1)); }
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_REL; }
+ virtual String pathSegTypeAsLetter() const { return "q"; }
+
+ private:
+ SVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float 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..3377709
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.cpp
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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"
+
+namespace WebCore {
+
+SVGPathSegCurvetoQuadraticSmoothAbs::SVGPathSegCurvetoQuadraticSmoothAbs(float x, float y)
+ : SVGPathSegSingleCoord(x, y)
+{
+}
+
+SVGPathSegCurvetoQuadraticSmoothRel::SVGPathSegCurvetoQuadraticSmoothRel(float x, float y)
+ : SVGPathSegSingleCoord(x, 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..3017689
--- /dev/null
+++ b/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h
@@ -0,0 +1,59 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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 SVGPathSegSingleCoord {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> create(float x, float y) { return adoptRef(new SVGPathSegCurvetoQuadraticSmoothAbs(x, y)); }
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "T"; }
+
+ private:
+ SVGPathSegCurvetoQuadraticSmoothAbs(float x, float y);
+ };
+
+ class SVGPathSegCurvetoQuadraticSmoothRel : public SVGPathSegSingleCoord {
+ public:
+ static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> create(float x, float y) { return adoptRef(new SVGPathSegCurvetoQuadraticSmoothRel(x, y)); }
+
+ virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; }
+ virtual String pathSegTypeAsLetter() const { return "t"; }
+
+ private:
+ SVGPathSegCurvetoQuadraticSmoothRel(float x, float 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..ac3a8bd
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLineto.cpp
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2008 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"
+
+namespace WebCore {
+
+SVGPathSegLinetoAbs::SVGPathSegLinetoAbs(float x, float y)
+ : SVGPathSegSingleCoord(x, y)
+{
+}
+
+SVGPathSegLinetoRel::SVGPathSegLinetoRel(float x, float y)
+ : SVGPathSegSingleCoord(x, 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..1818ad2
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLineto.h
@@ -0,0 +1,59 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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 SVGPathSegSingleCoord {
+ public:
+ static PassRefPtr<SVGPathSegLinetoAbs> create(float x, float y) { return adoptRef(new SVGPathSegLinetoAbs(x, y)); }
+
+ virtual unsigned short pathSegType() const { return PATHSEG_LINETO_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "L"; }
+
+ private:
+ SVGPathSegLinetoAbs(float x, float y);
+ };
+
+ class SVGPathSegLinetoRel : public SVGPathSegSingleCoord {
+ public:
+ static PassRefPtr<SVGPathSegLinetoRel> create(float x, float y) { return adoptRef(new SVGPathSegLinetoRel(x, y)); }
+
+
+ virtual unsigned short pathSegType() const { return PATHSEG_LINETO_REL; }
+ virtual String pathSegTypeAsLetter() const { return "l"; }
+
+ private:
+ SVGPathSegLinetoRel(float x, float 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..3de2cc7
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoHorizontal.cpp
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2008 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"
+
+namespace WebCore {
+
+SVGPathSegLinetoHorizontalAbs::SVGPathSegLinetoHorizontalAbs(float x)
+ : SVGPathSegLinetoHorizontal(x)
+{
+}
+
+SVGPathSegLinetoHorizontalRel::SVGPathSegLinetoHorizontalRel(float x)
+ : SVGPathSegLinetoHorizontal(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..84965a5
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoHorizontal.h
@@ -0,0 +1,72 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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 SVGPathSegLinetoHorizontal : public SVGPathSeg {
+ public:
+ SVGPathSegLinetoHorizontal(float x) : SVGPathSeg(), m_x(x) {}
+
+ virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg", m_x); }
+
+ void setX(float x) { m_x = x; }
+ float x() const { return m_x; }
+
+ private:
+ float m_x;
+ };
+
+ class SVGPathSegLinetoHorizontalAbs : public SVGPathSegLinetoHorizontal {
+ public:
+ static PassRefPtr<SVGPathSegLinetoHorizontalAbs> create(float x) { return adoptRef(new SVGPathSegLinetoHorizontalAbs(x)); }
+
+ virtual unsigned short pathSegType() const { return PATHSEG_LINETO_HORIZONTAL_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "H"; }
+
+ private:
+ SVGPathSegLinetoHorizontalAbs(float x);
+ };
+
+ class SVGPathSegLinetoHorizontalRel : public SVGPathSegLinetoHorizontal {
+ public:
+ static PassRefPtr<SVGPathSegLinetoHorizontalRel> create(float x) { return adoptRef(new SVGPathSegLinetoHorizontalRel(x)); }
+
+ virtual unsigned short pathSegType() const { return PATHSEG_LINETO_HORIZONTAL_REL; }
+ virtual String pathSegTypeAsLetter() const { return "h"; }
+
+ private:
+ SVGPathSegLinetoHorizontalRel(float 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..4f667ee
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoVertical.cpp
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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"
+
+namespace WebCore {
+
+SVGPathSegLinetoVerticalAbs::SVGPathSegLinetoVerticalAbs(float y)
+ : SVGPathSegLinetoVertical(y)
+{
+}
+
+SVGPathSegLinetoVerticalRel::SVGPathSegLinetoVerticalRel(float y)
+ : SVGPathSegLinetoVertical(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..8d4ba29
--- /dev/null
+++ b/WebCore/svg/SVGPathSegLinetoVertical.h
@@ -0,0 +1,72 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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 SVGPathSegLinetoVertical : public SVGPathSeg {
+ public:
+ SVGPathSegLinetoVertical(float y) : SVGPathSeg(), m_y(y) {}
+
+ virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg", m_y); }
+
+ void setY(float y) { m_y = y; }
+ float y() const { return m_y; }
+
+ private:
+ float m_y;
+ };
+
+ class SVGPathSegLinetoVerticalAbs : public SVGPathSegLinetoVertical {
+ public:
+ static PassRefPtr<SVGPathSegLinetoVerticalAbs> create(float y) { return adoptRef(new SVGPathSegLinetoVerticalAbs(y)); }
+
+ virtual unsigned short pathSegType() const { return PATHSEG_LINETO_VERTICAL_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "V"; }
+
+ private:
+ SVGPathSegLinetoVerticalAbs(float y);
+ };
+
+ class SVGPathSegLinetoVerticalRel : public SVGPathSegLinetoVertical {
+ public:
+ static PassRefPtr<SVGPathSegLinetoVerticalRel> create(float y) { return adoptRef(new SVGPathSegLinetoVerticalRel(y)); }
+
+ virtual unsigned short pathSegType() const { return PATHSEG_LINETO_VERTICAL_REL; }
+ virtual String pathSegTypeAsLetter() const { return "v"; }
+
+ private:
+ SVGPathSegLinetoVerticalRel(float 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..8d6fdef
--- /dev/null
+++ b/WebCore/svg/SVGPathSegList.cpp
@@ -0,0 +1,260 @@
+/*
+ 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 "SVGPathSegArc.h"
+#include "SVGPathSegClosePath.h"
+#include "SVGPathSegMoveto.h"
+#include "SVGPathSegLineto.h"
+#include "SVGPathSegLinetoHorizontal.h"
+#include "SVGPathSegLinetoVertical.h"
+#include "SVGPathSegCurvetoCubic.h"
+#include "SVGPathSegCurvetoCubicSmooth.h"
+#include "SVGPathSegCurvetoQuadratic.h"
+#include "SVGPathSegCurvetoQuadraticSmooth.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;
+}
+
+static inline float blendFunc(float from, float to, float progress)
+{
+ return (to - from) * progress + from;
+}
+
+#define BLENDPATHSEG1(class, attr1) \
+ class::create(blendFunc(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress))
+
+#define BLENDPATHSEG2(class, attr1, attr2) \
+ class::create(blendFunc(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress), \
+ blendFunc(static_cast<class*>(from)->attr2(), static_cast<class*>(to)->attr2(), progress))
+
+#define BLENDPATHSEG4(class, attr1, attr2, attr3, attr4) \
+ class::create(blendFunc(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress), \
+ blendFunc(static_cast<class*>(from)->attr2(), static_cast<class*>(to)->attr2(), progress), \
+ blendFunc(static_cast<class*>(from)->attr3(), static_cast<class*>(to)->attr3(), progress), \
+ blendFunc(static_cast<class*>(from)->attr4(), static_cast<class*>(to)->attr4(), progress))
+
+#define BLENDPATHSEG6(class, attr1, attr2, attr3, attr4, attr5, attr6) \
+ class::create(blendFunc(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress), \
+ blendFunc(static_cast<class*>(from)->attr2(), static_cast<class*>(to)->attr2(), progress), \
+ blendFunc(static_cast<class*>(from)->attr3(), static_cast<class*>(to)->attr3(), progress), \
+ blendFunc(static_cast<class*>(from)->attr4(), static_cast<class*>(to)->attr4(), progress), \
+ blendFunc(static_cast<class*>(from)->attr5(), static_cast<class*>(to)->attr5(), progress), \
+ blendFunc(static_cast<class*>(from)->attr6(), static_cast<class*>(to)->attr6(), progress))
+
+#define BLENDPATHSEG7(class, attr1, attr2, attr3, attr4, attr5, bool1, bool2) \
+ class::create(blendFunc(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress), \
+ blendFunc(static_cast<class*>(from)->attr2(), static_cast<class*>(to)->attr2(), progress), \
+ blendFunc(static_cast<class*>(from)->attr3(), static_cast<class*>(to)->attr3(), progress), \
+ blendFunc(static_cast<class*>(from)->attr4(), static_cast<class*>(to)->attr4(), progress), \
+ blendFunc(static_cast<class*>(from)->attr5(), static_cast<class*>(to)->attr5(), progress), \
+ static_cast<bool>(blendFunc(static_cast<class*>(from)->bool1(), static_cast<class*>(to)->bool1(), progress)), \
+ static_cast<bool>(blendFunc(static_cast<class*>(from)->bool2(), static_cast<class*>(to)->bool2(), progress)))
+
+PassRefPtr<SVGPathSegList> SVGPathSegList::createAnimated(const SVGPathSegList* fromList, const SVGPathSegList* toList, float progress)
+{
+ unsigned itemCount = fromList->numberOfItems();
+ if (!itemCount || itemCount != toList->numberOfItems())
+ return 0;
+ RefPtr<SVGPathSegList> result = create(fromList->associatedAttributeName());
+ ExceptionCode ec;
+ for (unsigned n = 0; n < itemCount; ++n) {
+ SVGPathSeg* from = fromList->getItem(n, ec).get();
+ SVGPathSeg* to = toList->getItem(n, ec).get();
+ if (from->pathSegType() == SVGPathSeg::PATHSEG_UNKNOWN || from->pathSegType() != to->pathSegType())
+ return 0;
+ RefPtr<SVGPathSeg> segment = 0;
+ switch (static_cast<SVGPathSeg::SVGPathSegType>(from->pathSegType())) {
+ case SVGPathSeg::PATHSEG_CLOSEPATH:
+ segment = SVGPathSegClosePath::create();
+ break;
+ case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS:
+ segment = BLENDPATHSEG1(SVGPathSegLinetoHorizontalAbs, x);
+ break;
+ case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL:
+ segment = BLENDPATHSEG1(SVGPathSegLinetoHorizontalRel, x);
+ break;
+ case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS:
+ segment = BLENDPATHSEG1(SVGPathSegLinetoVerticalAbs, y);
+ break;
+ case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL:
+ segment = BLENDPATHSEG1(SVGPathSegLinetoVerticalRel, y);
+ break;
+ case SVGPathSeg::PATHSEG_MOVETO_ABS:
+ segment = BLENDPATHSEG2(SVGPathSegMovetoAbs, x, y);
+ break;
+ case SVGPathSeg::PATHSEG_MOVETO_REL:
+ segment = BLENDPATHSEG2(SVGPathSegMovetoRel, x, y);
+ break;
+ case SVGPathSeg::PATHSEG_LINETO_ABS:
+ segment = BLENDPATHSEG2(SVGPathSegLinetoAbs, x, y);
+ break;
+ case SVGPathSeg::PATHSEG_LINETO_REL:
+ segment = BLENDPATHSEG2(SVGPathSegLinetoRel, x, y);
+ break;
+ case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS:
+ segment = BLENDPATHSEG6(SVGPathSegCurvetoCubicAbs, x, y, x1, y1, x2, y2);
+ break;
+ case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL:
+ segment = BLENDPATHSEG6(SVGPathSegCurvetoCubicRel, x, y, x1, y1, x2, y2);
+ break;
+ case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
+ segment = BLENDPATHSEG4(SVGPathSegCurvetoCubicSmoothAbs, x, y, x2, y2);
+ break;
+ case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
+ segment = BLENDPATHSEG4(SVGPathSegCurvetoCubicSmoothRel, x, y, x2, y2);
+ break;
+ case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS:
+ segment = BLENDPATHSEG4(SVGPathSegCurvetoQuadraticAbs, x, y, x1, y1);
+ break;
+ case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL:
+ segment = BLENDPATHSEG4(SVGPathSegCurvetoQuadraticRel, x, y, x1, y1);
+ break;
+ case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
+ segment = BLENDPATHSEG2(SVGPathSegCurvetoQuadraticSmoothAbs, x, y);
+ break;
+ case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
+ segment = BLENDPATHSEG2(SVGPathSegCurvetoQuadraticSmoothRel, x, y);
+ break;
+ case SVGPathSeg::PATHSEG_ARC_ABS:
+ segment = BLENDPATHSEG7(SVGPathSegArcAbs, x, y, r1, r2, angle, largeArcFlag, sweepFlag);
+ break;
+ case SVGPathSeg::PATHSEG_ARC_REL:
+ segment = BLENDPATHSEG7(SVGPathSegArcRel, x, y, r1, r2, angle, largeArcFlag, sweepFlag);
+ break;
+ case SVGPathSeg::PATHSEG_UNKNOWN:
+ ASSERT_NOT_REACHED();
+ }
+ result->appendItem(segment, ec);
+ }
+ return result.release();
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPathSegList.h b/WebCore/svg/SVGPathSegList.h
new file mode 100644
index 0000000..d9325ce
--- /dev/null
+++ b/WebCore/svg/SVGPathSegList.h
@@ -0,0 +1,51 @@
+/*
+ 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();
+
+ static PassRefPtr<SVGPathSegList> createAnimated(const SVGPathSegList* fromList, const SVGPathSegList* toList, float progress);
+
+ 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..fc67b29
--- /dev/null
+++ b/WebCore/svg/SVGPathSegMoveto.cpp
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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"
+
+namespace WebCore {
+
+SVGPathSegMovetoAbs::SVGPathSegMovetoAbs(float x, float y)
+ : SVGPathSegSingleCoord(x, y)
+{
+}
+
+SVGPathSegMovetoRel::SVGPathSegMovetoRel(float x, float y)
+ : SVGPathSegSingleCoord(x, 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..726b819
--- /dev/null
+++ b/WebCore/svg/SVGPathSegMoveto.h
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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 SVGPathSegSingleCoord {
+ public:
+ static PassRefPtr<SVGPathSegMovetoAbs> create(float x, float y) { return adoptRef(new SVGPathSegMovetoAbs(x, y)); }
+
+ virtual unsigned short pathSegType() const { return PATHSEG_MOVETO_ABS; }
+ virtual String pathSegTypeAsLetter() const { return "M"; }
+
+ private:
+ SVGPathSegMovetoAbs(float x, float y);
+ };
+
+ class SVGPathSegMovetoRel : public SVGPathSegSingleCoord {
+ public:
+ static PassRefPtr<SVGPathSegMovetoRel> create(float x, float y) { return adoptRef(new SVGPathSegMovetoRel(x, y)); }
+
+ virtual unsigned short pathSegType() const { return PATHSEG_MOVETO_REL; }
+ virtual String pathSegTypeAsLetter() const { return "m"; }
+
+ private:
+ SVGPathSegMovetoRel(float x, float 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..e8ddb7c
--- /dev/null
+++ b/WebCore/svg/SVGPatternElement.cpp
@@ -0,0 +1,322 @@
+/*
+ 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, SVGNames::xAttr, LengthModeWidth)
+ , m_y(this, SVGNames::yAttr, LengthModeHeight)
+ , m_width(this, SVGNames::widthAttr, LengthModeWidth)
+ , m_height(this, SVGNames::heightAttr, LengthModeHeight)
+ , m_patternUnits(this, SVGNames::patternUnitsAttr, SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
+ , m_patternContentUnits(this, SVGNames::patternContentUnitsAttr, SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
+ , m_patternTransform(this, SVGNames::patternTransformAttr, SVGTransformList::create(SVGNames::patternTransformAttr))
+{
+}
+
+SVGPatternElement::~SVGPatternElement()
+{
+}
+
+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(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::widthAttr) {
+ setWidthBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ if (widthBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for pattern attribute <width> is not allowed");
+ } else if (attr->name() == SVGNames::heightAttr) {
+ setHeightBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ if (heightBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for pattern attribute <height> is not allowed");
+ } else {
+ if (SVGURIReference::parseMappedAttribute(attr))
+ return;
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ if (SVGFitToViewBox::parseMappedAttribute(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(this),
+ attributes.y().value(this),
+ attributes.width().value(this),
+ attributes.height().value(this));
+
+ // 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->patternUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
+
+ if (!attributes.hasBoundingBoxModeContent() && current->hasAttribute(SVGNames::patternContentUnitsAttr))
+ attributes.setBoundingBoxModeContent(current->patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_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..2e6399c
--- /dev/null
+++ b/WebCore/svg/SVGPatternElement.h
@@ -0,0 +1,85 @@
+/*
+ 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 "SVGExternalResourcesRequired.h"
+#include "SVGFitToViewBox.h"
+#include "SVGLangSpace.h"
+#include "SVGPaintServerPattern.h"
+#include "SVGStyledElement.h"
+#include "SVGTests.h"
+#include "SVGTransformList.h"
+#include "SVGURIReference.h"
+
+namespace WebCore {
+
+ struct PatternAttributes;
+
+ class SVGLength;
+
+ 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:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGNames::patternTagString, SVGNames::xAttrString, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGNames::patternTagString, SVGNames::yAttrString, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGNames::patternTagString, SVGNames::widthAttrString, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGNames::patternTagString, SVGNames::heightAttrString, SVGLength, Height, height)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGNames::patternTagString, SVGNames::patternUnitsAttrString, int, PatternUnits, patternUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGNames::patternTagString, SVGNames::patternContentUnitsAttrString, int, PatternContentUnits, patternContentUnits)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGNames::patternTagString, SVGNames::patternTransformAttrString, SVGTransformList, PatternTransform, patternTransform)
+
+ mutable RefPtr<SVGPaintServerPattern> m_resource;
+
+ 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..c5a6dd2
--- /dev/null
+++ b/WebCore/svg/SVGPointList.cpp
@@ -0,0 +1,60 @@
+/*
+ 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"
+#include "PlatformString.h"
+
+namespace WebCore {
+
+SVGPointList::SVGPointList(const QualifiedName& attributeName)
+ : SVGPODList<FloatPoint>(attributeName)
+{
+}
+
+SVGPointList::~SVGPointList()
+{
+}
+
+String SVGPointList::valueAsString() const
+{
+ String result;
+
+ ExceptionCode ec = 0;
+ for (unsigned int i = 0; i < numberOfItems(); ++i) {
+ if (i > 0)
+ result += " ";
+
+ FloatPoint point = getItem(i, ec);
+ ASSERT(ec == 0);
+
+ result += String::format("%.6lg %.6lg", point.x(), point.y());
+ }
+
+ return result;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPointList.h b/WebCore/svg/SVGPointList.h
new file mode 100644
index 0000000..d443e2d
--- /dev/null
+++ b/WebCore/svg/SVGPointList.h
@@ -0,0 +1,49 @@
+/*
+ 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 String;
+
+ class SVGPointList : public SVGPODList<FloatPoint> {
+ public:
+ static PassRefPtr<SVGPointList> create(const QualifiedName& attributeName) { return adoptRef(new SVGPointList(attributeName)); }
+ virtual ~SVGPointList();
+
+ String valueAsString() const;
+
+ 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..3d15a43
--- /dev/null
+++ b/WebCore/svg/SVGPolyElement.cpp
@@ -0,0 +1,130 @@
+/*
+ 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 "SVGAnimatedProperty.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()
+{
+}
+
+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)
+{
+ SVGStyledTransformableElement::svgAttributeChanged(attrName);
+
+ if (!renderer())
+ return;
+
+ if (attrName == SVGNames::pointsAttr) {
+ setSynchronizedSVGAttributes(false);
+ renderer()->setNeedsLayout(true);
+ return;
+ }
+
+ if (SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledTransformableElement::isKnownAttribute(attrName))
+ renderer()->setNeedsLayout(true);
+}
+
+// Custom SVG<->XML synchronization logic, as SVGPoly*Element doesn't use animated
+// properties for this, but a special solution: SVGAnimatedPoints inheritance.
+void SVGPolyElement::updateAnimatedSVGAttribute(const String& name) const
+{
+ ASSERT(!m_areSVGAttributesValid);
+
+ if (m_synchronizingSVGAttributes)
+ return;
+
+ if (name == SVGNames::pointsAttr.localName()) {
+ m_synchronizingSVGAttributes = true;
+
+ synchronizeProperty<SVGPolyElement, SVGPointList*>(this, SVGNames::pointsAttr, m_points.get());
+ setSynchronizedSVGAttributes(true);
+ m_synchronizingSVGAttributes = false;
+ return;
+ }
+
+ SVGStyledTransformableElement::updateAnimatedSVGAttribute(name);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPolyElement.h b/WebCore/svg/SVGPolyElement.h
new file mode 100644
index 0000000..0de9f1b
--- /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; }
+
+ virtual void updateAnimatedSVGAttribute(const String&) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ bool m_ignoreAttributeChanges : 1;
+ mutable RefPtr<SVGPointList> m_points;
+ };
+
+} // 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..cde4966
--- /dev/null
+++ b/WebCore/svg/SVGPreserveAspectRatio.cpp
@@ -0,0 +1,261 @@
+/*
+ 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 "AffineTransform.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;
+}
+
+String SVGPreserveAspectRatio::valueAsString() const
+{
+ String result;
+
+ switch ((SVGPreserveAspectRatioType) align()) {
+ default:
+ case SVG_PRESERVEASPECTRATIO_NONE:
+ result = "none";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMINYMIN:
+ result = "xMinYMin";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMIDYMIN:
+ result = "xMidYMin";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMAXYMIN:
+ result = "xMaxYMin";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMINYMID:
+ result = "xMinYMid";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMIDYMID:
+ result = "xMidYMid";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMAXYMID:
+ result = "xMaxYMid";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMINYMAX:
+ result = "xMinYMax";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMIDYMAX:
+ result = "xMidYMax";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMAXYMAX:
+ result = "xMaxYMax";
+ break;
+ };
+
+ switch ((SVGMeetOrSliceType) meetOrSlice()) {
+ default:
+ case SVG_MEETORSLICE_UNKNOWN:
+ break;
+ case SVG_MEETORSLICE_MEET:
+ result += " meet";
+ break;
+ case SVG_MEETORSLICE_SLICE:
+ result += " slice";
+ break;
+ };
+
+ return result;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPreserveAspectRatio.h b/WebCore/svg/SVGPreserveAspectRatio.h
new file mode 100644
index 0000000..0dfe940
--- /dev/null
+++ b/WebCore/svg/SVGPreserveAspectRatio.h
@@ -0,0 +1,92 @@
+/*
+ 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);
+ String valueAsString() const;
+
+ 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..1f25ffb
--- /dev/null
+++ b/WebCore/svg/SVGRadialGradientElement.cpp
@@ -0,0 +1,177 @@
+/*
+ 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, SVGNames::cxAttr, LengthModeWidth, "50%")
+ , m_cy(this, SVGNames::cyAttr, LengthModeHeight, "50%")
+ , m_r(this, SVGNames::rAttr, LengthModeOther, "50%")
+ , m_fx(this, SVGNames::fxAttr, LengthModeWidth)
+ , m_fy(this, SVGNames::fyAttr, LengthModeHeight)
+{
+ // Spec: If the cx/cy/r attribute is not specified, the effect is as if a value of "50%" were specified.
+}
+
+SVGRadialGradientElement::~SVGRadialGradientElement()
+{
+}
+
+void SVGRadialGradientElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::cxAttr)
+ setCxBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::cyAttr)
+ setCyBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::rAttr) {
+ setRBaseValue(SVGLength(LengthModeOther, attr->value()));
+ if (rBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for radial gradient radius <r> is not allowed");
+ } else if (attr->name() == SVGNames::fxAttr)
+ setFxBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::fyAttr)
+ setFyBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else
+ SVGGradientElement::parseMappedAttribute(attr);
+}
+
+void SVGRadialGradientElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGGradientElement::svgAttributeChanged(attrName);
+
+ if (!m_resource)
+ return;
+
+ if (attrName == SVGNames::cxAttr || attrName == SVGNames::cyAttr ||
+ attrName == SVGNames::fxAttr || 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((GradientSpreadMethod) current->spreadMethod());
+
+ if (!attributes.hasBoundingBoxMode() && current->hasAttribute(SVGNames::gradientUnitsAttr))
+ attributes.setBoundingBoxMode(current->gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_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..6813e65
--- /dev/null
+++ b/WebCore/svg/SVGRadialGradientElement.h
@@ -0,0 +1,59 @@
+/*
+ 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;
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRadialGradientElement, SVGNames::radialGradientTagString, SVGNames::cxAttrString, SVGLength, Cx, cx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRadialGradientElement, SVGNames::radialGradientTagString, SVGNames::cyAttrString, SVGLength, Cy, cy)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRadialGradientElement, SVGNames::radialGradientTagString, SVGNames::rAttrString, SVGLength, R, r)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRadialGradientElement, SVGNames::radialGradientTagString, SVGNames::fxAttrString, SVGLength, Fx, fx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRadialGradientElement, SVGNames::radialGradientTagString, SVGNames::fyAttrString, 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..367e12e
--- /dev/null
+++ b/WebCore/svg/SVGRectElement.cpp
@@ -0,0 +1,126 @@
+/*
+ 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, SVGNames::xAttr, LengthModeWidth)
+ , m_y(this, SVGNames::yAttr, LengthModeHeight)
+ , m_width(this, SVGNames::widthAttr, LengthModeWidth)
+ , m_height(this, SVGNames::heightAttr, LengthModeHeight)
+ , m_rx(this, SVGNames::rxAttr, LengthModeWidth)
+ , m_ry(this, SVGNames::ryAttr, LengthModeHeight)
+{
+}
+
+SVGRectElement::~SVGRectElement()
+{
+}
+
+void SVGRectElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::xAttr)
+ setXBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::rxAttr) {
+ setRxBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ if (rxBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for rect <rx> is not allowed");
+ } else if (attr->name() == SVGNames::ryAttr) {
+ setRyBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ if (ryBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for rect <ry> is not allowed");
+ } else if (attr->name() == SVGNames::widthAttr) {
+ setWidthBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ if (widthBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for rect <width> is not allowed");
+ } else if (attr->name() == SVGNames::heightAttr) {
+ setHeightBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ if (heightBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for 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 ||
+ attrName == SVGNames::rxAttr || attrName == SVGNames::ryAttr ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledTransformableElement::isKnownAttribute(attrName))
+ renderer()->setNeedsLayout(true);
+}
+
+Path SVGRectElement::toPathData() const
+{
+ FloatRect rect(x().value(this), y().value(this), width().value(this), height().value(this));
+
+ bool hasRx = hasAttribute(SVGNames::rxAttr);
+ bool hasRy = hasAttribute(SVGNames::ryAttr);
+ if (hasRx || hasRy) {
+ float _rx = hasRx ? rx().value(this) : ry().value(this);
+ float _ry = hasRy ? ry().value(this) : rx().value(this);
+ return Path::createRoundedRectangle(rect, FloatSize(_rx, _ry));
+ }
+
+ return Path::createRectangle(rect);
+}
+
+bool SVGRectElement::hasRelativeValues() const
+{
+ return (x().isRelative() || width().isRelative() ||
+ y().isRelative() || height().isRelative() ||
+ rx().isRelative() || ry().isRelative());
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGRectElement.h b/WebCore/svg/SVGRectElement.h
new file mode 100644
index 0000000..2937c23
--- /dev/null
+++ b/WebCore/svg/SVGRectElement.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 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_DECLARATIONS(SVGRectElement, SVGNames::rectTagString, SVGNames::xAttrString, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGNames::rectTagString, SVGNames::yAttrString, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGNames::rectTagString, SVGNames::widthAttrString, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGNames::rectTagString, SVGNames::heightAttrString, SVGLength, Height, height)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGNames::rectTagString, SVGNames::rxAttrString, SVGLength, Rx, rx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGNames::rectTagString, SVGNames::ryAttrString, 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..23a1fd9
--- /dev/null
+++ b/WebCore/svg/SVGSVGElement.cpp
@@ -0,0 +1,541 @@
+/*
+ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007, 2008 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 "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 "SMILTimeContainer.h"
+
+namespace WebCore {
+
+using namespace HTMLNames;
+using namespace SVGNames;
+
+SVGSVGElement::SVGSVGElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledLocatableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , SVGFitToViewBox()
+ , SVGZoomAndPan()
+ , m_x(this, SVGNames::xAttr, LengthModeWidth)
+ , m_y(this, SVGNames::yAttr, LengthModeHeight)
+ , m_width(this, SVGNames::widthAttr, LengthModeWidth, "100%")
+ , m_height(this, SVGNames::heightAttr, LengthModeHeight, "100%")
+ , m_useCurrentView(false)
+ , m_timeContainer(SMILTimeContainer::create(this))
+ , m_viewSpec(0)
+ , m_containerSize(300, 150)
+ , m_hasSetContainerSize(false)
+{
+ doc->registerForDocumentActivationCallbacks(this);
+}
+
+SVGSVGElement::~SVGSVGElement()
+{
+ document()->unregisterForDocumentActivationCallbacks(this);
+ // There are cases where removedFromDocument() is not called.
+ // see ContainerNode::removeAllChildren, called by its destructor.
+ document()->accessSVGExtensions()->removeTimeContainer(this);
+
+ // Call detach() here because if we wait until ~Node() calls it, we crash during
+ // RenderSVGViewportContainer destruction, as the renderer assumes that the element
+ // is still fully constructed. See <https://bugs.webkit.org/show_bug.cgi?id=21293>.
+ if (renderer())
+ detach();
+}
+
+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(this);
+ _y = y().value(this);
+ }
+ float w = width().value(this);
+ float h = height().value(this);
+ 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();
+ return 1.0f;
+}
+
+void SVGSVGElement::setCurrentScale(float scale)
+{
+ if (document() && document()->frame())
+ document()->frame()->setZoomFactor(scale, true);
+}
+
+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::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (!nearestViewportElement()) {
+ bool setListener = true;
+
+ // Only handle events if we're the outermost <svg> element
+ if (attr->name() == onunloadAttr)
+ document()->setWindowInlineEventListenerForTypeAndAttribute(eventNames().unloadEvent, attr);
+ else if (attr->name() == onresizeAttr)
+ document()->setWindowInlineEventListenerForTypeAndAttribute(eventNames().resizeEvent, attr);
+ else if (attr->name() == onscrollAttr)
+ document()->setWindowInlineEventListenerForTypeAndAttribute(eventNames().scrollEvent, attr);
+ else if (attr->name() == SVGNames::onzoomAttr)
+ document()->setWindowInlineEventListenerForTypeAndAttribute(eventNames().zoomEvent, attr);
+ else
+ setListener = false;
+
+ if (setListener)
+ return;
+ }
+
+ if (attr->name() == onabortAttr)
+ document()->setWindowInlineEventListenerForTypeAndAttribute(eventNames().abortEvent, attr);
+ else if (attr->name() == onerrorAttr)
+ document()->setWindowInlineEventListenerForTypeAndAttribute(eventNames().errorEvent, attr);
+ else if (attr->name() == SVGNames::xAttr)
+ setXBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::widthAttr) {
+ setWidthBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ addCSSProperty(attr, CSSPropertyWidth, attr->value());
+ if (widthBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for svg attribute <width> is not allowed");
+ } else if (attr->name() == SVGNames::heightAttr) {
+ setHeightBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ addCSSProperty(attr, CSSPropertyHeight, attr->value());
+ if (heightBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for svg attribute <height> is not allowed");
+ } else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ if (SVGFitToViewBox::parseMappedAttribute(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()->selection()->clear();
+}
+
+float SVGSVGElement::createSVGNumber()
+{
+ return 0.0f;
+}
+
+SVGLength SVGSVGElement::createSVGLength()
+{
+ return SVGLength();
+}
+
+PassRefPtr<SVGAngle> SVGSVGElement::createSVGAngle()
+{
+ return SVGAngle::create();
+}
+
+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(this), y().value(this));
+
+ if (attributes()->getNamedItem(SVGNames::viewBoxAttr)) {
+ AffineTransform viewBox = viewBoxToViewTransform(width().value(this), height().value(this));
+ mat = viewBox * mat;
+ }
+
+ return mat;
+}
+
+AffineTransform SVGSVGElement::getScreenCTM() const
+{
+ document()->updateLayoutIgnorePendingStylesheets();
+ float rootX = 0.0f;
+ float rootY = 0.0f;
+
+ if (RenderObject* renderer = this->renderer()) {
+ if (isOutermostSVG()) {
+ int tx = 0;
+ int ty = 0;
+ if (renderer->parent())
+ renderer->absolutePosition(tx, ty, true);
+ rootX += tx;
+ rootY += ty;
+ } else {
+ rootX += x().value(this);
+ rootY += y().value(this);
+ }
+ }
+
+ AffineTransform mat = SVGStyledLocatableElement::getScreenCTM();
+ mat.translate(rootX, rootY);
+
+ if (attributes()->getNamedItem(SVGNames::viewBoxAttr)) {
+ AffineTransform viewBox = viewBoxToViewTransform(width().value(this), height().value(this));
+ 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_timeContainer->isPaused())
+ m_timeContainer->pause();
+}
+
+void SVGSVGElement::unpauseAnimations()
+{
+ if (m_timeContainer->isPaused())
+ m_timeContainer->resume();
+}
+
+bool SVGSVGElement::animationsPaused() const
+{
+ return m_timeContainer->isPaused();
+}
+
+float SVGSVGElement::getCurrentTime() const
+{
+ return narrowPrecisionToFloat(m_timeContainer->elapsed().value());
+}
+
+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);
+}
+
+void SVGSVGElement::documentWillBecomeInactive()
+{
+ pauseAnimations();
+}
+
+void SVGSVGElement::documentDidBecomeActive()
+{
+ unpauseAnimations();
+}
+
+}
+
+#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..bd8b7f9
--- /dev/null
+++ b/WebCore/svg/SVGSVGElement.h
@@ -0,0 +1,167 @@
+/*
+ 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 SMILTimeContainer;
+ 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&);
+
+ SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); }
+
+ 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 PassRefPtr<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:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::xAttrString, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::yAttrString, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::widthAttrString, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::heightAttrString, SVGLength, Height, height)
+
+ virtual void documentWillBecomeInactive();
+ virtual void documentDidBecomeActive();
+
+ bool m_useCurrentView;
+ RefPtr<SMILTimeContainer> m_timeContainer;
+ FloatPoint m_translation;
+ mutable OwnPtr<SVGViewSpec> m_viewSpec;
+ IntSize m_containerSize;
+ bool m_hasSetContainerSize;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
diff --git a/WebCore/svg/SVGSVGElement.idl b/WebCore/svg/SVGSVGElement.idl
new file mode 100644
index 0000000..32b4e3c
--- /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 [Immutable] 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 [Immutable] 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..3c3a7a3
--- /dev/null
+++ b/WebCore/svg/SVGScriptElement.cpp
@@ -0,0 +1,212 @@
+/*
+ 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 "SVGScriptElement.h"
+
+#include "EventNames.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+SVGScriptElement::SVGScriptElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+ , SVGURIReference()
+ , SVGExternalResourcesRequired()
+ , m_data(this, this)
+{
+}
+
+SVGScriptElement::~SVGScriptElement()
+{
+}
+
+void SVGScriptElement::setCreatedByParser(bool createdByParser)
+{
+ m_data.setCreatedByParser(createdByParser);
+}
+
+String SVGScriptElement::scriptContent() const
+{
+ return m_data.scriptContent();
+}
+
+void SVGScriptElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const QualifiedName& attrName = attr->name();
+
+ if (attrName == SVGNames::typeAttr)
+ setType(attr->value());
+ else {
+ if (SVGURIReference::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+
+ SVGElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGElement::svgAttributeChanged(attrName);
+
+ if (SVGURIReference::isKnownAttribute(attrName))
+ handleSourceAttribute(m_data, href());
+ else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) {
+ // Handle dynamic updates of the 'externalResourcesRequired' attribute. Only possible case: changing from 'true' to 'false'
+ // causes an immediate dispatch of the SVGLoad event. If the attribute value was 'false' before inserting the script element
+ // in the document, the SVGLoad event has already been dispatched.
+ if (!externalResourcesRequiredBaseValue() && !m_data.haveFiredLoadEvent() && !m_data.createdByParser()) {
+ m_data.setHaveFiredLoadEvent(true);
+ ASSERT(haveLoadedRequiredResources());
+
+ sendSVGLoadEventIfPossible();
+ }
+ }
+}
+
+void SVGScriptElement::insertedIntoDocument()
+{
+ SVGElement::insertedIntoDocument();
+ ScriptElement::insertedIntoDocument(m_data, sourceAttributeValue());
+
+ if (m_data.createdByParser())
+ return;
+
+ // Eventually send SVGLoad event now for the dynamically inserted script element
+ if (!externalResourcesRequiredBaseValue()) {
+ m_data.setHaveFiredLoadEvent(true);
+ sendSVGLoadEventIfPossible();
+ }
+}
+
+void SVGScriptElement::removedFromDocument()
+{
+ SVGElement::removedFromDocument();
+ ScriptElement::removedFromDocument(m_data);
+}
+
+void SVGScriptElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+{
+ ScriptElement::childrenChanged(m_data);
+ SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+}
+
+bool SVGScriptElement::isURLAttribute(Attribute* attr) const
+{
+ return attr->name() == sourceAttributeValue();
+}
+
+void SVGScriptElement::finishParsingChildren()
+{
+ ScriptElement::finishParsingChildren(m_data, sourceAttributeValue());
+ SVGElement::finishParsingChildren();
+
+ // A SVGLoad event has been fired by SVGElement::finishParsingChildren.
+ if (!externalResourcesRequiredBaseValue())
+ m_data.setHaveFiredLoadEvent(true);
+}
+
+String SVGScriptElement::type() const
+{
+ return m_type;
+}
+
+void SVGScriptElement::setType(const String& type)
+{
+ m_type = type;
+}
+
+String SVGScriptElement::scriptCharset() const
+{
+ return m_data.scriptCharset();
+}
+
+void SVGScriptElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+ urls.append(href());
+}
+
+bool SVGScriptElement::haveLoadedRequiredResources()
+{
+ return !externalResourcesRequiredBaseValue() || m_data.haveFiredLoadEvent();
+}
+
+String SVGScriptElement::sourceAttributeValue() const
+{
+ return href();
+}
+
+String SVGScriptElement::charsetAttributeValue() const
+{
+ return String();
+}
+
+String SVGScriptElement::typeAttributeValue() const
+{
+ return type();
+}
+
+String SVGScriptElement::languageAttributeValue() const
+{
+ return String();
+}
+
+void SVGScriptElement::dispatchLoadEvent()
+{
+ bool externalResourcesRequired = externalResourcesRequiredBaseValue();
+
+ if (m_data.createdByParser())
+ ASSERT(externalResourcesRequired != m_data.haveFiredLoadEvent());
+ else if (m_data.haveFiredLoadEvent()) {
+ // If we've already fired an load event and externalResourcesRequired is set to 'true'
+ // externalResourcesRequired has been modified while loading the <script>. Don't dispatch twice.
+ if (externalResourcesRequired)
+ return;
+ }
+
+ // HTML and SVG differ completly in the 'onload' event handling of <script> elements.
+ // HTML fires the 'load' event after it sucessfully loaded a remote resource, otherwhise an error event.
+ // SVG fires the SVGLoad event immediately after parsing the <script> element, if externalResourcesRequired
+ // is set to 'false', otherwhise it dispatches the 'SVGLoad' event just after loading the remote resource.
+ if (externalResourcesRequired) {
+ ASSERT(!m_data.haveFiredLoadEvent());
+
+ // Dispatch SVGLoad event
+ m_data.setHaveFiredLoadEvent(true);
+ ASSERT(haveLoadedRequiredResources());
+
+ sendSVGLoadEventIfPossible();
+ }
+}
+
+void SVGScriptElement::dispatchErrorEvent()
+{
+ dispatchEventForType(eventNames().errorEvent, true, false);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGScriptElement.h b/WebCore/svg/SVGScriptElement.h
new file mode 100644
index 0000000..0475881
--- /dev/null
+++ b/WebCore/svg/SVGScriptElement.h
@@ -0,0 +1,81 @@
+/*
+ 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 SVGScriptElement_h
+#define SVGScriptElement_h
+
+#if ENABLE(SVG)
+#include "ScriptElement.h"
+#include "SVGElement.h"
+#include "SVGURIReference.h"
+#include "SVGExternalResourcesRequired.h"
+
+namespace WebCore {
+
+ class SVGScriptElement : public SVGElement
+ , public SVGURIReference
+ , public SVGExternalResourcesRequired
+ , public ScriptElement {
+ public:
+ SVGScriptElement(const QualifiedName&, Document*);
+ virtual ~SVGScriptElement();
+
+ void setCreatedByParser(bool);
+ virtual String scriptContent() const;
+
+ 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);
+
+ virtual void svgAttributeChanged(const QualifiedName&);
+ virtual bool isURLAttribute(Attribute*) const;
+ virtual void finishParsingChildren();
+
+ String type() const;
+ void setType(const String&);
+
+ virtual String scriptCharset() const;
+
+ virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+ virtual bool haveLoadedRequiredResources();
+
+ virtual String sourceAttributeValue() const;
+ virtual String charsetAttributeValue() const;
+ virtual String typeAttributeValue() const;
+ virtual String languageAttributeValue() const;
+
+ virtual void dispatchLoadEvent();
+ virtual void dispatchErrorEvent();
+
+ private:
+ ScriptElementData m_data;
+ String m_type;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..5800580
--- /dev/null
+++ b/WebCore/svg/SVGSetElement.cpp
@@ -0,0 +1,37 @@
+/*
+ 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_ANIMATION)
+#include "SVGSetElement.h"
+
+namespace WebCore {
+
+SVGSetElement::SVGSetElement(const QualifiedName& tagName, Document *doc)
+ : SVGAnimateElement(tagName, doc)
+{
+}
+}
+
+// vim:ts=4:noet
+#endif // ENABLE(SVG_ANIMATION)
+
diff --git a/WebCore/svg/SVGSetElement.h b/WebCore/svg/SVGSetElement.h
new file mode 100644
index 0000000..d47e003
--- /dev/null
+++ b/WebCore/svg/SVGSetElement.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 SVGSetElement_h
+#define SVGSetElement_h
+#if ENABLE(SVG_ANIMATION)
+
+#include "SVGAnimateElement.h"
+
+namespace WebCore
+{
+ // SVGAnimateElement implements superset of the functionality.
+ class SVGSetElement : public SVGAnimateElement
+ {
+ public:
+ SVGSetElement(const QualifiedName&, Document*);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG_ANIMATION)
+#endif
+
+// vim:ts=4:noet
diff --git a/WebCore/svg/SVGSetElement.idl b/WebCore/svg/SVGSetElement.idl
new file mode 100644
index 0000000..2ee36f1
--- /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_ANIMATION] SVGSetElement : SVGAnimationElement {
+ };
+
+}
diff --git a/WebCore/svg/SVGStopElement.cpp b/WebCore/svg/SVGStopElement.cpp
new file mode 100644
index 0000000..4747824
--- /dev/null
+++ b/WebCore/svg/SVGStopElement.cpp
@@ -0,0 +1,66 @@
+/*
+ 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(this, SVGNames::offsetAttr, 0.0f)
+{
+}
+
+SVGStopElement::~SVGStopElement()
+{
+}
+
+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..bbfd770
--- /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, SVGNames::stopTagString, SVGNames::offsetAttrString, 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..2612de0
--- /dev/null
+++ b/WebCore/svg/SVGStyleElement.cpp
@@ -0,0 +1,139 @@
+/*
+ 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();
+ document()->addStyleSheetCandidateNode(this, m_createdByParser);
+ if (!m_createdByParser)
+ StyleElement::insertedIntoDocument(document(), this);
+}
+
+void SVGStyleElement::removedFromDocument()
+{
+ SVGElement::removedFromDocument();
+ if (document()->renderer())
+ document()->removeStyleSheetCandidateNode(this);
+ 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..e87b79f
--- /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 core::DOMString 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..466ce3c
--- /dev/null
+++ b/WebCore/svg/SVGStyledElement.cpp
@@ -0,0 +1,281 @@
+/*
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2007, 2008 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;
+
+char SVGStyledElementIdentifier[] = "SVGStyledElement";
+static HashSet<const SVGStyledElement*>* gElementsWithInstanceUpdatesBlocked = 0;
+
+SVGStyledElement::SVGStyledElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+ , m_className(this, HTMLNames::classAttr)
+{
+}
+
+SVGStyledElement::~SVGStyledElement()
+{
+ SVGResource::removeClient(this);
+}
+
+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)
+{
+ const QualifiedName& attrName = attr->name();
+ // 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(attrName);
+ if (propId > 0) {
+ addCSSProperty(attr, propId, attr->value());
+ setChanged();
+ return;
+ }
+
+ // SVG animation has currently requires special storage of values so we set
+ // the className here. svgAttributeChanged actually causes the resulting
+ // style updates (instead of StyledElement::parseMappedAttribute). We don't
+ // tell StyledElement about the change to avoid parsing the class list twice
+ if (attrName.matches(HTMLNames::classAttr))
+ setClassName(attr->value());
+ else
+ // id is handled by StyledElement which SVGElement inherits from
+ 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 (attrName.matches(HTMLNames::classAttr))
+ classAttributeChanged(className());
+
+ // If we're the child of a resource element, be sure to invalidate it.
+ invalidateResourcesInAncestorChain();
+
+ // Invalidate all SVGElementInstances associated with us
+ SVGElementInstance::invalidateAllInstancesOfElement(this);
+}
+
+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;
+
+ // Invalidate all SVGElementInstances associated with us
+ SVGElementInstance::invalidateAllInstancesOfElement(this);
+}
+
+PassRefPtr<RenderStyle> SVGStyledElement::resolveStyle(RenderStyle* parentStyle)
+{
+ if (renderer())
+ return renderer()->style();
+ return document()->styleSelector()->styleForElement(this, parentStyle);
+}
+
+PassRefPtr<CSSValue> SVGStyledElement::getPresentationAttribute(const String& name)
+{
+ Attribute* attr = mappedAttributes()->getAttributeItem(name, false);
+ if (!attr || !attr->isMappedAttribute() || !attr->style())
+ return 0;
+
+ MappedAttribute* cssSVGAttr = static_cast<MappedAttribute*>(attr);
+
+ // FIXME: Is it possible that the style will not be shared at the time this
+ // is called, but a later addition to the DOM will make it shared?
+ if (!cssSVGAttr->style()->hasOneRef()) {
+ cssSVGAttr->setDecl(0);
+ int propId = SVGStyledElement::cssPropertyIdForSVGAttributeName(cssSVGAttr->name());
+ addCSSProperty(cssSVGAttr, propId, cssSVGAttr->value());
+ }
+
+ return cssSVGAttr->style()->getPropertyCSSValue(name);
+}
+
+void SVGStyledElement::detach()
+{
+ SVGResource::removeClient(this);
+ SVGElement::detach();
+}
+
+void SVGStyledElement::setInstanceUpdatesBlocked(bool blockUpdates)
+{
+ if (blockUpdates) {
+ if (!gElementsWithInstanceUpdatesBlocked)
+ gElementsWithInstanceUpdatesBlocked = new HashSet<const SVGStyledElement*>;
+ gElementsWithInstanceUpdatesBlocked->add(this);
+ } else {
+ ASSERT(gElementsWithInstanceUpdatesBlocked);
+ ASSERT(gElementsWithInstanceUpdatesBlocked->contains(this));
+ gElementsWithInstanceUpdatesBlocked->remove(this);
+ }
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGStyledElement.h b/WebCore/svg/SVGStyledElement.h
new file mode 100644
index 0000000..e21db97
--- /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 "HTMLNames.h"
+#include "SVGElement.h"
+#include "SVGStylable.h"
+
+namespace WebCore {
+
+ extern char SVGStyledElementIdentifier[];
+ class SVGResource;
+
+ 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.
+ PassRefPtr<RenderStyle> resolveStyle(RenderStyle* parentStyle);
+
+ void invalidateResourcesInAncestorChain() const;
+ virtual void detach();
+
+ void setInstanceUpdatesBlocked(bool);
+
+ protected:
+ virtual bool hasRelativeValues() const { return true; }
+
+ static int cssPropertyIdForSVGAttributeName(const QualifiedName&);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGStyledElement, SVGStyledElementIdentifier, HTMLNames::classAttrString, String, ClassName, className)
+ };
+
+} // 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..a7b5c41
--- /dev/null
+++ b/WebCore/svg/SVGStyledTransformableElement.cpp
@@ -0,0 +1,126 @@
+/*
+ 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 {
+
+char SVGStyledTransformableElementIdentifier[] = "SVGStyledTransformableElement";
+
+SVGStyledTransformableElement::SVGStyledTransformableElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledLocatableElement(tagName, doc)
+ , SVGTransformable()
+ , m_transform(this, SVGNames::transformAttr, SVGTransformList::create(SVGNames::transformAttr))
+{
+}
+
+SVGStyledTransformableElement::~SVGStyledTransformableElement()
+{
+}
+
+AffineTransform SVGStyledTransformableElement::getCTM() const
+{
+ return SVGTransformable::getCTM(this);
+}
+
+AffineTransform SVGStyledTransformableElement::getScreenCTM() const
+{
+ return SVGTransformable::getScreenCTM(this);
+}
+
+AffineTransform SVGStyledTransformableElement::animatedLocalTransform() const
+{
+ return m_supplementalTransform ? transform()->concatenate().matrix() * *m_supplementalTransform : transform()->concatenate().matrix();
+}
+
+AffineTransform* SVGStyledTransformableElement::supplementalTransform()
+{
+ if (!m_supplementalTransform)
+ m_supplementalTransform.set(new AffineTransform());
+ return m_supplementalTransform.get();
+}
+
+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);
+}
+
+Path SVGStyledTransformableElement::toClipPath() const
+{
+ Path pathData = toPathData();
+ // FIXME: How do we know the element has done a layout?
+ pathData.transform(animatedLocalTransform());
+ return pathData;
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGStyledTransformableElement.h b/WebCore/svg/SVGStyledTransformableElement.h
new file mode 100644
index 0000000..43ccc68
--- /dev/null
+++ b/WebCore/svg/SVGStyledTransformableElement.h
@@ -0,0 +1,75 @@
+/*
+ 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 "Path.h"
+#include "SVGStyledLocatableElement.h"
+#include "SVGTransformable.h"
+
+namespace WebCore {
+
+ extern char SVGStyledTransformableElementIdentifier[];
+
+ class AffineTransform;
+
+ 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 AffineTransform* supplementalTransform();
+
+ 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;
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ protected:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGStyledTransformableElement, SVGStyledTransformableElementIdentifier,
+ SVGNames::transformAttrString, SVGTransformList, Transform, transform)
+
+ private:
+ // Used by <animateMotion>
+ OwnPtr<AffineTransform> m_supplementalTransform;
+ };
+
+} // 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..82153d9
--- /dev/null
+++ b/WebCore/svg/SVGSwitchElement.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 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;
+ };
+
+} // 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..a6ccbce
--- /dev/null
+++ b/WebCore/svg/SVGSymbolElement.h
@@ -0,0 +1,54 @@
+/*
+ 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; }
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..88eeef1
--- /dev/null
+++ b/WebCore/svg/SVGTRefElement.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 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:
+ void updateReferencedText();
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..eadae1e
--- /dev/null
+++ b/WebCore/svg/SVGTSpanElement.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)
+#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()
+#if ENABLE(SVG_FONTS)
+ || child->hasTagName(SVGNames::altGlyphTag)
+#endif
+ || 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..7a29e96
--- /dev/null
+++ b/WebCore/svg/SVGTSpanElement.h
@@ -0,0 +1,43 @@
+/*
+ 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 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;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..06a81f2
--- /dev/null
+++ b/WebCore/svg/SVGTests.cpp
@@ -0,0 +1,120 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 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.
+*/
+
+#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::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..e53d662
--- /dev/null
+++ b/WebCore/svg/SVGTextContentElement.cpp
@@ -0,0 +1,529 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007, 2008 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 "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 {
+
+char SVGTextContentElementIdentifier[] = "SVGTextContentElement";
+
+SVGTextContentElement::SVGTextContentElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , m_textLength(this, SVGNames::textLengthAttr, LengthModeOther)
+ , m_lengthAdjust(this, SVGNames::lengthAdjustAttr, LENGTHADJUST_SPACING)
+{
+}
+
+SVGTextContentElement::~SVGTextContentElement()
+{
+}
+
+static inline float cumulativeCharacterRangeLength(const Vector<SVGChar>::iterator& start, const Vector<SVGChar>::iterator& end, SVGInlineTextBox* textBox,
+ int startOffset, long startPosition, long length, bool isVerticalText, long& atCharacter)
+{
+ if (!length)
+ return 0.0f;
+
+ 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->direction() == RTL)
+ newOffset = textBox->start() + textBox->end() - newOffset;
+
+ // FIXME: does this handle multichar glyphs ok? not sure
+ int charsConsumed = 0;
+ String glyphName;
+ if (isVerticalText)
+ textLength += textBox->calculateGlyphHeight(style, newOffset, 0);
+ else
+ textLength += textBox->calculateGlyphWidth(style, newOffset, 0, charsConsumed, glyphName);
+ }
+
+ if (!usesFullRange) {
+ if (atCharacter == startPosition + length - 1)
+ break;
+
+ atCharacter++;
+ }
+ }
+
+ 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 = cumulativeCharacterRangeLength(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 = cumulativeCharacterRangeLength(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->direction() == RTL)
+ newOffset = textBox->start() + textBox->end() - newOffset;
+
+ int charsConsumed;
+ String glyphName;
+ // calculateGlyph{Height,Width} will consume at least one character. This is the number of characters available
+ // to them beyond that first one.
+ int extraCharactersAvailable = end - it - 1;
+ if (isVerticalText)
+ m_queryPointResult.move(it->x, it->y + textBox->calculateGlyphHeight(style, newOffset, extraCharactersAvailable));
+ else
+ m_queryPointResult.move(it->x + textBox->calculateGlyphWidth(style, newOffset, extraCharactersAvailable, charsConsumed, glyphName), 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
+{
+ document()->updateLayoutIgnorePendingStylesheets();
+
+ return executeTextQuery(this, SVGInlineTextBoxQueryWalker::NumberOfCharacters).longResult();
+}
+
+float SVGTextContentElement::getComputedTextLength() const
+{
+ document()->updateLayoutIgnorePendingStylesheets();
+
+ return executeTextQuery(this, SVGInlineTextBoxQueryWalker::TextLength).floatResult();
+}
+
+float SVGTextContentElement::getSubStringLength(long charnum, long nchars, ExceptionCode& ec) const
+{
+ document()->updateLayoutIgnorePendingStylesheets();
+
+ long numberOfChars = getNumberOfChars();
+ if (charnum < 0 || nchars < 0 || charnum >= numberOfChars) {
+ ec = INDEX_SIZE_ERR;
+ return 0.0f;
+ }
+
+ return executeTextQuery(this, SVGInlineTextBoxQueryWalker::SubStringLength, charnum, nchars).floatResult();
+}
+
+FloatPoint SVGTextContentElement::getStartPositionOfChar(long charnum, ExceptionCode& ec) const
+{
+ document()->updateLayoutIgnorePendingStylesheets();
+
+ 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
+{
+ document()->updateLayoutIgnorePendingStylesheets();
+
+ 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
+{
+ document()->updateLayoutIgnorePendingStylesheets();
+
+ 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
+{
+ document()->updateLayoutIgnorePendingStylesheets();
+
+ 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
+{
+ document()->updateLayoutIgnorePendingStylesheets();
+
+ 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()->selection();
+ 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(LengthModeOther, attr->value()));
+ if (textLengthBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for text attribute <textLength> is not allowed");
+ } else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr)) {
+ if (attr->name().matches(XMLNames::spaceAttr)) {
+ static const AtomicString preserveString("preserve");
+
+ if (attr->value() == preserveString)
+ addCSSProperty(attr, CSSPropertyWhiteSpace, CSSValuePre);
+ else
+ addCSSProperty(attr, CSSPropertyWhiteSpace, CSSValueNowrap);
+ }
+ return;
+ }
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+
+ SVGStyledElement::parseMappedAttribute(attr);
+ }
+}
+
+bool SVGTextContentElement::isKnownAttribute(const QualifiedName& attrName)
+{
+ return (attrName.matches(SVGNames::lengthAdjustAttr) ||
+ attrName.matches(SVGNames::textLengthAttr) ||
+ SVGTests::isKnownAttribute(attrName) ||
+ SVGLangSpace::isKnownAttribute(attrName) ||
+ SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
+ SVGStyledElement::isKnownAttribute(attrName));
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGTextContentElement.h b/WebCore/svg/SVGTextContentElement.h
new file mode 100644
index 0000000..d6b9d93
--- /dev/null
+++ b/WebCore/svg/SVGTextContentElement.h
@@ -0,0 +1,80 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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 {
+
+ extern char SVGTextContentElementIdentifier[];
+
+ 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; }
+
+ long getNumberOfChars() const;
+ float getComputedTextLength() const;
+ float getSubStringLength(long charnum, 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*);
+
+ bool isKnownAttribute(const QualifiedName&);
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextContentElement, SVGTextContentElementIdentifier, SVGNames::textLengthAttrString, SVGLength, TextLength, textLength)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextContentElement, SVGTextContentElementIdentifier, SVGNames::lengthAdjustAttrString, int, LengthAdjust, lengthAdjust)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..1ace1a9
--- /dev/null
+++ b/WebCore/svg/SVGTextElement.cpp
@@ -0,0 +1,134 @@
+/*
+ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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(this, SVGNames::transformAttr, SVGTransformList::create(SVGNames::transformAttr))
+{
+}
+
+SVGTextElement::~SVGTextElement()
+{
+}
+
+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 m_supplementalTransform ? transform()->concatenate().matrix() * *m_supplementalTransform : transform()->concatenate().matrix();
+}
+
+AffineTransform* SVGTextElement::supplementalTransform()
+{
+ if (!m_supplementalTransform)
+ m_supplementalTransform.set(new AffineTransform());
+ return m_supplementalTransform.get();
+}
+
+RenderObject* SVGTextElement::createRenderer(RenderArena* arena, RenderStyle* style)
+{
+ return new (arena) RenderSVGText(this);
+}
+
+bool SVGTextElement::childShouldCreateRenderer(Node* child) const
+{
+ if (child->isTextNode()
+#if ENABLE(SVG_FONTS)
+ || child->hasTagName(SVGNames::altGlyphTag)
+#endif
+ || child->hasTagName(SVGNames::tspanTag) || child->hasTagName(SVGNames::trefTag) || child->hasTagName(SVGNames::aTag) || child->hasTagName(SVGNames::textPathTag))
+ return true;
+ return false;
+}
+
+void SVGTextElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ SVGTextPositioningElement::svgAttributeChanged(attrName);
+
+ if (!renderer())
+ return;
+
+ if (SVGTextPositioningElement::isKnownAttribute(attrName))
+ renderer()->setNeedsLayout(true);
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGTextElement.h b/WebCore/svg/SVGTextElement.h
new file mode 100644
index 0000000..3ae6139
--- /dev/null
+++ b/WebCore/svg/SVGTextElement.h
@@ -0,0 +1,64 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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 AffineTransform* supplementalTransform();
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+ virtual bool childShouldCreateRenderer(Node*) const;
+
+ virtual void svgAttributeChanged(const QualifiedName&);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextElement, SVGNames::textTagString, SVGNames::transformAttrString, SVGTransformList, Transform, transform)
+
+ // Used by <animateMotion>
+ OwnPtr<AffineTransform> m_supplementalTransform;
+ };
+
+} // 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..d9c5f13
--- /dev/null
+++ b/WebCore/svg/SVGTextPathElement.cpp
@@ -0,0 +1,107 @@
+/*
+ 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, SVGNames::startOffsetAttr, LengthModeOther)
+ , m_method(this, SVGNames::methodAttr, SVG_TEXTPATH_METHODTYPE_ALIGN)
+ , m_spacing(this, SVGNames::spacingAttr, SVG_TEXTPATH_SPACINGTYPE_EXACT)
+{
+}
+
+SVGTextPathElement::~SVGTextPathElement()
+{
+}
+
+void SVGTextPathElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const String& value = attr->value();
+
+ if (attr->name() == SVGNames::startOffsetAttr)
+ setStartOffsetBaseValue(SVGLength(LengthModeOther, value));
+ else if (attr->name() == SVGNames::methodAttr) {
+ if (value == "align")
+ setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_ALIGN);
+ else if(value == "stretch")
+ setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_STRETCH);
+ } else if (attr->name() == SVGNames::spacingAttr) {
+ if (value == "auto")
+ setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_AUTO);
+ else if (value == "exact")
+ setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_EXACT);
+ } else {
+ if (SVGURIReference::parseMappedAttribute(attr))
+ return;
+ SVGTextContentElement::parseMappedAttribute(attr);
+ }
+}
+
+RenderObject* SVGTextPathElement::createRenderer(RenderArena* arena, RenderStyle* style)
+{
+ return new (arena) RenderSVGTextPath(this);
+}
+
+bool SVGTextPathElement::childShouldCreateRenderer(Node* child) const
+{
+ if (child->isTextNode()
+#if ENABLE(SVG_FONTS)
+ || child->hasTagName(SVGNames::altGlyphTag)
+#endif
+ || 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..e1dd938
--- /dev/null
+++ b/WebCore/svg/SVGTextPathElement.h
@@ -0,0 +1,81 @@
+/*
+ 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_DECLARATIONS(SVGTextPathElement, SVGNames::textPathTagString, SVGNames::startOffsetAttrString, SVGLength, StartOffset, startOffset)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPathElement, SVGNames::textPathTagString, SVGNames::methodAttrString, int, Method, method)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPathElement, SVGNames::textPathTagString, SVGNames::spacingAttrString, int, Spacing, spacing)
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif
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..e9ceaa1
--- /dev/null
+++ b/WebCore/svg/SVGTextPositioningElement.cpp
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2007, 2008 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 {
+
+char SVGTextPositioningElementIdentifier[] = "SVGTextPositioningElement";
+
+SVGTextPositioningElement::SVGTextPositioningElement(const QualifiedName& tagName, Document* doc)
+ : SVGTextContentElement(tagName, doc)
+ , m_x(this, SVGNames::xAttr, SVGLengthList::create(SVGNames::xAttr))
+ , m_y(this, SVGNames::yAttr, SVGLengthList::create(SVGNames::yAttr))
+ , m_dx(this, SVGNames::dxAttr, SVGLengthList::create(SVGNames::dxAttr))
+ , m_dy(this, SVGNames::dyAttr, SVGLengthList::create(SVGNames::dyAttr))
+ , m_rotate(this, SVGNames::rotateAttr, SVGNumberList::create(SVGNames::rotateAttr))
+{
+}
+
+SVGTextPositioningElement::~SVGTextPositioningElement()
+{
+}
+
+void SVGTextPositioningElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::xAttr)
+ xBaseValue()->parse(attr->value(), LengthModeWidth);
+ else if (attr->name() == SVGNames::yAttr)
+ yBaseValue()->parse(attr->value(), LengthModeHeight);
+ else if (attr->name() == SVGNames::dxAttr)
+ dxBaseValue()->parse(attr->value(), LengthModeWidth);
+ else if (attr->name() == SVGNames::dyAttr)
+ dyBaseValue()->parse(attr->value(), LengthModeHeight);
+ else if (attr->name() == SVGNames::rotateAttr)
+ rotateBaseValue()->parse(attr->value());
+ else
+ SVGTextContentElement::parseMappedAttribute(attr);
+}
+
+bool SVGTextPositioningElement::isKnownAttribute(const QualifiedName& attrName)
+{
+ return (attrName.matches(SVGNames::xAttr) ||
+ attrName.matches(SVGNames::yAttr) ||
+ attrName.matches(SVGNames::dxAttr) ||
+ attrName.matches(SVGNames::dyAttr) ||
+ attrName.matches(SVGNames::rotateAttr) ||
+ SVGTextContentElement::isKnownAttribute(attrName));
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGTextPositioningElement.h b/WebCore/svg/SVGTextPositioningElement.h
new file mode 100644
index 0000000..3e01dab
--- /dev/null
+++ b/WebCore/svg/SVGTextPositioningElement.h
@@ -0,0 +1,55 @@
+/*
+ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ 2004, 2005, 2006, 2008 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"
+#include "SVGLengthList.h"
+#include "SVGNumberList.h"
+
+namespace WebCore {
+
+ extern char SVGTextPositioningElementIdentifier[];
+
+ class SVGTextPositioningElement : public SVGTextContentElement {
+ public:
+ SVGTextPositioningElement(const QualifiedName&, Document*);
+ virtual ~SVGTextPositioningElement();
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+ bool isKnownAttribute(const QualifiedName&);
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPositioningElement, SVGTextPositioningElementIdentifier, SVGNames::xAttrString, SVGLengthList, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPositioningElement, SVGTextPositioningElementIdentifier, SVGNames::yAttrString, SVGLengthList, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPositioningElement, SVGTextPositioningElementIdentifier, SVGNames::dxAttrString, SVGLengthList, Dx, dx)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPositioningElement, SVGTextPositioningElementIdentifier, SVGNames::dyAttrString, SVGLengthList, Dy, dy)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGTextPositioningElement, SVGTextPositioningElementIdentifier, SVGNames::rotateAttrString, 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/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..86477e4
--- /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(AffineTransform matrix) //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..c3c150c
--- /dev/null
+++ b/WebCore/svg/SVGTransform.h
@@ -0,0 +1,99 @@
+/*
+ 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 SVGTransform_h
+#define SVGTransform_h
+
+#if ENABLE(SVG)
+#include "AffineTransform.h"
+#include "FloatPoint.h"
+#include "SVGNames.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 setMatrix(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();
+
+ // Throughout SVG 1.1 'SVGTransform' is only used for the 'transform' attribute
+ const QualifiedName& associatedAttributeName() const { return SVGNames::transformAttr; }
+
+ 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..59c24a5
--- /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 = toSVGTransform.scale().width() - fromSVGTransform.scale().width();
+ float scaleY = toSVGTransform.scale().height() - fromSVGTransform.scale().height();
+ 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..9800922
--- /dev/null
+++ b/WebCore/svg/SVGTransformList.cpp
@@ -0,0 +1,97 @@
+/*
+ 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());
+}
+
+String SVGTransformList::valueAsString() const
+{
+ // TODO: We may want to build a real transform string, instead of concatting to a matrix(...).
+ SVGTransform transform = concatenate();
+ if (transform.type() == SVGTransform::SVG_TRANSFORM_MATRIX) {
+ AffineTransform matrix = transform.matrix();
+ return String::format("matrix(%f %f %f %f %f %f)", matrix.a(), matrix.b(), matrix.c(), matrix.d(), matrix.e(), matrix.f());
+ }
+
+ return String();
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGTransformList.h b/WebCore/svg/SVGTransformList.h
new file mode 100644
index 0000000..a405c58
--- /dev/null
+++ b/WebCore/svg/SVGTransformList.h
@@ -0,0 +1,56 @@
+/*
+ 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 String;
+
+ 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;
+
+ String valueAsString() 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..de806a3
--- /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"
+#include "SVGTransformList.h"
+
+namespace WebCore {
+
+ class AffineTransform;
+ class AtomicString;
+ class SVGTransform;
+ 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..d18e49a
--- /dev/null
+++ b/WebCore/svg/SVGURIReference.cpp
@@ -0,0 +1,70 @@
+/*
+ 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"
+
+namespace WebCore {
+
+char SVGURIReferenceIdentifier[] = "SVGURIReference";
+
+SVGURIReference::SVGURIReference()
+ : m_href(this, XLinkNames::hrefAttr)
+{
+}
+
+SVGURIReference::~SVGURIReference()
+{
+}
+
+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..35ac640
--- /dev/null
+++ b/WebCore/svg/SVGURIReference.h
@@ -0,0 +1,54 @@
+/*
+ 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"
+#include "XLinkNames.h"
+
+namespace WebCore {
+
+ extern char SVGURIReferenceIdentifier[];
+ class MappedAttribute;
+
+ class SVGURIReference {
+ public:
+ SVGURIReference();
+ virtual ~SVGURIReference();
+
+ bool parseMappedAttribute(MappedAttribute*);
+ bool isKnownAttribute(const QualifiedName&);
+
+ static String getTarget(const String& url);
+
+ virtual const SVGElement* contextElement() const = 0;
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGURIReference, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, 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..83ad559
--- /dev/null
+++ b/WebCore/svg/SVGUseElement.cpp
@@ -0,0 +1,879 @@
+/*
+ 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 "EventListener.h"
+#include "HTMLNames.h"
+#include "NodeRenderStyle.h"
+#include "RegisteredEventListener.h"
+#include "RenderSVGTransformableContainer.h"
+#include "SVGElementInstance.h"
+#include "SVGElementInstanceList.h"
+#include "SVGGElement.h"
+#include "SVGLength.h"
+#include "SVGPreserveAspectRatio.h"
+#include "SVGSMILElement.h"
+#include "SVGSVGElement.h"
+#include "SVGSymbolElement.h"
+#include "XLinkNames.h"
+#include "XMLSerializer.h"
+
+namespace WebCore {
+
+SVGUseElement::SVGUseElement(const QualifiedName& tagName, Document* doc)
+ : SVGStyledTransformableElement(tagName, doc)
+ , SVGTests()
+ , SVGLangSpace()
+ , SVGExternalResourcesRequired()
+ , SVGURIReference()
+ , m_x(this, SVGNames::xAttr, LengthModeWidth)
+ , m_y(this, SVGNames::yAttr, LengthModeHeight)
+ , m_width(this, SVGNames::widthAttr, LengthModeWidth)
+ , m_height(this, SVGNames::heightAttr, LengthModeHeight)
+{
+}
+
+SVGUseElement::~SVGUseElement()
+{
+}
+
+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(LengthModeWidth, attr->value()));
+ else if (attr->name() == SVGNames::yAttr)
+ setYBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ else if (attr->name() == SVGNames::widthAttr) {
+ setWidthBaseValue(SVGLength(LengthModeWidth, attr->value()));
+ if (widthBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for use attribute <width> is not allowed");
+ } else if (attr->name() == SVGNames::heightAttr) {
+ setHeightBaseValue(SVGLength(LengthModeHeight, attr->value()));
+ if (heightBaseValue().value(this) < 0.0)
+ document()->accessSVGExtensions()->reportError("A negative value for use attribute <height> is not allowed");
+ } else {
+ if (SVGTests::parseMappedAttribute(attr))
+ return;
+ if (SVGLangSpace::parseMappedAttribute(attr))
+ return;
+ if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+ return;
+ if (SVGURIReference::parseMappedAttribute(attr))
+ return;
+ SVGStyledTransformableElement::parseMappedAttribute(attr);
+ }
+}
+
+void SVGUseElement::insertedIntoDocument()
+{
+ SVGElement::insertedIntoDocument();
+ buildPendingResource();
+}
+
+void SVGUseElement::removedFromDocument()
+{
+ m_targetElementInstance = 0;
+ m_shadowTreeRootElement = 0;
+ SVGElement::removedFromDocument();
+}
+
+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)) {
+ 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();
+}
+
+static bool shadowTreeContainsChangedNodes(SVGElementInstance* target)
+{
+ if (target->needsUpdate())
+ return true;
+
+ for (SVGElementInstance* instance = target->firstChild(); instance; instance = instance->nextSibling())
+ if (shadowTreeContainsChangedNodes(instance))
+ return true;
+
+ return false;
+}
+
+void SVGUseElement::recalcStyle(StyleChange change)
+{
+ if (attached() && changed() && shadowTreeContainsChangedNodes(m_targetElementInstance.get())) {
+ buildPendingResource();
+
+ if (m_shadowTreeRootElement)
+ m_shadowTreeRootElement->setChanged();
+ }
+
+ 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()) {
+ RefPtr<RenderStyle> newStyle = document()->styleSelector()->styleForElement(m_shadowTreeRootElement.get());
+ StyleChange ch = Node::diff(m_shadowTreeRootElement->renderStyle(), newStyle.get());
+ 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);
+ return;
+ }
+ }
+
+ // 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 this=%p, (parentNode=%s, firstChild=%s, correspondingElement=%s (%p), shadowTreeElement=%p, id=%s)\n",
+ targetInstance, parentNodeName.latin1().data(), firstChildNodeName.latin1().data(), elementNodeName.latin1().data(),
+ element, targetInstance->shadowTreeElement(), elementId.latin1().data());
+
+ for (unsigned int i = 0; i < depth; ++i)
+ text += " ";
+
+ HashSet<SVGElementInstance*> elementInstances = element->instancesForElement();
+ text += String::format("Corresponding element is associated with %i instance(s):\n", elementInstances.size());
+
+ HashSet<SVGElementInstance*>::iterator end = elementInstances.end();
+ for (HashSet<SVGElementInstance*>::iterator it = elementInstances.begin(); it != end; ++it) {
+ for (unsigned int i = 0; i < depth; ++i)
+ text += " ";
+
+ text += String::format(" -> SVGElementInstance this=%p, (refCount: %i, shadowTreeElement in document? %i)\n",
+ *it, (*it)->refCount(), (*it)->shadowTreeElement()->inDocument());
+ }
+
+ ++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
+#if ENABLE(SVG_ANIMATION)
+ if (SVGSMILElement::isSMILElement(element))
+ 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);
+
+ if (m_targetElementInstance) {
+ m_targetElementInstance->forgetWrapper();
+ m_targetElementInstance = 0;
+ }
+
+ // Do not allow self-referencing.
+ // 'target' may be null, if it's a non SVG namespaced element.
+ if (!target || target == this) {
+ 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(this) != 0.0 || y().value(this) != 0.0) {
+ String transformString = String::format("translate(%f, %f)", x().value(this), y().value(this));
+ 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;
+
+ PassRefPtr<XMLSerializer> serializer = XMLSerializer::create();
+
+ 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
+
+ // Transfer event listeners assigned to the referenced element to our shadow tree elements.
+ transferEventListenersToShadowTree(m_targetElementInstance.get());
+
+ // 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);
+ targetInstance->appendChild(instancePtr);
+
+ // 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(static_cast<SVGUseElement*>(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(static_cast<SVGUseElement*>(target), targetInstance, foundProblem);
+}
+
+void SVGUseElement::handleDeepUseReferencing(SVGUseElement* 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(this));
+ String heightString = String::number(height().value(this));
+
+ if (hasAttribute(SVGNames::widthAttr))
+ target->setAttribute(SVGNames::widthAttr, widthString);
+
+ if (hasAttribute(SVGNames::heightAttr))
+ target->setAttribute(SVGNames::heightAttr, heightString);
+}
+
+void SVGUseElement::removeDisallowedElementsFromSubtree(Node* subtree)
+{
+ ASSERT(!subtree->inDocument());
+ ExceptionCode ec;
+ Node* node = subtree->firstChild();
+ while (node) {
+ if (isDisallowedElement(node)) {
+ Node* next = node->traverseNextSibling(subtree);
+ // The subtree is not in document so this won't generate events that could mutate the tree.
+ node->parent()->removeChild(node, ec);
+ node = next;
+ } else
+ node = node->traverseNextNode(subtree);
+ }
+}
+
+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(this) != 0.0 || use->y().value(this) != 0.0) {
+ if (!cloneParent->hasAttribute(SVGNames::transformAttr)) {
+ String transformString = String::format("translate(%f, %f)", use->x().value(this), use->y().value(this));
+ cloneParent->setAttribute(SVGNames::transformAttr, transformString);
+ } else {
+ String transformString = String::format(" translate(%f, %f)", use->x().value(this), use->y().value(this));
+ 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()->setAttributes(*element->attributes());
+
+ // Explicitly re-set width/height values
+ String widthString = String::number(width().value(this));
+ String heightString = String::number(height().value(this));
+
+ 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())) {
+ RefPtr<RenderStyle> style = m_shadowTreeRootElement->styleForRenderer();
+
+ if (m_shadowTreeRootElement->rendererIsNeeded(style.get())) {
+ m_shadowTreeRootElement->setRenderer(m_shadowTreeRootElement->createRenderer(document()->renderArena(), style.get()));
+ if (RenderObject* shadowRenderer = m_shadowTreeRootElement->renderer()) {
+ shadowRenderer->setStyle(style.release());
+ renderer()->addChild(shadowRenderer, m_shadowTreeRootElement->nextRenderer());
+ m_shadowTreeRootElement->setAttached();
+ }
+ }
+
+ // 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::transferEventListenersToShadowTree(SVGElementInstance* target)
+{
+ if (!target)
+ return;
+
+ SVGElement* originalElement = target->correspondingElement();
+ ASSERT(originalElement);
+
+ if (SVGElement* shadowTreeElement = target->shadowTreeElement()) {
+ if (RegisteredEventListenerList* localEventListeners = originalElement->localEventListeners()) {
+ RegisteredEventListenerList::Iterator end = localEventListeners->end();
+ for (RegisteredEventListenerList::Iterator it = localEventListeners->begin(); it != end; ++it) {
+ EventListener* listener = (*it)->listener();
+ ASSERT(listener);
+
+ // Event listeners created from markup have already been transfered to the shadow tree during cloning!
+ if (listener->wasCreatedFromMarkup())
+ continue;
+
+ shadowTreeElement->addEventListener((*it)->eventType(), listener, (*it)->useCapture());
+ }
+ }
+ }
+
+ for (SVGElementInstance* instance = target->firstChild(); instance; instance = instance->nextSibling())
+ transferEventListenersToShadowTree(instance);
+}
+
+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>
+#if ENABLE(SVG) && ENABLE(SVG_USE) && ENABLE(SVG_FOREIGN_OBJECT)
+ ASSERT(target->nodeName() == SVGNames::svgTag);
+#endif
+ } 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()->setAttributes(*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..1e5b81c
--- /dev/null
+++ b/WebCore/svg/SVGUseElement.h
@@ -0,0 +1,112 @@
+/*
+ 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;
+
+ static void removeDisallowedElementsFromSubtree(Node* element);
+ SVGElementInstance* instanceForShadowTreeElement(Node* element) const;
+
+ protected:
+ virtual const SVGElement* contextElement() const { return this; }
+
+ private:
+ ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGNames::useTagString, SVGNames::xAttrString, SVGLength, X, x)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGNames::useTagString, SVGNames::yAttrString, SVGLength, Y, y)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGNames::useTagString, SVGNames::widthAttrString, SVGLength, Width, width)
+ ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGNames::useTagString, SVGNames::heightAttrString, SVGLength, Height, height)
+
+ private:
+ // Instance tree handling
+ void buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstance, bool& foundCycle);
+ void handleDeepUseReferencing(SVGUseElement* use, SVGElementInstance* targetInstance, bool& foundCycle);
+
+ // Shadow tree handling
+ PassRefPtr<SVGSVGElement> buildShadowTreeForSymbolTag(SVGElement* target, SVGElementInstance* targetInstance);
+ void alterShadowTreeForSVGTag(SVGElement* target);
+
+ 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;
+ void transferEventListenersToShadowTree(SVGElementInstance* target);
+
+ 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..840dea9
--- /dev/null
+++ b/WebCore/svg/SVGViewElement.h
@@ -0,0 +1,59 @@
+/*
+ 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;
+ };
+
+} // 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..6aa3857
--- /dev/null
+++ b/WebCore/svg/SVGViewSpec.cpp
@@ -0,0 +1,179 @@
+/*
+ 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 "Document.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..8624089
--- /dev/null
+++ b/WebCore/svg/SVGViewSpec.h
@@ -0,0 +1,67 @@
+/*
+ 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;
+
+ 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..a16f131
--- /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 library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; 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:
+ static PassRefPtr<SVGZoomEvent> create() { return adoptRef(new 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:
+ SVGZoomEvent();
+
+ 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..8327bef
--- /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 [Immutable] SVGRect zoomRectScreen;
+ readonly attribute float previousScale;
+ readonly attribute [Immutable] SVGPoint previousTranslate;
+ readonly attribute float newScale;
+ readonly attribute [Immutable] SVGPoint newTranslate;
+ };
+
+}
diff --git a/WebCore/svg/SynchronizableTypeWrapper.h b/WebCore/svg/SynchronizableTypeWrapper.h
new file mode 100644
index 0000000..418c76d
--- /dev/null
+++ b/WebCore/svg/SynchronizableTypeWrapper.h
@@ -0,0 +1,180 @@
+/*
+ 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 SynchronizableTypeWrapper_h
+#define SynchronizableTypeWrapper_h
+
+#if ENABLE(SVG)
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+ template<typename StoredType>
+ class SynchronizableTypeWrapperBase : Noncopyable {
+ protected:
+ SynchronizableTypeWrapperBase();
+
+ template<typename AssignableType>
+ void assign(AssignableType type);
+
+ bool needsSynchronization() const;
+ void setSynchronized();
+
+ protected:
+ StoredType m_value;
+ bool m_needsSynchronization;
+ };
+
+ template<typename StoredType>
+ class SynchronizableTypeWrapper : private SynchronizableTypeWrapperBase<StoredType> {
+ public:
+ typedef SynchronizableTypeWrapperBase<StoredType> Base;
+ SynchronizableTypeWrapper();
+
+ // "Forwarding constructors" for primitive type assignment with more than one argument, for exampe SVGLength
+ template<typename T1> SynchronizableTypeWrapper(const T1&);
+ template<typename T1, typename T2> SynchronizableTypeWrapper(const T1&, const T2&);
+ template<typename T1, typename T2, typename T3> SynchronizableTypeWrapper(const T1&, const T2&, const T3&);
+
+ SynchronizableTypeWrapper& operator=(const StoredType&);
+ operator StoredType() const;
+
+ using Base::needsSynchronization;
+ using Base::setSynchronized;
+
+ private:
+ using Base::m_value;
+ };
+
+ template<typename StoredPointerType>
+ class SynchronizableTypeWrapper<RefPtr<StoredPointerType> > : private SynchronizableTypeWrapperBase<RefPtr<StoredPointerType> > {
+ public:
+ typedef SynchronizableTypeWrapperBase<RefPtr<StoredPointerType> > Base;
+ SynchronizableTypeWrapper();
+ SynchronizableTypeWrapper(const PassRefPtr<StoredPointerType>&);
+
+ SynchronizableTypeWrapper& operator=(StoredPointerType*);
+ operator StoredPointerType*() const;
+
+ using Base::needsSynchronization;
+ using Base::setSynchronized;
+
+ private:
+ using Base::m_value;
+ };
+
+ // SynchronizableTypeWrapperBase implementation
+ template<typename StoredType>
+ inline SynchronizableTypeWrapperBase<StoredType>::SynchronizableTypeWrapperBase()
+ : m_value()
+ , m_needsSynchronization(false)
+ {
+ }
+
+ template<typename StoredType> template<typename AssignableType>
+ inline void SynchronizableTypeWrapperBase<StoredType>::assign(AssignableType type)
+ {
+ m_value = type;
+ m_needsSynchronization = true;
+ }
+
+ template<typename StoredType>
+ inline bool SynchronizableTypeWrapperBase<StoredType>::needsSynchronization() const
+ {
+ return m_needsSynchronization;
+ }
+
+ template<typename StoredType>
+ inline void SynchronizableTypeWrapperBase<StoredType>::setSynchronized()
+ {
+ m_needsSynchronization = false;
+ }
+
+ // SynchronizableTypeWrapper implementation for primitive types
+ template<typename StoredType>
+ inline SynchronizableTypeWrapper<StoredType>::SynchronizableTypeWrapper()
+ : Base()
+ {
+ }
+
+ template<typename StoredType> template<typename T1>
+ inline SynchronizableTypeWrapper<StoredType>::SynchronizableTypeWrapper(const T1& arg1)
+ : Base()
+ {
+ m_value = StoredType(arg1);
+ }
+
+ template<typename StoredType> template<typename T1, typename T2>
+ inline SynchronizableTypeWrapper<StoredType>::SynchronizableTypeWrapper(const T1& arg1, const T2& arg2)
+ : Base()
+ {
+ m_value = StoredType(arg1, arg2);
+ }
+
+ template<typename StoredType> template<typename T1, typename T2, typename T3>
+ inline SynchronizableTypeWrapper<StoredType>::SynchronizableTypeWrapper(const T1& arg1, const T2& arg2, const T3& arg3)
+ : Base()
+ {
+ m_value = StoredType(arg1, arg2, arg3);
+ }
+
+ template<typename StoredType>
+ inline SynchronizableTypeWrapper<StoredType>& SynchronizableTypeWrapper<StoredType>::operator=(const StoredType& other)
+ {
+ Base::assign(other);
+ return (*this);
+ }
+
+ template<typename StoredType>
+ inline SynchronizableTypeWrapper<StoredType>::operator StoredType() const
+ {
+ return m_value;
+ }
+
+ // SynchronizableTypeWrapper implementation for refcounted types
+ template<typename StoredPointerType>
+ inline SynchronizableTypeWrapper<RefPtr<StoredPointerType> >::SynchronizableTypeWrapper()
+ : Base()
+ {
+ }
+
+ template<typename StoredPointerType>
+ inline SynchronizableTypeWrapper<RefPtr<StoredPointerType> >::SynchronizableTypeWrapper(const PassRefPtr<StoredPointerType>& type)
+ : Base()
+ {
+ Base::m_value = type;
+ }
+
+ template<typename StoredPointerType>
+ inline SynchronizableTypeWrapper<RefPtr<StoredPointerType> >& SynchronizableTypeWrapper<RefPtr<StoredPointerType> >::operator=(StoredPointerType* other)
+ {
+ Base::assign(other);
+ return (*this);
+ }
+
+ template<typename StoredPointerType>
+ inline SynchronizableTypeWrapper<RefPtr<StoredPointerType> >::operator StoredPointerType*() const
+ {
+ return Base::m_value.get();
+ }
+
+};
+
+#endif
+#endif
diff --git a/WebCore/svg/animation/SMILTime.cpp b/WebCore/svg/animation/SMILTime.cpp
new file mode 100644
index 0000000..70f9487
--- /dev/null
+++ b/WebCore/svg/animation/SMILTime.cpp
@@ -0,0 +1,64 @@
+/*
+ * 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 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 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 "SMILTime.h"
+
+#include <float.h>
+
+using namespace WebCore;
+
+const double SMILTime::unresolvedValue = DBL_MAX;
+// Just a big value smaller than DBL_MAX. Our times are relative to 0, we don't really need the full range.
+const double SMILTime::indefiniteValue = FLT_MAX;
+
+SMILTime WebCore::operator+(const SMILTime& a, const SMILTime& b) {
+ if (a.isUnresolved() || b.isUnresolved())
+ return SMILTime::unresolved();
+ if (a.isIndefinite() || b.isIndefinite())
+ return SMILTime::indefinite();
+ return a.value() + b.value();
+}
+
+SMILTime WebCore::operator-(const SMILTime& a, const SMILTime& b) {
+ if (a.isUnresolved() || b.isUnresolved())
+ return SMILTime::unresolved();
+ if (a.isIndefinite() || b.isIndefinite())
+ return SMILTime::indefinite();
+ return a.value() - b.value();
+}
+
+SMILTime WebCore::operator*(const SMILTime& a, const SMILTime& b) {
+ if (a.isUnresolved() || b.isUnresolved())
+ return SMILTime::unresolved();
+ if (a.value() == 0 || b.value() == 0)
+ return SMILTime(0);
+ if (a.isIndefinite() || b.isIndefinite())
+ return SMILTime::indefinite();
+ return a.value() * b.value();
+}
+#endif
+
diff --git a/WebCore/svg/animation/SMILTime.h b/WebCore/svg/animation/SMILTime.h
new file mode 100644
index 0000000..5196030
--- /dev/null
+++ b/WebCore/svg/animation/SMILTime.h
@@ -0,0 +1,74 @@
+/*
+ * 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 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 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 SMILTime_h
+#define SMILTime_h
+
+#if ENABLE(SVG)
+
+#include <algorithm>
+
+namespace WebCore {
+
+ class SMILTime {
+ public:
+ SMILTime() : m_time(0) { }
+ SMILTime(double time) : m_time(time) { }
+ SMILTime(const SMILTime& o) : m_time(o.m_time) { }
+
+ static SMILTime unresolved() { return unresolvedValue; }
+ static SMILTime indefinite() { return indefiniteValue; }
+
+ SMILTime& operator=(const SMILTime& o) { m_time = o.m_time; return *this; }
+ double value() const { return m_time; }
+
+ bool isFinite() const { return m_time < indefiniteValue; }
+ bool isIndefinite() const { return m_time == indefiniteValue; }
+ bool isUnresolved() const { return m_time == unresolvedValue; }
+
+ private:
+ static const double unresolvedValue;
+ static const double indefiniteValue;
+
+ double m_time;
+ };
+
+ inline bool operator==(const SMILTime& a, const SMILTime& b) { return a.isFinite() && a.value() == b.value(); }
+ inline bool operator!=(const SMILTime& a, const SMILTime& b) { return !operator==(a, b); }
+ inline bool operator>(const SMILTime& a, const SMILTime& b) { return a.value() > b.value(); }
+ inline bool operator<(const SMILTime& a, const SMILTime& b) { return a.value() < b.value(); }
+ inline bool operator>=(const SMILTime& a, const SMILTime& b) { return a.value() > b.value() || operator==(a, b); }
+ inline bool operator<=(const SMILTime& a, const SMILTime& b) { return a.value() < b.value() || operator==(a, b); }
+
+ inline SMILTime max(const SMILTime& a, const SMILTime& b) { return std::max(a.value(), b.value()); }
+ inline SMILTime min(const SMILTime& a, const SMILTime& b) { return std::min(a.value(), b.value()); }
+ SMILTime operator+(const SMILTime&, const SMILTime&);
+ SMILTime operator-(const SMILTime&, const SMILTime&);
+ // So multiplying times does not make too much sense but SMIL defines it for duration * repeatCount
+ SMILTime operator*(const SMILTime&, const SMILTime&);
+}
+
+#endif
+#endif
diff --git a/WebCore/svg/animation/SMILTimeContainer.cpp b/WebCore/svg/animation/SMILTimeContainer.cpp
new file mode 100644
index 0000000..0e809fb
--- /dev/null
+++ b/WebCore/svg/animation/SMILTimeContainer.cpp
@@ -0,0 +1,286 @@
+/*
+ * 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 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 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"
+#include "SMILTimeContainer.h"
+
+#if ENABLE(SVG)
+
+#include "CSSComputedStyleDeclaration.h"
+#include "CSSParser.h"
+#include "Document.h"
+#include "SVGAnimationElement.h"
+#include "SVGSMILElement.h"
+#include "SVGSVGElement.h"
+#include "SystemTime.h"
+
+using namespace std;
+
+namespace WebCore {
+
+static const double animationFrameDelay = 0.025;
+
+SMILTimeContainer::SMILTimeContainer(SVGSVGElement* owner)
+ : m_beginTime(0)
+ , m_pauseTime(0)
+ , m_accumulatedPauseTime(0)
+ , m_documentOrderIndexesDirty(false)
+ , m_timer(this, &SMILTimeContainer::timerFired)
+ , m_ownerSVGElement(owner)
+{
+}
+
+#if !ENABLE(SVG_ANIMATION)
+void SMILTimeContainer::begin() {}
+void SMILTimeContainer::pause() {}
+void SMILTimeContainer::resume() {}
+SMILTime SMILTimeContainer::elapsed() const { return 0; }
+bool SMILTimeContainer::isPaused() const { return false; }
+void SMILTimeContainer::timerFired(Timer<SMILTimeContainer>*) {}
+#else
+
+void SMILTimeContainer::schedule(SVGSMILElement* animation)
+{
+ ASSERT(animation->timeContainer() == this);
+ SMILTime nextFireTime = animation->nextProgressTime();
+ if (!nextFireTime.isFinite())
+ return;
+ m_scheduledAnimations.add(animation);
+ startTimer(0);
+}
+
+void SMILTimeContainer::unschedule(SVGSMILElement* animation)
+{
+ ASSERT(animation->timeContainer() == this);
+
+ m_scheduledAnimations.remove(animation);
+}
+
+SMILTime SMILTimeContainer::elapsed() const
+{
+ if (!m_beginTime)
+ return 0;
+ return currentTime() - m_beginTime - m_accumulatedPauseTime;
+}
+
+bool SMILTimeContainer::isActive() const
+{
+ return m_beginTime && !isPaused();
+}
+
+bool SMILTimeContainer::isPaused() const
+{
+ return m_pauseTime;
+}
+
+void SMILTimeContainer::begin()
+{
+ ASSERT(!m_beginTime);
+ m_beginTime = currentTime();
+ updateAnimations(0);
+}
+
+void SMILTimeContainer::pause()
+{
+ if (!m_beginTime)
+ return;
+ ASSERT(!isPaused());
+ m_pauseTime = currentTime();
+ m_timer.stop();
+}
+
+void SMILTimeContainer::resume()
+{
+ if (!m_beginTime)
+ return;
+ ASSERT(isPaused());
+ m_accumulatedPauseTime += currentTime() - m_pauseTime;
+ m_pauseTime = 0;
+ startTimer(0);
+}
+
+void SMILTimeContainer::startTimer(SMILTime fireTime, SMILTime minimumDelay)
+{
+ if (!m_beginTime || isPaused())
+ return;
+
+ if (!fireTime.isFinite())
+ return;
+
+ SMILTime delay = max(fireTime - elapsed(), minimumDelay);
+ m_timer.startOneShot(delay.value());
+}
+
+void SMILTimeContainer::timerFired(Timer<SMILTimeContainer>*)
+{
+ ASSERT(m_beginTime);
+ ASSERT(!m_pauseTime);
+ SMILTime elapsed = this->elapsed();
+ updateAnimations(elapsed);
+}
+
+void SMILTimeContainer::updateDocumentOrderIndexes()
+{
+ unsigned timingElementCount = 0;
+ for (Node* node = m_ownerSVGElement; node; node = node->traverseNextNode(m_ownerSVGElement)) {
+ if (SVGSMILElement::isSMILElement(node))
+ static_cast<SVGSMILElement*>(node)->setDocumentOrderIndex(timingElementCount++);
+ }
+ m_documentOrderIndexesDirty = false;
+}
+
+struct PriorityCompare {
+ PriorityCompare(SMILTime elapsed) : m_elapsed(elapsed) {}
+ bool operator()(SVGSMILElement* a, SVGSMILElement* b)
+ {
+ // FIXME: This should also consider possible timing relations between the elements.
+ SMILTime aBegin = a->intervalBegin();
+ SMILTime bBegin = b->intervalBegin();
+ // Frozen elements need to be prioritized based on their previous interval.
+ aBegin = a->isFrozen() && m_elapsed < aBegin ? a->previousIntervalBegin() : aBegin;
+ bBegin = b->isFrozen() && m_elapsed < bBegin ? b->previousIntervalBegin() : bBegin;
+ if (aBegin == bBegin)
+ return a->documentOrderIndex() < b->documentOrderIndex();
+ return aBegin < bBegin;
+ }
+ SMILTime m_elapsed;
+};
+
+void SMILTimeContainer::sortByPriority(Vector<SVGSMILElement*>& smilElements, SMILTime elapsed)
+{
+ if (m_documentOrderIndexesDirty)
+ updateDocumentOrderIndexes();
+ std::sort(smilElements.begin(), smilElements.end(), PriorityCompare(elapsed));
+}
+
+static bool applyOrderSortFunction(SVGSMILElement* a, SVGSMILElement* b)
+{
+ if (!a->hasTagName(SVGNames::animateTransformTag) && b->hasTagName(SVGNames::animateTransformTag))
+ return true;
+ return false;
+}
+
+static void sortByApplyOrder(Vector<SVGSMILElement*>& smilElements)
+{
+ std::sort(smilElements.begin(), smilElements.end(), applyOrderSortFunction);
+}
+
+String SMILTimeContainer::baseValueFor(ElementAttributePair key)
+{
+ // FIXME: We wouldn't need to do this if we were keeping base values around properly in DOM.
+ // Currently animation overwrites them so we need to save them somewhere.
+ BaseValueMap::iterator it = m_savedBaseValues.find(key);
+ if (it != m_savedBaseValues.end())
+ return it->second;
+
+ SVGElement* target = key.first;
+ String attributeName = key.second;
+ ASSERT(target);
+ ASSERT(!attributeName.isEmpty());
+ String baseValue;
+ if (SVGAnimationElement::attributeIsCSS(attributeName))
+ baseValue = computedStyle(target)->getPropertyValue(cssPropertyID(attributeName));
+ else
+ baseValue = target->getAttribute(attributeName);
+ m_savedBaseValues.add(key, baseValue);
+ return baseValue;
+}
+
+void SMILTimeContainer::updateAnimations(SMILTime elapsed)
+{
+ SMILTime earliersFireTime = SMILTime::unresolved();
+
+ Vector<SVGSMILElement*> toAnimate;
+ copyToVector(m_scheduledAnimations, toAnimate);
+
+ // Sort according to priority. Elements with later begin time have higher priority.
+ // In case of a tie, document order decides.
+ // FIXME: This should also consider timing relationships between the elements. Dependents
+ // have higher priority.
+ sortByPriority(toAnimate, elapsed);
+
+ // Calculate animation contributions.
+ typedef HashMap<ElementAttributePair, SVGSMILElement*> ResultElementMap;
+ ResultElementMap resultsElements;
+ for (unsigned n = 0; n < toAnimate.size(); ++n) {
+ SVGSMILElement* animation = toAnimate[n];
+ ASSERT(animation->timeContainer() == this);
+
+ SVGElement* targetElement = animation->targetElement();
+ if (!targetElement)
+ continue;
+ String attributeName = animation->attributeName();
+ if (attributeName.isEmpty()) {
+ if (animation->hasTagName(SVGNames::animateMotionTag))
+ attributeName = SVGNames::animateMotionTag.localName();
+ else
+ continue;
+ }
+
+ // Results are accumulated to the first animation that animates a particular element/attribute pair.
+ ElementAttributePair key(targetElement, attributeName);
+ SVGSMILElement* resultElement = resultsElements.get(key);
+ if (!resultElement) {
+ resultElement = animation;
+ resultElement->resetToBaseValue(baseValueFor(key));
+ resultsElements.add(key, resultElement);
+ }
+
+ // This will calculate the contribution from the animation and add it to the resultsElement.
+ animation->progress(elapsed, resultElement);
+
+ SMILTime nextFireTime = animation->nextProgressTime();
+ if (nextFireTime.isFinite())
+ earliersFireTime = min(nextFireTime, earliersFireTime);
+ else if (!animation->isContributing(elapsed)) {
+ m_scheduledAnimations.remove(animation);
+ if (m_scheduledAnimations.isEmpty())
+ m_savedBaseValues.clear();
+ }
+ }
+
+ Vector<SVGSMILElement*> animationsToApply;
+ ResultElementMap::iterator end = resultsElements.end();
+ for (ResultElementMap::iterator it = resultsElements.begin(); it != end; ++it)
+ animationsToApply.append(it->second);
+
+ // Sort <animateTranform> to be the last one to be applied. <animate> may change transform attribute as
+ // well (directly or indirectly by modifying <use> x/y) and this way transforms combine properly.
+ sortByApplyOrder(animationsToApply);
+
+ // Apply results to target elements.
+ for (unsigned n = 0; n < animationsToApply.size(); ++n)
+ animationsToApply[n]->applyResultsToTarget();
+
+ startTimer(earliersFireTime, animationFrameDelay);
+
+ Document::updateDocumentsRendering();
+}
+
+#endif
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/animation/SMILTimeContainer.h b/WebCore/svg/animation/SMILTimeContainer.h
new file mode 100644
index 0000000..5cef507
--- /dev/null
+++ b/WebCore/svg/animation/SMILTimeContainer.h
@@ -0,0 +1,95 @@
+/*
+ * 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 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 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 SMILTimeContainer_H
+#define SMILTimeContainer_H
+
+#if ENABLE(SVG)
+
+#include "PlatformString.h"
+#include "SMILTime.h"
+#include "StringHash.h"
+#include "Timer.h"
+#include <wtf/HashSet.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class SVGElement;
+ class SVGSMILElement;
+ class SVGSVGElement;
+
+ class SMILTimeContainer : public RefCounted<SMILTimeContainer> {
+ public:
+ static PassRefPtr<SMILTimeContainer> create(SVGSVGElement* owner) { return adoptRef(new SMILTimeContainer(owner)); }
+
+ void schedule(SVGSMILElement*);
+ void unschedule(SVGSMILElement*);
+
+ SMILTime elapsed() const;
+
+ bool isActive() const;
+ bool isPaused() const;
+
+ void begin();
+ void pause();
+ void resume();
+
+ void setDocumentOrderIndexesDirty() { m_documentOrderIndexesDirty = true; }
+
+ private:
+ SMILTimeContainer(SVGSVGElement* owner);
+
+ void timerFired(Timer<SMILTimeContainer>*);
+ void startTimer(SMILTime fireTime, SMILTime minimumDelay = 0);
+ void updateAnimations(SMILTime elapsed);
+
+ void updateDocumentOrderIndexes();
+ void sortByPriority(Vector<SVGSMILElement*>& smilElements, SMILTime elapsed);
+
+ typedef pair<SVGElement*, String> ElementAttributePair;
+ String baseValueFor(ElementAttributePair);
+
+ double m_beginTime;
+ double m_pauseTime;
+ double m_accumulatedPauseTime;
+
+ bool m_documentOrderIndexesDirty;
+
+ Timer<SMILTimeContainer> m_timer;
+
+ typedef HashSet<SVGSMILElement*> TimingElementSet;
+ TimingElementSet m_scheduledAnimations;
+
+ typedef HashMap<ElementAttributePair, String> BaseValueMap;
+ BaseValueMap m_savedBaseValues;
+
+ SVGSVGElement* m_ownerSVGElement;
+ };
+}
+
+#endif
+#endif
diff --git a/WebCore/svg/animation/SVGSMILElement.cpp b/WebCore/svg/animation/SVGSMILElement.cpp
new file mode 100644
index 0000000..a07a407
--- /dev/null
+++ b/WebCore/svg/animation/SVGSMILElement.cpp
@@ -0,0 +1,929 @@
+/*
+ * 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 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 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_ANIMATION)
+#include "SVGSMILElement.h"
+
+#include "CSSPropertyNames.h"
+#include "Document.h"
+#include "Event.h"
+#include "EventListener.h"
+#include "FloatConversion.h"
+#include "FrameView.h"
+#include "HTMLNames.h"
+#include "SVGNames.h"
+#include "SVGParserUtilities.h"
+#include "SVGSVGElement.h"
+#include "SVGURIReference.h"
+#include "SMILTimeContainer.h"
+#include "XLinkNames.h"
+#include <math.h>
+#include <wtf/MathExtras.h>
+#include <wtf/Vector.h>
+
+using namespace std;
+
+namespace WebCore {
+
+// This is used for duration type time values that can't be negative.
+static const double invalidCachedTime = -1.;
+
+class ConditionEventListener : public EventListener {
+public:
+ static PassRefPtr<ConditionEventListener> create(SVGSMILElement* animation, Element* eventBase, SVGSMILElement::Condition* condition)
+ {
+ return adoptRef(new ConditionEventListener(animation, eventBase, condition));
+ }
+
+ void unregister()
+ {
+ // If this has only one ref then the event base is dead already and we don't need to remove ourself.
+ if (!hasOneRef())
+ m_eventBase->removeEventListener(m_condition->m_name, this, false);
+ }
+
+ virtual void handleEvent(Event* event, bool isWindowEvent)
+ {
+ m_animation->handleConditionEvent(event, m_condition);
+ }
+
+private:
+ ConditionEventListener(SVGSMILElement* animation, Element* eventBase, SVGSMILElement::Condition* condition)
+ : m_animation(animation)
+ , m_condition(condition)
+ , m_eventBase(eventBase)
+ {
+ m_eventBase->addEventListener(m_condition->m_name, this, false);
+ }
+
+ SVGSMILElement* m_animation;
+ SVGSMILElement::Condition* m_condition;
+ Element* m_eventBase;
+};
+
+SVGSMILElement::Condition::Condition(Type type, BeginOrEnd beginOrEnd, const String& baseID, const String& name, SMILTime offset, int repeats)
+ : m_type(type)
+ , m_beginOrEnd(beginOrEnd)
+ , m_baseID(baseID)
+ , m_name(name)
+ , m_offset(offset)
+ , m_repeats(repeats)
+{
+}
+
+SVGSMILElement::SVGSMILElement(const QualifiedName& tagName, Document* doc)
+ : SVGElement(tagName, doc)
+ , m_conditionsConnected(false)
+ , m_hasEndEventConditions(false)
+ , m_intervalBegin(SMILTime::unresolved())
+ , m_intervalEnd(SMILTime::unresolved())
+ , m_previousIntervalBegin(SMILTime::unresolved())
+ , m_isWaitingForFirstInterval(true)
+ , m_activeState(Inactive)
+ , m_lastPercent(0)
+ , m_lastRepeat(0)
+ , m_nextProgressTime(0)
+ , m_documentOrderIndex(0)
+ , m_cachedDur(invalidCachedTime)
+ , m_cachedRepeatDur(invalidCachedTime)
+ , m_cachedRepeatCount(invalidCachedTime)
+ , m_cachedMin(invalidCachedTime)
+ , m_cachedMax(invalidCachedTime)
+{
+}
+
+SVGSMILElement::~SVGSMILElement()
+{
+ disconnectConditions();
+ if (m_timeContainer)
+ m_timeContainer->unschedule(this);
+}
+
+void SVGSMILElement::insertedIntoDocument()
+{
+ SVGElement::insertedIntoDocument();
+#ifndef NDEBUG
+ // Verify we are not in <use> instance tree.
+ for (Node* n = this; n; n = n->parent())
+ ASSERT(!n->isShadowNode());
+#endif
+ SVGSVGElement* owner = ownerSVGElement();
+ if (!owner)
+ return;
+ m_timeContainer = owner->timeContainer();
+ ASSERT(m_timeContainer);
+ m_timeContainer->setDocumentOrderIndexesDirty();
+ reschedule();
+}
+
+void SVGSMILElement::removedFromDocument()
+{
+ if (m_timeContainer) {
+ m_timeContainer->unschedule(this);
+ m_timeContainer = 0;
+ }
+ // Calling disconnectConditions() may kill us if there are syncbase conditions.
+ // OK, but we don't want to die inside the call.
+ RefPtr<SVGSMILElement> keepAlive(this);
+ disconnectConditions();
+ SVGElement::removedFromDocument();
+}
+
+void SVGSMILElement::finishParsingChildren()
+{
+ SVGElement::finishParsingChildren();
+
+ // "If no attribute is present, the default begin value (an offset-value of 0) must be evaluated."
+ if (!hasAttribute(SVGNames::beginAttr))
+ m_beginTimes.append(0);
+
+ if (m_isWaitingForFirstInterval) {
+ resolveFirstInterval();
+ reschedule();
+ }
+}
+
+SMILTime SVGSMILElement::parseOffsetValue(const String& data)
+{
+ bool ok;
+ double result = 0;
+ String parse = data.stripWhiteSpace();
+ if (parse.endsWith("h"))
+ result = parse.left(parse.length() - 1).toDouble(&ok) * 60 * 60;
+ else if (parse.endsWith("min"))
+ result = parse.left(parse.length() - 3).toDouble(&ok) * 60;
+ else if (parse.endsWith("ms"))
+ result = parse.left(parse.length() - 2).toDouble(&ok) / 1000;
+ else if (parse.endsWith("s"))
+ result = parse.left(parse.length() - 1).toDouble(&ok);
+ else
+ result = parse.toDouble(&ok);
+ if (!ok)
+ return SMILTime::unresolved();
+ return result;
+}
+
+SMILTime SVGSMILElement::parseClockValue(const String& data)
+{
+ if (data.isNull())
+ return SMILTime::unresolved();
+
+ String parse = data.stripWhiteSpace();
+
+ static const AtomicString indefiniteValue("indefinite");
+ if (parse == indefiniteValue)
+ return SMILTime::indefinite();
+
+ double result = 0;
+ bool ok;
+ int doublePointOne = parse.find(':');
+ int doublePointTwo = parse.find(':', doublePointOne + 1);
+ if (doublePointOne == 2 && doublePointTwo == 5 && parse.length() >= 8) {
+ result += parse.substring(0, 2).toUIntStrict(&ok) * 60 * 60;
+ if (!ok)
+ return SMILTime::unresolved();
+ result += parse.substring(3, 2).toUIntStrict(&ok) * 60;
+ if (!ok)
+ return SMILTime::unresolved();
+ result += parse.substring(6).toDouble(&ok);
+ } else if (doublePointOne == 2 && doublePointTwo == -1 && parse.length() >= 5) {
+ result += parse.substring(0, 2).toUIntStrict(&ok) * 60;
+ if (!ok)
+ return SMILTime::unresolved();
+ result += parse.substring(3).toDouble(&ok);
+ } else
+ return parseOffsetValue(parse);
+
+ if (!ok)
+ return SMILTime::unresolved();
+ return result;
+}
+
+static void sortTimeList(Vector<SMILTime>& timeList)
+{
+ std::sort(timeList.begin(), timeList.end());
+}
+
+bool SVGSMILElement::parseCondition(const String& value, BeginOrEnd beginOrEnd)
+{
+ String parseString = value.stripWhiteSpace();
+
+ double sign = 1.;
+ bool ok;
+ int pos = parseString.find('+');
+ if (pos == -1) {
+ pos = parseString.find('-');
+ if (pos != -1)
+ sign = -1.;
+ }
+ String conditionString;
+ SMILTime offset = 0;
+ if (pos == -1)
+ conditionString = parseString;
+ else {
+ conditionString = parseString.left(pos).stripWhiteSpace();
+ String offsetString = parseString.substring(pos + 1).stripWhiteSpace();
+ offset = parseOffsetValue(offsetString);
+ if (offset.isUnresolved())
+ return false;
+ offset = offset * sign;
+ }
+ if (conditionString.isEmpty())
+ return false;
+ pos = conditionString.find('.');
+
+ String baseID;
+ String nameString;
+ if (pos == -1)
+ nameString = conditionString;
+ else {
+ baseID = conditionString.left(pos);
+ nameString = conditionString.substring(pos + 1);
+ }
+ if (nameString.isEmpty())
+ return false;
+
+ Condition::Type type;
+ int repeats = -1;
+ if (nameString.startsWith("repeat(") && nameString.endsWith(")")) {
+ // FIXME: For repeat events we just need to add the data carrying TimeEvent class and
+ // fire the events at appropiate times.
+ repeats = nameString.substring(7, nameString.length() - 8).toUIntStrict(&ok);
+ if (!ok)
+ return false;
+ nameString = "repeat";
+ type = Condition::EventBase;
+ } else if (nameString == "begin" || nameString == "end") {
+ if (baseID.isEmpty())
+ return false;
+ type = Condition::Syncbase;
+ } else if (nameString.startsWith("accesskey(")) {
+ // FIXME: accesskey() support.
+ type = Condition::AccessKey;
+ } else
+ type = Condition::EventBase;
+
+ m_conditions.append(Condition(type, beginOrEnd, baseID, nameString, offset, repeats));
+
+ if (type == Condition::EventBase && beginOrEnd == End)
+ m_hasEndEventConditions = true;
+
+ return true;
+}
+
+bool SVGSMILElement::isSMILElement(Node* node)
+{
+ if (!node)
+ return false;
+ return node->hasTagName(SVGNames::setTag) || node->hasTagName(SVGNames::animateTag) || node->hasTagName(SVGNames::animateMotionTag)
+ || node->hasTagName(SVGNames::animateTransformTag) || node->hasTagName(SVGNames::animateColorTag);
+}
+
+void SVGSMILElement::parseBeginOrEnd(const String& parseString, BeginOrEnd beginOrEnd)
+{
+ Vector<SMILTime>& timeList = beginOrEnd == Begin ? m_beginTimes : m_endTimes;
+ if (beginOrEnd == End)
+ m_hasEndEventConditions = false;
+ HashSet<double> existing;
+ for (unsigned n = 0; n < timeList.size(); ++n)
+ existing.add(timeList[n].value());
+ Vector<String> splitString;
+ parseString.split(';', splitString);
+ for (unsigned n = 0; n < splitString.size(); ++n) {
+ SMILTime value = parseClockValue(splitString[n]);
+ if (value.isUnresolved())
+ parseCondition(splitString[n], beginOrEnd);
+ else if (!existing.contains(value.value()))
+ timeList.append(value);
+ }
+ sortTimeList(timeList);
+}
+
+void SVGSMILElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == SVGNames::beginAttr) {
+ if (!m_conditions.isEmpty()) {
+ disconnectConditions();
+ m_conditions.clear();
+ parseBeginOrEnd(getAttribute(SVGNames::endAttr), End);
+ }
+ parseBeginOrEnd(attr->value().string(), Begin);
+ if (inDocument())
+ connectConditions();
+ } else if (attr->name() == SVGNames::endAttr) {
+ if (!m_conditions.isEmpty()) {
+ disconnectConditions();
+ m_conditions.clear();
+ parseBeginOrEnd(getAttribute(SVGNames::beginAttr), Begin);
+ }
+ parseBeginOrEnd(attr->value().string(), End);
+ if (inDocument())
+ connectConditions();
+ } else
+ SVGElement::parseMappedAttribute(attr);
+}
+
+void SVGSMILElement::attributeChanged(Attribute* attr, bool preserveDecls)
+{
+ SVGElement::attributeChanged(attr, preserveDecls);
+
+ const QualifiedName& attrName = attr->name();
+ if (attrName == SVGNames::durAttr)
+ m_cachedDur = invalidCachedTime;
+ else if (attrName == SVGNames::repeatDurAttr)
+ m_cachedRepeatDur = invalidCachedTime;
+ else if (attrName == SVGNames::repeatCountAttr)
+ m_cachedRepeatCount = invalidCachedTime;
+ else if (attrName == SVGNames::minAttr)
+ m_cachedMin = invalidCachedTime;
+ else if (attrName == SVGNames::maxAttr)
+ m_cachedMax = invalidCachedTime;
+
+ if (inDocument()) {
+ if (attrName == SVGNames::beginAttr)
+ beginListChanged();
+ else if (attrName == SVGNames::endAttr)
+ endListChanged();
+ }
+}
+
+void SVGSMILElement::connectConditions()
+{
+ if (m_conditionsConnected)
+ disconnectConditions();
+ m_conditionsConnected = true;
+ for (unsigned n = 0; n < m_conditions.size(); ++n) {
+ Condition& condition = m_conditions[n];
+ if (condition.m_type == Condition::EventBase) {
+ ASSERT(!condition.m_syncbase);
+ Element* eventBase = condition.m_baseID.isEmpty() ? targetElement() : document()->getElementById(condition.m_baseID);
+ if (!eventBase)
+ continue;
+ ASSERT(!condition.m_eventListener);
+ condition.m_eventListener = ConditionEventListener::create(this, eventBase, &condition);
+ } else if (condition.m_type == Condition::Syncbase) {
+ ASSERT(!condition.m_baseID.isEmpty());
+ condition.m_syncbase = document()->getElementById(condition.m_baseID);
+ if (!isSMILElement(condition.m_syncbase.get())) {
+ condition.m_syncbase = 0;
+ continue;
+ }
+ SVGSMILElement* syncbase = static_cast<SVGSMILElement*>(condition.m_syncbase.get());
+ syncbase->addTimeDependent(this);
+ }
+ }
+}
+
+void SVGSMILElement::disconnectConditions()
+{
+ if (!m_conditionsConnected)
+ return;
+ m_conditionsConnected = false;
+ for (unsigned n = 0; n < m_conditions.size(); ++n) {
+ Condition& condition = m_conditions[n];
+ if (condition.m_type == Condition::EventBase) {
+ ASSERT(!condition.m_syncbase);
+ if (condition.m_eventListener) {
+ condition.m_eventListener->unregister();
+ condition.m_eventListener = 0;
+ }
+ } else if (condition.m_type == Condition::Syncbase) {
+ if (condition.m_syncbase) {
+ ASSERT(isSMILElement(condition.m_syncbase.get()));
+ static_cast<SVGSMILElement*>(condition.m_syncbase.get())->removeTimeDependent(this);
+ }
+ }
+ condition.m_syncbase = 0;
+ }
+}
+
+void SVGSMILElement::reschedule()
+{
+ if (m_timeContainer)
+ m_timeContainer->schedule(this);
+}
+
+SVGElement* SVGSMILElement::targetElement() const
+{
+ String href = xlinkHref();
+ Node* target = href.isEmpty() ? parentNode() : document()->getElementById(SVGURIReference::getTarget(href));
+ if (target && target->isSVGElement())
+ return static_cast<SVGElement*>(target);
+ return 0;
+}
+
+String SVGSMILElement::attributeName() const
+{
+ return getAttribute(SVGNames::attributeNameAttr).string().stripWhiteSpace();
+}
+
+SMILTime SVGSMILElement::elapsed() const
+{
+ return m_timeContainer ? m_timeContainer->elapsed() : 0;
+}
+
+bool SVGSMILElement::isInactive() const
+{
+ return m_activeState == Inactive;
+}
+
+bool SVGSMILElement::isFrozen() const
+{
+ return m_activeState == Frozen;
+}
+
+SVGSMILElement::Restart SVGSMILElement::restart() const
+{
+ static const AtomicString never("never");
+ static const AtomicString whenNotActive("whenNotActive");
+ const AtomicString& value = getAttribute(SVGNames::restartAttr);
+ if (value == never)
+ return RestartNever;
+ if (value == whenNotActive)
+ return RestartWhenNotActive;
+ return RestartAlways;
+}
+
+SVGSMILElement::FillMode SVGSMILElement::fill() const
+{
+ static const AtomicString freeze("freeze");
+ const AtomicString& value = getAttribute(SVGNames::fillAttr);
+ return value == freeze ? FillFreeze : FillRemove;
+}
+
+String SVGSMILElement::xlinkHref() const
+{
+ return getAttribute(XLinkNames::hrefAttr);
+}
+
+SMILTime SVGSMILElement::dur() const
+{
+ if (m_cachedDur != invalidCachedTime)
+ return m_cachedDur;
+ const AtomicString& value = getAttribute(SVGNames::durAttr);
+ SMILTime clockValue = parseClockValue(value);
+ return m_cachedDur = clockValue <= 0 ? SMILTime::unresolved() : clockValue;
+}
+
+SMILTime SVGSMILElement::repeatDur() const
+{
+ if (m_cachedRepeatDur != invalidCachedTime)
+ return m_cachedRepeatDur;
+ const AtomicString& value = getAttribute(SVGNames::repeatDurAttr);
+ SMILTime clockValue = parseClockValue(value);
+ return m_cachedRepeatDur = clockValue < 0 ? SMILTime::unresolved() : clockValue;
+}
+
+// So a count is not really a time but let just all pretend we did not notice.
+SMILTime SVGSMILElement::repeatCount() const
+{
+ if (m_cachedRepeatCount != invalidCachedTime)
+ return m_cachedRepeatCount;
+ const AtomicString& value = getAttribute(SVGNames::repeatCountAttr);
+ if (value.isNull())
+ return SMILTime::unresolved();
+
+ static const AtomicString indefiniteValue("indefinite");
+ if (value == indefiniteValue)
+ return SMILTime::indefinite();
+ bool ok;
+ double result = value.string().toDouble(&ok);
+ return m_cachedRepeatCount = ok && result > 0 ? result : SMILTime::unresolved();
+}
+
+SMILTime SVGSMILElement::maxValue() const
+{
+ if (m_cachedMax != invalidCachedTime)
+ return m_cachedMax;
+ const AtomicString& value = getAttribute(SVGNames::maxAttr);
+ SMILTime result = parseClockValue(value);
+ return m_cachedMax = (result.isUnresolved() || result < 0) ? SMILTime::indefinite() : result;
+}
+
+SMILTime SVGSMILElement::minValue() const
+{
+ if (m_cachedMin != invalidCachedTime)
+ return m_cachedMin;
+ const AtomicString& value = getAttribute(SVGNames::minAttr);
+ SMILTime result = parseClockValue(value);
+ return m_cachedMin = (result.isUnresolved() || result < 0) ? 0 : result;
+}
+
+SMILTime SVGSMILElement::simpleDuration() const
+{
+ return min(dur(), SMILTime::indefinite());
+}
+
+void SVGSMILElement::addBeginTime(SMILTime time)
+{
+ m_beginTimes.append(time);
+ sortTimeList(m_beginTimes);
+ beginListChanged();
+}
+
+void SVGSMILElement::addEndTime(SMILTime time)
+{
+ m_endTimes.append(time);
+ sortTimeList(m_endTimes);
+ endListChanged();
+}
+
+SMILTime SVGSMILElement::findInstanceTime(BeginOrEnd beginOrEnd, SMILTime minimumTime, bool equalsMinimumOK) const
+{
+ // FIXME: This searches from the beginning which is inefficient. The list is usually not long
+ // (one entry in common cases) but you can construct a case where it does grow.
+ const Vector<SMILTime>& list = beginOrEnd == Begin ? m_beginTimes : m_endTimes;
+ for (unsigned n = 0; n < list.size(); ++n) {
+ SMILTime time = list[n];
+ ASSERT(!time.isUnresolved());
+ if (time.isIndefinite() && beginOrEnd == Begin) {
+ // "The special value "indefinite" does not yield an instance time in the begin list."
+ continue;
+ }
+ if (equalsMinimumOK) {
+ if (time >= minimumTime)
+ return time;
+ } else if (time > minimumTime)
+ return time;
+ }
+ return SMILTime::unresolved();
+}
+
+SMILTime SVGSMILElement::repeatingDuration() const
+{
+ // Computing the active duration
+ // http://www.w3.org/TR/SMIL2/smil-timing.html#Timing-ComputingActiveDur
+ SMILTime repeatCount = this->repeatCount();
+ SMILTime repeatDur = this->repeatDur();
+ SMILTime simpleDuration = this->simpleDuration();
+ if (simpleDuration == 0 || (repeatDur.isUnresolved() && repeatCount.isUnresolved()))
+ return simpleDuration;
+ SMILTime repeatCountDuration = simpleDuration * repeatCount;
+ return min(repeatCountDuration, min(repeatDur, SMILTime::indefinite()));
+}
+
+SMILTime SVGSMILElement::resolveActiveEnd(SMILTime resolvedBegin, SMILTime resolvedEnd) const
+{
+ // Computing the active duration
+ // http://www.w3.org/TR/SMIL2/smil-timing.html#Timing-ComputingActiveDur
+ SMILTime preliminaryActiveDuration;
+ if (!resolvedEnd.isUnresolved() && dur().isUnresolved() && repeatDur().isUnresolved() && repeatCount().isUnresolved())
+ preliminaryActiveDuration = resolvedEnd - resolvedBegin;
+ else if (!resolvedEnd.isFinite())
+ preliminaryActiveDuration = repeatingDuration();
+ else
+ preliminaryActiveDuration = min(repeatingDuration(), resolvedEnd - resolvedBegin);
+
+ SMILTime minValue = this->minValue();
+ SMILTime maxValue = this->maxValue();
+ if (minValue > maxValue) {
+ // Ignore both.
+ // http://www.w3.org/TR/2001/REC-smil-animation-20010904/#MinMax
+ minValue = 0;
+ maxValue = SMILTime::indefinite();
+ }
+ return resolvedBegin + min(maxValue, max(minValue, preliminaryActiveDuration));
+}
+
+void SVGSMILElement::resolveInterval(bool first, SMILTime& beginResult, SMILTime& endResult) const
+{
+ // See the pseudocode in
+ // http://www.w3.org/TR/2001/REC-smil-animation-20010904/#Timing-BeginEnd-LifeCycle
+ SMILTime beginAfter = first ? -numeric_limits<double>::infinity() : m_intervalEnd;
+ SMILTime lastIntervalTempEnd = numeric_limits<double>::infinity();
+ while (true) {
+ SMILTime tempBegin = findInstanceTime(Begin, beginAfter, true);
+ if (tempBegin.isUnresolved())
+ break;
+ SMILTime tempEnd;
+ if (m_endTimes.isEmpty())
+ tempEnd = resolveActiveEnd(tempBegin, SMILTime::indefinite());
+ else {
+ tempEnd = findInstanceTime(End, tempBegin, true);
+ if ((first && tempBegin == tempEnd && tempEnd == lastIntervalTempEnd) || (!first && tempEnd == m_intervalEnd))
+ tempEnd = findInstanceTime(End, tempBegin, false);
+ if (tempEnd.isUnresolved()) {
+ if (!m_endTimes.isEmpty() && !m_hasEndEventConditions)
+ break;
+ }
+ tempEnd = resolveActiveEnd(tempBegin, tempEnd);
+ }
+ if (tempEnd > 0 || !first) {
+ beginResult = tempBegin;
+ endResult = tempEnd;
+ return;
+ } else if (restart() == RestartNever)
+ break;
+ else
+ beginAfter = tempEnd;
+ lastIntervalTempEnd = tempEnd;
+ }
+ beginResult = SMILTime::unresolved();
+ endResult = SMILTime::unresolved();
+}
+
+void SVGSMILElement::resolveFirstInterval()
+{
+ SMILTime begin;
+ SMILTime end;
+ resolveInterval(true, begin, end);
+ ASSERT(!begin.isIndefinite());
+
+ if (!begin.isUnresolved() && (begin != m_intervalBegin || end != m_intervalEnd)) {
+ bool wasUnresolved = m_intervalBegin.isUnresolved();
+ m_intervalBegin = begin;
+ m_intervalEnd = end;
+ notifyDependentsIntervalChanged(wasUnresolved ? NewInterval : ExistingInterval);
+ m_nextProgressTime = min(m_nextProgressTime, m_intervalBegin);
+ reschedule();
+ }
+}
+
+void SVGSMILElement::resolveNextInterval()
+{
+ SMILTime begin;
+ SMILTime end;
+ resolveInterval(false, begin, end);
+ ASSERT(!begin.isIndefinite());
+
+ if (!begin.isUnresolved() && begin != m_intervalBegin) {
+ m_intervalBegin = begin;
+ m_intervalEnd = end;
+ notifyDependentsIntervalChanged(NewInterval);
+ m_nextProgressTime = min(m_nextProgressTime, m_intervalBegin);
+ }
+}
+
+SMILTime SVGSMILElement::nextProgressTime() const
+{
+ return m_nextProgressTime;
+}
+
+void SVGSMILElement::beginListChanged()
+{
+ SMILTime elapsed = this->elapsed();
+ if (m_isWaitingForFirstInterval)
+ resolveFirstInterval();
+ else if (elapsed < m_intervalBegin) {
+ SMILTime newBegin = findInstanceTime(Begin, elapsed, false);
+ if (newBegin < m_intervalBegin) {
+ // Begin time changed, re-resolve the interval.
+ SMILTime oldBegin = m_intervalBegin;
+ m_intervalBegin = elapsed;
+ resolveInterval(false, m_intervalBegin, m_intervalEnd);
+ ASSERT(!m_intervalBegin.isUnresolved());
+ if (m_intervalBegin != oldBegin)
+ notifyDependentsIntervalChanged(ExistingInterval);
+ }
+ }
+ m_nextProgressTime = elapsed;
+ reschedule();
+}
+
+void SVGSMILElement::endListChanged()
+{
+ SMILTime elapsed = this->elapsed();
+ if (m_isWaitingForFirstInterval)
+ resolveFirstInterval();
+ else if (elapsed < m_intervalEnd && m_intervalBegin.isFinite()) {
+ SMILTime newEnd = findInstanceTime(End, m_intervalBegin, false);
+ if (newEnd < m_intervalEnd) {
+ newEnd = resolveActiveEnd(m_intervalBegin, newEnd);
+ if (newEnd != m_intervalEnd) {
+ m_intervalEnd = newEnd;
+ notifyDependentsIntervalChanged(ExistingInterval);
+ }
+ }
+ }
+ m_nextProgressTime = elapsed;
+ reschedule();
+}
+
+void SVGSMILElement::checkRestart(SMILTime elapsed)
+{
+ ASSERT(!m_isWaitingForFirstInterval);
+ ASSERT(elapsed >= m_intervalBegin);
+
+ Restart restart = this->restart();
+ if (restart == RestartNever)
+ return;
+
+ if (elapsed < m_intervalEnd) {
+ if (restart != RestartAlways)
+ return;
+ SMILTime nextBegin = findInstanceTime(Begin, m_intervalBegin, false);
+ if (nextBegin < m_intervalEnd) {
+ m_intervalEnd = nextBegin;
+ notifyDependentsIntervalChanged(ExistingInterval);
+ }
+ }
+ if (elapsed >= m_intervalEnd)
+ resolveNextInterval();
+}
+
+float SVGSMILElement::calculateAnimationPercentAndRepeat(SMILTime elapsed, unsigned& repeat) const
+{
+ SMILTime simpleDuration = this->simpleDuration();
+ repeat = 0;
+ if (simpleDuration.isIndefinite()) {
+ repeat = 0;
+ return 0.f;
+ }
+ if (simpleDuration == 0) {
+ repeat = 0;
+ return 1.f;
+ }
+ ASSERT(m_intervalBegin.isFinite());
+ ASSERT(simpleDuration.isFinite());
+ SMILTime activeTime = elapsed - m_intervalBegin;
+ SMILTime repeatingDuration = this->repeatingDuration();
+ if (elapsed >= m_intervalEnd || activeTime > repeatingDuration) {
+ repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuration.value());
+ if (fmod(repeatingDuration.value(), simpleDuration.value() == 0.))
+ repeat--;
+ return 1.f;
+ }
+ repeat = static_cast<unsigned>(activeTime.value() / simpleDuration.value());
+ SMILTime simpleTime = fmod(activeTime.value(), simpleDuration.value());
+ return narrowPrecisionToFloat(simpleTime.value() / simpleDuration.value());
+}
+
+SMILTime SVGSMILElement::calculateNextProgressTime(SMILTime elapsed) const
+{
+ if (m_activeState == Active) {
+ // If duration is indefinite the value does not actually change over time. Same is true for <set>.
+ SMILTime simpleDuration = this->simpleDuration();
+ if (simpleDuration.isIndefinite() || hasTagName(SVGNames::setTag)) {
+ SMILTime repeatCount = this->repeatCount();
+ SMILTime repeatingDurationEnd = m_intervalBegin + repeatingDuration();
+ // We are supposed to do freeze semantics when repeating ends, even if the element is still active.
+ // Take care that we get a timer callback at that point.
+ if (elapsed < repeatingDurationEnd && repeatingDurationEnd < m_intervalEnd && repeatingDurationEnd.isFinite())
+ return repeatingDurationEnd;
+ return m_intervalEnd;
+ }
+ return elapsed + 0.025;
+ }
+ return m_intervalBegin >= elapsed ? m_intervalBegin : SMILTime::unresolved();
+}
+
+SVGSMILElement::ActiveState SVGSMILElement::determineActiveState(SMILTime elapsed) const
+{
+ if (elapsed >= m_intervalBegin && elapsed < m_intervalEnd)
+ return Active;
+
+ if (m_activeState == Active)
+ return fill() == FillFreeze ? Frozen : Inactive;
+
+ return m_activeState;
+}
+
+bool SVGSMILElement::isContributing(SMILTime elapsed) const
+{
+ // Animation does not contribute during the active time if it is past its repeating duration and has fill=remove.
+ return (m_activeState == Active && (fill() == FillFreeze || elapsed <= m_intervalBegin + repeatingDuration())) || m_activeState == Frozen;
+}
+
+void SVGSMILElement::progress(SMILTime elapsed, SVGSMILElement* resultElement)
+{
+ ASSERT(m_timeContainer);
+ ASSERT(m_isWaitingForFirstInterval || m_intervalBegin.isFinite());
+
+ if (!m_conditionsConnected)
+ connectConditions();
+
+ if (!m_intervalBegin.isFinite()) {
+ ASSERT(m_activeState == Inactive);
+ m_nextProgressTime = SMILTime::unresolved();
+ return;
+ }
+
+ if (elapsed < m_intervalBegin) {
+ ASSERT(m_activeState != Active);
+ if (m_activeState == Frozen && resultElement)
+ updateAnimation(m_lastPercent, m_lastRepeat, resultElement);
+ m_nextProgressTime = m_intervalBegin;
+ return;
+ }
+
+ m_previousIntervalBegin = m_intervalBegin;
+
+ if (m_activeState == Inactive) {
+ m_isWaitingForFirstInterval = false;
+ m_activeState = Active;
+ startedActiveInterval();
+ }
+
+ unsigned repeat;
+ float percent = calculateAnimationPercentAndRepeat(elapsed, repeat);
+
+ checkRestart(elapsed);
+
+ ActiveState oldActiveState = m_activeState;
+ m_activeState = determineActiveState(elapsed);
+
+ if (isContributing(elapsed)) {
+ if (resultElement)
+ updateAnimation(percent, repeat, resultElement);
+ m_lastPercent = percent;
+ m_lastRepeat = repeat;
+ }
+
+ if (oldActiveState == Active && m_activeState != Active)
+ endedActiveInterval();
+
+ m_nextProgressTime = calculateNextProgressTime(elapsed);
+}
+
+void SVGSMILElement::notifyDependentsIntervalChanged(NewOrExistingInterval newOrExisting)
+{
+ ASSERT(m_intervalBegin.isFinite());
+ static HashSet<SVGSMILElement*> loopBreaker;
+ if (loopBreaker.contains(this))
+ return;
+ loopBreaker.add(this);
+
+ TimeDependentSet::iterator end = m_timeDependents.end();
+ for (TimeDependentSet::iterator it = m_timeDependents.begin(); it != end; ++it) {
+ SVGSMILElement* dependent = *it;
+ dependent->createInstanceTimesFromSyncbase(this, newOrExisting);
+ }
+
+ loopBreaker.remove(this);
+}
+
+void SVGSMILElement::createInstanceTimesFromSyncbase(SVGSMILElement* syncbase, NewOrExistingInterval newOrExisting)
+{
+ // FIXME: To be really correct, this should handle updating exising interval by changing
+ // the associated times instead of creating new ones.
+ for (unsigned n = 0; n < m_conditions.size(); ++n) {
+ Condition& condition = m_conditions[n];
+ if (condition.m_type == Condition::Syncbase && condition.m_syncbase == syncbase) {
+ ASSERT(condition.m_name == "begin" || condition.m_name == "end");
+ // No nested time containers in SVG, no need for crazy time space conversions. Phew!
+ SMILTime time = 0;
+ if (condition.m_name == "begin")
+ time = syncbase->m_intervalBegin + condition.m_offset;
+ else
+ time = syncbase->m_intervalEnd + condition.m_offset;
+ ASSERT(time.isFinite());
+ if (condition.m_beginOrEnd == Begin)
+ addBeginTime(time);
+ else
+ addEndTime(time);
+ }
+ }
+}
+
+void SVGSMILElement::addTimeDependent(SVGSMILElement* animation)
+{
+ m_timeDependents.add(animation);
+ if (m_intervalBegin.isFinite())
+ animation->createInstanceTimesFromSyncbase(this, NewInterval);
+}
+
+void SVGSMILElement::removeTimeDependent(SVGSMILElement* animation)
+{
+ m_timeDependents.remove(animation);
+}
+
+void SVGSMILElement::handleConditionEvent(Event* event, Condition* condition)
+{
+ if (condition->m_beginOrEnd == Begin)
+ addBeginTime(elapsed() + condition->m_offset);
+ else
+ addEndTime(elapsed() + condition->m_offset);
+}
+
+void SVGSMILElement::beginByLinkActivation()
+{
+ addBeginTime(elapsed());
+}
+
+}
+
+#endif
+
diff --git a/WebCore/svg/animation/SVGSMILElement.h b/WebCore/svg/animation/SVGSMILElement.h
new file mode 100644
index 0000000..fac102e
--- /dev/null
+++ b/WebCore/svg/animation/SVGSMILElement.h
@@ -0,0 +1,197 @@
+/*
+ * 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 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 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 SVGSMILElement_h
+#define SVGSMILElement_h
+#if ENABLE(SVG_ANIMATION)
+
+#include "SVGElement.h"
+#include "SMILTime.h"
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+
+ class ConditionEventListener;
+ class SMILTimeContainer;
+
+ // This class implements SMIL interval timing model as needed for SVG animation.
+ class SVGSMILElement : public SVGElement
+ {
+ public:
+ SVGSMILElement(const QualifiedName&, Document*);
+ virtual ~SVGSMILElement();
+
+ static bool isSMILElement(Node* node);
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual void attributeChanged(Attribute*, bool preserveDecls);
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
+ virtual void finishParsingChildren();
+
+ SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); }
+
+ SVGElement* targetElement() const;
+ String attributeName() const;
+
+ void beginByLinkActivation();
+
+ enum Restart { RestartAlways, RestartWhenNotActive, RestartNever };
+ Restart restart() const;
+
+ enum FillMode { FillRemove, FillFreeze };
+ FillMode fill() const;
+
+ String xlinkHref() const;
+
+ SMILTime dur() const;
+ SMILTime repeatDur() const;
+ SMILTime repeatCount() const;
+ SMILTime maxValue() const;
+ SMILTime minValue() const;
+
+ SMILTime elapsed() const;
+
+ SMILTime intervalBegin() const { return m_intervalBegin; }
+ SMILTime intervalEnd() const { return m_intervalEnd; }
+ SMILTime previousIntervalBegin() const { return m_previousIntervalBegin; }
+ SMILTime simpleDuration() const;
+
+ void progress(SMILTime elapsed, SVGSMILElement* resultsElement);
+ SMILTime nextProgressTime() const;
+
+ static SMILTime parseClockValue(const String&);
+ static SMILTime parseOffsetValue(const String&);
+
+ bool isContributing(SMILTime elapsed) const;
+ bool isInactive() const;
+ bool isFrozen() const;
+
+ unsigned documentOrderIndex() const { return m_documentOrderIndex; }
+ void setDocumentOrderIndex(unsigned index) { m_documentOrderIndex = index; }
+
+ virtual bool isAdditive() const = 0;
+ virtual void resetToBaseValue(const String&) = 0;
+ virtual void applyResultsToTarget() = 0;
+
+protected:
+ void addBeginTime(SMILTime time);
+ void addEndTime(SMILTime time);
+
+private:
+ virtual void startedActiveInterval() = 0;
+ virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) = 0;
+ virtual void endedActiveInterval() = 0;
+
+ enum BeginOrEnd { Begin, End };
+ SMILTime findInstanceTime(BeginOrEnd beginOrEnd, SMILTime minimumTime, bool equalsMinimumOK) const;
+ void resolveFirstInterval();
+ void resolveNextInterval();
+ void resolveInterval(bool first, SMILTime& beginResult, SMILTime& endResult) const;
+ SMILTime resolveActiveEnd(SMILTime resolvedBegin, SMILTime resolvedEnd) const;
+ SMILTime repeatingDuration() const;
+ void checkRestart(SMILTime elapsed);
+ void beginListChanged();
+ void endListChanged();
+ void reschedule();
+
+ // This represents conditions on elements begin or end list that need to be resolved on runtime
+ // for example <animate begin="otherElement.begin + 8s; button.click" ... />
+ struct Condition {
+ enum Type { EventBase, Syncbase, AccessKey };
+ Condition(Type, BeginOrEnd beginOrEnd, const String& baseID, const String& name, SMILTime offset, int repeats = -1);
+ Type m_type;
+ BeginOrEnd m_beginOrEnd;
+ String m_baseID;
+ String m_name;
+ SMILTime m_offset;
+ int m_repeats;
+ RefPtr<Element> m_syncbase;
+ RefPtr<ConditionEventListener> m_eventListener;
+ };
+ bool parseCondition(const String&, BeginOrEnd beginOrEnd);
+ void parseBeginOrEnd(const String&, BeginOrEnd beginOrEnd);
+
+ void connectConditions();
+ void disconnectConditions();
+
+ // Event base timing
+ void handleConditionEvent(Event*, Condition*);
+
+ // Syncbase timing
+ enum NewOrExistingInterval { NewInterval, ExistingInterval };
+ void notifyDependentsIntervalChanged(NewOrExistingInterval);
+ void createInstanceTimesFromSyncbase(SVGSMILElement* syncbase, NewOrExistingInterval);
+ void addTimeDependent(SVGSMILElement*);
+ void removeTimeDependent(SVGSMILElement*);
+
+ enum ActiveState { Inactive, Active, Frozen };
+ ActiveState determineActiveState(SMILTime elapsed) const;
+ float calculateAnimationPercentAndRepeat(SMILTime elapsed, unsigned& repeat) const;
+ SMILTime calculateNextProgressTime(SMILTime elapsed) const;
+
+ Vector<Condition> m_conditions;
+ bool m_conditionsConnected;
+ bool m_hasEndEventConditions;
+
+ typedef HashSet<SVGSMILElement*> TimeDependentSet;
+ TimeDependentSet m_timeDependents;
+
+ // Instance time lists
+ Vector<SMILTime> m_beginTimes;
+ Vector<SMILTime> m_endTimes;
+
+ // This is the upcoming or current interval
+ SMILTime m_intervalBegin;
+ SMILTime m_intervalEnd;
+
+ SMILTime m_previousIntervalBegin;
+
+ bool m_isWaitingForFirstInterval;
+
+ ActiveState m_activeState;
+ float m_lastPercent;
+ unsigned m_lastRepeat;
+
+ SMILTime m_nextProgressTime;
+
+ RefPtr<SMILTimeContainer> m_timeContainer;
+ unsigned m_documentOrderIndex;
+
+ mutable SMILTime m_cachedDur;
+ mutable SMILTime m_cachedRepeatDur;
+ mutable SMILTime m_cachedRepeatCount;
+ mutable SMILTime m_cachedMin;
+ mutable SMILTime m_cachedMax;
+
+ friend class ConditionEventListener;
+ };
+
+}
+
+#endif
+#endif
+
diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp
new file mode 100644
index 0000000..4427277
--- /dev/null
+++ b/WebCore/svg/graphics/SVGImage.cpp
@@ -0,0 +1,221 @@
+/*
+ * 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 "FloatRect.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "ImageObserver.h"
+#include "NotImplemented.h"
+#include "Page.h"
+#include "RenderView.h"
+#include "ResourceError.h"
+#include "SVGDocument.h"
+#include "SVGLength.h"
+#include "SVGRenderSupport.h"
+#include "SVGSVGElement.h"
+#include "Settings.h"
+
+#include "EmptyClients.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;
+
+ if (!m_frame || !m_frame->document())
+ return;
+ SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement();
+ if (!rootElement)
+ return;
+
+ rootElement->setContainerSize(containerSize);
+}
+
+bool SVGImage::usesContainerSize() const
+{
+ if (!m_frame || !m_frame->document())
+ return false;
+ 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(rootElement)));
+
+ if (height.unitType() == LengthTypePercentage)
+ svgSize.setHeight(rootElement->relativeHeightValue());
+ else
+ svgSize.setHeight(static_cast<int>(height.value(rootElement)));
+
+ return svgSize;
+}
+
+bool SVGImage::hasRelativeWidth() const
+{
+ if (!m_frame || !m_frame->document())
+ return false;
+ SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement();
+ if (!rootElement)
+ return false;
+
+ return rootElement->width().unitType() == LengthTypePercentage;
+}
+
+bool SVGImage::hasRelativeHeight() const
+{
+ if (!m_frame || !m_frame->document())
+ return false;
+ 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->setCompositeOperation(compositeOp);
+ context->clip(enclosingIntRect(dstRect));
+ if (compositeOp != CompositeSourceOver)
+ context->beginTransparencyLayer(1.0f);
+ 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->view()->paint(context, enclosingIntRect(srcRect));
+
+ if (compositeOp != CompositeSourceOver)
+ context->endTransparencyLayer();
+
+ 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->contentRenderer());
+ }
+ return m_frameCache->image()->nativeImageForCurrentFrame();
+}
+
+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 EmptyChromeClient;
+ static FrameLoaderClient* dummyFrameLoaderClient = new EmptyFrameLoaderClient;
+ static EditorClient* dummyEditorClient = new EmptyEditorClient;
+ static ContextMenuClient* dummyContextMenuClient = new EmptyContextMenuClient;
+ static DragClient* dummyDragClient = new EmptyDragClient;
+ static InspectorClient* dummyInspectorClient = new EmptyInspectorClient;
+
+ // 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_page->settings()->setPluginsEnabled(false);
+
+ m_frame = Frame::create(m_page.get(), 0, dummyFrameLoaderClient);
+ m_frameView = new FrameView(m_frame.get());
+ m_frameView->deref(); // FIXME: FrameView starts with a refcount of 1
+ m_frame->setView(m_frameView.get());
+ m_frame->init();
+ 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();
+ m_frameView->setTransparent(true); // SVG Images are transparent.
+ }
+ 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..994cf91
--- /dev/null
+++ b/WebCore/svg/graphics/SVGImage.h
@@ -0,0 +1,84 @@
+/*
+ * 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:
+ static PassRefPtr<SVGImage> create(ImageObserver* observer)
+ {
+ return adoptRef(new SVGImage(observer));
+ }
+ ~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);
+
+ // FIXME: SVGImages are underreporting decoded sizes and will be unable
+ // to prune because these functions are not implemented yet.
+ virtual void destroyDecodedData(bool incremental = false, bool preserveNearbyFrames = false) { }
+ virtual unsigned decodedSize() const { return 0; }
+
+ virtual NativeImagePtr frameAtIndex(size_t) { return 0; }
+
+private:
+ SVGImage(ImageObserver*);
+ 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/SVGPaintServer.cpp b/WebCore/svg/graphics/SVGPaintServer.cpp
new file mode 100644
index 0000000..0240532
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServer.cpp
@@ -0,0 +1,183 @@
+/*
+ * 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 "GraphicsContext.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;
+}
+
+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());
+ if (style->svgStyle()->joinStyle() == MiterJoin)
+ context->setMiterLimit(style->svgStyle()->strokeMiterLimit());
+
+ const DashArray& dashes = dashArrayFromRenderingStyle(object->style());
+ float dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0f);
+ context->setLineDash(dashes, dashOffset);
+}
+
+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->itemWithoutBoundsCheck(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..0d37e9f
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServer.h
@@ -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.
+ */
+
+#ifndef SVGPaintServer_h
+#define SVGPaintServer_h
+
+#if ENABLE(SVG)
+
+#include "DashArray.h"
+#include "SVGResource.h"
+
+#if PLATFORM(CG)
+#include <ApplicationServices/ApplicationServices.h>
+#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
+
+ protected:
+ SVGPaintServer();
+ };
+
+ TextStream& operator<<(TextStream&, const SVGPaintServer&);
+
+ SVGPaintServer* getPaintServerById(Document*, const AtomicString&);
+
+ void applyStrokeStyleToContext(GraphicsContext*, RenderStyle*, const RenderObject*);
+ 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..58dd6bf
--- /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, GradientSpreadMethod m)
+{
+ switch (m) {
+ case SpreadMethodPad:
+ ts << "PAD"; break;
+ case SpreadMethodRepeat:
+ ts << "REPEAT"; break;
+ case SpreadMethodReflect:
+ 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(SpreadMethodPad)
+ , 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;
+}
+
+GradientSpreadMethod SVGPaintServerGradient::spreadMethod() const
+{
+ return m_spreadMethod;
+}
+
+void SVGPaintServerGradient::setGradientSpreadMethod(const GradientSpreadMethod& 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() != SpreadMethodPad)
+ 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..99dac8e
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServerGradient.h
@@ -0,0 +1,142 @@
+/*
+ * 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 "GraphicsContext.h"
+#include "SVGPaintServer.h"
+
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+#if PLATFORM(QT)
+#include <qglobal.h>
+QT_BEGIN_NAMESPACE
+class QGradient;
+QT_END_NAMESPACE
+#endif
+
+namespace WebCore {
+
+ class ImageBuffer;
+ class SVGGradientElement;
+
+#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>&);
+
+ GradientSpreadMethod spreadMethod() const;
+ void setGradientSpreadMethod(const GradientSpreadMethod&);
+
+ // 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;
+ GradientSpreadMethod 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..65b28e9
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServerPattern.h
@@ -0,0 +1,88 @@
+/*
+ * 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;
+
+ virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
+#if PLATFORM(CG) || PLATFORM(QT)
+ virtual void teardown(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..0166c87
--- /dev/null
+++ b/WebCore/svg/graphics/SVGPaintServerSolid.h
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+ virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
+
+ 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..e237962
--- /dev/null
+++ b/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; 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();
+
+ const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+ RenderStyle* style = object->style();
+
+ if (this->type() == LinearGradientPaintServer) {
+ const SVGPaintServerLinearGradient* linear = static_cast<const SVGPaintServerLinearGradient*>(this);
+
+ if (boundingBoxMode()) {
+ FloatRect bbox = object->relativeBBox(false);
+ if (bbox.width() == 0 || bbox.height() == 0) {
+ applyStrokeStyleToContext(context, style, object);
+ cairo_set_source_rgb(cr, 0, 0, 0);
+ return true;
+ }
+ cairo_matrix_translate(&matrix, bbox.x(), bbox.y());
+ cairo_matrix_scale(&matrix, bbox.width(), bbox.height());
+ }
+
+ double x0 = linear->gradientStart().x();
+ double y0 = linear->gradientStart().y();
+ double x1 = linear->gradientEnd().x();
+ double 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);
+
+ if (boundingBoxMode()) {
+ FloatRect bbox = object->relativeBBox(false);
+ if (bbox.width() == 0 || bbox.height() == 0) {
+ applyStrokeStyleToContext(context, style, object);
+ cairo_set_source_rgb(cr, 0, 0, 0);
+ return true;
+ }
+ cairo_matrix_translate(&matrix, bbox.x(), bbox.y());
+ cairo_matrix_scale(&matrix, bbox.width(), bbox.height());
+ }
+
+ double cx = radial->gradientCenter().x();
+ double cy = radial->gradientCenter().y();
+ double radius = radial->gradientRadius();
+ double fx = radial->gradientFocal().x();
+ double fy = radial->gradientFocal().y();
+
+ fx -= cx;
+ fy -= cy;
+
+ double fradius = 0.0;
+
+ if (sqrt(fx * fx + fy * fy) >= radius) {
+ double angle = atan2(fy, fx);
+ if ((fx + cx) < cx)
+ fx = cos(angle) * radius + 0.002;
+ else
+ fx = cos(angle) * radius - 0.002;
+ if ((fy + cy) < cy)
+ fy = sin(angle) * radius + 0.002;
+ else
+ fy = sin(angle) * radius - 0.002;
+ }
+
+ pattern = cairo_pattern_create_radial(fx + cx, fy + cy, fradius, cx, cy, radius);
+
+ } else {
+ return false;
+ }
+
+ cairo_pattern_set_filter(pattern, CAIRO_FILTER_BILINEAR);
+
+ switch (spreadMethod()) {
+ case SpreadMethodPad:
+ cairo_pattern_set_extend(pattern, CAIRO_EXTEND_PAD);
+ break;
+ case SpreadMethodReflect:
+ cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REFLECT);
+ break;
+ case SpreadMethodRepeat:
+ cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
+ break;
+ default:
+ cairo_pattern_set_extend(pattern, CAIRO_EXTEND_NONE);
+ break;
+ }
+
+ cairo_matrix_multiply(&matrix, &matrix, &gradient_matrix);
+ cairo_matrix_invert(&matrix);
+ 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;
+ if (i > 0 && offset < stops[i - 1].first)
+ offset = stops[i - 1].first;
+
+ cairo_pattern_add_color_stop_rgba(pattern, offset, color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0, color.alpha() / 255.0);
+ }
+
+ if ((type & ApplyToFillTargetType) && svgStyle->hasFill())
+ context->setFillRule(svgStyle->fillRule());
+
+ if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke())
+ applyStrokeStyleToContext(context, style, object);
+
+ 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..86530bc
--- /dev/null
+++ b/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; 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 "GraphicsContext.h"
+#include "Image.h"
+#include "ImageBuffer.h"
+#include "RenderObject.h"
+#include "SVGPatternElement.h"
+
+#include <wtf/OwnArrayPtr.h>
+
+namespace WebCore {
+
+bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ FloatRect targetRect = object->relativeBBox(false);
+
+ const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+ RenderStyle* style = object->style();
+
+ float strokeWidth = SVGRenderStyle::cssPrimitiveToLength(object, svgStyle->strokeWidth(), 1.0f);
+
+ if (targetRect.width() == 0)
+ targetRect = FloatRect(targetRect.x(), targetRect.y(), strokeWidth, targetRect.height());
+ if (targetRect.height() == 0)
+ targetRect = FloatRect(targetRect.x(), targetRect.y(), targetRect.width(), strokeWidth);
+
+ m_ownerElement->buildPattern(targetRect);
+
+ cairo_surface_t* image = tile()->image()->nativeImageForCurrentFrame();
+ if (!image)
+ return false;
+
+ cairo_t* cr = context->platformContext();
+
+ cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image);
+ cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
+
+ cairo_pattern_set_filter(pattern, CAIRO_FILTER_BEST);
+ cairo_matrix_t pattern_matrix = patternTransform();
+ cairo_matrix_t matrix = {1, 0, 0, 1, patternBoundaries().x(), patternBoundaries().y()};
+ cairo_matrix_multiply(&matrix, &matrix, &pattern_matrix);
+ cairo_matrix_invert(&matrix);
+ cairo_pattern_set_matrix(pattern, &matrix);
+
+ if ((type & ApplyToFillTargetType) && svgStyle->hasFill())
+ context->setFillRule(svgStyle->fillRule());
+
+ if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke())
+ applyStrokeStyleToContext(context, style, object);
+
+ cairo_set_source(cr, pattern);
+ cairo_pattern_destroy(pattern);
+
+ 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..49e6f55
--- /dev/null
+++ b/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp
@@ -0,0 +1,59 @@
+/*
+ * 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* svgStyle = object->style()->svgStyle();
+ RenderStyle* style = object->style();
+
+ float red, green, blue, alpha;
+ color().getRGBA(red, green, blue, alpha);
+
+ if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) {
+ alpha = svgStyle->fillOpacity();
+ context->setFillRule(svgStyle->fillRule());
+ }
+
+ if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
+ alpha = svgStyle->strokeOpacity();
+ applyStrokeStyleToContext(context, style, object);
+ }
+
+ 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..6aec0ae
--- /dev/null
+++ b/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; 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 "CairoPath.h"
+#include "GraphicsContext.h"
+
+#include <cairo.h>
+
+namespace WebCore {
+
+void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
+{
+ cairo_t* cr = context->platformContext();
+ if (m_clipData.clipData().size() < 1)
+ return;
+
+ cairo_reset_clip(cr);
+ context->beginPath();
+
+ for (unsigned int x = 0; x < m_clipData.clipData().size(); x++) {
+ ClipData data = m_clipData.clipData()[x];
+
+ Path path = data.path;
+ if (path.isEmpty())
+ continue;
+ path.closeSubpath();
+
+ if (data.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_path_t* clipPath = cairo_copy_path(path.platformPath()->m_cr);
+ cairo_append_path(cr, clipPath);
+
+ cairo_set_fill_rule(cr, data.windRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
+ }
+
+ cairo_clip(cr);
+}
+
+} // 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..1f690b5
--- /dev/null
+++ b/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp
@@ -0,0 +1,48 @@
+/*
+ * 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 "Image.h"
+#include "ImageBuffer.h"
+#include "GraphicsContext.h"
+
+#include <cairo.h>
+
+namespace WebCore {
+
+void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& boundingBox)
+{
+ if (!m_mask)
+ return;
+
+ cairo_t* cr = context->platformContext();
+ cairo_surface_t* surface = m_mask->image()->nativeImageForCurrentFrame();
+ 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..f9bfb4c
--- /dev/null
+++ b/WebCore/svg/graphics/cg/CgSupport.cpp
@@ -0,0 +1,100 @@
+/*
+ * 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 {
+
+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 sufficient 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..de6e4b3
--- /dev/null
+++ b/WebCore/svg/graphics/cg/CgSupport.h
@@ -0,0 +1,50 @@
+/*
+ * 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;
+
+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..bfa5017
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp
@@ -0,0 +1,336 @@
+/*
+ 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 "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());
+ m_savedContext->clipToImageBuffer(textBoundary, m_imageBuffer);
+ 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
+{
+ if (boundingBoxMode()) {
+ // Choose default gradient bounding box
+ FloatRect gradientBBox(0.0f, 0.0f, 1.0f, 1.0f);
+
+ // Generate a transform to map between both bounding boxes
+ context->concatCTM(makeMapBetweenRects(gradientBBox, targetRect));
+ }
+
+ // Apply the gradient's own transform
+ context->concatCTM(gradientTransform());
+}
+
+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..416d5fe
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp
@@ -0,0 +1,130 @@
+/*
+ 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);
+ CGContextSaveGState(context);
+ CGContextTranslateCTM(context, 0, patternImage->size().height());
+ CGContextScaleCTM(context, 1.0f, -1.0f);
+ CGContextDrawImage(context, CGRect(FloatRect(FloatPoint(), patternImage->size())), patternImage->image()->getCGImageRef());
+ CGContextRestoreGState(context);
+}
+
+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..bd2a56f
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp
@@ -0,0 +1,77 @@
+/*
+ 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 "Color.h"
+#include "CgSupport.h"
+#include "GraphicsContext.h"
+#include "RenderObject.h"
+
+namespace WebCore {
+
+bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ // FIXME: This function does not use any CG-specific calls, however it's not yet
+ // cross platform, because CG handles fill rule different from other graphics
+ // platforms. CG makes you use two separate fill calls, other platforms set
+ // the fill rule state on the context and then call a generic "fillPath"
+
+ RenderStyle* style = object ? object->style() : 0;
+
+ if ((type & ApplyToFillTargetType) && (!style || style->svgStyle()->hasFill())) {
+ RGBA32 rgba = color().rgb();
+ ASSERT(!color().hasAlpha());
+ if (style)
+ rgba = colorWithOverrideAlpha(rgba, style->svgStyle()->fillOpacity());
+
+ context->setFillColor(rgba);
+
+ if (isPaintingText)
+ context->setTextDrawingMode(cTextFill);
+ }
+
+ if ((type & ApplyToStrokeTargetType) && (!style || style->svgStyle()->hasStroke())) {
+ RGBA32 rgba = color().rgb();
+ ASSERT(!color().hasAlpha());
+ if (style)
+ rgba = colorWithOverrideAlpha(rgba, style->svgStyle()->strokeOpacity());
+
+ context->setStrokeColor(rgba);
+
+ 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..b04a0dc
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp
@@ -0,0 +1,82 @@
+/*
+ * 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 "AffineTransform.h"
+#include "GraphicsContext.h"
+
+#include <ApplicationServices/ApplicationServices.h>
+
+namespace WebCore {
+
+void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
+{
+ if (m_clipData.clipData().size() < 1)
+ return;
+
+ bool heterogenousClipRules = false;
+ WindRule clipRule = m_clipData.clipData()[0].windRule;
+
+ context->beginPath();
+
+ AffineTransform bboxTransform = makeMapBetweenRects(FloatRect(0.0f, 0.0f, 1.0f, 1.0f), boundingBox);
+
+ for (unsigned x = 0; x < m_clipData.clipData().size(); x++) {
+ ClipData data = m_clipData.clipData()[x];
+ if (data.windRule != clipRule)
+ heterogenousClipRules = true;
+
+ Path clipPath = data.path;
+
+ if (data.bboxUnits)
+ clipPath.transform(bboxTransform);
+
+ context->addPath(clipPath);
+ }
+
+ CGContextRef cgContext = context->platformContext();
+ 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..f867f9c
--- /dev/null
+++ b/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm
@@ -0,0 +1,129 @@
+/*
+ * 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->image()->getCGImageRef()];
+ 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->image()->getCGImageRef());
+ 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..25c2045
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGDistantLightSource.h
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
+ 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 DistantLightSource : public LightSource {
+ public:
+ DistantLightSource(float azimuth, float elevation)
+ : LightSource(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/SVGFEConvolveMatrix.cpp b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp
new file mode 100644
index 0000000..4b82e5a
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp
@@ -0,0 +1,177 @@
+/*
+ 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 "SVGFEConvolveMatrix.h"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+FEConvolveMatrix::FEConvolveMatrix(FilterEffect* in, FilterEffect* in2, const FloatSize& kernelSize,
+ const float& divisor, const float& bias, const FloatSize& targetOffset, EdgeModeType edgeMode,
+ const FloatPoint& kernelUnitLength, bool preserveAlpha, const Vector<float>& kernelMatrix)
+ : FilterEffect()
+ , m_in(in)
+ , m_in2(in2)
+ , m_kernelSize(kernelSize)
+ , m_divisor(divisor)
+ , m_bias(bias)
+ , m_targetOffset(targetOffset)
+ , m_edgeMode(edgeMode)
+ , m_kernelUnitLength(kernelUnitLength)
+ , m_preserveAlpha(preserveAlpha)
+ , m_kernelMatrix(kernelMatrix)
+{
+}
+
+PassRefPtr<FEConvolveMatrix> FEConvolveMatrix::create(FilterEffect* in, FilterEffect* in2, const FloatSize& kernelSize,
+ const float& divisor, const float& bias, const FloatSize& targetOffset, EdgeModeType edgeMode,
+ const FloatPoint& kernelUnitLength, bool preserveAlpha, const Vector<float>& kernelMatrix)
+{
+ return adoptRef(new FEConvolveMatrix(in, in2, kernelSize, divisor, bias, targetOffset, edgeMode, kernelUnitLength,
+ preserveAlpha, kernelMatrix));
+}
+
+
+FloatSize FEConvolveMatrix::kernelSize() const
+{
+ return m_kernelSize;
+}
+
+void FEConvolveMatrix::setKernelSize(FloatSize kernelSize)
+{
+ m_kernelSize = kernelSize;
+}
+
+const Vector<float>& FEConvolveMatrix::kernel() const
+{
+ return m_kernelMatrix;
+}
+
+void FEConvolveMatrix::setKernel(const Vector<float>& kernel)
+{
+ m_kernelMatrix = kernel;
+}
+
+float FEConvolveMatrix::divisor() const
+{
+ return m_divisor;
+}
+
+void FEConvolveMatrix::setDivisor(float divisor)
+{
+ m_divisor = divisor;
+}
+
+float FEConvolveMatrix::bias() const
+{
+ return m_bias;
+}
+
+void FEConvolveMatrix::setBias(float bias)
+{
+ m_bias = bias;
+}
+
+FloatSize FEConvolveMatrix::targetOffset() const
+{
+ return m_targetOffset;
+}
+
+void FEConvolveMatrix::setTargetOffset(FloatSize targetOffset)
+{
+ m_targetOffset = targetOffset;
+}
+
+EdgeModeType FEConvolveMatrix::edgeMode() const
+{
+ return m_edgeMode;
+}
+
+void FEConvolveMatrix::setEdgeMode(EdgeModeType edgeMode)
+{
+ m_edgeMode = edgeMode;
+}
+
+FloatPoint FEConvolveMatrix::kernelUnitLength() const
+{
+ return m_kernelUnitLength;
+}
+
+void FEConvolveMatrix::setKernelUnitLength(FloatPoint kernelUnitLength)
+{
+ m_kernelUnitLength = kernelUnitLength;
+}
+
+bool FEConvolveMatrix::preserveAlpha() const
+{
+ return m_preserveAlpha;
+}
+
+void FEConvolveMatrix::setPreserveAlpha(bool preserveAlpha)
+{
+ m_preserveAlpha = preserveAlpha;
+}
+
+void FEConvolveMatrix::apply()
+{
+}
+
+void FEConvolveMatrix::dump()
+{
+}
+
+static TextStream& operator<<(TextStream& ts, EdgeModeType t)
+{
+ switch (t)
+ {
+ case EDGEMODE_UNKNOWN:
+ ts << "UNKNOWN";break;
+ case EDGEMODE_DUPLICATE:
+ ts << "DUPLICATE";break;
+ case EDGEMODE_WRAP:
+ ts << "WRAP"; break;
+ case EDGEMODE_NONE:
+ ts << "NONE"; break;
+ }
+ return ts;
+}
+
+TextStream& FEConvolveMatrix::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=CONVOLVE-MATRIX] ";
+ FilterEffect::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..c3eea2b
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h
@@ -0,0 +1,95 @@
+/*
+ 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 "FilterEffect.h"
+#include "FloatPoint.h"
+#include "FloatSize.h"
+
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+ enum EdgeModeType {
+ EDGEMODE_UNKNOWN = 0,
+ EDGEMODE_DUPLICATE = 1,
+ EDGEMODE_WRAP = 2,
+ EDGEMODE_NONE = 3
+ };
+
+ class FEConvolveMatrix : public FilterEffect {
+ public:
+ static PassRefPtr<FEConvolveMatrix> create(FilterEffect*, FilterEffect*, const FloatSize&,
+ const float&, const float&, const FloatSize&, EdgeModeType, const FloatPoint&,
+ bool, const Vector<float>&);
+
+ 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);
+
+ EdgeModeType edgeMode() const;
+ void setEdgeMode(EdgeModeType);
+
+ FloatPoint kernelUnitLength() const;
+ void setKernelUnitLength(FloatPoint);
+
+ bool preserveAlpha() const;
+ void setPreserveAlpha(bool);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEConvolveMatrix(FilterEffect*, FilterEffect*, const FloatSize&, const float&, const float&,
+ const FloatSize&, EdgeModeType, const FloatPoint&, bool, const Vector<float>&);
+
+ RefPtr<FilterEffect> m_in;
+ RefPtr<FilterEffect> m_in2;
+ FloatSize m_kernelSize;
+ float m_divisor;
+ float m_bias;
+ FloatSize m_targetOffset;
+ EdgeModeType m_edgeMode;
+ FloatPoint m_kernelUnitLength;
+ bool m_preserveAlpha;
+ Vector<float> m_kernelMatrix;
+ };
+
+} // 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..6399c5e
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp
@@ -0,0 +1,135 @@
+/*
+ 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"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+FEDiffuseLighting::FEDiffuseLighting(FilterEffect* in , const Color& lightingColor, const float& surfaceScale,
+ const float& diffuseConstant, const float& kernelUnitLengthX, const float& kernelUnitLengthY, LightSource* lightSource)
+ : FilterEffect()
+ , m_in(in)
+ , m_lightingColor(lightingColor)
+ , m_surfaceScale(surfaceScale)
+ , m_diffuseConstant(diffuseConstant)
+ , m_kernelUnitLengthX(kernelUnitLengthX)
+ , m_kernelUnitLengthY(kernelUnitLengthY)
+ , m_lightSource(lightSource)
+{
+}
+
+PassRefPtr<FEDiffuseLighting> FEDiffuseLighting::create(FilterEffect* in , const Color& lightingColor,
+ const float& surfaceScale, const float& diffuseConstant, const float& kernelUnitLengthX,
+ const float& kernelUnitLengthY, LightSource* lightSource)
+{
+ return adoptRef(new FEDiffuseLighting(in, lightingColor, surfaceScale, diffuseConstant, kernelUnitLengthX, kernelUnitLengthY, lightSource));
+}
+
+FEDiffuseLighting::~FEDiffuseLighting()
+{
+}
+
+Color FEDiffuseLighting::lightingColor() const
+{
+ return m_lightingColor;
+}
+
+void FEDiffuseLighting::setLightingColor(const Color& lightingColor)
+{
+ m_lightingColor = lightingColor;
+}
+
+float FEDiffuseLighting::surfaceScale() const
+{
+ return m_surfaceScale;
+}
+
+void FEDiffuseLighting::setSurfaceScale(float surfaceScale)
+{
+ m_surfaceScale = surfaceScale;
+}
+
+float FEDiffuseLighting::diffuseConstant() const
+{
+ return m_diffuseConstant;
+}
+
+void FEDiffuseLighting::setDiffuseConstant(float diffuseConstant)
+{
+ m_diffuseConstant = diffuseConstant;
+}
+
+float FEDiffuseLighting::kernelUnitLengthX() const
+{
+ return m_kernelUnitLengthX;
+}
+
+void FEDiffuseLighting::setKernelUnitLengthX(float kernelUnitLengthX)
+{
+ m_kernelUnitLengthX = kernelUnitLengthX;
+}
+
+float FEDiffuseLighting::kernelUnitLengthY() const
+{
+ return m_kernelUnitLengthY;
+}
+
+void FEDiffuseLighting::setKernelUnitLengthY(float kernelUnitLengthY)
+{
+ m_kernelUnitLengthY = kernelUnitLengthY;
+}
+
+const LightSource* FEDiffuseLighting::lightSource() const
+{
+ return m_lightSource.get();
+}
+
+void FEDiffuseLighting::setLightSource(LightSource* lightSource)
+{
+ m_lightSource = lightSource;
+}
+
+void FEDiffuseLighting::apply()
+{
+}
+
+void FEDiffuseLighting::dump()
+{
+}
+
+TextStream& FEDiffuseLighting::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=DIFFUSE-LIGHTING] ";
+ FilterEffect::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..a817ce2
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.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 SVGFEDiffuseLighting_h
+#define SVGFEDiffuseLighting_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "Color.h"
+#include "FilterEffect.h"
+
+namespace WebCore {
+
+ class LightSource;
+
+ class FEDiffuseLighting : public FilterEffect {
+ public:
+ static PassRefPtr<FEDiffuseLighting> create(FilterEffect*, const Color&, const float&, const float&,
+ const float&, const float&, LightSource*);
+ virtual ~FEDiffuseLighting();
+
+ 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 LightSource* lightSource() const;
+ void setLightSource(LightSource*);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEDiffuseLighting(FilterEffect*, const Color&, const float&, const float&,
+ const float&, const float&, LightSource*);
+
+ RefPtr<FilterEffect> m_in;
+ Color m_lightingColor;
+ float m_surfaceScale;
+ float m_diffuseConstant;
+ float m_kernelUnitLengthX;
+ float m_kernelUnitLengthY;
+ RefPtr<LightSource> 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..f7996e3
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp
@@ -0,0 +1,116 @@
+/*
+ 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 "SVGFEDisplacementMap.h"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+FEDisplacementMap::FEDisplacementMap(FilterEffect* in, FilterEffect* in2, ChannelSelectorType xChannelSelector,
+ ChannelSelectorType yChannelSelector, const float& scale)
+ : FilterEffect()
+ , m_in(in)
+ , m_in2(in2)
+ , m_xChannelSelector(xChannelSelector)
+ , m_yChannelSelector(yChannelSelector)
+ , m_scale(scale)
+{
+}
+
+PassRefPtr<FEDisplacementMap> FEDisplacementMap::create(FilterEffect* in, FilterEffect* in2,
+ ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, const float& scale)
+{
+ return adoptRef(new FEDisplacementMap(in, in2, xChannelSelector, yChannelSelector, scale));
+}
+
+ChannelSelectorType FEDisplacementMap::xChannelSelector() const
+{
+ return m_xChannelSelector;
+}
+
+void FEDisplacementMap::setXChannelSelector(const ChannelSelectorType xChannelSelector)
+{
+ m_xChannelSelector = xChannelSelector;
+}
+
+ChannelSelectorType FEDisplacementMap::yChannelSelector() const
+{
+ return m_yChannelSelector;
+}
+
+void FEDisplacementMap::setYChannelSelector(const ChannelSelectorType yChannelSelector)
+{
+ m_yChannelSelector = yChannelSelector;
+}
+
+float FEDisplacementMap::scale() const
+{
+ return m_scale;
+}
+
+void FEDisplacementMap::setScale(float scale)
+{
+ m_scale = scale;
+}
+
+void FEDisplacementMap::apply()
+{
+}
+
+void FEDisplacementMap::dump()
+{
+}
+
+static TextStream& operator<<(TextStream& ts, ChannelSelectorType t)
+{
+ switch (t)
+ {
+ case CHANNEL_UNKNOWN:
+ ts << "UNKNOWN"; break;
+ case CHANNEL_R:
+ ts << "RED"; break;
+ case CHANNEL_G:
+ ts << "GREEN"; break;
+ case CHANNEL_B:
+ ts << "BLUE"; break;
+ case CHANNEL_A:
+ ts << "ALPHA"; break;
+ }
+ return ts;
+}
+
+TextStream& FEDisplacementMap::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=DISPLACEMENT-MAP] ";
+ FilterEffect::externalRepresentation(ts);
+ ts << " [in2=" << m_in2.get() << "]"
+ << " [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..0218d57
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h
@@ -0,0 +1,72 @@
+/*
+ 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 "PlatformString.h"
+#include "FilterEffect.h"
+
+namespace WebCore {
+
+ enum ChannelSelectorType {
+ CHANNEL_UNKNOWN = 0,
+ CHANNEL_R = 1,
+ CHANNEL_G = 2,
+ CHANNEL_B = 3,
+ CHANNEL_A = 4
+ };
+
+ class FEDisplacementMap : public FilterEffect {
+ public:
+ static PassRefPtr<FEDisplacementMap> create(FilterEffect*, FilterEffect*, ChannelSelectorType,
+ ChannelSelectorType, const float&);
+
+ ChannelSelectorType xChannelSelector() const;
+ void setXChannelSelector(const ChannelSelectorType);
+
+ ChannelSelectorType yChannelSelector() const;
+ void setYChannelSelector(const ChannelSelectorType);
+
+ float scale() const;
+ void setScale(float scale);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEDisplacementMap(FilterEffect*, FilterEffect*, ChannelSelectorType,
+ ChannelSelectorType, const float&);
+
+ RefPtr<FilterEffect> m_in;
+ RefPtr<FilterEffect> m_in2;
+ ChannelSelectorType m_xChannelSelector;
+ ChannelSelectorType m_yChannelSelector;
+ float m_scale;
+ };
+
+} // 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..3d52f63
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEFlood.cpp
@@ -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.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEFlood.h"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+FEFlood::FEFlood(const Color& floodColor, const float& floodOpacity)
+ : FilterEffect()
+ , m_floodColor(floodColor)
+ , m_floodOpacity(floodOpacity)
+{
+}
+
+PassRefPtr<FEFlood> FEFlood::create(const Color& floodColor, const float& floodOpacity)
+{
+ return adoptRef(new FEFlood(floodColor, floodOpacity));
+}
+
+Color FEFlood::floodColor() const
+{
+ return m_floodColor;
+}
+
+void FEFlood::setFloodColor(const Color& color)
+{
+ m_floodColor = color;
+}
+
+float FEFlood::floodOpacity() const
+{
+ return m_floodOpacity;
+}
+
+void FEFlood::setFloodOpacity(float floodOpacity)
+{
+ m_floodOpacity = floodOpacity;
+}
+
+void FEFlood::apply()
+{
+}
+
+void FEFlood::dump()
+{
+}
+
+TextStream& FEFlood::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=FLOOD] ";
+ FilterEffect::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..0558774
--- /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 "FilterEffect.h"
+
+namespace WebCore {
+
+ class FEFlood : public FilterEffect {
+ public:
+ static PassRefPtr<FEFlood> create(const Color&, const float&);
+
+ Color floodColor() const;
+ void setFloodColor(const Color &);
+
+ float floodOpacity() const;
+ void setFloodOpacity(float);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEFlood(const Color&, const float&);
+
+ 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..4e64c58
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp
@@ -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.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEGaussianBlur.h"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+FEGaussianBlur::FEGaussianBlur(FilterEffect* in, const float& x, const float& y)
+ : FilterEffect()
+ , m_in(in)
+ , m_x(x)
+ , m_y(y)
+{
+}
+
+PassRefPtr<FEGaussianBlur> FEGaussianBlur::create(FilterEffect* in, const float& x, const float& y)
+{
+ return adoptRef(new FEGaussianBlur(in, x, y));
+}
+
+float FEGaussianBlur::stdDeviationX() const
+{
+ return m_x;
+}
+
+void FEGaussianBlur::setStdDeviationX(float x)
+{
+ m_x = x;
+}
+
+float FEGaussianBlur::stdDeviationY() const
+{
+ return m_y;
+}
+
+void FEGaussianBlur::setStdDeviationY(float y)
+{
+ m_y = y;
+}
+
+void FEGaussianBlur::apply()
+{
+}
+
+void FEGaussianBlur::dump()
+{
+}
+
+TextStream& FEGaussianBlur::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=GAUSSIAN-BLUR] ";
+ FilterEffect::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..33ad0c7
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.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 SVGFEGaussianBlur_h
+#define SVGFEGaussianBlur_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "FilterEffect.h"
+
+namespace WebCore {
+
+ class FEGaussianBlur : public FilterEffect {
+ public:
+ static PassRefPtr<FEGaussianBlur> create(FilterEffect*, const float&, const float&);
+
+ float stdDeviationX() const;
+ void setStdDeviationX(float);
+
+ float stdDeviationY() const;
+ void setStdDeviationY(float);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEGaussianBlur(FilterEffect*, const float&, const float&);
+
+ RefPtr<FilterEffect> m_in;
+ 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..2bf83be
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEImage.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 "SVGFEImage.h"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+FEImage::FEImage(CachedImage* cachedImage)
+ : FilterEffect()
+ , m_cachedImage(cachedImage)
+{
+}
+
+PassRefPtr<FEImage> FEImage::create(CachedImage* cachedImage)
+{
+ return adoptRef(new FEImage(cachedImage));
+}
+
+FEImage::~FEImage()
+{
+ if (m_cachedImage)
+ m_cachedImage->removeClient(this);
+}
+
+CachedImage* FEImage::cachedImage() const
+{
+ return m_cachedImage.get();
+}
+
+void FEImage::setCachedImage(CachedImage* image)
+{
+ if (m_cachedImage == image)
+ return;
+
+ if (m_cachedImage)
+ m_cachedImage->removeClient(this);
+
+ m_cachedImage = image;
+
+ if (m_cachedImage)
+ m_cachedImage->addClient(this);
+}
+
+void FEImage::apply()
+{
+}
+
+void FEImage::dump()
+{
+}
+
+TextStream& FEImage::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=IMAGE] ";
+ FilterEffect::externalRepresentation(ts);
+ // FIXME: should this dump also object returned by SVGFEImage::image() ?
+ return ts;
+}
+
+} // 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..fcf413f
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEImage.h
@@ -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.
+*/
+
+#ifndef SVGFEImage_h
+#define SVGFEImage_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "CachedImage.h"
+#include "CachedResourceClient.h"
+#include "CachedResourceHandle.h"
+#include "FilterEffect.h"
+
+namespace WebCore {
+
+ class FEImage : public FilterEffect
+ , public CachedResourceClient {
+ public:
+ static PassRefPtr<FEImage> create(CachedImage*);
+ virtual ~FEImage();
+
+ // FIXME: We need to support <svg> (RenderObject*) as well as image data.
+
+ CachedImage* cachedImage() const;
+ void setCachedImage(CachedImage*);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEImage(CachedImage*);
+
+ CachedResourceHandle<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..8ce15a7
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEMerge.cpp
@@ -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.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEMerge.h"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+FEMerge::FEMerge(const Vector<FilterEffect*>& mergeInputs)
+ : FilterEffect()
+ , m_mergeInputs(mergeInputs)
+{
+}
+
+PassRefPtr<FEMerge> FEMerge::create(const Vector<FilterEffect*>& mergeInputs)
+{
+ return adoptRef(new FEMerge(mergeInputs));
+}
+
+const Vector<FilterEffect*>& FEMerge::mergeInputs() const
+{
+ return m_mergeInputs;
+}
+
+void FEMerge::setMergeInputs(const Vector<FilterEffect*>& mergeInputs)
+{
+ m_mergeInputs = mergeInputs;
+}
+
+void FEMerge::apply()
+{
+}
+
+void FEMerge::dump()
+{
+}
+
+TextStream& FEMerge::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=MERGE] ";
+ FilterEffect::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..6415c9f
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEMerge.h
@@ -0,0 +1,53 @@
+/*
+ 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 "FilterEffect.h"
+
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+ class FEMerge : public FilterEffect {
+ public:
+ static PassRefPtr<FEMerge> create(const Vector<FilterEffect*>&);
+
+ const Vector<FilterEffect*>& mergeInputs() const;
+ void setMergeInputs(const Vector<FilterEffect*>& mergeInputs);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEMerge(const Vector<FilterEffect*>&);
+
+ Vector<FilterEffect*> 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..7838a8c
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEMorphology.cpp
@@ -0,0 +1,107 @@
+/*
+ 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"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+FEMorphology::FEMorphology(FilterEffect* in, MorphologyOperatorType type, const float& radiusX, const float& radiusY)
+ : FilterEffect()
+ , m_in(in)
+ , m_type(type)
+ , m_radiusX(radiusX)
+ , m_radiusY(radiusY)
+{
+}
+
+PassRefPtr<FEMorphology> FEMorphology::create(FilterEffect* in, MorphologyOperatorType type, const float& radiusX, const float& radiusY)
+{
+ return adoptRef(new FEMorphology(in, type, radiusX, radiusY));
+}
+
+MorphologyOperatorType FEMorphology::morphologyOperator() const
+{
+ return m_type;
+}
+
+void FEMorphology::setMorphologyOperator(MorphologyOperatorType type)
+{
+ m_type = type;
+}
+
+float FEMorphology::radiusX() const
+{
+ return m_radiusX;
+}
+
+void FEMorphology::setRadiusX(float radiusX)
+{
+ m_radiusX = radiusX;
+}
+
+float FEMorphology::radiusY() const
+{
+ return m_radiusY;
+}
+
+void FEMorphology::setRadiusY(float radiusY)
+{
+ m_radiusY = radiusY;
+}
+
+void FEMorphology::apply()
+{
+}
+
+void FEMorphology::dump()
+{
+}
+
+static TextStream& operator<<(TextStream& ts, MorphologyOperatorType t)
+{
+ switch (t)
+ {
+ case FEMORPHOLOGY_OPERATOR_UNKNOWN:
+ ts << "UNKNOWN"; break;
+ case FEMORPHOLOGY_OPERATOR_ERODE:
+ ts << "ERODE"; break;
+ case FEMORPHOLOGY_OPERATOR_DIALATE:
+ ts << "DIALATE"; break;
+ }
+ return ts;
+}
+
+TextStream& FEMorphology::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=MORPHOLOGY] ";
+ FilterEffect::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..98ab633
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEMorphology.h
@@ -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.
+*/
+
+#ifndef SVGFEMorphology_h
+#define SVGFEMorphology_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "FilterEffect.h"
+
+namespace WebCore {
+
+ enum MorphologyOperatorType {
+ FEMORPHOLOGY_OPERATOR_UNKNOWN = 0,
+ FEMORPHOLOGY_OPERATOR_ERODE = 1,
+ FEMORPHOLOGY_OPERATOR_DIALATE = 2
+ };
+
+ class FEMorphology : public FilterEffect {
+ public:
+ PassRefPtr<FEMorphology> create(FilterEffect*, MorphologyOperatorType, const float&, const float&);
+ MorphologyOperatorType morphologyOperator() const;
+ void setMorphologyOperator(MorphologyOperatorType);
+
+ float radiusX() const;
+ void setRadiusX(float);
+
+ float radiusY() const;
+ void setRadiusY(float);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEMorphology(FilterEffect*, MorphologyOperatorType, const float&, const float&);
+
+ RefPtr<FilterEffect> m_in;
+ MorphologyOperatorType m_type;
+ 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..c2a0fc9
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEOffset.cpp
@@ -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.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "SVGFEOffset.h"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+FEOffset::FEOffset(FilterEffect* in, const float& dx, const float& dy)
+ : FilterEffect()
+ , m_in(in)
+ , m_dx(dx)
+ , m_dy(dy)
+{
+}
+
+PassRefPtr<FEOffset> FEOffset::create(FilterEffect* in, const float& dx, const float& dy)
+{
+ return adoptRef(new FEOffset(in, dx, dy));
+}
+
+float FEOffset::dx() const
+{
+ return m_dx;
+}
+
+void FEOffset::setDx(float dx)
+{
+ m_dx = dx;
+}
+
+float FEOffset::dy() const
+{
+ return m_dy;
+}
+
+void FEOffset::setDy(float dy)
+{
+ m_dy = dy;
+}
+
+void FEOffset::apply()
+{
+}
+
+void FEOffset::dump()
+{
+}
+
+TextStream& FEOffset::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=OFFSET] ";
+ FilterEffect::externalRepresentation(ts);
+ 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..86128da
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFEOffset.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 SVGFEOffset_h
+#define SVGFEOffset_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "FilterEffect.h"
+
+namespace WebCore {
+
+ class FEOffset : public FilterEffect {
+ public:
+ static PassRefPtr<FEOffset> create(FilterEffect*, const float&, const float&);
+
+ float dx() const;
+ void setDx(float);
+
+ float dy() const;
+ void setDy(float);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEOffset(FilterEffect*, const float&, const float&);
+
+ RefPtr<FilterEffect> m_in;
+ 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..e3446ed
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp
@@ -0,0 +1,147 @@
+/*
+ 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"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+FESpecularLighting::FESpecularLighting(FilterEffect* in, const Color& lightingColor, const float& surfaceScale,
+ const float& specularConstant, const float& specularExponent, const float& kernelUnitLengthX,
+ const float& kernelUnitLengthY, LightSource* lightSource)
+ : FilterEffect()
+ , m_in(in)
+ , m_lightingColor(lightingColor)
+ , m_surfaceScale(surfaceScale)
+ , m_specularConstant(specularConstant)
+ , m_specularExponent(specularExponent)
+ , m_kernelUnitLengthX(kernelUnitLengthX)
+ , m_kernelUnitLengthY(kernelUnitLengthY)
+ , m_lightSource(lightSource)
+{
+}
+
+PassRefPtr<FESpecularLighting> FESpecularLighting::create(FilterEffect* in, const Color& lightingColor,
+ const float& surfaceScale, const float& specularConstant, const float& specularExponent,
+ const float& kernelUnitLengthX, const float& kernelUnitLengthY, LightSource* lightSource)
+{
+ return adoptRef(new FESpecularLighting(in, lightingColor, surfaceScale, specularConstant, specularExponent,
+ kernelUnitLengthX, kernelUnitLengthY, lightSource));
+}
+
+FESpecularLighting::~FESpecularLighting()
+{
+}
+
+Color FESpecularLighting::lightingColor() const
+{
+ return m_lightingColor;
+}
+
+void FESpecularLighting::setLightingColor(const Color& lightingColor)
+{
+ m_lightingColor = lightingColor;
+}
+
+float FESpecularLighting::surfaceScale() const
+{
+ return m_surfaceScale;
+}
+
+void FESpecularLighting::setSurfaceScale(float surfaceScale)
+{
+ m_surfaceScale = surfaceScale;
+}
+
+float FESpecularLighting::specularConstant() const
+{
+ return m_specularConstant;
+}
+
+void FESpecularLighting::setSpecularConstant(float specularConstant)
+{
+ m_specularConstant = specularConstant;
+}
+
+float FESpecularLighting::specularExponent() const
+{
+ return m_specularExponent;
+}
+
+void FESpecularLighting::setSpecularExponent(float specularExponent)
+{
+ m_specularExponent = specularExponent;
+}
+
+float FESpecularLighting::kernelUnitLengthX() const
+{
+ return m_kernelUnitLengthX;
+}
+
+void FESpecularLighting::setKernelUnitLengthX(float kernelUnitLengthX)
+{
+ m_kernelUnitLengthX = kernelUnitLengthX;
+}
+
+float FESpecularLighting::kernelUnitLengthY() const
+{
+ return m_kernelUnitLengthY;
+}
+
+void FESpecularLighting::setKernelUnitLengthY(float kernelUnitLengthY)
+{
+ m_kernelUnitLengthY = kernelUnitLengthY;
+}
+
+const LightSource* FESpecularLighting::lightSource() const
+{
+ return m_lightSource.get();
+}
+
+void FESpecularLighting::setLightSource(LightSource* lightSource)
+{
+ m_lightSource = lightSource;
+}
+
+void FESpecularLighting::apply()
+{
+}
+
+void FESpecularLighting::dump()
+{
+}
+
+TextStream& FESpecularLighting::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=SPECULAR-LIGHTING] ";
+ FilterEffect::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..e1c1930
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFESpecularLighting.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 SVGFESpecularLighting_h
+#define SVGFESpecularLighting_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "Color.h"
+#include "SVGLightSource.h"
+#include "FilterEffect.h"
+
+namespace WebCore {
+
+ class FESpecularLighting : public FilterEffect {
+ public:
+ static PassRefPtr<FESpecularLighting> create(FilterEffect*, const Color&, const float&, const float&,
+ const float&, const float&, const float&, LightSource*);
+ virtual ~FESpecularLighting();
+
+ 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 LightSource* lightSource() const;
+ void setLightSource(LightSource*);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FESpecularLighting(FilterEffect*, const Color&, const float&, const float&, const float&,
+ const float&, const float&, LightSource*);
+
+ RefPtr<FilterEffect> m_in;
+ Color m_lightingColor;
+ float m_surfaceScale;
+ float m_specularConstant;
+ float m_specularExponent;
+ float m_kernelUnitLengthX;
+ float m_kernelUnitLengthY;
+ RefPtr<LightSource> m_lightSource;
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
+#endif // SVGFESpecularLighting_h
diff --git a/WebCore/svg/graphics/filters/SVGFETile.cpp b/WebCore/svg/graphics/filters/SVGFETile.cpp
new file mode 100644
index 0000000..773a5cd
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFETile.cpp
@@ -0,0 +1,57 @@
+/*
+ Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.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
+ 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 "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+FETile::FETile(FilterEffect* in)
+ : FilterEffect()
+ , m_in(in)
+{
+}
+
+PassRefPtr<FETile> FETile::create(FilterEffect* in)
+{
+ return adoptRef(new FETile(in));
+}
+
+void FETile::apply()
+{
+}
+
+void FETile::dump()
+{
+}
+
+TextStream& FETile::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=TILE]";
+ FilterEffect::externalRepresentation(ts);
+ return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
diff --git a/WebCore/svg/graphics/filters/SVGFETile.h b/WebCore/svg/graphics/filters/SVGFETile.h
new file mode 100644
index 0000000..986f6fd
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFETile.h
@@ -0,0 +1,48 @@
+/*
+ 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 "FilterEffect.h"
+
+namespace WebCore {
+
+ class FETile : public FilterEffect {
+ public:
+ static PassRefPtr<FETile> create(FilterEffect*);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FETile(FilterEffect*);
+
+ RefPtr<FilterEffect> m_in;
+ };
+
+} // 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..9731c49
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFETurbulence.cpp
@@ -0,0 +1,145 @@
+/*
+ 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"
+#include "SVGRenderTreeAsText.h"
+
+namespace WebCore {
+
+FETurbulence::FETurbulence(TurbulanceType type, const float& baseFrequencyX, const float& baseFrequencyY,
+ const int& numOctaves, const float& seed, bool stitchTiles)
+ : FilterEffect()
+ , m_type(type)
+ , m_baseFrequencyX(baseFrequencyX)
+ , m_baseFrequencyY(baseFrequencyY)
+ , m_numOctaves(numOctaves)
+ , m_seed(seed)
+ , m_stitchTiles(stitchTiles)
+{
+}
+
+PassRefPtr<FETurbulence> FETurbulence::create(TurbulanceType type, const float& baseFrequencyX, const float& baseFrequencyY,
+ const int& numOctaves, const float& seed, bool stitchTiles)
+{
+ return adoptRef(new FETurbulence(type, baseFrequencyX, baseFrequencyY, numOctaves, seed, stitchTiles));
+}
+
+TurbulanceType FETurbulence::type() const
+{
+ return m_type;
+}
+
+void FETurbulence::setType(TurbulanceType type)
+{
+ m_type = type;
+}
+
+float FETurbulence::baseFrequencyY() const
+{
+ return m_baseFrequencyY;
+}
+
+void FETurbulence::setBaseFrequencyY(float baseFrequencyY)
+{
+ m_baseFrequencyY = baseFrequencyY;
+}
+
+float FETurbulence::baseFrequencyX() const
+{
+ return m_baseFrequencyX;
+}
+
+void FETurbulence::setBaseFrequencyX(float baseFrequencyX)
+{
+ m_baseFrequencyX = baseFrequencyX;
+}
+
+float FETurbulence::seed() const
+{
+ return m_seed;
+}
+
+void FETurbulence::setSeed(float seed)
+{
+ m_seed = seed;
+}
+
+int FETurbulence::numOctaves() const
+{
+ return m_numOctaves;
+}
+
+void FETurbulence::setNumOctaves(bool numOctaves)
+{
+ m_numOctaves = numOctaves;
+}
+
+bool FETurbulence::stitchTiles() const
+{
+ return m_stitchTiles;
+}
+
+void FETurbulence::setStitchTiles(bool stitch)
+{
+ m_stitchTiles = stitch;
+}
+
+void FETurbulence::apply()
+{
+}
+
+void FETurbulence::dump()
+{
+}
+
+static TextStream& operator<<(TextStream& ts, TurbulanceType t)
+{
+ switch (t)
+ {
+ case FETURBULENCE_TYPE_UNKNOWN:
+ ts << "UNKNOWN"; break;
+ case FETURBULENCE_TYPE_TURBULENCE:
+ ts << "TURBULANCE"; break;
+ case FETURBULENCE_TYPE_FRACTALNOISE:
+ ts << "NOISE"; break;
+ }
+ return ts;
+}
+
+TextStream& FETurbulence::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=TURBULENCE] ";
+ FilterEffect::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..6977460
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGFETurbulence.h
@@ -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.
+*/
+
+#ifndef SVGFETurbulence_h
+#define SVGFETurbulence_h
+
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "FilterEffect.h"
+
+namespace WebCore {
+
+ enum TurbulanceType {
+ FETURBULENCE_TYPE_UNKNOWN = 0,
+ FETURBULENCE_TYPE_FRACTALNOISE = 1,
+ FETURBULENCE_TYPE_TURBULENCE = 2
+ };
+
+ class FETurbulence : public FilterEffect {
+ public:
+ static PassRefPtr<FETurbulence> create(TurbulanceType, const float&, const float&, const int&, const float&,
+ bool);
+
+ TurbulanceType type() const;
+ void setType(TurbulanceType);
+
+ 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 void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FETurbulence(TurbulanceType, const float&, const float&, const int&, const float&,
+ bool);
+
+ TurbulanceType m_type;
+ float m_baseFrequencyX;
+ float m_baseFrequencyY;
+ int m_numOctaves;
+ float m_seed;
+ bool m_stitchTiles;
+ };
+
+} // 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..d497f8b
--- /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 RefCounted<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..77611ca
--- /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& PointLightSource::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=POINT-LIGHT] ";
+ ts << "[position=\"" << position() << "\"]";
+ return ts;
+}
+
+TextStream& SpotLightSource::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=SPOT-LIGHT] ";
+ ts << "[position=\"" << position() << "\"]";
+ ts << "[direction=\"" << direction() << "\"]";
+ ts << "[specularExponent=\"" << specularExponent() << "\"]";
+ ts << "[limitingConeAngle=\"" << limitingConeAngle() << "\"]";
+ return ts;
+}
+
+TextStream& DistantLightSource::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..779e147
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGLightSource.h
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
+ 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)
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ enum LightType {
+ LS_DISTANT,
+ LS_POINT,
+ LS_SPOT
+ };
+
+ class TextStream;
+
+ class LightSource : public RefCounted<LightSource> {
+ public:
+ LightSource(LightType type)
+ : m_type(type)
+ { }
+
+ virtual ~LightSource() { }
+
+ LightType type() const { return m_type; }
+ virtual TextStream& externalRepresentation(TextStream&) const = 0;
+
+ private:
+ LightType 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..099a165
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGPointLightSource.h
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
+ 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 PointLightSource : public LightSource {
+ public:
+ PointLightSource(const FloatPoint3D& position)
+ : LightSource(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..a4aa1fb
--- /dev/null
+++ b/WebCore/svg/graphics/filters/SVGSpotLightSource.h
@@ -0,0 +1,62 @@
+/*
+ Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
+ 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 SpotLightSource : public LightSource {
+ public:
+ SpotLightSource(const FloatPoint3D& position, const FloatPoint3D& direction, float specularExponent, float limitingConeAngle)
+ : LightSource(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/SVGFEHelpersCg.h b/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.h
new file mode 100644
index 0000000..f35e028
--- /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 LightSource;
+
+namespace WebCore {
+
+CIVector* getVectorForChannel(ChannelSelectorType channel);
+CIColor* ciColor(const Color& c);
+
+// Lighting
+CIFilter* getPointLightVectors(CIFilter* normals, CIVector* lightPosition, float surfaceScale);
+CIFilter* getLightVectors(CIFilter* normals, const LightSource* 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..0f2eb75
--- /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(ChannelSelectorType channel)
+{
+ switch (channel) {
+ case CHANNEL_UNKNOWN:
+ return nil;
+ case CHANNEL_R:
+ return [CIVector vectorWithX:1.0f Y:0.0f Z:0.0f W:0.0f];
+ case CHANNEL_G:
+ return [CIVector vectorWithX:0.0f Y:1.0f Z:0.0f W:0.0f];
+ case CHANNEL_B:
+ return [CIVector vectorWithX:0.0f Y:0.0f Z:1.0f W:0.0f];
+ case 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 LightSource* light, float surfaceScale)
+{
+ [WKDistantLightFilter class];
+ [WKPointLightFilter class];
+ [WKSpotLightFilter class];
+
+ CIFilter* filter = nil;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
+ switch (light->type()) {
+ case LS_DISTANT:
+ {
+ const DistantLightSource* dlight = static_cast<const DistantLightSource*>(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 PointLightSource* plight = static_cast<const PointLightSource*>(light);
+ return getPointLightVectors(normals, [CIVector vectorWithX:plight->position().x() Y:plight->position().y() Z:plight->position().z()], surfaceScale);
+ }
+ case LS_SPOT:
+ {
+ const SpotLightSource* slight = static_cast<const SpotLightSource*>(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/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..113f9a7
--- /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);
+
+ const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+ RenderStyle* style = object->style();
+
+ QGradient gradient = setupGradient(context, object);
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(Qt::NoBrush);
+
+ if (spreadMethod() == SpreadMethodRepeat)
+ gradient.setSpread(QGradient::RepeatSpread);
+ else if (spreadMethod() == SpreadMethodReflect)
+ gradient.setSpread(QGradient::ReflectSpread);
+ else
+ gradient.setSpread(QGradient::PadSpread);
+ double opacity = 1.0;
+
+ if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) {
+ fillColorArray(gradient, gradientStops(), opacity);
+
+ QBrush brush(gradient);
+ brush.setMatrix(gradientTransform());
+
+ painter->setBrush(brush);
+ context->setFillRule(svgStyle->fillRule());
+ }
+
+ if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
+ fillColorArray(gradient, gradientStops(), opacity);
+
+ QPen pen;
+ QBrush brush(gradient);
+ brush.setMatrix(gradientTransform());
+ pen.setBrush(brush);
+ painter->setPen(pen);
+
+ applyStrokeStyleToContext(context, style, object);
+ }
+
+ 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..70ec14c
--- /dev/null
+++ b/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp
@@ -0,0 +1,90 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 "AffineTransform.h"
+#include "GraphicsContext.h"
+#include "ImageBuffer.h"
+#include "Pattern.h"
+#include "RenderObject.h"
+#include "SVGPatternElement.h"
+
+#include <QPainter>
+#include <QPainterPath>
+
+namespace WebCore {
+
+bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ Q_ASSERT(context);
+ Q_ASSERT(object);
+
+ FloatRect targetRect = object->relativeBBox(false);
+ m_ownerElement->buildPattern(targetRect);
+
+ if (!tile())
+ return false;
+
+ QPainter* painter = context->platformContext();
+ QPainterPath* path = context->currentPath();
+
+ RenderStyle* style = object->style();
+ const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+
+ RefPtr<Pattern> pattern = Pattern::create(tile()->image(), true, true);
+
+ context->save();
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(Qt::NoBrush);
+
+ AffineTransform affine;
+ affine.translate(patternBoundaries().x(), patternBoundaries().y());
+ affine.multiply(patternTransform());
+
+ QBrush brush(pattern->createPlatformPattern(affine));
+ if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) {
+ painter->setBrush(brush);
+ context->setFillRule(svgStyle->fillRule());
+ }
+
+ if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
+ QPen pen;
+ pen.setBrush(brush);
+ painter->setPen(pen);
+ applyStrokeStyleToContext(context, style, object);
+ }
+
+ return true;
+}
+
+void SVGPaintServerPattern::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const
+{
+ context->restore();
+}
+
+} // 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..801201b
--- /dev/null
+++ b/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp
@@ -0,0 +1,72 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2008 Holger Hans Peter Freyther
+
+ 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::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 ? path->style(): 0;
+
+ QPainter* painter(context ? context->platformContext() : 0);
+ Q_ASSERT(painter);
+
+ QPainterPath* painterPath(context ? context->currentPath() : 0);
+ Q_ASSERT(painterPath);
+
+ if ((type & ApplyToFillTargetType) && (!renderStyle || renderStyle->svgStyle()->hasFill()))
+ painter->fillPath(*painterPath, painter->brush());
+
+ if ((type & ApplyToStrokeTargetType) && (!renderStyle || 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..e088df2
--- /dev/null
+++ b/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2008 Holger Hans Peter Freyther
+
+ 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);
+
+ const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+ RenderStyle* style = object ? object->style() : 0;
+ // TODO? painter->setOpacity(renderStyle->opacity());
+
+ QColor c = color();
+
+ if ((type & ApplyToFillTargetType) && (!style || svgStyle->hasFill())) {
+ if (style)
+ c.setAlphaF(svgStyle->fillOpacity());
+
+ QBrush brush(c);
+ painter->setBrush(brush);
+
+ if (style)
+ context->setFillRule(svgStyle->fillRule());
+
+ /* if(isPaintingText()) ... */
+ }
+
+ if ((type & ApplyToStrokeTargetType) && (!style || svgStyle->hasStroke())) {
+ if (style)
+ c.setAlphaF(svgStyle->strokeOpacity());
+
+ QPen pen(c);
+ painter->setPen(pen);
+ if (style)
+ applyStrokeStyleToContext(context, style, object);
+
+ /* 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..cbf90cd
--- /dev/null
+++ b/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp
@@ -0,0 +1,50 @@
+/*
+ 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_FILTERS)
+#include "SVGResourceFilter.h"
+#include "NotImplemented.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
+
+// 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..f1bd66b
--- /dev/null
+++ b/WebCore/svg/svgattrs.in
@@ -0,0 +1,253 @@
+namespace="SVG"
+namespaceURI="http://www.w3.org/2000/svg"
+guardFactoryWith="ENABLE(SVG)"
+attrsNullNamespace="1"
+exportStrings="1"
+
+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..c9c4fbc
--- /dev/null
+++ b/WebCore/svg/svgtags.in
@@ -0,0 +1,116 @@
+namespace="SVG"
+namespaceURI="http://www.w3.org/2000/svg"
+guardFactoryWith="ENABLE(SVG)"
+exportStrings="1"
+
+a
+#if ENABLE_SVG_FONTS
+altGlyph
+#endif
+#if 0
+altGlyphDef
+altGlyphItem
+#endif
+#if ENABLE_SVG_ANIMATION
+animate
+animateColor
+animateMotion
+animateTransform
+set
+#endif
+circle
+clipPath
+#if 0
+color_profile
+#endif
+cursor
+#if ENABLE_SVG_FONTS
+definition_src
+#endif
+defs
+desc
+ellipse
+#if 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
+#if ENABLE_SVG_FONTS
+font
+font_face
+font_face_format
+font_face_name
+font_face_src
+font_face_uri
+#endif
+#if ENABLE_SVG_FOREIGN_OBJECT
+foreignObject
+#endif
+g
+#if ENABLE_SVG_FONTS
+glyph
+#endif
+#if 0
+glyphRef
+#endif
+#if ENABLE_SVG_FONTS
+hkern interfaceName=HKernElement
+#endif
+image
+line
+linearGradient
+marker
+mask
+metadata
+#if ENABLE_SVG_FONTS
+missing_glyph
+#endif
+mpath interfaceName=MPathElement
+path
+pattern
+polygon
+polyline
+radialGradient
+rect
+script
+stop
+style
+svg interfaceName=SVGElement
+switch
+symbol
+text
+textPath
+title
+tref interfaceName=TRefElement
+tspan interfaceName=TSpanElement
+use
+view
+#if 0
+vkern interfaceName=VKernElement
+#endif
diff --git a/WebCore/svg/xlinkattrs.in b/WebCore/svg/xlinkattrs.in
new file mode 100644
index 0000000..f91fb97
--- /dev/null
+++ b/WebCore/svg/xlinkattrs.in
@@ -0,0 +1,11 @@
+namespace="XLink"
+namespaceURI="http://www.w3.org/1999/xlink"
+exportStrings="1"
+
+actuate
+arcrole
+href
+role
+show
+title
+type