summaryrefslogtreecommitdiffstats
path: root/WebCore/svg
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/svg')
-rw-r--r--WebCore/svg/GradientAttributes.h6
-rw-r--r--WebCore/svg/PatternAttributes.h6
-rw-r--r--WebCore/svg/SVGAElement.cpp4
-rw-r--r--WebCore/svg/SVGAllInOne.cpp152
-rw-r--r--WebCore/svg/SVGAltGlyphElement.cpp4
-rw-r--r--WebCore/svg/SVGAnimateMotionElement.cpp15
-rw-r--r--WebCore/svg/SVGAnimateMotionElement.h2
-rw-r--r--WebCore/svg/SVGAnimateTransformElement.cpp2
-rw-r--r--WebCore/svg/SVGAnimateTransformElement.h2
-rw-r--r--WebCore/svg/SVGAnimationElement.cpp21
-rw-r--r--WebCore/svg/SVGAnimationElement.h2
-rw-r--r--WebCore/svg/SVGColor.cpp4
-rw-r--r--WebCore/svg/SVGCursorElement.cpp12
-rw-r--r--WebCore/svg/SVGCursorElement.h2
-rw-r--r--WebCore/svg/SVGElement.cpp31
-rw-r--r--WebCore/svg/SVGElement.h20
-rw-r--r--WebCore/svg/SVGElementInstance.cpp11
-rw-r--r--WebCore/svg/SVGFEImageElement.cpp6
-rw-r--r--WebCore/svg/SVGFEImageElement.h2
-rw-r--r--WebCore/svg/SVGFitToViewBox.cpp6
-rw-r--r--WebCore/svg/SVGFitToViewBox.h4
-rw-r--r--WebCore/svg/SVGFont.cpp15
-rw-r--r--WebCore/svg/SVGFontFaceElement.cpp3
-rw-r--r--WebCore/svg/SVGFontFaceUriElement.cpp41
-rw-r--r--WebCore/svg/SVGFontFaceUriElement.h17
-rw-r--r--WebCore/svg/SVGForeignObjectElement.cpp2
-rw-r--r--WebCore/svg/SVGGElement.h2
-rw-r--r--WebCore/svg/SVGImageElement.cpp10
-rw-r--r--WebCore/svg/SVGImageElement.h2
-rw-r--r--WebCore/svg/SVGLangSpace.cpp3
-rw-r--r--WebCore/svg/SVGLength.cpp7
-rw-r--r--WebCore/svg/SVGLinearGradientElement.cpp34
-rw-r--r--WebCore/svg/SVGLocatable.cpp24
-rw-r--r--WebCore/svg/SVGLocatable.h12
-rw-r--r--WebCore/svg/SVGMarkerElement.cpp2
-rw-r--r--WebCore/svg/SVGMatrix.idl22
-rw-r--r--WebCore/svg/SVGParserUtilities.cpp127
-rw-r--r--WebCore/svg/SVGPathSegCurvetoCubicSmooth.h2
-rw-r--r--WebCore/svg/SVGPatternElement.cpp4
-rw-r--r--WebCore/svg/SVGPreserveAspectRatio.cpp6
-rw-r--r--WebCore/svg/SVGPreserveAspectRatio.h4
-rw-r--r--WebCore/svg/SVGRadialGradientElement.cpp49
-rw-r--r--WebCore/svg/SVGSVGElement.cpp65
-rw-r--r--WebCore/svg/SVGSVGElement.h10
-rw-r--r--WebCore/svg/SVGScriptElement.cpp15
-rw-r--r--WebCore/svg/SVGScriptElement.h5
-rw-r--r--WebCore/svg/SVGStyleElement.cpp9
-rw-r--r--WebCore/svg/SVGStyleElement.h3
-rw-r--r--WebCore/svg/SVGStyledLocatableElement.cpp6
-rw-r--r--WebCore/svg/SVGStyledLocatableElement.h4
-rw-r--r--WebCore/svg/SVGStyledTransformableElement.cpp17
-rw-r--r--WebCore/svg/SVGStyledTransformableElement.h12
-rw-r--r--WebCore/svg/SVGTextContentElement.cpp5
-rw-r--r--WebCore/svg/SVGTextElement.cpp14
-rw-r--r--WebCore/svg/SVGTextElement.h10
-rw-r--r--WebCore/svg/SVGTextPathElement.cpp4
-rw-r--r--WebCore/svg/SVGTransform.cpp8
-rw-r--r--WebCore/svg/SVGTransform.h12
-rw-r--r--WebCore/svg/SVGTransformDistance.cpp12
-rw-r--r--WebCore/svg/SVGTransformDistance.h6
-rw-r--r--WebCore/svg/SVGTransformList.cpp8
-rw-r--r--WebCore/svg/SVGTransformList.h2
-rw-r--r--WebCore/svg/SVGTransformable.cpp15
-rw-r--r--WebCore/svg/SVGTransformable.h8
-rw-r--r--WebCore/svg/SVGUseElement.cpp24
-rw-r--r--WebCore/svg/animation/SMILTimeContainer.cpp2
-rw-r--r--WebCore/svg/animation/SVGSMILElement.cpp19
-rw-r--r--WebCore/svg/graphics/SVGImage.cpp44
-rw-r--r--WebCore/svg/graphics/SVGImage.h9
-rw-r--r--WebCore/svg/graphics/SVGPaintServer.cpp35
-rw-r--r--WebCore/svg/graphics/SVGPaintServer.h8
-rw-r--r--WebCore/svg/graphics/SVGPaintServerGradient.cpp182
-rw-r--r--WebCore/svg/graphics/SVGPaintServerGradient.h66
-rw-r--r--WebCore/svg/graphics/SVGPaintServerLinearGradient.h4
-rw-r--r--WebCore/svg/graphics/SVGPaintServerPattern.cpp102
-rw-r--r--WebCore/svg/graphics/SVGPaintServerPattern.h16
-rw-r--r--WebCore/svg/graphics/SVGPaintServerRadialGradient.h4
-rw-r--r--WebCore/svg/graphics/SVGPaintServerSolid.cpp32
-rw-r--r--WebCore/svg/graphics/SVGResource.cpp9
-rw-r--r--WebCore/svg/graphics/SVGResourceClipper.cpp39
-rw-r--r--WebCore/svg/graphics/SVGResourceMarker.cpp9
-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/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.mm10
-rw-r--r--WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm1
-rw-r--r--WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m2
-rw-r--r--WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h2
-rw-r--r--WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h2
-rw-r--r--WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm3
-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/skia/SVGResourceFilterSkia.cpp55
-rw-r--r--WebCore/svg/graphics/skia/SVGResourceMaskerSkia.cpp49
-rw-r--r--WebCore/svg/svgattrs.in4
-rw-r--r--WebCore/svg/svgtags.in20
-rw-r--r--WebCore/svg/xlinkattrs.in2
114 files changed, 1210 insertions, 2654 deletions
diff --git a/WebCore/svg/GradientAttributes.h b/WebCore/svg/GradientAttributes.h
index a5f0f37..2d7c32a 100644
--- a/WebCore/svg/GradientAttributes.h
+++ b/WebCore/svg/GradientAttributes.h
@@ -39,12 +39,12 @@ namespace WebCore
GradientSpreadMethod spreadMethod() const { return m_spreadMethod; }
bool boundingBoxMode() const { return m_boundingBoxMode; }
- AffineTransform gradientTransform() const { return m_gradientTransform; }
+ TransformationMatrix 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 setGradientTransform(const TransformationMatrix& 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; }
@@ -56,7 +56,7 @@ namespace WebCore
// Properties
GradientSpreadMethod m_spreadMethod;
bool m_boundingBoxMode;
- AffineTransform m_gradientTransform;
+ TransformationMatrix m_gradientTransform;
Vector<SVGGradientStop> m_stops;
// Property states
diff --git a/WebCore/svg/PatternAttributes.h b/WebCore/svg/PatternAttributes.h
index e6a347c..2940baf 100644
--- a/WebCore/svg/PatternAttributes.h
+++ b/WebCore/svg/PatternAttributes.h
@@ -52,7 +52,7 @@ namespace WebCore
SVGLength height() const { return m_height; }
bool boundingBoxMode() const { return m_boundingBoxMode; }
bool boundingBoxModeContent() const { return m_boundingBoxModeContent; }
- AffineTransform patternTransform() const { return m_patternTransform; }
+ TransformationMatrix patternTransform() const { return m_patternTransform; }
const SVGPatternElement* patternContentElement() const { return m_patternContentElement; }
void setX(const SVGLength& value) { m_x = value; m_xSet = true; }
@@ -61,7 +61,7 @@ namespace WebCore
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 setPatternTransform(const TransformationMatrix& value) { m_patternTransform = value; m_patternTransformSet = true; }
void setPatternContentElement(const SVGPatternElement* value) { m_patternContentElement = value; m_patternContentElementSet = true; }
bool hasX() const { return m_xSet; }
@@ -81,7 +81,7 @@ namespace WebCore
SVGLength m_height;
bool m_boundingBoxMode;
bool m_boundingBoxModeContent;
- AffineTransform m_patternTransform;
+ TransformationMatrix m_patternTransform;
const SVGPatternElement* m_patternContentElement;
// Property states
diff --git a/WebCore/svg/SVGAElement.cpp b/WebCore/svg/SVGAElement.cpp
index 9236af4..c7e055c 100644
--- a/WebCore/svg/SVGAElement.cpp
+++ b/WebCore/svg/SVGAElement.cpp
@@ -96,7 +96,7 @@ void SVGAElement::svgAttributeChanged(const QualifiedName& attrName)
}
}
-RenderObject* SVGAElement::createRenderer(RenderArena* arena, RenderStyle* style)
+RenderObject* SVGAElement::createRenderer(RenderArena* arena, RenderStyle*)
{
if (static_cast<SVGElement*>(parent())->isTextContent())
return new (arena) RenderSVGInline(this);
@@ -151,7 +151,7 @@ void SVGAElement::defaultEventHandler(Event* evt)
}
#endif
if (document()->frame())
- document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt, false, true);
+ document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt, false, false, true);
}
evt->setDefaultHandled();
diff --git a/WebCore/svg/SVGAllInOne.cpp b/WebCore/svg/SVGAllInOne.cpp
new file mode 100644
index 0000000..2e34ee3
--- /dev/null
+++ b/WebCore/svg/SVGAllInOne.cpp
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+// This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
+
+#include "ColorDistance.cpp"
+#include "SVGAElement.cpp"
+#include "SVGAltGlyphElement.cpp"
+#include "SVGAngle.cpp"
+#include "SVGAnimateColorElement.cpp"
+#include "SVGAnimateElement.cpp"
+#include "SVGAnimateMotionElement.cpp"
+#include "SVGAnimateTransformElement.cpp"
+#include "SVGAnimatedPathData.cpp"
+#include "SVGAnimatedPoints.cpp"
+#include "SVGAnimationElement.cpp"
+#include "SVGCircleElement.cpp"
+#include "SVGClipPathElement.cpp"
+#include "SVGColor.cpp"
+#include "SVGComponentTransferFunctionElement.cpp"
+#include "SVGCursorElement.cpp"
+#include "SVGDefinitionSrcElement.cpp"
+#include "SVGDefsElement.cpp"
+#include "SVGDescElement.cpp"
+#include "SVGDocument.cpp"
+#include "SVGDocumentExtensions.cpp"
+#include "SVGElement.cpp"
+#include "SVGElementInstance.cpp"
+#include "SVGElementInstanceList.cpp"
+#include "SVGEllipseElement.cpp"
+#include "SVGExternalResourcesRequired.cpp"
+#include "SVGFEBlendElement.cpp"
+#include "SVGFEColorMatrixElement.cpp"
+#include "SVGFEComponentTransferElement.cpp"
+#include "SVGFECompositeElement.cpp"
+#include "SVGFEDiffuseLightingElement.cpp"
+#include "SVGFEDisplacementMapElement.cpp"
+#include "SVGFEDistantLightElement.cpp"
+#include "SVGFEFloodElement.cpp"
+#include "SVGFEFuncAElement.cpp"
+#include "SVGFEFuncBElement.cpp"
+#include "SVGFEFuncGElement.cpp"
+#include "SVGFEFuncRElement.cpp"
+#include "SVGFEGaussianBlurElement.cpp"
+#include "SVGFEImageElement.cpp"
+#include "SVGFELightElement.cpp"
+#include "SVGFEMergeElement.cpp"
+#include "SVGFEMergeNodeElement.cpp"
+#include "SVGFEOffsetElement.cpp"
+#include "SVGFEPointLightElement.cpp"
+#include "SVGFESpecularLightingElement.cpp"
+#include "SVGFESpotLightElement.cpp"
+#include "SVGFETileElement.cpp"
+#include "SVGFETurbulenceElement.cpp"
+#include "SVGFilterElement.cpp"
+#include "SVGFilterPrimitiveStandardAttributes.cpp"
+#include "SVGFitToViewBox.cpp"
+#include "SVGFont.cpp"
+#include "SVGFontData.cpp"
+#include "SVGFontElement.cpp"
+#include "SVGFontFaceFormatElement.cpp"
+#include "SVGFontFaceNameElement.cpp"
+#include "SVGFontFaceSrcElement.cpp"
+#include "SVGFontFaceUriElement.cpp"
+#include "SVGForeignObjectElement.cpp"
+#include "SVGGElement.cpp"
+#include "SVGGradientElement.cpp"
+#include "SVGImageElement.cpp"
+#include "SVGImageLoader.cpp"
+#include "SVGLangSpace.cpp"
+#include "SVGLength.cpp"
+#include "SVGLengthList.cpp"
+#include "SVGLineElement.cpp"
+#include "SVGLinearGradientElement.cpp"
+#include "SVGLocatable.cpp"
+#include "SVGMPathElement.cpp"
+#include "SVGMarkerElement.cpp"
+#include "SVGMetadataElement.cpp"
+#include "SVGMissingGlyphElement.cpp"
+#include "SVGNumberList.cpp"
+#include "SVGPaint.cpp"
+#include "SVGParserUtilities.cpp"
+#include "SVGPathElement.cpp"
+#include "SVGPathSegArc.cpp"
+#include "SVGPathSegClosePath.cpp"
+#include "SVGPathSegCurvetoCubic.cpp"
+#include "SVGPathSegCurvetoCubicSmooth.cpp"
+#include "SVGPathSegCurvetoQuadratic.cpp"
+#include "SVGPathSegCurvetoQuadraticSmooth.cpp"
+#include "SVGPathSegLineto.cpp"
+#include "SVGPathSegLinetoHorizontal.cpp"
+#include "SVGPathSegLinetoVertical.cpp"
+#include "SVGPathSegList.cpp"
+#include "SVGPathSegMoveto.cpp"
+#include "SVGPatternElement.cpp"
+#include "SVGPointList.cpp"
+#include "SVGPolyElement.cpp"
+#include "SVGPolygonElement.cpp"
+#include "SVGPolylineElement.cpp"
+#include "SVGPreserveAspectRatio.cpp"
+#include "SVGRadialGradientElement.cpp"
+#include "SVGRectElement.cpp"
+#include "SVGSVGElement.cpp"
+#include "SVGScriptElement.cpp"
+#include "SVGSetElement.cpp"
+#include "SVGStopElement.cpp"
+#include "SVGStringList.cpp"
+#include "SVGStylable.cpp"
+#include "SVGStyledLocatableElement.cpp"
+#include "SVGStyledTransformableElement.cpp"
+#include "SVGSwitchElement.cpp"
+#include "SVGSymbolElement.cpp"
+#include "SVGTRefElement.cpp"
+#include "SVGTSpanElement.cpp"
+#include "SVGTests.cpp"
+#include "SVGTextContentElement.cpp"
+#include "SVGTextElement.cpp"
+#include "SVGTextPathElement.cpp"
+#include "SVGTextPositioningElement.cpp"
+#include "SVGTitleElement.cpp"
+#include "SVGTransform.cpp"
+#include "SVGTransformDistance.cpp"
+#include "SVGTransformList.cpp"
+#include "SVGTransformable.cpp"
+#include "SVGURIReference.cpp"
+#include "SVGUseElement.cpp"
+#include "SVGViewElement.cpp"
+#include "SVGViewSpec.cpp"
+#include "SVGZoomAndPan.cpp"
+#include "SVGZoomEvent.cpp"
diff --git a/WebCore/svg/SVGAltGlyphElement.cpp b/WebCore/svg/SVGAltGlyphElement.cpp
index e88e9b9..d9da3f6 100644
--- a/WebCore/svg/SVGAltGlyphElement.cpp
+++ b/WebCore/svg/SVGAltGlyphElement.cpp
@@ -42,7 +42,7 @@ SVGAltGlyphElement::~SVGAltGlyphElement()
{
}
-void SVGAltGlyphElement::setGlyphRef(const AtomicString& type, ExceptionCode& ec)
+void SVGAltGlyphElement::setGlyphRef(const AtomicString&, ExceptionCode& ec)
{
ec = NO_MODIFICATION_ALLOWED_ERR;
}
@@ -52,7 +52,7 @@ const AtomicString& SVGAltGlyphElement::glyphRef() const
return getAttribute(SVGNames::glyphRefAttr);
}
-void SVGAltGlyphElement::setFormat(const AtomicString& type, ExceptionCode& ec)
+void SVGAltGlyphElement::setFormat(const AtomicString&, ExceptionCode& ec)
{
ec = NO_MODIFICATION_ALLOWED_ERR;
}
diff --git a/WebCore/svg/SVGAnimateMotionElement.cpp b/WebCore/svg/SVGAnimateMotionElement.cpp
index 60ffc47..b6422f5 100644
--- a/WebCore/svg/SVGAnimateMotionElement.cpp
+++ b/WebCore/svg/SVGAnimateMotionElement.cpp
@@ -32,6 +32,7 @@
#include "SVGPathElement.h"
#include "SVGTransformList.h"
#include <math.h>
+#include <wtf/StdLibExtras.h>
namespace WebCore {
@@ -91,8 +92,8 @@ void SVGAnimateMotionElement::parseMappedAttribute(MappedAttribute* attr)
SVGAnimateMotionElement::RotateMode SVGAnimateMotionElement::rotateMode() const
{
- static const AtomicString autoVal("auto");
- static const AtomicString autoReverse("auto-reverse");
+ DEFINE_STATIC_LOCAL(const AtomicString, autoVal, ("auto"));
+ DEFINE_STATIC_LOCAL(const AtomicString, autoReverse, ("auto-reverse"));
String rotate = getAttribute(SVGNames::rotateAttr);
if (rotate == autoVal)
return RotateAuto;
@@ -146,7 +147,7 @@ void SVGAnimateMotionElement::resetToBaseValue(const String&)
if (!hasValidTarget())
return;
SVGElement* target = targetElement();
- AffineTransform* transform = target->supplementalTransform();
+ TransformationMatrix* transform = target->supplementalTransform();
if (!transform)
return;
transform->reset();
@@ -168,12 +169,12 @@ bool SVGAnimateMotionElement::calculateFromAndByValues(const String& fromString,
return true;
}
-void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement*)
+void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned, SVGSMILElement*)
{
SVGElement* target = targetElement();
if (!target)
return;
- AffineTransform* transform = target->supplementalTransform();
+ TransformationMatrix* transform = target->supplementalTransform();
if (!transform)
return;
@@ -217,8 +218,8 @@ void SVGAnimateMotionElement::applyResultsToTarget()
for (HashSet<SVGElementInstance*>::iterator it = instances.begin(); it != end; ++it) {
SVGElement* shadowTreeElement = (*it)->shadowTreeElement();
ASSERT(shadowTreeElement);
- AffineTransform* transform = shadowTreeElement->supplementalTransform();
- AffineTransform* t = targetElement->supplementalTransform();
+ TransformationMatrix* transform = shadowTreeElement->supplementalTransform();
+ TransformationMatrix* t = targetElement->supplementalTransform();
transform->setMatrix(t->a(), t->b(), t->c(), t->d(), t->e(), t->f());
if (shadowTreeElement->renderer())
shadowTreeElement->renderer()->setNeedsLayout(true);
diff --git a/WebCore/svg/SVGAnimateMotionElement.h b/WebCore/svg/SVGAnimateMotionElement.h
index ff58264..910ef17 100644
--- a/WebCore/svg/SVGAnimateMotionElement.h
+++ b/WebCore/svg/SVGAnimateMotionElement.h
@@ -25,7 +25,7 @@
#if ENABLE(SVG_ANIMATION)
#include "SVGAnimationElement.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "Path.h"
namespace WebCore {
diff --git a/WebCore/svg/SVGAnimateTransformElement.cpp b/WebCore/svg/SVGAnimateTransformElement.cpp
index c5b4e9d..99e4c42 100644
--- a/WebCore/svg/SVGAnimateTransformElement.cpp
+++ b/WebCore/svg/SVGAnimateTransformElement.cpp
@@ -26,7 +26,7 @@
#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
#include "SVGAnimateTransformElement.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "RenderObject.h"
#include "SVGAngle.h"
#include "SVGElementInstance.h"
diff --git a/WebCore/svg/SVGAnimateTransformElement.h b/WebCore/svg/SVGAnimateTransformElement.h
index 3c31d17..9b1f192 100644
--- a/WebCore/svg/SVGAnimateTransformElement.h
+++ b/WebCore/svg/SVGAnimateTransformElement.h
@@ -32,7 +32,7 @@
namespace WebCore {
- class AffineTransform;
+ class TransformationMatrix;
class SVGAnimateTransformElement : public SVGAnimationElement {
public:
diff --git a/WebCore/svg/SVGAnimationElement.cpp b/WebCore/svg/SVGAnimationElement.cpp
index 5910ac8..649b74d 100644
--- a/WebCore/svg/SVGAnimationElement.cpp
+++ b/WebCore/svg/SVGAnimationElement.cpp
@@ -40,6 +40,7 @@
#include "SVGUseElement.h"
#include "XLinkNames.h"
#include <math.h>
+#include <wtf/StdLibExtras.h>
using namespace std;
@@ -158,7 +159,7 @@ bool SVGAnimationElement::beginElement(ExceptionCode& ec)
return beginElementAt(0, ec);
}
-bool SVGAnimationElement::beginElementAt(float offset, ExceptionCode& ec)
+bool SVGAnimationElement::beginElementAt(float offset, ExceptionCode&)
{
addBeginTime(elapsed() + offset);
return true;
@@ -169,7 +170,7 @@ bool SVGAnimationElement::endElement(ExceptionCode& ec)
return endElementAt(0, ec);
}
-bool SVGAnimationElement::endElementAt(float offset, ExceptionCode& ec)
+bool SVGAnimationElement::endElementAt(float offset, ExceptionCode&)
{
if (offset < 0)
return false;
@@ -196,10 +197,10 @@ SVGAnimationElement::AnimationMode SVGAnimationElement::animationMode() const
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");
+ DEFINE_STATIC_LOCAL(const AtomicString, discrete, ("discrete"));
+ DEFINE_STATIC_LOCAL(const AtomicString, linear, ("linear"));
+ DEFINE_STATIC_LOCAL(const AtomicString, paced, ("paced"));
+ DEFINE_STATIC_LOCAL(const AtomicString, spline, ("spline"));
const AtomicString& value = getAttribute(SVGNames::calcModeAttr);
if (value == discrete)
return CalcModeDiscrete;
@@ -214,8 +215,8 @@ SVGAnimationElement::CalcMode SVGAnimationElement::calcMode() const
SVGAnimationElement::AttributeType SVGAnimationElement::attributeType() const
{
- static const AtomicString css("CSS");
- static const AtomicString xml("XML");
+ DEFINE_STATIC_LOCAL(const AtomicString, css, ("CSS"));
+ DEFINE_STATIC_LOCAL(const AtomicString, xml, ("XML"));
const AtomicString& value = getAttribute(SVGNames::attributeTypeAttr);
if (value == css)
return AttributeTypeCSS;
@@ -241,14 +242,14 @@ String SVGAnimationElement::fromValue() const
bool SVGAnimationElement::isAdditive() const
{
- static const AtomicString sum("sum");
+ DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum"));
const AtomicString& value = getAttribute(SVGNames::additiveAttr);
return value == sum || animationMode() == ByAnimation;
}
bool SVGAnimationElement::isAccumulated() const
{
- static const AtomicString sum("sum");
+ DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum"));
const AtomicString& value = getAttribute(SVGNames::accumulateAttr);
return value == sum && animationMode() != ToAnimation;
}
diff --git a/WebCore/svg/SVGAnimationElement.h b/WebCore/svg/SVGAnimationElement.h
index b4d4b78..120beb4 100644
--- a/WebCore/svg/SVGAnimationElement.h
+++ b/WebCore/svg/SVGAnimationElement.h
@@ -99,7 +99,7 @@ namespace WebCore {
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 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;
diff --git a/WebCore/svg/SVGColor.cpp b/WebCore/svg/SVGColor.cpp
index b56a80e..5939b48 100644
--- a/WebCore/svg/SVGColor.cpp
+++ b/WebCore/svg/SVGColor.cpp
@@ -88,12 +88,12 @@ Color SVGColor::colorFromRGBColorString(const String& colorString)
return Color();
}
-void SVGColor::setRGBColorICCColor(const String& /* rgbColor */, const String& /* iccColor */, ExceptionCode& ec)
+void SVGColor::setRGBColorICCColor(const String& /* rgbColor */, const String& /* iccColor */, ExceptionCode&)
{
// TODO: implement me!
}
-void SVGColor::setColor(unsigned short colorType, const String& /* rgbColor */ , const String& /* iccColor */, ExceptionCode& ec)
+void SVGColor::setColor(unsigned short colorType, const String& /* rgbColor */ , const String& /* iccColor */, ExceptionCode&)
{
// TODO: implement me!
m_colorType = colorType;
diff --git a/WebCore/svg/SVGCursorElement.cpp b/WebCore/svg/SVGCursorElement.cpp
index 161a061..8ff9735 100644
--- a/WebCore/svg/SVGCursorElement.cpp
+++ b/WebCore/svg/SVGCursorElement.cpp
@@ -26,6 +26,7 @@
#include "SVGCursorElement.h"
#include "Attr.h"
+#include "Document.h"
#include "SVGNames.h"
#include "SVGLength.h"
@@ -43,6 +44,9 @@ SVGCursorElement::SVGCursorElement(const QualifiedName& tagName, Document* doc)
SVGCursorElement::~SVGCursorElement()
{
+ HashSet<SVGElement*>::iterator end = m_clients.end();
+ for (HashSet<SVGElement*>::iterator it = m_clients.begin(); it != end; ++it)
+ (*it)->setCursorElement(0);
}
void SVGCursorElement::parseMappedAttribute(MappedAttribute* attr)
@@ -66,11 +70,13 @@ void SVGCursorElement::parseMappedAttribute(MappedAttribute* attr)
void SVGCursorElement::addClient(SVGElement* element)
{
m_clients.add(element);
+ element->setCursorElement(this);
}
void SVGCursorElement::removeClient(SVGElement* element)
{
m_clients.remove(element);
+ element->setCursorElement(0);
}
void SVGCursorElement::svgAttributeChanged(const QualifiedName& attrName)
@@ -89,9 +95,11 @@ void SVGCursorElement::svgAttributeChanged(const QualifiedName& attrName)
}
}
-void SVGCursorElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+void SVGCursorElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
{
- urls.append(href());
+ SVGElement::addSubresourceAttributeURLs(urls);
+
+ addSubresourceURL(urls, document()->completeURL(href()));
}
}
diff --git a/WebCore/svg/SVGCursorElement.h b/WebCore/svg/SVGCursorElement.h
index d8d7eba..ddafb76 100644
--- a/WebCore/svg/SVGCursorElement.h
+++ b/WebCore/svg/SVGCursorElement.h
@@ -48,7 +48,7 @@ namespace WebCore {
virtual void parseMappedAttribute(MappedAttribute*);
virtual void svgAttributeChanged(const QualifiedName&);
- virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+ virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
protected:
virtual const SVGElement* contextElement() const { return this; }
diff --git a/WebCore/svg/SVGElement.cpp b/WebCore/svg/SVGElement.cpp
index 9ecfe7d..7f54dd0 100644
--- a/WebCore/svg/SVGElement.cpp
+++ b/WebCore/svg/SVGElement.cpp
@@ -25,6 +25,7 @@
#if ENABLE(SVG)
#include "SVGElement.h"
+#include "CSSCursorImageValue.h"
#include "DOMImplementation.h"
#include "Document.h"
#include "Event.h"
@@ -33,7 +34,9 @@
#include "FrameView.h"
#include "HTMLNames.h"
#include "PlatformString.h"
+#include "RegisteredEventListener.h"
#include "RenderObject.h"
+#include "SVGCursorElement.h"
#include "SVGDocumentExtensions.h"
#include "SVGElementInstance.h"
#include "SVGNames.h"
@@ -42,7 +45,6 @@
#include "SVGURIReference.h"
#include "SVGUseElement.h"
#include "XMLNames.h"
-#include "RegisteredEventListener.h"
namespace WebCore {
@@ -51,11 +53,17 @@ using namespace HTMLNames;
SVGElement::SVGElement(const QualifiedName& tagName, Document* doc)
: StyledElement(tagName, doc)
, m_shadowParent(0)
+ , m_cursorElement(0)
+ , m_cursorImageValue(0)
{
}
SVGElement::~SVGElement()
{
+ if (m_cursorElement)
+ m_cursorElement->removeClient(this);
+ if (m_cursorImageValue)
+ m_cursorImageValue->removeReferencedElement(this);
}
bool SVGElement::isSupported(StringImpl* feature, StringImpl* version) const
@@ -180,13 +188,12 @@ 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;
+ const RegisteredEventListenerVector& listeners = static_cast<Element*>(currentNode)->eventListeners();
+ size_t size = listeners.size();
+ for (size_t i = 0; i < size; ++i) {
+ const RegisteredEventListener& r = *listeners[i];
+ if (r.eventType() == eventNames().loadEvent && r.useCapture() || currentNode == node)
+ return true;
}
currentNode = currentNode->parentNode();
}
@@ -204,8 +211,7 @@ void SVGElement::sendSVGLoadEventIfPossible(bool sendParentLoadEvents)
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->dispatchGenericEvent(event.release());
}
currentTarget = (parent && parent->isSVGElement()) ? static_pointer_cast<SVGElement>(parent) : 0;
}
@@ -281,6 +287,11 @@ void SVGElement::setSynchronizedSVGAttributes(bool value) const
m_areSVGAttributesValid = value;
}
+ContainerNode* SVGElement::eventParentNode()
+{
+ return m_shadowParent ? m_shadowParent : StyledElement::eventParentNode();
+}
+
}
#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGElement.h b/WebCore/svg/SVGElement.h
index 0223bf7..aed7e59 100644
--- a/WebCore/svg/SVGElement.h
+++ b/WebCore/svg/SVGElement.h
@@ -30,10 +30,12 @@
namespace WebCore {
- class AffineTransform;
+ class TransformationMatrix;
+ class CSSCursorImageValue;
class Document;
- class SVGElementInstance;
+ class SVGCursorElement;
class SVGDocumentExtensions;
+ class SVGElementInstance;
class SVGSVGElement;
class SVGElement : public StyledElement {
@@ -64,8 +66,8 @@ namespace WebCore {
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(); }
+ void setShadowParentNode(ContainerNode* node) { m_shadowParent = node; }
+ virtual ContainerNode* eventParentNode();
// For SVGTests
virtual bool isValid() const { return true; }
@@ -82,7 +84,7 @@ namespace WebCore {
void sendSVGLoadEventIfPossible(bool sendParentLoadEvents = false);
- virtual AffineTransform* supplementalTransform() { return 0; }
+ virtual TransformationMatrix* supplementalTransform() { return 0; }
virtual void updateAnimatedSVGAttribute(const String&) const;
virtual void setSynchronizedSVGAttributes(bool) const;
@@ -117,6 +119,9 @@ namespace WebCore {
m_svgPropertyMap.set(attrName.localName(), &base);
}
+ void setCursorElement(SVGCursorElement* cursorElement) { m_cursorElement = cursorElement; }
+ void setCursorImageValue(CSSCursorImageValue* cursorImageValue) { m_cursorImageValue = cursorImageValue; }
+
private:
friend class SVGElementInstance;
@@ -125,9 +130,12 @@ namespace WebCore {
virtual bool haveLoadedRequiredResources();
- Node* m_shadowParent;
+ ContainerNode* m_shadowParent;
mutable HashMap<String, const SVGAnimatedPropertyBase*> m_svgPropertyMap;
+ SVGCursorElement* m_cursorElement;
+ CSSCursorImageValue* m_cursorImageValue;
+
HashSet<SVGElementInstance*> m_elementInstances;
};
diff --git a/WebCore/svg/SVGElementInstance.cpp b/WebCore/svg/SVGElementInstance.cpp
index e548900..b5fa984 100644
--- a/WebCore/svg/SVGElementInstance.cpp
+++ b/WebCore/svg/SVGElementInstance.cpp
@@ -31,12 +31,15 @@
#include "EventListener.h"
#include "EventNames.h"
#include "FrameView.h"
-#include "GCController.h"
#include "SVGElementInstanceList.h"
#include "SVGUseElement.h"
#include <wtf/RefCountedLeakCounter.h>
+#if USE(JSC)
+#include "GCController.h"
+#endif
+
namespace WebCore {
#ifndef NDEBUG
@@ -88,6 +91,7 @@ void SVGElementInstance::setShadowTreeElement(SVGElement* element)
void SVGElementInstance::forgetWrapper()
{
+#if USE(JSC)
// 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.
@@ -95,7 +99,8 @@ void SVGElementInstance::forgetWrapper()
// 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();
+ gcController().garbageCollectNow();
+#endif
}
void SVGElementInstance::appendChild(PassRefPtr<SVGElementInstance> child)
@@ -164,7 +169,7 @@ bool SVGElementInstance::dispatchEvent(PassRefPtr<Event> e, ExceptionCode& ec)
evt->setTarget(this);
RefPtr<FrameView> view = element->document()->view();
- return element->dispatchGenericEvent(evt.release(), ec);
+ return element->dispatchGenericEvent(evt.release());
}
EventListener* SVGElementInstance::onabort() const
diff --git a/WebCore/svg/SVGFEImageElement.cpp b/WebCore/svg/SVGFEImageElement.cpp
index e19ee78..3ceb560 100644
--- a/WebCore/svg/SVGFEImageElement.cpp
+++ b/WebCore/svg/SVGFEImageElement.cpp
@@ -103,9 +103,11 @@ bool SVGFEImageElement::build(FilterBuilder* builder)
return true;
}
-void SVGFEImageElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+void SVGFEImageElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
{
- urls.append(href());
+ SVGFilterPrimitiveStandardAttributes::addSubresourceAttributeURLs(urls);
+
+ addSubresourceURL(urls, document()->completeURL(href()));
}
}
diff --git a/WebCore/svg/SVGFEImageElement.h b/WebCore/svg/SVGFEImageElement.h
index dc88c0a..98d5941 100644
--- a/WebCore/svg/SVGFEImageElement.h
+++ b/WebCore/svg/SVGFEImageElement.h
@@ -46,7 +46,7 @@ namespace WebCore {
virtual void parseMappedAttribute(MappedAttribute*);
virtual void notifyFinished(CachedResource*);
- virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+ virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
bool build(FilterBuilder*);
protected:
diff --git a/WebCore/svg/SVGFitToViewBox.cpp b/WebCore/svg/SVGFitToViewBox.cpp
index 69e077e..13e4c03 100644
--- a/WebCore/svg/SVGFitToViewBox.cpp
+++ b/WebCore/svg/SVGFitToViewBox.cpp
@@ -25,7 +25,7 @@
#if ENABLE(SVG)
#include "SVGFitToViewBox.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "Document.h"
#include "FloatRect.h"
#include "SVGNames.h"
@@ -80,11 +80,11 @@ bool SVGFitToViewBox::parseViewBox(const UChar*& c, const UChar* end, float& x,
return true;
}
-AffineTransform SVGFitToViewBox::viewBoxToViewTransform(float viewWidth, float viewHeight) const
+TransformationMatrix SVGFitToViewBox::viewBoxToViewTransform(float viewWidth, float viewHeight) const
{
FloatRect viewBoxRect = viewBox();
if (!viewBoxRect.width() || !viewBoxRect.height())
- return AffineTransform();
+ return TransformationMatrix();
return preserveAspectRatio()->getCTM(viewBoxRect.x(),
viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(),
diff --git a/WebCore/svg/SVGFitToViewBox.h b/WebCore/svg/SVGFitToViewBox.h
index cc612ec..ac03df4 100644
--- a/WebCore/svg/SVGFitToViewBox.h
+++ b/WebCore/svg/SVGFitToViewBox.h
@@ -31,7 +31,7 @@ namespace WebCore {
extern char SVGFitToViewBoxIdentifier[];
- class AffineTransform;
+ class TransformationMatrix;
class SVGFitToViewBox {
public:
@@ -39,7 +39,7 @@ namespace WebCore {
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;
+ virtual TransformationMatrix viewBoxToViewTransform(float viewWidth, float viewHeight) const;
bool parseMappedAttribute(MappedAttribute*);
bool isKnownAttribute(const QualifiedName&);
diff --git a/WebCore/svg/SVGFont.cpp b/WebCore/svg/SVGFont.cpp
index ece667f..3dae585 100644
--- a/WebCore/svg/SVGFont.cpp
+++ b/WebCore/svg/SVGFont.cpp
@@ -340,7 +340,7 @@ struct SVGTextRunWalkerMeasuredLengthData {
const Font* font;
};
-bool floatWidthUsingSVGFontCallback(const SVGGlyphIdentifier& identifier, SVGTextRunWalkerMeasuredLengthData& data)
+static bool floatWidthUsingSVGFontCallback(const SVGGlyphIdentifier& identifier, SVGTextRunWalkerMeasuredLengthData& data)
{
if (data.at >= data.from && data.at < data.to)
data.length += identifier.horizontalAdvanceX * data.scale;
@@ -349,7 +349,7 @@ bool floatWidthUsingSVGFontCallback(const SVGGlyphIdentifier& identifier, SVGTex
return data.at < data.to;
}
-void floatWidthMissingGlyphCallback(const TextRun& run, SVGTextRunWalkerMeasuredLengthData& data)
+static void floatWidthMissingGlyphCallback(const TextRun& run, SVGTextRunWalkerMeasuredLengthData& data)
{
// Handle system font fallback
FontDescription fontDescription(data.font->fontDescription());
@@ -442,13 +442,13 @@ struct SVGTextRunWalkerDrawTextData {
Vector<UChar> fallbackCharacters;
};
-bool drawTextUsingSVGFontCallback(const SVGGlyphIdentifier& identifier, SVGTextRunWalkerDrawTextData& data)
+static bool drawTextUsingSVGFontCallback(const SVGGlyphIdentifier& identifier, SVGTextRunWalkerDrawTextData& data)
{
data.glyphIdentifiers.append(identifier);
return true;
}
-void drawTextMissingGlyphCallback(const TextRun& run, SVGTextRunWalkerDrawTextData& data)
+static void drawTextMissingGlyphCallback(const TextRun& run, SVGTextRunWalkerDrawTextData& data)
{
ASSERT(run.length() == 1);
data.glyphIdentifiers.append(SVGGlyphIdentifier());
@@ -506,6 +506,7 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
}
data.extraCharsAvailable = 0;
+ data.charsConsumed = 0;
SVGTextRunWalker<SVGTextRunWalkerDrawTextData> runWalker(fontData, fontElement, data, drawTextUsingSVGFontCallback, drawTextMissingGlyphCallback);
runWalker.walk(run, isVerticalText, language, from, to);
@@ -552,10 +553,10 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
currentPoint.move(identifier.horizontalAdvanceX * scale, 0.0f);
} else {
// Handle system font fallback
- FontDescription fontDescription(context->font().fontDescription());
+ FontDescription fontDescription(m_fontDescription);
fontDescription.setFamily(FontFamily());
Font font(fontDescription, 0, 0); // spacing handled by SVG text code.
- font.update(context->font().fontSelector());
+ font.update(fontSelector());
TextRun fallbackCharacterRun(run);
fallbackCharacterRun.setText(&data.fallbackCharacters[run.rtl() ? data.fallbackCharacters.size() - fallbackCharacterIndex - 1 : fallbackCharacterIndex], 1);
@@ -581,7 +582,7 @@ FloatRect Font::selectionRectForTextUsingSVGFont(const TextRun& run, const IntPo
point.y(), floatWidthOfSubStringUsingSVGFont(this, run, 0, from, to, charsConsumed, glyphName), height);
}
-int Font::offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const
+int Font::offsetForPositionForTextUsingSVGFont(const TextRun&, int, bool) 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.
diff --git a/WebCore/svg/SVGFontFaceElement.cpp b/WebCore/svg/SVGFontFaceElement.cpp
index 21fd277..973e890 100644
--- a/WebCore/svg/SVGFontFaceElement.cpp
+++ b/WebCore/svg/SVGFontFaceElement.cpp
@@ -34,6 +34,7 @@
#include "CSSValueKeywords.h"
#include "CSSValueList.h"
#include "Document.h"
+#include "Font.h"
#include "SVGDefinitionSrcElement.h"
#include "SVGFontElement.h"
#include "SVGFontFaceSrcElement.h"
@@ -133,7 +134,7 @@ unsigned SVGFontFaceElement::unitsPerEm() const
{
const AtomicString& value = getAttribute(units_per_emAttr);
if (value.isEmpty())
- return 1000;
+ return defaultUnitsPerEm;
return static_cast<unsigned>(ceilf(value.toFloat()));
}
diff --git a/WebCore/svg/SVGFontFaceUriElement.cpp b/WebCore/svg/SVGFontFaceUriElement.cpp
index 7f6c6d2..3509691 100644
--- a/WebCore/svg/SVGFontFaceUriElement.cpp
+++ b/WebCore/svg/SVGFontFaceUriElement.cpp
@@ -1,5 +1,6 @@
/*
Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ Copyright (C) 2009 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
@@ -23,6 +24,9 @@
#include "SVGFontFaceUriElement.h"
#include "CSSFontFaceSrcValue.h"
+#include "CachedFont.h"
+#include "DocLoader.h"
+#include "Document.h"
#include "SVGFontFaceElement.h"
#include "SVGNames.h"
#include "XLinkNames.h"
@@ -36,6 +40,12 @@ SVGFontFaceUriElement::SVGFontFaceUriElement(const QualifiedName& tagName, Docum
{
}
+SVGFontFaceUriElement::~SVGFontFaceUriElement()
+{
+ if (m_cachedFont)
+ m_cachedFont->removeClient(this);
+}
+
PassRefPtr<CSSFontFaceSrcValue> SVGFontFaceUriElement::srcValue() const
{
RefPtr<CSSFontFaceSrcValue> src = CSSFontFaceSrcValue::create(getAttribute(XLinkNames::hrefAttr));
@@ -44,6 +54,15 @@ PassRefPtr<CSSFontFaceSrcValue> SVGFontFaceUriElement::srcValue() const
return src.release();
}
+void SVGFontFaceUriElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ const QualifiedName& attrName = attr->name();
+ if (attrName == XLinkNames::hrefAttr)
+ loadFont();
+ else
+ SVGElement::parseMappedAttribute(attr);
+}
+
void SVGFontFaceUriElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
{
SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
@@ -56,6 +75,28 @@ void SVGFontFaceUriElement::childrenChanged(bool changedByParser, Node* beforeCh
static_cast<SVGFontFaceElement*>(grandParent)->rebuildFontFace();
}
+void SVGFontFaceUriElement::insertedIntoDocument()
+{
+ loadFont();
+ SVGElement::insertedIntoDocument();
+}
+
+void SVGFontFaceUriElement::loadFont()
+{
+ if (m_cachedFont)
+ m_cachedFont->removeClient(this);
+
+ String href = getAttribute(XLinkNames::hrefAttr);
+ if (!href.isNull()) {
+ DocLoader* docLoader = document()->docLoader();
+ m_cachedFont = docLoader->requestFont(href);
+ m_cachedFont->setSVGFont(true);
+ m_cachedFont->addClient(this);
+ m_cachedFont->beginLoadIfNeeded(docLoader);
+ } else
+ m_cachedFont = 0;
+}
+
}
#endif // ENABLE(SVG_FONTS)
diff --git a/WebCore/svg/SVGFontFaceUriElement.h b/WebCore/svg/SVGFontFaceUriElement.h
index cdeb743..1d880e5 100644
--- a/WebCore/svg/SVGFontFaceUriElement.h
+++ b/WebCore/svg/SVGFontFaceUriElement.h
@@ -21,17 +21,30 @@
#define SVGFontFaceUriElement_h
#if ENABLE(SVG_FONTS)
+#include "CachedResourceClient.h"
+#include "CachedResourceHandle.h"
#include "SVGElement.h"
namespace WebCore {
+
class CSSFontFaceSrcValue;
- class SVGFontFaceUriElement : public SVGElement {
+ class CachedFont;
+
+ class SVGFontFaceUriElement : public SVGElement, public CachedResourceClient {
public:
SVGFontFaceUriElement(const QualifiedName&, Document*);
+ ~SVGFontFaceUriElement();
PassRefPtr<CSSFontFaceSrcValue> srcValue() const;
-
+
+ virtual void parseMappedAttribute(MappedAttribute*);
virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+ virtual void insertedIntoDocument();
+
+ private:
+ void loadFont();
+
+ CachedResourceHandle<CachedFont> m_cachedFont;
};
} // namespace WebCore
diff --git a/WebCore/svg/SVGForeignObjectElement.cpp b/WebCore/svg/SVGForeignObjectElement.cpp
index f7c4582..342a6f0 100644
--- a/WebCore/svg/SVGForeignObjectElement.cpp
+++ b/WebCore/svg/SVGForeignObjectElement.cpp
@@ -151,7 +151,7 @@ void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName)
renderer()->setNeedsLayout(true);
}
-RenderObject* SVGForeignObjectElement::createRenderer(RenderArena* arena, RenderStyle* style)
+RenderObject* SVGForeignObjectElement::createRenderer(RenderArena* arena, RenderStyle*)
{
return new (arena) RenderForeignObject(this);
}
diff --git a/WebCore/svg/SVGGElement.h b/WebCore/svg/SVGGElement.h
index fe52d05..8e3b368 100644
--- a/WebCore/svg/SVGGElement.h
+++ b/WebCore/svg/SVGGElement.h
@@ -52,7 +52,7 @@ namespace WebCore {
private:
friend class SVGUseElement;
- AffineTransform localMatrix() const;
+ TransformationMatrix localMatrix() const;
};
} // namespace WebCore
diff --git a/WebCore/svg/SVGImageElement.cpp b/WebCore/svg/SVGImageElement.cpp
index d7daebc..c827c89 100644
--- a/WebCore/svg/SVGImageElement.cpp
+++ b/WebCore/svg/SVGImageElement.cpp
@@ -108,7 +108,7 @@ void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName)
renderer()->setNeedsLayout(true);
if (isURIAttribute)
- m_imageLoader.updateFromElement();
+ m_imageLoader.updateFromElementIgnoringPreviousError();
}
}
@@ -118,7 +118,7 @@ bool SVGImageElement::hasRelativeValues() const
y().isRelative() || height().isRelative());
}
-RenderObject* SVGImageElement::createRenderer(RenderArena* arena, RenderStyle* style)
+RenderObject* SVGImageElement::createRenderer(RenderArena* arena, RenderStyle*)
{
return new (arena) RenderSVGImage(this);
}
@@ -154,9 +154,11 @@ const QualifiedName& SVGImageElement::imageSourceAttributeName() const
return XLinkNames::hrefAttr;
}
-void SVGImageElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+void SVGImageElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
{
- urls.append(href());
+ SVGStyledTransformableElement::addSubresourceAttributeURLs(urls);
+
+ addSubresourceURL(urls, document()->completeURL(href()));
}
}
diff --git a/WebCore/svg/SVGImageElement.h b/WebCore/svg/SVGImageElement.h
index bddfddd..1d242b5 100644
--- a/WebCore/svg/SVGImageElement.h
+++ b/WebCore/svg/SVGImageElement.h
@@ -56,7 +56,7 @@ namespace WebCore {
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual const QualifiedName& imageSourceAttributeName() const;
- virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+ virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
protected:
virtual bool haveLoadedRequiredResources();
diff --git a/WebCore/svg/SVGLangSpace.cpp b/WebCore/svg/SVGLangSpace.cpp
index 638f0c1..099934d 100644
--- a/WebCore/svg/SVGLangSpace.cpp
+++ b/WebCore/svg/SVGLangSpace.cpp
@@ -27,6 +27,7 @@
#include "SVGElement.h"
#include "XMLNames.h"
+#include <wtf/StdLibExtras.h>
namespace WebCore {
@@ -51,7 +52,7 @@ void SVGLangSpace::setXmllang(const AtomicString& xmlLang)
const AtomicString& SVGLangSpace::xmlspace() const
{
if (!m_space) {
- static const AtomicString defaultString("default");
+ DEFINE_STATIC_LOCAL(const AtomicString, defaultString, ("default"));
return defaultString;
}
diff --git a/WebCore/svg/SVGLength.cpp b/WebCore/svg/SVGLength.cpp
index 86714f9..d1b8856 100644
--- a/WebCore/svg/SVGLength.cpp
+++ b/WebCore/svg/SVGLength.cpp
@@ -301,8 +301,11 @@ float SVGLength::PercentageOfViewport(float value, const SVGElement* context, SV
}
} else if (context->parent() && !context->parent()->isSVGElement()) {
if (RenderObject* renderer = context->renderer()) {
- width = renderer->width();
- height = renderer->height();
+ if (renderer->isBox()) {
+ RenderBox* box = toRenderBox(renderer);
+ width = box->width();
+ height = box->height();
+ }
}
}
diff --git a/WebCore/svg/SVGLinearGradientElement.cpp b/WebCore/svg/SVGLinearGradientElement.cpp
index 04469a9..ac2b6b1 100644
--- a/WebCore/svg/SVGLinearGradientElement.cpp
+++ b/WebCore/svg/SVGLinearGradientElement.cpp
@@ -1,8 +1,8 @@
/*
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
+ 2008 Eric Seidel <eric@webkit.org>
+ 2008 Dirk Schulze <krit@webkit.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -81,18 +81,36 @@ void SVGLinearGradientElement::buildGradient() const
{
LinearGradientAttributes attributes = collectGradientProperties();
- // If we didn't find any gradient containing stop elements, ignore the request.
+ RefPtr<SVGPaintServerLinearGradient> linearGradient = WTF::static_pointer_cast<SVGPaintServerLinearGradient>(m_resource);
+
+ FloatPoint startPoint = FloatPoint::narrowPrecision(attributes.x1(), attributes.y1());
+ FloatPoint endPoint = FloatPoint::narrowPrecision(attributes.x2(), attributes.y2());
+
+ RefPtr<Gradient> gradient = Gradient::create(startPoint, endPoint);
+
+ Vector<SVGGradientStop> m_stops = attributes.stops();
+ float previousOffset = 0.0f;
+ for (unsigned i = 0; i < m_stops.size(); ++i) {
+ float offset = std::min(std::max(previousOffset, m_stops[i].first), 1.0f);
+ previousOffset = offset;
+ gradient->addColorStop(offset, m_stops[i].second);
+ }
+
+ linearGradient->setGradient(gradient);
+
if (attributes.stops().isEmpty())
return;
- RefPtr<SVGPaintServerLinearGradient> linearGradient = WTF::static_pointer_cast<SVGPaintServerLinearGradient>(m_resource);
-
- linearGradient->setGradientStops(attributes.stops());
+ // This code should go away. PaintServers should go away too.
+ // Only this code should care about bounding boxes
linearGradient->setBoundingBoxMode(attributes.boundingBoxMode());
+ linearGradient->setGradientStops(attributes.stops());
+
+ // These should possibly be supported on Gradient
linearGradient->setGradientSpreadMethod(attributes.spreadMethod());
linearGradient->setGradientTransform(attributes.gradientTransform());
- linearGradient->setGradientStart(FloatPoint::narrowPrecision(attributes.x1(), attributes.y1()));
- linearGradient->setGradientEnd(FloatPoint::narrowPrecision(attributes.x2(), attributes.y2()));
+ linearGradient->setGradientStart(startPoint);
+ linearGradient->setGradientEnd(endPoint);
}
LinearGradientAttributes SVGLinearGradientElement::collectGradientProperties() const
diff --git a/WebCore/svg/SVGLocatable.cpp b/WebCore/svg/SVGLocatable.cpp
index 956a4f9..002bf28 100644
--- a/WebCore/svg/SVGLocatable.cpp
+++ b/WebCore/svg/SVGLocatable.cpp
@@ -25,7 +25,7 @@
#include "SVGLocatable.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "RenderPath.h"
#include "SVGException.h"
#include "SVGSVGElement.h"
@@ -98,18 +98,18 @@ FloatRect SVGLocatable::getBBox(const SVGElement* e)
return bboxRect;
}
-AffineTransform SVGLocatable::getCTM(const SVGElement* element)
+TransformationMatrix SVGLocatable::getCTM(const SVGElement* element)
{
if (!element)
- return AffineTransform();
+ return TransformationMatrix();
- AffineTransform ctm;
+ TransformationMatrix 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();
+ TransformationMatrix parentCTM = static_cast<SVGStyledLocatableElement*>(parentElement)->getCTM();
ctm = parentCTM * ctm;
}
}
@@ -117,18 +117,18 @@ AffineTransform SVGLocatable::getCTM(const SVGElement* element)
return ctm;
}
-AffineTransform SVGLocatable::getScreenCTM(const SVGElement* element)
+TransformationMatrix SVGLocatable::getScreenCTM(const SVGElement* element)
{
if (!element)
- return AffineTransform();
+ return TransformationMatrix();
- AffineTransform ctm;
+ TransformationMatrix 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();
+ TransformationMatrix parentCTM = static_cast<SVGStyledLocatableElement*>(parentElement)->getScreenCTM();
ctm = parentCTM * ctm;
}
}
@@ -136,12 +136,12 @@ AffineTransform SVGLocatable::getScreenCTM(const SVGElement* element)
return ctm;
}
-AffineTransform SVGLocatable::getTransformToElement(SVGElement* target, ExceptionCode& ec) const
+TransformationMatrix SVGLocatable::getTransformToElement(SVGElement* target, ExceptionCode& ec) const
{
- AffineTransform ctm = getCTM();
+ TransformationMatrix ctm = getCTM();
if (target && target->isStyledLocatable()) {
- AffineTransform targetCTM = static_cast<SVGStyledLocatableElement*>(target)->getCTM();
+ TransformationMatrix targetCTM = static_cast<SVGStyledLocatableElement*>(target)->getCTM();
if (!targetCTM.isInvertible()) {
ec = SVGException::SVG_MATRIX_NOT_INVERTABLE;
return ctm;
diff --git a/WebCore/svg/SVGLocatable.h b/WebCore/svg/SVGLocatable.h
index b1601ce..ccb9072 100644
--- a/WebCore/svg/SVGLocatable.h
+++ b/WebCore/svg/SVGLocatable.h
@@ -29,7 +29,7 @@
namespace WebCore {
- class AffineTransform;
+ class TransformationMatrix;
class FloatRect;
class SVGElement;
@@ -43,17 +43,17 @@ namespace WebCore {
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;
+ virtual TransformationMatrix getCTM() const = 0;
+ virtual TransformationMatrix getScreenCTM() const = 0;
+ TransformationMatrix 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*);
+ static TransformationMatrix getCTM(const SVGElement*);
+ static TransformationMatrix getScreenCTM(const SVGElement*);
};
} // namespace WebCore
diff --git a/WebCore/svg/SVGMarkerElement.cpp b/WebCore/svg/SVGMarkerElement.cpp
index 6145f7c..a89c478 100644
--- a/WebCore/svg/SVGMarkerElement.cpp
+++ b/WebCore/svg/SVGMarkerElement.cpp
@@ -183,7 +183,7 @@ SVGResource* SVGMarkerElement::canvasResource()
return m_marker.get();
}
-RenderObject* SVGMarkerElement::createRenderer(RenderArena* arena, RenderStyle* style)
+RenderObject* SVGMarkerElement::createRenderer(RenderArena* arena, RenderStyle*)
{
RenderSVGViewportContainer* markerContainer = new (arena) RenderSVGViewportContainer(this);
markerContainer->setDrawsContents(false); // Marker contents will be explicitly drawn.
diff --git a/WebCore/svg/SVGMatrix.idl b/WebCore/svg/SVGMatrix.idl
index efc5459..cb8c08b 100644
--- a/WebCore/svg/SVGMatrix.idl
+++ b/WebCore/svg/SVGMatrix.idl
@@ -24,9 +24,9 @@
module svg {
- interface [Conditional=SVG, PODType=AffineTransform] SVGMatrix {
+ interface [Conditional=SVG, PODType=TransformationMatrix] SVGMatrix {
// FIXME: these attributes should all be floats but since we implement
- // AffineTransform with doubles setting these as doubles makes more sense.
+ // TransformationMatrix with doubles setting these as doubles makes more sense.
attribute double a;
attribute double b;
attribute double c;
@@ -34,19 +34,19 @@ module svg {
attribute double e;
attribute double f;
- [Custom] SVGMatrix multiply(in SVGMatrix secondMatrix);
+ [Immutable] 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);
+ [Immutable] SVGMatrix translate(in float x, in float y);
+ [Immutable] SVGMatrix scale(in float scaleFactor);
+ [Immutable] SVGMatrix scaleNonUniform(in float scaleFactorX, in float scaleFactorY);
+ [Immutable] 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);
+ [Immutable] SVGMatrix flipX();
+ [Immutable] SVGMatrix flipY();
+ [Immutable] SVGMatrix skewX(in float angle);
+ [Immutable] SVGMatrix skewY(in float angle);
};
}
diff --git a/WebCore/svg/SVGParserUtilities.cpp b/WebCore/svg/SVGParserUtilities.cpp
index 894af80..7d93f59 100644
--- a/WebCore/svg/SVGParserUtilities.cpp
+++ b/WebCore/svg/SVGParserUtilities.cpp
@@ -1,8 +1,8 @@
-/* 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.
+ Copyrigth (C) 2007, 2009 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
@@ -203,8 +203,7 @@ bool pointsListFromSVGData(SVGPointList* pointsList, const String& points)
* 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
- {
+ class SVGPathParser {
public:
virtual ~SVGPathParser() { }
bool parseSVG(const String& d, bool process = false);
@@ -212,23 +211,21 @@ bool pointsListFromSVGData(SVGPointList* pointsList, const String& points)
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 svgLineToHorizontal(double, 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 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();
@@ -672,13 +669,16 @@ void SVGPathParser::calculateArc(bool relative, double& curx, double& cury, doub
cury += y;
}
-class PathBuilder : public SVGPathParser
-{
+class PathBuilder : private SVGPathParser {
public:
bool build(Path* path, const String& d)
{
- m_path = path;
- return parseSVG(d, true);
+ Path temporaryPath;
+ m_path = &temporaryPath;
+ if (!parseSVG(d, true))
+ return false;
+ temporaryPath.swap(*path);
+ return true;
}
private:
@@ -712,6 +712,7 @@ private:
{
m_path->closeSubpath();
}
+
Path* m_path;
FloatPoint current;
};
@@ -722,118 +723,106 @@ bool pathFromSVGData(Path& path, const String& d)
return builder.build(&path, d);
}
-class SVGPathSegListBuilder : public SVGPathParser
-{
+class SVGPathSegListBuilder : private SVGPathParser {
public:
bool build(SVGPathSegList* segList, const String& d, bool process)
{
- m_pathSegList = segList;
- return parseSVG(d, process);
+ if (!parseSVG(d, process))
+ return false;
+ size_t size = m_vector.size();
+ for (size_t i = 0; i < size; ++i) {
+ ExceptionCode ec;
+ segList->appendItem(m_vector[i].release(), ec);
+ }
+ m_vector.clear();
+ return true;
}
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);
+ m_vector.append(SVGPathElement::createSVGPathSegMovetoAbs(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1)));
else
- m_pathSegList->appendItem(SVGPathElement::createSVGPathSegMovetoRel(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1)), ec);
+ m_vector.append(SVGPathElement::createSVGPathSegMovetoRel(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1)));
}
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);
+ m_vector.append(SVGPathElement::createSVGPathSegLinetoAbs(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1)));
else
- m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoRel(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1)), ec);
+ m_vector.append(SVGPathElement::createSVGPathSegLinetoRel(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1)));
}
virtual void svgLineToHorizontal(double x, bool abs)
{
- ExceptionCode ec = 0;
-
if (abs)
- m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoHorizontalAbs(narrowPrecisionToFloat(x)), ec);
+ m_vector.append(SVGPathElement::createSVGPathSegLinetoHorizontalAbs(narrowPrecisionToFloat(x)));
else
- m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoHorizontalRel(narrowPrecisionToFloat(x)), ec);
+ m_vector.append(SVGPathElement::createSVGPathSegLinetoHorizontalRel(narrowPrecisionToFloat(x)));
}
virtual void svgLineToVertical(double y, bool abs)
{
- ExceptionCode ec = 0;
-
if (abs)
- m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoVerticalAbs(narrowPrecisionToFloat(y)), ec);
+ m_vector.append(SVGPathElement::createSVGPathSegLinetoVerticalAbs(narrowPrecisionToFloat(y)));
else
- m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoVerticalRel(narrowPrecisionToFloat(y)), ec);
+ m_vector.append(SVGPathElement::createSVGPathSegLinetoVerticalRel(narrowPrecisionToFloat(y)));
}
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),
+ m_vector.append(SVGPathElement::createSVGPathSegCurvetoCubicAbs(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y),
narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1),
- narrowPrecisionToFloat(x2), narrowPrecisionToFloat(y2)), ec);
+ narrowPrecisionToFloat(x2), narrowPrecisionToFloat(y2)));
else
- m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoCubicRel(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y),
+ m_vector.append(SVGPathElement::createSVGPathSegCurvetoCubicRel(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y),
narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1),
- narrowPrecisionToFloat(x2), narrowPrecisionToFloat(y2)), ec);
+ narrowPrecisionToFloat(x2), narrowPrecisionToFloat(y2)));
}
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);
+ m_vector.append(SVGPathElement::createSVGPathSegCurvetoCubicSmoothAbs(narrowPrecisionToFloat(x2), narrowPrecisionToFloat(y2),
+ narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)));
else
- m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoCubicSmoothRel(narrowPrecisionToFloat(x2), narrowPrecisionToFloat(y2),
- narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)), ec);
+ m_vector.append(SVGPathElement::createSVGPathSegCurvetoCubicSmoothRel(narrowPrecisionToFloat(x2), narrowPrecisionToFloat(y2),
+ narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)));
}
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);
+ m_vector.append(SVGPathElement::createSVGPathSegCurvetoQuadraticAbs(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1),
+ narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)));
else
- m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoQuadraticRel(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1),
- narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)), ec);
+ m_vector.append(SVGPathElement::createSVGPathSegCurvetoQuadraticRel(narrowPrecisionToFloat(x1), narrowPrecisionToFloat(y1),
+ narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)));
}
virtual void svgCurveToQuadraticSmooth(double x, double y, bool abs)
{
- ExceptionCode ec = 0;
-
if (abs)
- m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothAbs(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)), ec);
+ m_vector.append(SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothAbs(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)));
else
- m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothRel(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)), ec);
+ m_vector.append(SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothRel(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)));
}
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),
+ m_vector.append(SVGPathElement::createSVGPathSegArcAbs(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y),
narrowPrecisionToFloat(r1), narrowPrecisionToFloat(r2),
- narrowPrecisionToFloat(angle), largeArcFlag, sweepFlag), ec);
+ narrowPrecisionToFloat(angle), largeArcFlag, sweepFlag));
else
- m_pathSegList->appendItem(SVGPathElement::createSVGPathSegArcRel(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y),
+ m_vector.append(SVGPathElement::createSVGPathSegArcRel(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y),
narrowPrecisionToFloat(r1), narrowPrecisionToFloat(r2),
- narrowPrecisionToFloat(angle), largeArcFlag, sweepFlag), ec);
+ narrowPrecisionToFloat(angle), largeArcFlag, sweepFlag));
}
virtual void svgClosePath()
{
- ExceptionCode ec = 0;
- m_pathSegList->appendItem(SVGPathElement::createSVGPathSegClosePath(), ec);
+ m_vector.append(SVGPathElement::createSVGPathSegClosePath());
}
- SVGPathSegList* m_pathSegList;
+
+ Vector<RefPtr<SVGPathSeg> > m_vector;
};
-bool pathSegListFromSVGData(SVGPathSegList* path , const String& d, bool process)
+bool pathSegListFromSVGData(SVGPathSegList* path, const String& d, bool process)
{
SVGPathSegListBuilder builder;
return builder.build(path, d, process);
diff --git a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h
index 8b8998c..816ba0f 100644
--- a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h
+++ b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h
@@ -32,7 +32,7 @@ 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) {}
+ : m_x(x), m_y(y), m_x2(x2), m_y2(y2) { }
virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg %.6lg %.6lg", m_x2, m_y2, m_x, m_y); }
diff --git a/WebCore/svg/SVGPatternElement.cpp b/WebCore/svg/SVGPatternElement.cpp
index e8ddb7c..5d21b94 100644
--- a/WebCore/svg/SVGPatternElement.cpp
+++ b/WebCore/svg/SVGPatternElement.cpp
@@ -25,7 +25,7 @@
#if ENABLE(SVG)
#include "SVGPatternElement.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "Document.h"
#include "FloatConversion.h"
#include "GraphicsContext.h"
@@ -195,7 +195,7 @@ void SVGPatternElement::buildPattern(const FloatRect& targetRect) const
}
}
- AffineTransform viewBoxCTM = viewBoxToViewTransform(patternBoundaries.width(), patternBoundaries.height());
+ TransformationMatrix viewBoxCTM = viewBoxToViewTransform(patternBoundaries.width(), patternBoundaries.height());
FloatRect patternBoundariesIncludingOverflow = patternBoundaries;
// Apply objectBoundingBoxMode fixup for patternContentUnits, if viewBox is not set.
diff --git a/WebCore/svg/SVGPreserveAspectRatio.cpp b/WebCore/svg/SVGPreserveAspectRatio.cpp
index cde4966..9c9e110 100644
--- a/WebCore/svg/SVGPreserveAspectRatio.cpp
+++ b/WebCore/svg/SVGPreserveAspectRatio.cpp
@@ -25,7 +25,7 @@
#if ENABLE(SVG)
#include "SVGPreserveAspectRatio.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "SVGParserUtilities.h"
#include "SVGSVGElement.h"
@@ -164,12 +164,12 @@ bail_out:
return ret;
}
-AffineTransform SVGPreserveAspectRatio::getCTM(double logicX, double logicY,
+TransformationMatrix SVGPreserveAspectRatio::getCTM(double logicX, double logicY,
double logicWidth, double logicHeight,
double /*physX*/, double /*physY*/,
double physWidth, double physHeight)
{
- AffineTransform temp;
+ TransformationMatrix temp;
if (align() == SVG_PRESERVEASPECTRATIO_UNKNOWN)
return temp;
diff --git a/WebCore/svg/SVGPreserveAspectRatio.h b/WebCore/svg/SVGPreserveAspectRatio.h
index 0dfe940..a0100ff 100644
--- a/WebCore/svg/SVGPreserveAspectRatio.h
+++ b/WebCore/svg/SVGPreserveAspectRatio.h
@@ -32,7 +32,7 @@
namespace WebCore {
class String;
- class AffineTransform;
+ class TransformationMatrix;
class SVGStyledElement;
class SVGPreserveAspectRatio : public RefCounted<SVGPreserveAspectRatio> {
@@ -67,7 +67,7 @@ namespace WebCore {
void setMeetOrSlice(unsigned short);
unsigned short meetOrSlice() const;
- AffineTransform getCTM(double logicX, double logicY,
+ TransformationMatrix getCTM(double logicX, double logicY,
double logicWidth, double logicHeight,
double physX, double physY,
double physWidth, double physHeight);
diff --git a/WebCore/svg/SVGRadialGradientElement.cpp b/WebCore/svg/SVGRadialGradientElement.cpp
index 1f25ffb..4f4fd8f 100644
--- a/WebCore/svg/SVGRadialGradientElement.cpp
+++ b/WebCore/svg/SVGRadialGradientElement.cpp
@@ -1,8 +1,8 @@
/*
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
+ 2008 Eric Seidel <eric@webkit.org>
+ 2008 Dirk Schulze <krit@webkit.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -89,19 +89,52 @@ void SVGRadialGradientElement::buildGradient() const
{
RadialGradientAttributes attributes = collectGradientProperties();
- // If we didn't find any gradient containing stop elements, ignore the request.
+ RefPtr<SVGPaintServerRadialGradient> radialGradient = WTF::static_pointer_cast<SVGPaintServerRadialGradient>(m_resource);
+
+ double adjustedFocusX = attributes.fx();
+ double adjustedFocusY = attributes.fy();
+
+ double fdx = attributes.fx() - attributes.cx();
+ double fdy = attributes.fy() - attributes.cy();
+
+ // 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) > attributes.r()) {
+ double angle = atan2(attributes.fy() * 100.0, attributes.fx() * 100.0);
+ adjustedFocusX = cos(angle) * attributes.r();
+ adjustedFocusY = sin(angle) * attributes.r();
+ }
+
+ FloatPoint focalPoint = FloatPoint::narrowPrecision(attributes.fx(), attributes.fy());
+ FloatPoint centerPoint = FloatPoint::narrowPrecision(attributes.cx(), attributes.cy());
+
+ RefPtr<Gradient> gradient = Gradient::create(
+ FloatPoint::narrowPrecision(adjustedFocusX, adjustedFocusY),
+ 0.f, // SVG does not support a "focus radius"
+ centerPoint,
+ narrowPrecisionToFloat(attributes.r()));
+
+ Vector<SVGGradientStop> stops = attributes.stops();
+ float previousOffset = 0.0f;
+ for (unsigned i = 0; i < stops.size(); ++i) {
+ float offset = std::min(std::max(previousOffset, stops[i].first), 1.0f);
+ previousOffset = offset;
+ gradient->addColorStop(offset, stops[i].second);
+ }
+
+ radialGradient->setGradient(gradient);
+
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->setGradientCenter(centerPoint);
+ radialGradient->setGradientFocal(focalPoint);
radialGradient->setGradientRadius(narrowPrecisionToFloat(attributes.r()));
+ radialGradient->setGradientStops(attributes.stops());
}
RadialGradientAttributes SVGRadialGradientElement::collectGradientProperties() const
diff --git a/WebCore/svg/SVGSVGElement.cpp b/WebCore/svg/SVGSVGElement.cpp
index 23a1fd9..27f11aa 100644
--- a/WebCore/svg/SVGSVGElement.cpp
+++ b/WebCore/svg/SVGSVGElement.cpp
@@ -24,7 +24,7 @@
#if ENABLE(SVG)
#include "SVGSVGElement.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "CSSHelper.h"
#include "CSSPropertyNames.h"
#include "Document.h"
@@ -47,6 +47,7 @@
#include "SVGZoomEvent.h"
#include "SelectionController.h"
#include "SMILTimeContainer.h"
+#include <wtf/StdLibExtras.h>
namespace WebCore {
@@ -89,7 +90,7 @@ SVGSVGElement::~SVGSVGElement()
const AtomicString& SVGSVGElement::contentScriptType() const
{
- static const AtomicString defaultValue("text/ecmascript");
+ DEFINE_STATIC_LOCAL(const AtomicString, defaultValue, ("text/ecmascript"));
const AtomicString& n = getAttribute(contentScriptTypeAttr);
return n.isNull() ? defaultValue : n;
}
@@ -101,7 +102,7 @@ void SVGSVGElement::setContentScriptType(const AtomicString& type)
const AtomicString& SVGSVGElement::contentStyleType() const
{
- static const AtomicString defaultValue("text/css");
+ DEFINE_STATIC_LOCAL(const AtomicString, defaultValue, ("text/css"));
const AtomicString& n = getAttribute(contentStyleTypeAttr);
return n.isNull() ? defaultValue : n;
}
@@ -121,7 +122,7 @@ FloatRect SVGSVGElement::viewport() const
}
float w = width().value(this);
float h = height().value(this);
- AffineTransform viewBox = viewBoxToViewTransform(w, h);
+ TransformationMatrix viewBox = viewBoxToViewTransform(w, h);
double wDouble = w;
double hDouble = h;
viewBox.map(_x, _y, &_x, &_y);
@@ -291,7 +292,7 @@ unsigned long SVGSVGElement::suspendRedraw(unsigned long /* max_wait_millisecond
return 0;
}
-void SVGSVGElement::unsuspendRedraw(unsigned long /* suspend_handle_id */, ExceptionCode& ec)
+void SVGSVGElement::unsuspendRedraw(unsigned long /* suspend_handle_id */, ExceptionCode&)
{
// if suspend_handle_id is not found, throw exception
// FIXME: Implement me (see bug 11275)
@@ -307,19 +308,19 @@ void SVGSVGElement::forceRedraw()
// FIXME: Implement me (see bug 11275)
}
-NodeList* SVGSVGElement::getIntersectionList(const FloatRect& rect, SVGElement*)
+NodeList* SVGSVGElement::getIntersectionList(const FloatRect&, SVGElement*)
{
// FIXME: Implement me (see bug 11274)
return 0;
}
-NodeList* SVGSVGElement::getEnclosureList(const FloatRect& rect, SVGElement*)
+NodeList* SVGSVGElement::getEnclosureList(const FloatRect&, SVGElement*)
{
// FIXME: Implement me (see bug 11274)
return 0;
}
-bool SVGSVGElement::checkIntersection(SVGElement* element, const FloatRect& rect)
+bool SVGSVGElement::checkIntersection(SVGElement*, const FloatRect& rect)
{
// TODO : take into account pointer-events?
// FIXME: Why is element ignored??
@@ -327,7 +328,7 @@ bool SVGSVGElement::checkIntersection(SVGElement* element, const FloatRect& rect
return rect.intersects(getBBox());
}
-bool SVGSVGElement::checkEnclosure(SVGElement* element, const FloatRect& rect)
+bool SVGSVGElement::checkEnclosure(SVGElement*, const FloatRect& rect)
{
// TODO : take into account pointer-events?
// FIXME: Why is element ignored??
@@ -360,9 +361,9 @@ FloatPoint SVGSVGElement::createSVGPoint()
return FloatPoint();
}
-AffineTransform SVGSVGElement::createSVGMatrix()
+TransformationMatrix SVGSVGElement::createSVGMatrix()
{
- return AffineTransform();
+ return TransformationMatrix();
}
FloatRect SVGSVGElement::createSVGRect()
@@ -375,50 +376,46 @@ SVGTransform SVGSVGElement::createSVGTransform()
return SVGTransform();
}
-SVGTransform SVGSVGElement::createSVGTransformFromMatrix(const AffineTransform& matrix)
+SVGTransform SVGSVGElement::createSVGTransformFromMatrix(const TransformationMatrix& matrix)
{
return SVGTransform(matrix);
}
-AffineTransform SVGSVGElement::getCTM() const
+TransformationMatrix SVGSVGElement::getCTM() const
{
- AffineTransform mat;
+ TransformationMatrix 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));
+ TransformationMatrix viewBox = viewBoxToViewTransform(width().value(this), height().value(this));
mat = viewBox * mat;
}
return mat;
}
-AffineTransform SVGSVGElement::getScreenCTM() const
+TransformationMatrix SVGSVGElement::getScreenCTM() const
{
document()->updateLayoutIgnorePendingStylesheets();
- float rootX = 0.0f;
- float rootY = 0.0f;
-
+ FloatPoint rootLocation;
+
if (RenderObject* renderer = this->renderer()) {
if (isOutermostSVG()) {
- int tx = 0;
- int ty = 0;
+ // FIXME: This doesn't work correctly with CSS transforms.
+ FloatPoint point;
if (renderer->parent())
- renderer->absolutePosition(tx, ty, true);
- rootX += tx;
- rootY += ty;
- } else {
- rootX += x().value(this);
- rootY += y().value(this);
- }
+ point = renderer->localToAbsolute(point, true);
+ rootLocation.move(point.x(), point.y());
+ } else
+ rootLocation.move(x().value(this), y().value(this));
}
- AffineTransform mat = SVGStyledLocatableElement::getScreenCTM();
- mat.translate(rootX, rootY);
+ TransformationMatrix mat = SVGStyledLocatableElement::getScreenCTM();
+ mat.translate(rootLocation.x(), rootLocation.y());
if (attributes()->getNamedItem(SVGNames::viewBoxAttr)) {
- AffineTransform viewBox = viewBoxToViewTransform(width().value(this), height().value(this));
+ TransformationMatrix viewBox = viewBoxToViewTransform(width().value(this), height().value(this));
mat = viewBox * mat;
}
@@ -484,7 +481,7 @@ bool SVGSVGElement::isOutermostSVG() const
return !parentNode()->isSVGElement();
}
-AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float viewHeight) const
+TransformationMatrix SVGSVGElement::viewBoxToViewTransform(float viewWidth, float viewHeight) const
{
FloatRect viewBoxRect;
if (useCurrentView()) {
@@ -493,9 +490,9 @@ AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie
} else
viewBoxRect = viewBox();
if (!viewBoxRect.width() || !viewBoxRect.height())
- return AffineTransform();
+ return TransformationMatrix();
- AffineTransform ctm = preserveAspectRatio()->getCTM(viewBoxRect.x(),
+ TransformationMatrix ctm = preserveAspectRatio()->getCTM(viewBoxRect.x(),
viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(),
0, 0, viewWidth, viewHeight);
diff --git a/WebCore/svg/SVGSVGElement.h b/WebCore/svg/SVGSVGElement.h
index bd8b7f9..fe8575b 100644
--- a/WebCore/svg/SVGSVGElement.h
+++ b/WebCore/svg/SVGSVGElement.h
@@ -111,16 +111,16 @@ namespace WebCore
static SVGLength createSVGLength();
static PassRefPtr<SVGAngle> createSVGAngle();
static FloatPoint createSVGPoint();
- static AffineTransform createSVGMatrix();
+ static TransformationMatrix createSVGMatrix();
static FloatRect createSVGRect();
static SVGTransform createSVGTransform();
- static SVGTransform createSVGTransformFromMatrix(const AffineTransform&);
+ static SVGTransform createSVGTransformFromMatrix(const TransformationMatrix&);
virtual void parseMappedAttribute(MappedAttribute*);
// 'virtual SVGLocatable' functions
- virtual AffineTransform getCTM() const;
- virtual AffineTransform getScreenCTM() const;
+ virtual TransformationMatrix getCTM() const;
+ virtual TransformationMatrix getScreenCTM() const;
virtual bool rendererIsNeeded(RenderStyle* style) { return StyledElement::rendererIsNeeded(style); }
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
@@ -130,7 +130,7 @@ namespace WebCore
virtual void svgAttributeChanged(const QualifiedName&);
- virtual AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) const;
+ virtual TransformationMatrix viewBoxToViewTransform(float viewWidth, float viewHeight) const;
void inheritViewAttributes(SVGViewElement*);
diff --git a/WebCore/svg/SVGScriptElement.cpp b/WebCore/svg/SVGScriptElement.cpp
index 3c3a7a3..1b7f4d9 100644
--- a/WebCore/svg/SVGScriptElement.cpp
+++ b/WebCore/svg/SVGScriptElement.cpp
@@ -25,28 +25,25 @@
#if ENABLE(SVG)
#include "SVGScriptElement.h"
+#include "Document.h"
#include "EventNames.h"
#include "SVGNames.h"
namespace WebCore {
-SVGScriptElement::SVGScriptElement(const QualifiedName& tagName, Document* doc)
+SVGScriptElement::SVGScriptElement(const QualifiedName& tagName, Document* doc, bool createdByParser)
: SVGElement(tagName, doc)
, SVGURIReference()
, SVGExternalResourcesRequired()
, m_data(this, this)
{
+ m_data.setCreatedByParser(createdByParser);
}
SVGScriptElement::~SVGScriptElement()
{
}
-void SVGScriptElement::setCreatedByParser(bool createdByParser)
-{
- m_data.setCreatedByParser(createdByParser);
-}
-
String SVGScriptElement::scriptContent() const
{
return m_data.scriptContent();
@@ -144,9 +141,11 @@ String SVGScriptElement::scriptCharset() const
return m_data.scriptCharset();
}
-void SVGScriptElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+void SVGScriptElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
{
- urls.append(href());
+ SVGElement::addSubresourceAttributeURLs(urls);
+
+ addSubresourceURL(urls, document()->completeURL(href()));
}
bool SVGScriptElement::haveLoadedRequiredResources()
diff --git a/WebCore/svg/SVGScriptElement.h b/WebCore/svg/SVGScriptElement.h
index 0475881..090cd2d 100644
--- a/WebCore/svg/SVGScriptElement.h
+++ b/WebCore/svg/SVGScriptElement.h
@@ -36,10 +36,9 @@ namespace WebCore {
, public SVGExternalResourcesRequired
, public ScriptElement {
public:
- SVGScriptElement(const QualifiedName&, Document*);
+ SVGScriptElement(const QualifiedName&, Document*, bool createdByParser);
virtual ~SVGScriptElement();
- void setCreatedByParser(bool);
virtual String scriptContent() const;
virtual void parseMappedAttribute(MappedAttribute*);
@@ -56,7 +55,7 @@ namespace WebCore {
virtual String scriptCharset() const;
- virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+ virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
protected:
virtual const SVGElement* contextElement() const { return this; }
diff --git a/WebCore/svg/SVGStyleElement.cpp b/WebCore/svg/SVGStyleElement.cpp
index 2612de0..2f59680 100644
--- a/WebCore/svg/SVGStyleElement.cpp
+++ b/WebCore/svg/SVGStyleElement.cpp
@@ -30,14 +30,15 @@
#include "ExceptionCode.h"
#include "HTMLNames.h"
#include "XMLNames.h"
+#include <wtf/StdLibExtras.h>
namespace WebCore {
using namespace HTMLNames;
-SVGStyleElement::SVGStyleElement(const QualifiedName& tagName, Document* doc)
+SVGStyleElement::SVGStyleElement(const QualifiedName& tagName, Document* doc, bool createdByParser)
: SVGElement(tagName, doc)
- , m_createdByParser(false)
+ , m_createdByParser(createdByParser)
{
}
@@ -53,7 +54,7 @@ void SVGStyleElement::setXmlspace(const AtomicString&, ExceptionCode& ec)
const AtomicString& SVGStyleElement::type() const
{
- static const AtomicString defaultValue("text/css");
+ DEFINE_STATIC_LOCAL(const AtomicString, defaultValue, ("text/css"));
const AtomicString& n = getAttribute(typeAttr);
return n.isNull() ? defaultValue : n;
}
@@ -65,7 +66,7 @@ void SVGStyleElement::setType(const AtomicString&, ExceptionCode& ec)
const AtomicString& SVGStyleElement::media() const
{
- static const AtomicString defaultValue("all");
+ DEFINE_STATIC_LOCAL(const AtomicString, defaultValue, ("all"));
const AtomicString& n = getAttribute(mediaAttr);
return n.isNull() ? defaultValue : n;
}
diff --git a/WebCore/svg/SVGStyleElement.h b/WebCore/svg/SVGStyleElement.h
index f0774aa..48afdb1 100644
--- a/WebCore/svg/SVGStyleElement.h
+++ b/WebCore/svg/SVGStyleElement.h
@@ -31,7 +31,7 @@ namespace WebCore {
class SVGStyleElement : public SVGElement, public StyleElement {
public:
- SVGStyleElement(const QualifiedName&, Document*);
+ SVGStyleElement(const QualifiedName&, Document*, bool createdByParser);
// Derived from: 'Element'
virtual void parseMappedAttribute(MappedAttribute*);
@@ -39,7 +39,6 @@ namespace WebCore {
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
diff --git a/WebCore/svg/SVGStyledLocatableElement.cpp b/WebCore/svg/SVGStyledLocatableElement.cpp
index eaed36d..39ecb7d 100644
--- a/WebCore/svg/SVGStyledLocatableElement.cpp
+++ b/WebCore/svg/SVGStyledLocatableElement.cpp
@@ -27,7 +27,7 @@
#include "RenderPath.h"
#include "SVGElement.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "SVGSVGElement.h"
namespace WebCore {
@@ -57,12 +57,12 @@ FloatRect SVGStyledLocatableElement::getBBox() const
return SVGLocatable::getBBox(this);
}
-AffineTransform SVGStyledLocatableElement::getCTM() const
+TransformationMatrix SVGStyledLocatableElement::getCTM() const
{
return SVGLocatable::getCTM(this);
}
-AffineTransform SVGStyledLocatableElement::getScreenCTM() const
+TransformationMatrix SVGStyledLocatableElement::getScreenCTM() const
{
return SVGLocatable::getScreenCTM(this);
}
diff --git a/WebCore/svg/SVGStyledLocatableElement.h b/WebCore/svg/SVGStyledLocatableElement.h
index 9af3337..41a034d 100644
--- a/WebCore/svg/SVGStyledLocatableElement.h
+++ b/WebCore/svg/SVGStyledLocatableElement.h
@@ -43,8 +43,8 @@ namespace WebCore {
virtual SVGElement* farthestViewportElement() const;
virtual FloatRect getBBox() const;
- virtual AffineTransform getCTM() const;
- virtual AffineTransform getScreenCTM() const;
+ virtual TransformationMatrix getCTM() const;
+ virtual TransformationMatrix getScreenCTM() const;
};
} // namespace WebCore
diff --git a/WebCore/svg/SVGStyledTransformableElement.cpp b/WebCore/svg/SVGStyledTransformableElement.cpp
index a7b5c41..901ab0f 100644
--- a/WebCore/svg/SVGStyledTransformableElement.cpp
+++ b/WebCore/svg/SVGStyledTransformableElement.cpp
@@ -26,10 +26,9 @@
#include "SVGStyledTransformableElement.h"
#include "Attr.h"
-#include "RegularExpression.h"
#include "RenderPath.h"
#include "SVGDocument.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "SVGStyledElement.h"
#include "SVGTransformList.h"
@@ -48,25 +47,25 @@ SVGStyledTransformableElement::~SVGStyledTransformableElement()
{
}
-AffineTransform SVGStyledTransformableElement::getCTM() const
+TransformationMatrix SVGStyledTransformableElement::getCTM() const
{
return SVGTransformable::getCTM(this);
}
-AffineTransform SVGStyledTransformableElement::getScreenCTM() const
+TransformationMatrix SVGStyledTransformableElement::getScreenCTM() const
{
return SVGTransformable::getScreenCTM(this);
}
-AffineTransform SVGStyledTransformableElement::animatedLocalTransform() const
+TransformationMatrix SVGStyledTransformableElement::animatedLocalTransform() const
{
return m_supplementalTransform ? transform()->concatenate().matrix() * *m_supplementalTransform : transform()->concatenate().matrix();
}
-AffineTransform* SVGStyledTransformableElement::supplementalTransform()
+TransformationMatrix* SVGStyledTransformableElement::supplementalTransform()
{
if (!m_supplementalTransform)
- m_supplementalTransform.set(new AffineTransform());
+ m_supplementalTransform.set(new TransformationMatrix());
return m_supplementalTransform.get();
}
@@ -107,10 +106,10 @@ FloatRect SVGStyledTransformableElement::getBBox() const
return SVGTransformable::getBBox(this);
}
-RenderObject* SVGStyledTransformableElement::createRenderer(RenderArena* arena, RenderStyle* style)
+RenderObject* SVGStyledTransformableElement::createRenderer(RenderArena* arena, RenderStyle*)
{
// By default, any subclass is expected to do path-based drawing
- return new (arena) RenderPath(style, this);
+ return new (arena) RenderPath(this);
}
Path SVGStyledTransformableElement::toClipPath() const
diff --git a/WebCore/svg/SVGStyledTransformableElement.h b/WebCore/svg/SVGStyledTransformableElement.h
index 43ccc68..cf5713e 100644
--- a/WebCore/svg/SVGStyledTransformableElement.h
+++ b/WebCore/svg/SVGStyledTransformableElement.h
@@ -32,7 +32,7 @@ namespace WebCore {
extern char SVGStyledTransformableElementIdentifier[];
- class AffineTransform;
+ class TransformationMatrix;
class SVGStyledTransformableElement : public SVGStyledLocatableElement,
public SVGTransformable {
@@ -42,13 +42,13 @@ namespace WebCore {
virtual bool isStyledTransformable() const { return true; }
- virtual AffineTransform getCTM() const;
- virtual AffineTransform getScreenCTM() const;
+ virtual TransformationMatrix getCTM() const;
+ virtual TransformationMatrix getScreenCTM() const;
virtual SVGElement* nearestViewportElement() const;
virtual SVGElement* farthestViewportElement() const;
- virtual AffineTransform animatedLocalTransform() const;
- virtual AffineTransform* supplementalTransform();
+ virtual TransformationMatrix animatedLocalTransform() const;
+ virtual TransformationMatrix* supplementalTransform();
virtual FloatRect getBBox() const;
@@ -66,7 +66,7 @@ namespace WebCore {
private:
// Used by <animateMotion>
- OwnPtr<AffineTransform> m_supplementalTransform;
+ OwnPtr<TransformationMatrix> m_supplementalTransform;
};
} // namespace WebCore
diff --git a/WebCore/svg/SVGTextContentElement.cpp b/WebCore/svg/SVGTextContentElement.cpp
index e53d662..6057da8 100644
--- a/WebCore/svg/SVGTextContentElement.cpp
+++ b/WebCore/svg/SVGTextContentElement.cpp
@@ -38,6 +38,7 @@
#include "SVGInlineTextBox.h"
#include "SVGNames.h"
#include "XMLNames.h"
+#include <wtf/StdLibExtras.h>
namespace WebCore {
@@ -124,7 +125,7 @@ struct SVGInlineTextBoxQueryWalker {
{
}
- void chunkPortionCallback(SVGInlineTextBox* textBox, int startOffset, const AffineTransform& chunkCtm,
+ void chunkPortionCallback(SVGInlineTextBox* textBox, int startOffset, const TransformationMatrix&,
const Vector<SVGChar>::iterator& start, const Vector<SVGChar>::iterator& end)
{
RenderStyle* style = textBox->textObject()->style();
@@ -498,7 +499,7 @@ void SVGTextContentElement::parseMappedAttribute(MappedAttribute* attr)
return;
if (SVGLangSpace::parseMappedAttribute(attr)) {
if (attr->name().matches(XMLNames::spaceAttr)) {
- static const AtomicString preserveString("preserve");
+ DEFINE_STATIC_LOCAL(const AtomicString, preserveString, ("preserve"));
if (attr->value() == preserveString)
addCSSProperty(attr, CSSPropertyWhiteSpace, CSSValuePre);
diff --git a/WebCore/svg/SVGTextElement.cpp b/WebCore/svg/SVGTextElement.cpp
index 1ace1a9..b2ee798 100644
--- a/WebCore/svg/SVGTextElement.cpp
+++ b/WebCore/svg/SVGTextElement.cpp
@@ -25,7 +25,7 @@
#if ENABLE(SVG)
#include "SVGTextElement.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "FloatRect.h"
#include "RenderSVGText.h"
#include "SVGLengthList.h"
@@ -80,29 +80,29 @@ FloatRect SVGTextElement::getBBox() const
return SVGTransformable::getBBox(this);
}
-AffineTransform SVGTextElement::getScreenCTM() const
+TransformationMatrix SVGTextElement::getScreenCTM() const
{
return SVGTransformable::getScreenCTM(this);
}
-AffineTransform SVGTextElement::getCTM() const
+TransformationMatrix SVGTextElement::getCTM() const
{
return SVGTransformable::getCTM(this);
}
-AffineTransform SVGTextElement::animatedLocalTransform() const
+TransformationMatrix SVGTextElement::animatedLocalTransform() const
{
return m_supplementalTransform ? transform()->concatenate().matrix() * *m_supplementalTransform : transform()->concatenate().matrix();
}
-AffineTransform* SVGTextElement::supplementalTransform()
+TransformationMatrix* SVGTextElement::supplementalTransform()
{
if (!m_supplementalTransform)
- m_supplementalTransform.set(new AffineTransform());
+ m_supplementalTransform.set(new TransformationMatrix());
return m_supplementalTransform.get();
}
-RenderObject* SVGTextElement::createRenderer(RenderArena* arena, RenderStyle* style)
+RenderObject* SVGTextElement::createRenderer(RenderArena* arena, RenderStyle*)
{
return new (arena) RenderSVGText(this);
}
diff --git a/WebCore/svg/SVGTextElement.h b/WebCore/svg/SVGTextElement.h
index 3ae6139..a5cb382 100644
--- a/WebCore/svg/SVGTextElement.h
+++ b/WebCore/svg/SVGTextElement.h
@@ -41,10 +41,10 @@ namespace WebCore {
virtual SVGElement* farthestViewportElement() const;
virtual FloatRect getBBox() const;
- virtual AffineTransform getCTM() const;
- virtual AffineTransform getScreenCTM() const;
- virtual AffineTransform animatedLocalTransform() const;
- virtual AffineTransform* supplementalTransform();
+ virtual TransformationMatrix getCTM() const;
+ virtual TransformationMatrix getScreenCTM() const;
+ virtual TransformationMatrix animatedLocalTransform() const;
+ virtual TransformationMatrix* supplementalTransform();
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual bool childShouldCreateRenderer(Node*) const;
@@ -55,7 +55,7 @@ namespace WebCore {
ANIMATED_PROPERTY_DECLARATIONS(SVGTextElement, SVGNames::textTagString, SVGNames::transformAttrString, SVGTransformList, Transform, transform)
// Used by <animateMotion>
- OwnPtr<AffineTransform> m_supplementalTransform;
+ OwnPtr<TransformationMatrix> m_supplementalTransform;
};
} // namespace WebCore
diff --git a/WebCore/svg/SVGTextPathElement.cpp b/WebCore/svg/SVGTextPathElement.cpp
index d9c5f13..f7f974b 100644
--- a/WebCore/svg/SVGTextPathElement.cpp
+++ b/WebCore/svg/SVGTextPathElement.cpp
@@ -24,7 +24,7 @@
#if ENABLE(SVG)
#include "SVGTextPathElement.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "FloatRect.h"
#include "RenderSVGTextPath.h"
#include "SVGLengthList.h"
@@ -71,7 +71,7 @@ void SVGTextPathElement::parseMappedAttribute(MappedAttribute* attr)
}
}
-RenderObject* SVGTextPathElement::createRenderer(RenderArena* arena, RenderStyle* style)
+RenderObject* SVGTextPathElement::createRenderer(RenderArena* arena, RenderStyle*)
{
return new (arena) RenderSVGTextPath(this);
}
diff --git a/WebCore/svg/SVGTransform.cpp b/WebCore/svg/SVGTransform.cpp
index 86477e4..fac88bd 100644
--- a/WebCore/svg/SVGTransform.cpp
+++ b/WebCore/svg/SVGTransform.cpp
@@ -43,11 +43,11 @@ SVGTransform::SVGTransform(SVGTransformType type)
: m_type(type)
, m_angle(0)
, m_center(FloatPoint())
- , m_matrix(AffineTransform())
+ , m_matrix(TransformationMatrix())
{
}
-SVGTransform::SVGTransform(const AffineTransform& matrix)
+SVGTransform::SVGTransform(const TransformationMatrix& matrix)
: m_type(SVG_TRANSFORM_MATRIX)
, m_angle(0)
, m_matrix(matrix)
@@ -68,7 +68,7 @@ SVGTransform::SVGTransformType SVGTransform::type() const
return m_type;
}
-AffineTransform SVGTransform::matrix() const
+TransformationMatrix SVGTransform::matrix() const
{
return m_matrix;
}
@@ -83,7 +83,7 @@ FloatPoint SVGTransform::rotationCenter() const
return m_center;
}
-void SVGTransform::setMatrix(AffineTransform matrix) //const AffineTransform& matrix)
+void SVGTransform::setMatrix(TransformationMatrix matrix) //const TransformationMatrix& matrix)
{
m_type = SVG_TRANSFORM_MATRIX;
m_angle = 0;
diff --git a/WebCore/svg/SVGTransform.h b/WebCore/svg/SVGTransform.h
index c3c150c..0a5e410 100644
--- a/WebCore/svg/SVGTransform.h
+++ b/WebCore/svg/SVGTransform.h
@@ -24,7 +24,7 @@
#define SVGTransform_h
#if ENABLE(SVG)
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "FloatPoint.h"
#include "SVGNames.h"
@@ -46,18 +46,18 @@ namespace WebCore {
SVGTransform();
SVGTransform(SVGTransformType);
- explicit SVGTransform(const AffineTransform&);
+ explicit SVGTransform(const TransformationMatrix&);
virtual ~SVGTransform();
SVGTransformType type() const;
- AffineTransform matrix() const;
+ TransformationMatrix matrix() const;
float angle() const;
FloatPoint rotationCenter() const;
-// void setMatrix(const AffineTransform&);
- void setMatrix(AffineTransform);
+// void setMatrix(const TransformationMatrix&);
+ void setMatrix(TransformationMatrix);
void setTranslate(float tx, float ty);
void setScale(float sx, float sy);
@@ -78,7 +78,7 @@ namespace WebCore {
SVGTransformType m_type;
float m_angle;
FloatPoint m_center;
- AffineTransform m_matrix;
+ TransformationMatrix m_matrix;
};
inline bool operator==(const SVGTransform& a, const SVGTransform& b)
diff --git a/WebCore/svg/SVGTransformDistance.cpp b/WebCore/svg/SVGTransformDistance.cpp
index 59c24a5..b46370b 100644
--- a/WebCore/svg/SVGTransformDistance.cpp
+++ b/WebCore/svg/SVGTransformDistance.cpp
@@ -38,7 +38,7 @@ SVGTransformDistance::SVGTransformDistance()
{
}
-SVGTransformDistance::SVGTransformDistance(SVGTransform::SVGTransformType type, float angle, float cx, float cy, const AffineTransform& transform)
+SVGTransformDistance::SVGTransformDistance(SVGTransform::SVGTransformType type, float angle, float cx, float cy, const TransformationMatrix& transform)
: m_type(type)
, m_angle(angle)
, m_cx(cx)
@@ -95,20 +95,20 @@ SVGTransformDistance SVGTransformDistance::scaledDistance(float scaleFactor) con
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());
+ return SVGTransformDistance(m_type, m_angle * scaleFactor, m_cx * scaleFactor, m_cy * scaleFactor, TransformationMatrix());
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));
+ return SVGTransformDistance(m_type, m_angle * scaleFactor, m_cx * scaleFactor, m_cy * scaleFactor, TransformationMatrix(m_transform).scale(scaleFactor));
case SVGTransform::SVG_TRANSFORM_TRANSLATE:
{
- AffineTransform newTransform(m_transform);
+ TransformationMatrix 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());
+ return SVGTransformDistance(m_type, m_angle * scaleFactor, m_cx * scaleFactor, m_cy * scaleFactor, TransformationMatrix());
}
ASSERT_NOT_REACHED();
@@ -249,7 +249,7 @@ SVGTransform SVGTransformDistance::addToSVGTransform(const SVGTransform& transfo
bool SVGTransformDistance::isZero() const
{
- return (m_transform == AffineTransform() && m_angle == 0);
+ return (m_transform == TransformationMatrix() && m_angle == 0);
}
float SVGTransformDistance::distance() const
diff --git a/WebCore/svg/SVGTransformDistance.h b/WebCore/svg/SVGTransformDistance.h
index b3663ad..470e2eb 100644
--- a/WebCore/svg/SVGTransformDistance.h
+++ b/WebCore/svg/SVGTransformDistance.h
@@ -27,7 +27,7 @@
namespace WebCore {
- class AffineTransform;
+ class TransformationMatrix;
class SVGTransformDistance {
public:
@@ -44,13 +44,13 @@ namespace WebCore {
float distance() const;
private:
- SVGTransformDistance(SVGTransform::SVGTransformType, float angle, float cx, float cy, const AffineTransform&);
+ SVGTransformDistance(SVGTransform::SVGTransformType, float angle, float cx, float cy, const TransformationMatrix&);
SVGTransform::SVGTransformType m_type;
float m_angle;
float m_cx;
float m_cy;
- AffineTransform m_transform; // for storing scale, translation or matrix transforms
+ TransformationMatrix m_transform; // for storing scale, translation or matrix transforms
};
}
diff --git a/WebCore/svg/SVGTransformList.cpp b/WebCore/svg/SVGTransformList.cpp
index 9800922..ed457f4 100644
--- a/WebCore/svg/SVGTransformList.cpp
+++ b/WebCore/svg/SVGTransformList.cpp
@@ -23,7 +23,7 @@
#include "config.h"
#if ENABLE(SVG)
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "SVGTransform.h"
#include "SVGSVGElement.h"
#include "SVGTransformDistance.h"
@@ -40,7 +40,7 @@ SVGTransformList::~SVGTransformList()
{
}
-SVGTransform SVGTransformList::createSVGTransformFromMatrix(const AffineTransform& matrix) const
+SVGTransform SVGTransformList::createSVGTransformFromMatrix(const TransformationMatrix& matrix) const
{
return SVGSVGElement::createSVGTransformFromMatrix(matrix);
}
@@ -57,7 +57,7 @@ SVGTransform SVGTransformList::concatenate() const
if (!length)
return SVGTransform();
- AffineTransform matrix;
+ TransformationMatrix matrix;
ExceptionCode ec = 0;
for (unsigned int i = 0; i < length; i++)
matrix = getItem(i, ec).matrix() * matrix;
@@ -87,7 +87,7 @@ 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();
+ TransformationMatrix 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());
}
diff --git a/WebCore/svg/SVGTransformList.h b/WebCore/svg/SVGTransformList.h
index a405c58..442016b 100644
--- a/WebCore/svg/SVGTransformList.h
+++ b/WebCore/svg/SVGTransformList.h
@@ -37,7 +37,7 @@ namespace WebCore {
static PassRefPtr<SVGTransformList> create(const QualifiedName& attributeName) { return adoptRef(new SVGTransformList(attributeName)); }
virtual ~SVGTransformList();
- SVGTransform createSVGTransformFromMatrix(const AffineTransform&) const;
+ SVGTransform createSVGTransformFromMatrix(const TransformationMatrix&) const;
SVGTransform consolidate();
// Internal use only
diff --git a/WebCore/svg/SVGTransformable.cpp b/WebCore/svg/SVGTransformable.cpp
index 8614d55..6dbfc1a 100644
--- a/WebCore/svg/SVGTransformable.cpp
+++ b/WebCore/svg/SVGTransformable.cpp
@@ -26,9 +26,8 @@
#if ENABLE(SVG)
#include "SVGTransformable.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "FloatConversion.h"
-#include "RegularExpression.h"
#include "SVGNames.h"
#include "SVGParserUtilities.h"
#include "SVGStyledElement.h"
@@ -44,19 +43,19 @@ SVGTransformable::~SVGTransformable()
{
}
-AffineTransform SVGTransformable::getCTM(const SVGElement* element) const
+TransformationMatrix SVGTransformable::getCTM(const SVGElement* element) const
{
- AffineTransform ctm = SVGLocatable::getCTM(element);
+ TransformationMatrix ctm = SVGLocatable::getCTM(element);
return animatedLocalTransform() * ctm;
}
-AffineTransform SVGTransformable::getScreenCTM(const SVGElement* element) const
+TransformationMatrix SVGTransformable::getScreenCTM(const SVGElement* element) const
{
- AffineTransform ctm = SVGLocatable::getScreenCTM(element);
+ TransformationMatrix ctm = SVGLocatable::getScreenCTM(element);
return animatedLocalTransform() * ctm;
}
-int parseTransformParamList(const UChar*& ptr, const UChar* end, float* values, int required, int optional)
+static int parseTransformParamList(const UChar*& ptr, const UChar* end, float* values, int required, int optional)
{
int optionalParams = 0, requiredParams = 0;
@@ -148,7 +147,7 @@ bool SVGTransformable::parseTransformValue(unsigned type, const UChar*& ptr, con
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]));
+ t.setMatrix(TransformationMatrix(values[0], values[1], values[2], values[3], values[4], values[5]));
break;
}
diff --git a/WebCore/svg/SVGTransformable.h b/WebCore/svg/SVGTransformable.h
index de806a3..da31c75 100644
--- a/WebCore/svg/SVGTransformable.h
+++ b/WebCore/svg/SVGTransformable.h
@@ -30,7 +30,7 @@
namespace WebCore {
- class AffineTransform;
+ class TransformationMatrix;
class AtomicString;
class SVGTransform;
class QualifiedName;
@@ -44,10 +44,10 @@ namespace WebCore {
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;
+ TransformationMatrix getCTM(const SVGElement*) const;
+ TransformationMatrix getScreenCTM(const SVGElement*) const;
- virtual AffineTransform animatedLocalTransform() const = 0;
+ virtual TransformationMatrix animatedLocalTransform() const = 0;
bool isKnownAttribute(const QualifiedName&);
};
diff --git a/WebCore/svg/SVGUseElement.cpp b/WebCore/svg/SVGUseElement.cpp
index 83ad559..4eb2d9f 100644
--- a/WebCore/svg/SVGUseElement.cpp
+++ b/WebCore/svg/SVGUseElement.cpp
@@ -767,18 +767,18 @@ void SVGUseElement::transferEventListenersToShadowTree(SVGElementInstance* targe
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());
- }
+ const RegisteredEventListenerVector& listeners = originalElement->eventListeners();
+ size_t size = listeners.size();
+ for (size_t i = 0; i < size; ++i) {
+ const RegisteredEventListener& r = *listeners[i];
+ EventListener* listener = r.listener();
+ ASSERT(listener);
+
+ // Event listeners created from markup have already been transfered to the shadow tree during cloning!
+ if (listener->wasCreatedFromMarkup())
+ continue;
+
+ shadowTreeElement->addEventListener(r.eventType(), listener, r.useCapture());
}
}
diff --git a/WebCore/svg/animation/SMILTimeContainer.cpp b/WebCore/svg/animation/SMILTimeContainer.cpp
index 0e809fb..48a2706 100644
--- a/WebCore/svg/animation/SMILTimeContainer.cpp
+++ b/WebCore/svg/animation/SMILTimeContainer.cpp
@@ -34,7 +34,7 @@
#include "SVGAnimationElement.h"
#include "SVGSMILElement.h"
#include "SVGSVGElement.h"
-#include "SystemTime.h"
+#include <wtf/CurrentTime.h>
using namespace std;
diff --git a/WebCore/svg/animation/SVGSMILElement.cpp b/WebCore/svg/animation/SVGSMILElement.cpp
index a07a407..a2e2b0e 100644
--- a/WebCore/svg/animation/SVGSMILElement.cpp
+++ b/WebCore/svg/animation/SVGSMILElement.cpp
@@ -42,6 +42,7 @@
#include "XLinkNames.h"
#include <math.h>
#include <wtf/MathExtras.h>
+#include <wtf/StdLibExtras.h>
#include <wtf/Vector.h>
using namespace std;
@@ -65,7 +66,7 @@ public:
m_eventBase->removeEventListener(m_condition->m_name, this, false);
}
- virtual void handleEvent(Event* event, bool isWindowEvent)
+ virtual void handleEvent(Event* event, bool)
{
m_animation->handleConditionEvent(event, m_condition);
}
@@ -193,7 +194,7 @@ SMILTime SVGSMILElement::parseClockValue(const String& data)
String parse = data.stripWhiteSpace();
- static const AtomicString indefiniteValue("indefinite");
+ DEFINE_STATIC_LOCAL(const AtomicString, indefiniteValue, ("indefinite"));
if (parse == indefiniteValue)
return SMILTime::indefinite();
@@ -457,8 +458,8 @@ bool SVGSMILElement::isFrozen() const
SVGSMILElement::Restart SVGSMILElement::restart() const
{
- static const AtomicString never("never");
- static const AtomicString whenNotActive("whenNotActive");
+ DEFINE_STATIC_LOCAL(const AtomicString, never, ("never"));
+ DEFINE_STATIC_LOCAL(const AtomicString, whenNotActive, ("whenNotActive"));
const AtomicString& value = getAttribute(SVGNames::restartAttr);
if (value == never)
return RestartNever;
@@ -469,7 +470,7 @@ SVGSMILElement::Restart SVGSMILElement::restart() const
SVGSMILElement::FillMode SVGSMILElement::fill() const
{
- static const AtomicString freeze("freeze");
+ DEFINE_STATIC_LOCAL(const AtomicString, freeze, ("freeze"));
const AtomicString& value = getAttribute(SVGNames::fillAttr);
return value == freeze ? FillFreeze : FillRemove;
}
@@ -506,7 +507,7 @@ SMILTime SVGSMILElement::repeatCount() const
if (value.isNull())
return SMILTime::unresolved();
- static const AtomicString indefiniteValue("indefinite");
+ DEFINE_STATIC_LOCAL(const AtomicString, indefiniteValue, ("indefinite"));
if (value == indefiniteValue)
return SMILTime::indefinite();
bool ok;
@@ -861,7 +862,7 @@ void SVGSMILElement::progress(SMILTime elapsed, SVGSMILElement* resultElement)
void SVGSMILElement::notifyDependentsIntervalChanged(NewOrExistingInterval newOrExisting)
{
ASSERT(m_intervalBegin.isFinite());
- static HashSet<SVGSMILElement*> loopBreaker;
+ DEFINE_STATIC_LOCAL(HashSet<SVGSMILElement*>, loopBreaker, ());
if (loopBreaker.contains(this))
return;
loopBreaker.add(this);
@@ -875,7 +876,7 @@ void SVGSMILElement::notifyDependentsIntervalChanged(NewOrExistingInterval newOr
loopBreaker.remove(this);
}
-void SVGSMILElement::createInstanceTimesFromSyncbase(SVGSMILElement* syncbase, NewOrExistingInterval newOrExisting)
+void SVGSMILElement::createInstanceTimesFromSyncbase(SVGSMILElement* syncbase, NewOrExistingInterval)
{
// FIXME: To be really correct, this should handle updating exising interval by changing
// the associated times instead of creating new ones.
@@ -910,7 +911,7 @@ void SVGSMILElement::removeTimeDependent(SVGSMILElement* animation)
m_timeDependents.remove(animation);
}
-void SVGSMILElement::handleConditionEvent(Event* event, Condition* condition)
+void SVGSMILElement::handleConditionEvent(Event*, Condition* condition)
{
if (condition->m_beginOrEnd == Begin)
addBeginTime(elapsed() + condition->m_offset);
diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp
index 4427277..d315dfa 100644
--- a/WebCore/svg/graphics/SVGImage.cpp
+++ b/WebCore/svg/graphics/SVGImage.cpp
@@ -50,9 +50,34 @@
namespace WebCore {
+class SVGImageChromeClient : public EmptyChromeClient {
+public:
+ SVGImageChromeClient(SVGImage* image)
+ : m_image(image)
+ {
+ }
+
+ SVGImage* image() const { return m_image; }
+
+private:
+ virtual void chromeDestroyed()
+ {
+ m_image = 0;
+ }
+
+ virtual void repaint(const IntRect& r, bool, bool, bool)
+ {
+ if (m_image && m_image->imageObserver())
+ m_image->imageObserver()->changedInRect(m_image, r);
+ }
+
+ SVGImage* m_image;
+};
+
SVGImage::SVGImage(ImageObserver* observer)
: Image(observer)
, m_document(0)
+ , m_chromeClient(0)
, m_page(0)
, m_frame(0)
, m_frameView(0)
@@ -63,6 +88,14 @@ SVGImage::~SVGImage()
{
if (m_frame)
m_frame->loader()->frameDetached(); // Break both the loader and view references to the frame
+
+ // Clear these manually so we can safely delete the ChromeClient afterwards
+ m_frameView.clear();
+ m_frame.clear();
+ m_page.clear();
+
+ // Verify that page teardown destroyed the Chrome
+ ASSERT(!m_chromeClient->image());
}
void SVGImage::setContainerSize(const IntSize& containerSize)
@@ -150,7 +183,9 @@ void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl
context->beginTransparencyLayer(1.0f);
context->translate(dstRect.location().x(), dstRect.location().y());
context->scale(FloatSize(dstRect.width()/srcRect.width(), dstRect.height()/srcRect.height()));
-
+
+ m_frame->view()->resize(size());
+
if (m_frame->view()->needsLayout())
m_frame->view()->layout();
m_frame->view()->paint(context, enclosingIntRect(srcRect));
@@ -185,16 +220,17 @@ bool SVGImage::dataChanged(bool allDataReceived)
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;
+ m_chromeClient.set(new SVGImageChromeClient(this));
+
// 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.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient));
m_page->settings()->setJavaScriptEnabled(false);
m_page->settings()->setPluginsEnabled(false);
@@ -204,7 +240,7 @@ bool SVGImage::dataChanged(bool allDataReceived)
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()->load(fakeRequest, false); // 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");
diff --git a/WebCore/svg/graphics/SVGImage.h b/WebCore/svg/graphics/SVGImage.h
index 994cf91..062c0a2 100644
--- a/WebCore/svg/graphics/SVGImage.h
+++ b/WebCore/svg/graphics/SVGImage.h
@@ -39,6 +39,7 @@ namespace WebCore {
class Frame;
class FrameView;
class Page;
+ class SVGImageChromeClient;
class SVGImage : public Image {
public:
@@ -46,7 +47,9 @@ namespace WebCore {
{
return adoptRef(new SVGImage(observer));
}
- ~SVGImage();
+
+ private:
+ virtual ~SVGImage();
virtual void setContainerSize(const IntSize&);
virtual bool usesContainerSize() const;
@@ -59,18 +62,18 @@ namespace WebCore {
// 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 void destroyDecodedData(bool) { }
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<SVGImageChromeClient> m_chromeClient;
OwnPtr<Page> m_page;
RefPtr<Frame> m_frame;
RefPtr<FrameView> m_frameView;
diff --git a/WebCore/svg/graphics/SVGPaintServer.cpp b/WebCore/svg/graphics/SVGPaintServer.cpp
index 0240532..4e7a8cf 100644
--- a/WebCore/svg/graphics/SVGPaintServer.cpp
+++ b/WebCore/svg/graphics/SVGPaintServer.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
* 2007 Rob Buis <buis@kde.org>
+ * 2008 Dirk Schulze <krit@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -158,6 +159,40 @@ void applyStrokeStyleToContext(GraphicsContext* context, RenderStyle* style, con
context->setLineDash(dashes, dashOffset);
}
+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::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
+{
+ const SVGRenderStyle* style = path ? path->style()->svgStyle() : 0;
+
+ if ((type & ApplyToFillTargetType) && (!style || style->hasFill()))
+ context->fillPath();
+
+ if ((type & ApplyToStrokeTargetType) && (!style || style->hasStroke()))
+ context->strokePath();
+}
+
+void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool) const
+{
+#if PLATFORM(SKIA)
+ // FIXME: Move this into the GraphicsContext
+ // WebKit implicitly expects us to reset the path.
+ // For example in fillAndStrokePath() of RenderPath.cpp the path is
+ // added back to the context after filling. This is because internally it
+ // calls CGContextFillPath() which closes the path.
+ context->beginPath();
+ context->platformContext()->setGradient(0);
+ context->platformContext()->setPattern(0);
+#endif
+}
+
DashArray dashArrayFromRenderingStyle(const RenderStyle* style)
{
DashArray array;
diff --git a/WebCore/svg/graphics/SVGPaintServer.h b/WebCore/svg/graphics/SVGPaintServer.h
index 0d37e9f..9174f66 100644
--- a/WebCore/svg/graphics/SVGPaintServer.h
+++ b/WebCore/svg/graphics/SVGPaintServer.h
@@ -77,14 +77,6 @@ namespace WebCore {
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();
};
diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.cpp b/WebCore/svg/graphics/SVGPaintServerGradient.cpp
index 58dd6bf..b06eca1 100644
--- a/WebCore/svg/graphics/SVGPaintServerGradient.cpp
+++ b/WebCore/svg/graphics/SVGPaintServerGradient.cpp
@@ -1,5 +1,7 @@
/*
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * 2008 Eric Seidel <eric@webkit.org>
+ * 2008 Dirk Schulze <krit@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,12 +30,26 @@
#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 "SVGRenderTreeAsText.h"
+#if PLATFORM(CG)
+#include <wtf/MathExtras.h>
+#include <wtf/RetainPtr.h>
+#endif
+
+using namespace std;
+
namespace WebCore {
-TextStream& operator<<(TextStream& ts, GradientSpreadMethod m)
+static TextStream& operator<<(TextStream& ts, GradientSpreadMethod m)
{
switch (m) {
case SpreadMethodPad:
@@ -47,7 +63,7 @@ TextStream& operator<<(TextStream& ts, GradientSpreadMethod m)
return ts;
}
-TextStream& operator<<(TextStream& ts, const Vector<SVGGradientStop>& l)
+static TextStream& operator<<(TextStream& ts, const Vector<SVGGradientStop>& l)
{
ts << "[";
for (Vector<SVGGradientStop>::const_iterator it = l.begin(); it != l.end(); ++it) {
@@ -65,8 +81,6 @@ SVGPaintServerGradient::SVGPaintServerGradient(const SVGGradientElement* owner)
, m_ownerElement(owner)
#if PLATFORM(CG)
- , m_stopsCache(0)
- , m_shadingCache(0)
, m_savedContext(0)
, m_imageBuffer(0)
#endif
@@ -76,19 +90,16 @@ SVGPaintServerGradient::SVGPaintServerGradient(const SVGGradientElement* owner)
SVGPaintServerGradient::~SVGPaintServerGradient()
{
-#if PLATFORM(CG)
- CGShadingRelease(m_shadingCache);
-#endif
}
-const Vector<SVGGradientStop>& SVGPaintServerGradient::gradientStops() const
+Gradient* SVGPaintServerGradient::gradient() const
{
- return m_stops;
+ return m_gradient.get();
}
-void SVGPaintServerGradient::setGradientStops(const Vector<SVGGradientStop>& stops)
+void SVGPaintServerGradient::setGradient(PassRefPtr<Gradient> gradient)
{
- m_stops = stops;
+ m_gradient = gradient;
}
GradientSpreadMethod SVGPaintServerGradient::spreadMethod() const
@@ -111,16 +122,161 @@ void SVGPaintServerGradient::setBoundingBoxMode(bool mode)
m_boundingBoxMode = mode;
}
-AffineTransform SVGPaintServerGradient::gradientTransform() const
+TransformationMatrix SVGPaintServerGradient::gradientTransform() const
{
return m_gradientTransform;
}
-void SVGPaintServerGradient::setGradientTransform(const AffineTransform& transform)
+void SVGPaintServerGradient::setGradientTransform(const TransformationMatrix& transform)
{
m_gradientTransform = transform;
}
+#if PLATFORM(CG)
+// Helper function for text painting in CG
+// This Cg specific code should move to GraphicsContext and Font* in a next step.
+static inline const RenderObject* findTextRootObject(const RenderObject* start)
+{
+ while (start && !start->isSVGText())
+ start = start->parent();
+ ASSERT(start);
+ ASSERT(start->isSVGText());
+
+ return start;
+}
+
+static inline bool createMaskAndSwapContextForTextGradient(
+ GraphicsContext*& context, GraphicsContext*& savedContext,
+ OwnPtr<ImageBuffer>& imageBuffer, const RenderObject* object)
+{
+ 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())
+ return false;
+
+ GraphicsContext* maskImageContext = maskImage->context();
+
+ maskImageContext->save();
+ maskImageContext->translate(-maskRect.x(), -maskRect.y());
+ maskImageContext->concatCTM(object->absoluteTransform());
+
+ imageBuffer.set(maskImage.release());
+ savedContext = context;
+
+ context = maskImageContext;
+
+ return true;
+}
+
+static inline void clipToTextMask(GraphicsContext* context,
+ OwnPtr<ImageBuffer>& imageBuffer, const RenderObject* object,
+ const SVGPaintServerGradient* gradientServer)
+{
+ FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->relativeBBox(false);
+
+ // Fixup transformations to be able to clip to mask
+ TransformationMatrix transform = object->absoluteTransform();
+ FloatRect textBoundary = transform.mapRect(maskBBox);
+
+ IntSize maskSize(lroundf(textBoundary.width()), lroundf(textBoundary.height()));
+ clampImageBufferSizeToViewport(object->document()->renderer(), maskSize);
+ textBoundary.setSize(textBoundary.size().shrunkTo(maskSize));
+
+ // Clip current context to mask image (gradient)
+ context->concatCTM(transform.inverse());
+ context->clipToImageBuffer(textBoundary, imageBuffer.get());
+ context->concatCTM(transform);
+
+ if (gradientServer->boundingBoxMode()) {
+ context->translate(maskBBox.x(), maskBBox.y());
+ context->scale(FloatSize(maskBBox.width(), maskBBox.height()));
+ }
+ context->concatCTM(gradientServer->gradientTransform());
+}
+#endif
+
+bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ m_ownerElement->buildGradient();
+
+ const SVGRenderStyle* style = object->style()->svgStyle();
+ bool isFilled = (type & ApplyToFillTargetType) && style->hasFill();
+ bool isStroked = (type & ApplyToStrokeTargetType) && style->hasStroke();
+
+ ASSERT(isFilled && !isStroked || !isFilled && isStroked);
+
+ context->save();
+
+ if (isPaintingText) {
+#if PLATFORM(CG)
+ if (!createMaskAndSwapContextForTextGradient(context, m_savedContext, m_imageBuffer, object)) {
+ context->restore();
+ return false;
+ }
+#endif
+ context->setTextDrawingMode(isFilled ? cTextFill : cTextStroke);
+ }
+
+ if (isFilled) {
+ context->setAlpha(style->fillOpacity());
+ context->setFillGradient(m_gradient);
+ context->setFillRule(style->fillRule());
+ }
+ if (isStroked) {
+ context->setAlpha(style->strokeOpacity());
+ context->setStrokeGradient(m_gradient);
+ applyStrokeStyleToContext(context, object->style(), object);
+ }
+
+ if (boundingBoxMode() && !isPaintingText) {
+ FloatRect bbox = object->relativeBBox(false);
+ // Don't use gradientes for 1d objects like horizontal/vertical
+ // lines or rectangles without width or height.
+ if (bbox.width() == 0 || bbox.height() == 0) {
+ Color color(0, 0, 0);
+ context->setStrokeColor(color);
+ return true;
+ }
+ context->translate(bbox.x(), bbox.y());
+ context->scale(FloatSize(bbox.width(), bbox.height()));
+
+ // With scaling the context, the strokeThickness is scaled too. We have to
+ // undo this.
+ float strokeThickness = std::max((context->strokeThickness() / ((bbox.width() + bbox.height()) / 2) - 0.001f), 0.f);
+ context->setStrokeThickness(strokeThickness);
+ }
+ context->concatCTM(gradientTransform());
+ context->setSpreadMethod(spreadMethod());
+
+ return true;
+}
+
+void SVGPaintServerGradient::teardown(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType, bool isPaintingText) const
+{
+#if PLATFORM(CG)
+ // renderPath() is not used when painting text, so we paint the gradient during teardown()
+ if (isPaintingText && m_savedContext) {
+ // Restore on-screen drawing context
+ context = m_savedContext;
+ m_savedContext = 0;
+
+ clipToTextMask(context, m_imageBuffer, object, this);
+
+ // finally fill the text clip with the shading
+ CGContextDrawShading(context->platformContext(), m_gradient->platformGradient());
+
+ m_imageBuffer.clear(); // we're done with our text mask buffer
+ }
+#endif
+ context->restore();
+}
+
TextStream& SVGPaintServerGradient::externalRepresentation(TextStream& ts) const
{
// Gradients/patterns aren't setup, until they are used for painting. Work around that fact.
diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.h b/WebCore/svg/graphics/SVGPaintServerGradient.h
index 99dac8e..16dab0b 100644
--- a/WebCore/svg/graphics/SVGPaintServerGradient.h
+++ b/WebCore/svg/graphics/SVGPaintServerGradient.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * 2008 Eric Seidel <eric@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,38 +29,28 @@
#if ENABLE(SVG)
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "Color.h"
+#include "Gradient.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>&);
+ void setGradient(PassRefPtr<Gradient>);
+ Gradient* gradient() const;
GradientSpreadMethod spreadMethod() const;
void setGradientSpreadMethod(const GradientSpreadMethod&);
@@ -70,63 +61,32 @@ namespace WebCore {
bool boundingBoxMode() const;
void setBoundingBoxMode(bool mode = true);
- AffineTransform gradientTransform() const;
- void setGradientTransform(const AffineTransform&);
+ TransformationMatrix gradientTransform() const;
+ void setGradientTransform(const TransformationMatrix&);
+
+ void setGradientStops(const Vector<SVGGradientStop>& stops) { m_stops = stops; }
+ const Vector<SVGGradientStop>& gradientStops() const { return m_stops; }
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;
+ RefPtr<Gradient> m_gradient;
GradientSpreadMethod m_spreadMethod;
bool m_boundingBoxMode;
- AffineTransform m_gradientTransform;
+ TransformationMatrix 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;
+ mutable OwnPtr<ImageBuffer> m_imageBuffer;
#endif
};
diff --git a/WebCore/svg/graphics/SVGPaintServerLinearGradient.h b/WebCore/svg/graphics/SVGPaintServerLinearGradient.h
index 4b7da32..f0568c7 100644
--- a/WebCore/svg/graphics/SVGPaintServerLinearGradient.h
+++ b/WebCore/svg/graphics/SVGPaintServerLinearGradient.h
@@ -48,10 +48,6 @@ namespace WebCore {
virtual TextStream& externalRepresentation(TextStream&) const;
-#if PLATFORM(QT)
- virtual QGradient setupGradient(GraphicsContext*&, const RenderObject*) const;
-#endif
-
private:
SVGPaintServerLinearGradient(const SVGGradientElement* owner);
diff --git a/WebCore/svg/graphics/SVGPaintServerPattern.cpp b/WebCore/svg/graphics/SVGPaintServerPattern.cpp
index c0e5b07..5926aad 100644
--- a/WebCore/svg/graphics/SVGPaintServerPattern.cpp
+++ b/WebCore/svg/graphics/SVGPaintServerPattern.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * 2008 Dirk Schulze <krit@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,9 +29,14 @@
#if ENABLE(SVG)
#include "SVGPaintServerPattern.h"
+#include "GraphicsContext.h"
+#include "Image.h"
#include "ImageBuffer.h"
+#include "Pattern.h"
+#include "RenderObject.h"
#include "SVGPatternElement.h"
#include "SVGRenderTreeAsText.h"
+#include "TransformationMatrix.h"
using namespace std;
@@ -38,20 +44,13 @@ 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
@@ -74,12 +73,12 @@ void SVGPaintServerPattern::setTile(auto_ptr<ImageBuffer> tile)
m_tile.set(tile.release());
}
-AffineTransform SVGPaintServerPattern::patternTransform() const
+TransformationMatrix SVGPaintServerPattern::patternTransform() const
{
return m_patternTransform;
}
-void SVGPaintServerPattern::setPatternTransform(const AffineTransform& transform)
+void SVGPaintServerPattern::setPatternTransform(const TransformationMatrix& transform)
{
m_patternTransform = transform;
}
@@ -96,6 +95,91 @@ TextStream& SVGPaintServerPattern::externalRepresentation(TextStream& ts) const
return ts;
}
+bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ FloatRect targetRect;
+ if (isPaintingText) {
+ IntRect textBoundary = const_cast<RenderObject*>(object)->absoluteBoundingBoxRect();
+ targetRect = object->absoluteTransform().inverse().mapRect(textBoundary);
+ } else
+ targetRect = object->relativeBBox(false);
+
+ const SVGRenderStyle* style = object->style()->svgStyle();
+ bool isFilled = (type & ApplyToFillTargetType) && style->hasFill();
+ bool isStroked = (type & ApplyToStrokeTargetType) && style->hasStroke();
+
+ ASSERT(isFilled && !isStroked || !isFilled && isStroked);
+
+ m_ownerElement->buildPattern(targetRect);
+ if (!tile())
+ return false;
+
+ context->save();
+ context->translate(patternBoundaries().x(), patternBoundaries().y());
+ context->concatCTM(patternTransform());
+
+ ASSERT(!m_pattern);
+
+ IntRect tileRect = tile()->image()->rect();
+ if (tileRect.width() > patternBoundaries().width() || tileRect.height() > patternBoundaries().height()) {
+ // Draw the first cell of the pattern manually to support overflow="visible" on all platforms.
+ int tileWidth = static_cast<int>(patternBoundaries().width() + 0.5f);
+ int tileHeight = static_cast<int>(patternBoundaries().height() + 0.5f);
+ std::auto_ptr<ImageBuffer> tileImage = ImageBuffer::create(IntSize(tileWidth, tileHeight), false);
+
+ GraphicsContext* tileImageContext = tileImage->context();
+
+ int numY = static_cast<int>(ceilf(tileRect.height() / tileHeight)) + 1;
+ int numX = static_cast<int>(ceilf(tileRect.width() / tileWidth)) + 1;
+
+ tileImageContext->save();
+ tileImageContext->translate(-patternBoundaries().width() * numX, -patternBoundaries().height() * numY);
+ for (int i = numY; i > 0; i--) {
+ tileImageContext->translate(0, patternBoundaries().height());
+ for (int j = numX; j > 0; j--) {
+ tileImageContext->translate(patternBoundaries().width(), 0);
+ tileImageContext->drawImage(tile()->image(), tileRect, tileRect);
+ }
+ tileImageContext->translate(-patternBoundaries().width() * numX, 0);
+ }
+ tileImageContext->restore();
+
+ m_pattern = Pattern::create(tileImage->image(), true, true);
+ }
+ else
+ m_pattern = Pattern::create(tile()->image(), true, true);
+
+ if (isFilled) {
+ context->setAlpha(style->fillOpacity());
+ context->setFillPattern(m_pattern);
+ context->setFillRule(style->fillRule());
+ }
+ if (isStroked) {
+ context->setAlpha(style->strokeOpacity());
+ context->setStrokePattern(m_pattern);
+ applyStrokeStyleToContext(context, object->style(), object);
+ }
+
+ if (isPaintingText) {
+ context->setTextDrawingMode(isFilled ? cTextFill : cTextStroke);
+#if PLATFORM(CG)
+ if (isFilled)
+ context->applyFillPattern();
+ else
+ context->applyStrokePattern();
+#endif
+ }
+
+ return true;
+}
+
+void SVGPaintServerPattern::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const
+{
+ m_pattern = 0;
+
+ context->restore();
+}
+
} // namespace WebCore
#endif
diff --git a/WebCore/svg/graphics/SVGPaintServerPattern.h b/WebCore/svg/graphics/SVGPaintServerPattern.h
index 65b28e9..48acd51 100644
--- a/WebCore/svg/graphics/SVGPaintServerPattern.h
+++ b/WebCore/svg/graphics/SVGPaintServerPattern.h
@@ -28,8 +28,9 @@
#if ENABLE(SVG)
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "FloatRect.h"
+#include "Pattern.h"
#include "SVGPaintServer.h"
#include <memory>
@@ -57,28 +58,23 @@ namespace WebCore {
ImageBuffer* tile() const;
void setTile(std::auto_ptr<ImageBuffer>);
- AffineTransform patternTransform() const;
- void setPatternTransform(const AffineTransform&);
+ TransformationMatrix patternTransform() const;
+ void setPatternTransform(const TransformationMatrix&);
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;
+ TransformationMatrix m_patternTransform;
FloatRect m_patternBoundaries;
-#if PLATFORM(CG)
- mutable CGColorSpaceRef m_patternSpace;
- mutable CGPatternRef m_pattern;
-#endif
+ mutable RefPtr<Pattern> m_pattern;
};
} // namespace WebCore
diff --git a/WebCore/svg/graphics/SVGPaintServerRadialGradient.h b/WebCore/svg/graphics/SVGPaintServerRadialGradient.h
index 265f76b..749ba08 100644
--- a/WebCore/svg/graphics/SVGPaintServerRadialGradient.h
+++ b/WebCore/svg/graphics/SVGPaintServerRadialGradient.h
@@ -51,10 +51,6 @@ namespace WebCore {
virtual TextStream& externalRepresentation(TextStream&) const;
-#if PLATFORM(QT)
- virtual QGradient setupGradient(GraphicsContext*&, const RenderObject*) const;
-#endif
-
private:
SVGPaintServerRadialGradient(const SVGGradientElement* owner);
diff --git a/WebCore/svg/graphics/SVGPaintServerSolid.cpp b/WebCore/svg/graphics/SVGPaintServerSolid.cpp
index cb58a3a..b333042 100644
--- a/WebCore/svg/graphics/SVGPaintServerSolid.cpp
+++ b/WebCore/svg/graphics/SVGPaintServerSolid.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,6 +28,9 @@
#if ENABLE(SVG)
#include "SVGPaintServerSolid.h"
+
+#include "GraphicsContext.h"
+#include "RenderPath.h"
#include "SVGRenderTreeAsText.h"
namespace WebCore {
@@ -56,6 +60,34 @@ TextStream& SVGPaintServerSolid::externalRepresentation(TextStream& ts) const
return ts;
}
+bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ RenderStyle* style = object ? object->style() : 0;
+ const SVGRenderStyle* svgStyle = style ? style->svgStyle() : 0;
+
+ if ((type & ApplyToFillTargetType) && (!style || svgStyle->hasFill())) {
+ context->setAlpha(style ? svgStyle->fillOpacity() : 1);
+ context->setFillColor(color().rgb());
+ context->setFillRule(style ? svgStyle->fillRule() : RULE_NONZERO);
+
+ if (isPaintingText)
+ context->setTextDrawingMode(cTextFill);
+ }
+
+ if ((type & ApplyToStrokeTargetType) && (!style || svgStyle->hasStroke())) {
+ context->setAlpha(style ? svgStyle->strokeOpacity() : 1);
+ context->setStrokeColor(color().rgb());
+
+ if (style)
+ applyStrokeStyleToContext(context, style, object);
+
+ if (isPaintingText)
+ context->setTextDrawingMode(cTextStroke);
+ }
+
+ return true;
+}
+
} // namespace WebCore
#endif
diff --git a/WebCore/svg/graphics/SVGResource.cpp b/WebCore/svg/graphics/SVGResource.cpp
index 10d6648..82c10ba 100644
--- a/WebCore/svg/graphics/SVGResource.cpp
+++ b/WebCore/svg/graphics/SVGResource.cpp
@@ -31,6 +31,7 @@
#include "RenderPath.h"
#include "SVGElement.h"
#include "SVGStyledElement.h"
+#include <wtf/StdLibExtras.h>
namespace WebCore {
@@ -47,8 +48,10 @@ struct ResourceSet {
SVGResource* resources[_ResourceTypeCount];
};
-static HashMap<SVGStyledElement*, ResourceSet*>& clientMap() {
- static HashMap<SVGStyledElement*, ResourceSet*> map;
+typedef HashMap<SVGStyledElement*, ResourceSet*> ResourceClientMap;
+
+static ResourceClientMap& clientMap() {
+ DEFINE_STATIC_LOCAL(ResourceClientMap, map, ());
return map;
}
@@ -116,7 +119,7 @@ void SVGResource::invalidateClients(HashSet<SVGStyledElement*> clients)
void SVGResource::removeClient(SVGStyledElement* item)
{
- HashMap<SVGStyledElement*, ResourceSet*>::iterator resourcePtr = clientMap().find(item);
+ ResourceClientMap::iterator resourcePtr = clientMap().find(item);
if (resourcePtr == clientMap().end())
return;
diff --git a/WebCore/svg/graphics/SVGResourceClipper.cpp b/WebCore/svg/graphics/SVGResourceClipper.cpp
index f03f5c2..51bda0d 100644
--- a/WebCore/svg/graphics/SVGResourceClipper.cpp
+++ b/WebCore/svg/graphics/SVGResourceClipper.cpp
@@ -28,8 +28,14 @@
#if ENABLE(SVG)
#include "SVGResourceClipper.h"
+#include "TransformationMatrix.h"
+#include "GraphicsContext.h"
#include "SVGRenderTreeAsText.h"
+#if PLATFORM(CG)
+#include <ApplicationServices/ApplicationServices.h>
+#endif
+
namespace WebCore {
SVGResourceClipper::SVGResourceClipper()
@@ -46,6 +52,39 @@ void SVGResourceClipper::resetClipData()
m_clipData.clear();
}
+void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
+{
+ if (m_clipData.clipData().isEmpty())
+ return;
+
+ bool heterogenousClipRules = false;
+ WindRule clipRule = m_clipData.clipData()[0].windRule;
+
+ context->beginPath();
+
+ for (unsigned x = 0; x < m_clipData.clipData().size(); x++) {
+ ClipData clipData = m_clipData.clipData()[x];
+ if (clipData.windRule != clipRule)
+ heterogenousClipRules = true;
+
+ Path clipPath = clipData.path;
+
+ if (clipData.bboxUnits) {
+ TransformationMatrix transform;
+ transform.translate(boundingBox.x(), boundingBox.y());
+ transform.scale(boundingBox.width(), boundingBox.height());
+ clipPath.transform(transform);
+ }
+ context->addPath(clipPath);
+ }
+
+ // 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
+ context->clipPath(clipRule);
+}
+
void SVGResourceClipper::addClipData(const Path& path, WindRule rule, bool bboxUnits)
{
m_clipData.addPath(path, rule, bboxUnits);
diff --git a/WebCore/svg/graphics/SVGResourceMarker.cpp b/WebCore/svg/graphics/SVGResourceMarker.cpp
index 3649321..c50f5e3 100644
--- a/WebCore/svg/graphics/SVGResourceMarker.cpp
+++ b/WebCore/svg/graphics/SVGResourceMarker.cpp
@@ -28,10 +28,11 @@
#if ENABLE(SVG)
#include "SVGResourceMarker.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "GraphicsContext.h"
#include "RenderSVGViewportContainer.h"
#include "TextStream.h"
+#include <wtf/StdLibExtras.h>
namespace WebCore {
@@ -65,7 +66,7 @@ void SVGResourceMarker::draw(GraphicsContext* context, const FloatRect& rect, do
if (!m_marker)
return;
- static HashSet<SVGResourceMarker*> currentlyDrawingMarkers;
+ DEFINE_STATIC_LOCAL(HashSet<SVGResourceMarker*>, currentlyDrawingMarkers, ());
// avoid drawing circular marker references
if (currentlyDrawingMarkers.contains(this))
@@ -73,13 +74,13 @@ void SVGResourceMarker::draw(GraphicsContext* context, const FloatRect& rect, do
currentlyDrawingMarkers.add(this);
- AffineTransform transform;
+ TransformationMatrix 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;
+ TransformationMatrix viewportTransform;
if (m_useStrokeWidth)
viewportTransform.scale(strokeWidth, strokeWidth);
viewportTransform *= m_marker->viewportTransform();
diff --git a/WebCore/svg/graphics/cairo/RenderPathCairo.cpp b/WebCore/svg/graphics/cairo/RenderPathCairo.cpp
deleted file mode 100644
index 72379b5..0000000
--- a/WebCore/svg/graphics/cairo/RenderPathCairo.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 37cab6f..0000000
--- a/WebCore/svg/graphics/cairo/SVGPaintServerCairo.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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
deleted file mode 100644
index e237962..0000000
--- a/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 86530bc..0000000
--- a/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 49e6f55..0000000
--- a/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 6aec0ae..0000000
--- a/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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/cg/CgSupport.cpp b/WebCore/svg/graphics/cg/CgSupport.cpp
deleted file mode 100644
index f9bfb4c..0000000
--- a/WebCore/svg/graphics/cg/CgSupport.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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
deleted file mode 100644
index de6e4b3..0000000
--- a/WebCore/svg/graphics/cg/CgSupport.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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
deleted file mode 100644
index eb8e482..0000000
--- a/WebCore/svg/graphics/cg/RenderPathCg.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 35eb239..0000000
--- a/WebCore/svg/graphics/cg/SVGPaintServerCg.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- 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
deleted file mode 100644
index bfa5017..0000000
--- a/WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- 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
deleted file mode 100644
index 416d5fe..0000000
--- a/WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- 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
deleted file mode 100644
index bd2a56f..0000000
--- a/WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- 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
deleted file mode 100644
index b04a0dc..0000000
--- a/WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.mm b/WebCore/svg/graphics/cg/SVGResourceFilterCg.mm
index f3dc819..a89ec1d 100644
--- a/WebCore/svg/graphics/cg/SVGResourceFilterCg.mm
+++ b/WebCore/svg/graphics/cg/SVGResourceFilterCg.mm
@@ -29,8 +29,7 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "SVGResourceFilter.h"
-#include "AffineTransform.h"
-#include "FoundationExtras.h"
+#include "TransformationMatrix.h"
#include "GraphicsContext.h"
#include "SVGResourceFilterPlatformDataMac.h"
@@ -63,7 +62,7 @@ void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const FloatRect
// <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]);
+ platform->m_filterCIContext = [CIContext contextWithCGContext:cgContext options:nil];
[filterContextPool drain];
FloatRect filterRect = filterBBoxForItemBBox(bbox);
@@ -73,7 +72,7 @@ void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const FloatRect
float width = filterRect.width();
float height = filterRect.height();
- platform->m_filterCGLayer = [platform->m_filterCIContext createCGLayerWithSize:CGSizeMake(width, height) info:NULL];
+ platform->m_filterCGLayer = [platform->m_filterCIContext.get() createCGLayerWithSize:CGSizeMake(width, height) info:NULL];
context = new GraphicsContext(CGLayerGetContext(platform->m_filterCGLayer));
context->save();
@@ -126,14 +125,13 @@ void SVGResourceFilter::applyFilter(GraphicsContext*& context, const FloatRect&
FloatPoint destOrigin = filterRect.location();
filterRect.setLocation(FloatPoint(0.0f, 0.0f));
- [platform->m_filterCIContext drawImage:outputImage atPoint:CGPoint(destOrigin) fromRect:filterRect];
+ [platform->m_filterCIContext.get() 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;
diff --git a/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm b/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm
index f867f9c..9793ba0 100644
--- a/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm
+++ b/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm
@@ -30,7 +30,6 @@
#import "SVGResourceMasker.h"
#import "BlockExceptions.h"
-#import "CgSupport.h"
#import "GraphicsContext.h"
#import "ImageBuffer.h"
#import "SVGMaskElement.h"
diff --git a/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m b/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m
index ecfed53..6582f9f 100644
--- a/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m
+++ b/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m
@@ -77,4 +77,4 @@ static CIKernel *linearTransferFilter = nil;
@end
-#endif ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h b/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h
index 1b76f2b..cce9e06 100644
--- a/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h
+++ b/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h
@@ -39,4 +39,4 @@
}
@end
-#endif ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h
index 3236ee5..54f8237 100644
--- a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h
+++ b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h
@@ -53,7 +53,7 @@ namespace WebCore {
NSArray* getCIFilterStack(CIImage* inputImage, const FloatRect& bbox);
- CIContext* m_filterCIContext;
+ RetainPtr<CIContext> m_filterCIContext;
CGLayerRef m_filterCGLayer;
RetainPtr<NSMutableDictionary> m_imagesByName;
SVGResourceFilter* m_filter;
diff --git a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm
index c031bbc..225c649 100644
--- a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm
+++ b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm
@@ -34,8 +34,7 @@ namespace WebCore {
static const char* const SVGPreviousFilterOutputName = "__previousOutput__";
SVGResourceFilterPlatformDataMac::SVGResourceFilterPlatformDataMac(SVGResourceFilter* filter)
- : m_filterCIContext(0)
- , m_filterCGLayer(0)
+ : m_filterCGLayer(0)
, m_imagesByName(AdoptNS, [[NSMutableDictionary alloc] init])
, m_filter(filter)
{
diff --git a/WebCore/svg/graphics/qt/RenderPathQt.cpp b/WebCore/svg/graphics/qt/RenderPathQt.cpp
deleted file mode 100644
index 8bee8b8..0000000
--- a/WebCore/svg/graphics/qt/RenderPathQt.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- 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
deleted file mode 100644
index 113f9a7..0000000
--- a/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- 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
deleted file mode 100644
index 69934ab..0000000
--- a/WebCore/svg/graphics/qt/SVGPaintServerLinearGradientQt.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- 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
deleted file mode 100644
index 70ec14c..0000000
--- a/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- 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
deleted file mode 100644
index 801201b..0000000
--- a/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- 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
deleted file mode 100644
index 95d71a3..0000000
--- a/WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- 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
deleted file mode 100644
index e088df2..0000000
--- a/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- 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
deleted file mode 100644
index 42d3855..0000000
--- a/WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- 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/skia/SVGResourceFilterSkia.cpp b/WebCore/svg/graphics/skia/SVGResourceFilterSkia.cpp
new file mode 100644
index 0000000..b54eb4b
--- /dev/null
+++ b/WebCore/svg/graphics/skia/SVGResourceFilterSkia.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2008, Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR 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 COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (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/skia/SVGResourceMaskerSkia.cpp b/WebCore/svg/graphics/skia/SVGResourceMaskerSkia.cpp
new file mode 100644
index 0000000..06e6833
--- /dev/null
+++ b/WebCore/svg/graphics/skia/SVGResourceMaskerSkia.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2008, Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR 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 COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (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 "GraphicsContext.h"
+
+#include "NotImplemented.h"
+
+namespace WebCore {
+
+void SVGResourceMasker::applyMask(GraphicsContext*, const FloatRect& boundingBox)
+{
+ notImplemented();
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/svg/svgattrs.in b/WebCore/svg/svgattrs.in
index f1bd66b..1ab5b06 100644
--- a/WebCore/svg/svgattrs.in
+++ b/WebCore/svg/svgattrs.in
@@ -1,8 +1,8 @@
namespace="SVG"
namespaceURI="http://www.w3.org/2000/svg"
guardFactoryWith="ENABLE(SVG)"
-attrsNullNamespace="1"
-exportStrings="1"
+attrsNullNamespace
+exportStrings
accent-height
accumulate
diff --git a/WebCore/svg/svgtags.in b/WebCore/svg/svgtags.in
index c9c4fbc..fe19f3d 100644
--- a/WebCore/svg/svgtags.in
+++ b/WebCore/svg/svgtags.in
@@ -1,7 +1,7 @@
namespace="SVG"
namespaceURI="http://www.w3.org/2000/svg"
guardFactoryWith="ENABLE(SVG)"
-exportStrings="1"
+exportStrings
a
#if ENABLE_SVG_FONTS
@@ -14,7 +14,7 @@ altGlyphItem
#if ENABLE_SVG_ANIMATION
animate
animateColor
-animateMotion
+animateMotion JSInterfaceName=SVGElement
animateTransform
set
#endif
@@ -80,7 +80,7 @@ glyph
glyphRef
#endif
#if ENABLE_SVG_FONTS
-hkern interfaceName=HKernElement
+hkern interfaceName=SVGHKernElement, JSInterfaceName=SVGElement
#endif
image
line
@@ -91,26 +91,26 @@ metadata
#if ENABLE_SVG_FONTS
missing_glyph
#endif
-mpath interfaceName=MPathElement
+mpath interfaceName=SVGMPathElement, JSInterfaceName=SVGElement
path
pattern
polygon
polyline
radialGradient
rect
-script
+script constructorNeedsCreatedByParser
stop
-style
-svg interfaceName=SVGElement
+style constructorNeedsCreatedByParser
+svg interfaceName=SVGSVGElement
switch
symbol
text
textPath
title
-tref interfaceName=TRefElement
-tspan interfaceName=TSpanElement
+tref interfaceName=SVGTRefElement
+tspan interfaceName=SVGTSpanElement
use
view
#if 0
-vkern interfaceName=VKernElement
+vkern interfaceName=SVGVKernElement
#endif
diff --git a/WebCore/svg/xlinkattrs.in b/WebCore/svg/xlinkattrs.in
index f91fb97..2e48903 100644
--- a/WebCore/svg/xlinkattrs.in
+++ b/WebCore/svg/xlinkattrs.in
@@ -1,6 +1,6 @@
namespace="XLink"
namespaceURI="http://www.w3.org/1999/xlink"
-exportStrings="1"
+exportStrings
actuate
arcrole