summaryrefslogtreecommitdiffstats
path: root/WebCore/svg
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-05-11 18:35:50 +0100
committerBen Murdoch <benm@google.com>2010-05-14 10:23:05 +0100
commit21939df44de1705786c545cd1bf519d47250322d (patch)
treeef56c310f5c0cdc379c2abb2e212308a3281ce20 /WebCore/svg
parent4ff1d8891d520763f17675827154340c7c740f90 (diff)
downloadexternal_webkit-21939df44de1705786c545cd1bf519d47250322d.zip
external_webkit-21939df44de1705786c545cd1bf519d47250322d.tar.gz
external_webkit-21939df44de1705786c545cd1bf519d47250322d.tar.bz2
Merge Webkit at r58956: Initial merge by Git.
Change-Id: I1d9fb60ea2c3f2ddc04c17a871acdb39353be228
Diffstat (limited to 'WebCore/svg')
-rw-r--r--WebCore/svg/GradientAttributes.h103
-rw-r--r--WebCore/svg/LinearGradientAttributes.h3
-rw-r--r--WebCore/svg/PatternAttributes.h181
-rw-r--r--WebCore/svg/RadialGradientAttributes.h3
-rw-r--r--WebCore/svg/SVGAElement.cpp8
-rw-r--r--WebCore/svg/SVGAnimateElement.cpp2
-rw-r--r--WebCore/svg/SVGAnimatedProperty.h8
-rw-r--r--WebCore/svg/SVGClipPathElement.cpp6
-rw-r--r--WebCore/svg/SVGClipPathElement.h1
-rw-r--r--WebCore/svg/SVGDocumentExtensions.cpp11
-rw-r--r--WebCore/svg/SVGDocumentExtensions.h22
-rw-r--r--WebCore/svg/SVGElement.cpp19
-rw-r--r--WebCore/svg/SVGElement.h6
-rw-r--r--WebCore/svg/SVGElementInstance.idl12
-rw-r--r--WebCore/svg/SVGFont.cpp25
-rw-r--r--WebCore/svg/SVGFontElement.cpp161
-rw-r--r--WebCore/svg/SVGFontElement.h2
-rw-r--r--WebCore/svg/SVGGElement.cpp16
-rw-r--r--WebCore/svg/SVGGElement.h2
-rw-r--r--WebCore/svg/SVGGradientElement.cpp85
-rw-r--r--WebCore/svg/SVGGradientElement.h17
-rw-r--r--WebCore/svg/SVGHKernElement.cpp12
-rw-r--r--WebCore/svg/SVGHKernElement.h14
-rw-r--r--WebCore/svg/SVGLinearGradientElement.cpp82
-rw-r--r--WebCore/svg/SVGLinearGradientElement.h7
-rw-r--r--WebCore/svg/SVGMarkerElement.cpp9
-rw-r--r--WebCore/svg/SVGMaskElement.cpp6
-rw-r--r--WebCore/svg/SVGParserUtilities.cpp120
-rw-r--r--WebCore/svg/SVGParserUtilities.h6
-rw-r--r--WebCore/svg/SVGPatternElement.cpp149
-rw-r--r--WebCore/svg/SVGPatternElement.h15
-rw-r--r--WebCore/svg/SVGPolyElement.cpp2
-rw-r--r--WebCore/svg/SVGPolyElement.h1
-rw-r--r--WebCore/svg/SVGRadialGradientElement.cpp125
-rw-r--r--WebCore/svg/SVGRadialGradientElement.h7
-rw-r--r--WebCore/svg/SVGStopElement.cpp11
-rw-r--r--WebCore/svg/SVGStopElement.h5
-rw-r--r--WebCore/svg/SVGStyledElement.cpp106
-rw-r--r--WebCore/svg/SVGStyledElement.h11
-rw-r--r--WebCore/svg/SVGTextContentElement.cpp2
-rw-r--r--WebCore/svg/SVGTextPathElement.h1
-rw-r--r--WebCore/svg/SVGURIReference.cpp4
-rw-r--r--WebCore/svg/graphics/SVGImage.cpp13
-rw-r--r--WebCore/svg/graphics/SVGPaintServer.h96
-rw-r--r--WebCore/svg/graphics/SVGPaintServerGradient.cpp276
-rw-r--r--WebCore/svg/graphics/SVGPaintServerGradient.h98
-rw-r--r--WebCore/svg/graphics/SVGPaintServerLinearGradient.cpp74
-rw-r--r--WebCore/svg/graphics/SVGPaintServerLinearGradient.h62
-rw-r--r--WebCore/svg/graphics/SVGPaintServerPattern.cpp183
-rw-r--r--WebCore/svg/graphics/SVGPaintServerPattern.h85
-rw-r--r--WebCore/svg/graphics/SVGPaintServerRadialGradient.cpp87
-rw-r--r--WebCore/svg/graphics/SVGPaintServerRadialGradient.h66
-rw-r--r--WebCore/svg/graphics/SVGPaintServerSolid.cpp93
-rw-r--r--WebCore/svg/graphics/SVGPaintServerSolid.h60
-rw-r--r--WebCore/svg/graphics/SVGResource.cpp138
-rw-r--r--WebCore/svg/graphics/SVGResource.h90
-rw-r--r--WebCore/svg/graphics/SVGResourceListener.h0
57 files changed, 662 insertions, 2147 deletions
diff --git a/WebCore/svg/GradientAttributes.h b/WebCore/svg/GradientAttributes.h
index ba513b8..473c1b9 100644
--- a/WebCore/svg/GradientAttributes.h
+++ b/WebCore/svg/GradientAttributes.h
@@ -21,51 +21,72 @@
#define GradientAttributes_h
#if ENABLE(SVG)
+#include "Color.h"
+#include "Gradient.h"
+#include "SVGLength.h"
namespace WebCore {
- struct GradientAttributes {
- GradientAttributes()
- : m_spreadMethod(SpreadMethodPad)
- , m_boundingBoxMode(true)
- , m_spreadMethodSet(false)
- , m_boundingBoxModeSet(false)
- , m_gradientTransformSet(false)
- , m_stopsSet(false)
- {
- }
-
- GradientSpreadMethod spreadMethod() const { return m_spreadMethod; }
- bool boundingBoxMode() const { return m_boundingBoxMode; }
- AffineTransform gradientTransform() const { return m_gradientTransform; }
- const Vector<SVGGradientStop>& stops() const { return m_stops; }
-
- void setSpreadMethod(GradientSpreadMethod value) { m_spreadMethod = value; m_spreadMethodSet = true; }
- void setBoundingBoxMode(bool value) { m_boundingBoxMode = value; m_boundingBoxModeSet = true; }
- void setGradientTransform(const AffineTransform& value) { m_gradientTransform = value; m_gradientTransformSet = true; }
- void setStops(const Vector<SVGGradientStop>& value) { m_stops = value; m_stopsSet = true; }
-
- bool hasSpreadMethod() const { return m_spreadMethodSet; }
- bool hasBoundingBoxMode() const { return m_boundingBoxModeSet; }
- bool hasGradientTransform() const { return m_gradientTransformSet; }
- bool hasStops() const { return m_stopsSet; }
-
- private:
- // Properties
- GradientSpreadMethod m_spreadMethod;
- bool m_boundingBoxMode;
- AffineTransform m_gradientTransform;
- Vector<SVGGradientStop> m_stops;
-
- // Property states
- bool m_spreadMethodSet : 1;
- bool m_boundingBoxModeSet : 1;
- bool m_gradientTransformSet : 1;
- bool m_stopsSet : 1;
- };
+
+struct GradientAttributes {
+ GradientAttributes()
+ : m_spreadMethod(SpreadMethodPad)
+ , m_boundingBoxMode(true)
+ , m_spreadMethodSet(false)
+ , m_boundingBoxModeSet(false)
+ , m_gradientTransformSet(false)
+ , m_stopsSet(false)
+ {
+ }
+
+ GradientSpreadMethod spreadMethod() const { return m_spreadMethod; }
+ bool boundingBoxMode() const { return m_boundingBoxMode; }
+ AffineTransform gradientTransform() const { return m_gradientTransform; }
+ const Vector<Gradient::ColorStop>& stops() const { return m_stops; }
+
+ void setSpreadMethod(GradientSpreadMethod value)
+ {
+ m_spreadMethod = value;
+ m_spreadMethodSet = true;
+ }
+
+ void setBoundingBoxMode(bool value)
+ {
+ m_boundingBoxMode = value;
+ m_boundingBoxModeSet = true;
+ }
+
+ void setGradientTransform(const AffineTransform& value)
+ {
+ m_gradientTransform = value;
+ m_gradientTransformSet = true;
+ }
+
+ void setStops(const Vector<Gradient::ColorStop>& value)
+ {
+ m_stops = value;
+ m_stopsSet = true;
+ }
+
+ bool hasSpreadMethod() const { return m_spreadMethodSet; }
+ bool hasBoundingBoxMode() const { return m_boundingBoxModeSet; }
+ bool hasGradientTransform() const { return m_gradientTransformSet; }
+ bool hasStops() const { return m_stopsSet; }
+
+private:
+ // Properties
+ GradientSpreadMethod m_spreadMethod;
+ bool m_boundingBoxMode;
+ AffineTransform m_gradientTransform;
+ Vector<Gradient::ColorStop> m_stops;
+
+ // Property states
+ bool m_spreadMethodSet : 1;
+ bool m_boundingBoxModeSet : 1;
+ bool m_gradientTransformSet : 1;
+ bool m_stopsSet : 1;
+};
} // namespace WebCore
#endif // ENABLE(SVG)
#endif
-
-// vim:ts=4:noet
diff --git a/WebCore/svg/LinearGradientAttributes.h b/WebCore/svg/LinearGradientAttributes.h
index b71dc22..af16b8a 100644
--- a/WebCore/svg/LinearGradientAttributes.h
+++ b/WebCore/svg/LinearGradientAttributes.h
@@ -20,9 +20,8 @@
#ifndef LinearGradientAttributes_h
#define LinearGradientAttributes_h
-#include "GradientAttributes.h"
-
#if ENABLE(SVG)
+#include "GradientAttributes.h"
namespace WebCore {
struct LinearGradientAttributes : GradientAttributes {
diff --git a/WebCore/svg/PatternAttributes.h b/WebCore/svg/PatternAttributes.h
index 2d25763..feaabd9 100644
--- a/WebCore/svg/PatternAttributes.h
+++ b/WebCore/svg/PatternAttributes.h
@@ -21,80 +21,121 @@
#define PatternAttributes_h
#if ENABLE(SVG)
+#include "SVGLength.h"
namespace WebCore {
- struct PatternAttributes {
- PatternAttributes()
- : m_x()
- , m_y()
- , m_width()
- , m_height()
- , m_boundingBoxMode(true)
- , m_boundingBoxModeContent(false)
- , m_patternContentElement(0)
- , m_xSet(false)
- , m_ySet(false)
- , m_widthSet(false)
- , m_heightSet(false)
- , m_boundingBoxModeSet(false)
- , m_boundingBoxModeContentSet(false)
- , m_patternTransformSet(false)
- , m_patternContentElementSet(false)
- {
- }
-
- SVGLength x() const { return m_x; }
- SVGLength y() const { return m_y; }
- SVGLength width() const { return m_width; }
- SVGLength height() const { return m_height; }
- bool boundingBoxMode() const { return m_boundingBoxMode; }
- bool boundingBoxModeContent() const { return m_boundingBoxModeContent; }
- AffineTransform patternTransform() const { return m_patternTransform; }
- const SVGPatternElement* patternContentElement() const { return m_patternContentElement; }
-
- void setX(const SVGLength& value) { m_x = value; m_xSet = true; }
- void setY(const SVGLength& value) { m_y = value; m_ySet = true; }
- void setWidth(const SVGLength& value) { m_width = value; m_widthSet = true; }
- void setHeight(const SVGLength& value) { m_height = value; m_heightSet = true; }
- void setBoundingBoxMode(bool value) { m_boundingBoxMode = value; m_boundingBoxModeSet = true; }
- void setBoundingBoxModeContent(bool value) { m_boundingBoxModeContent = value; m_boundingBoxModeContentSet = true; }
- void setPatternTransform(const AffineTransform& value) { m_patternTransform = value; m_patternTransformSet = true; }
- void setPatternContentElement(const SVGPatternElement* value) { m_patternContentElement = value; m_patternContentElementSet = true; }
-
- bool hasX() const { return m_xSet; }
- bool hasY() const { return m_ySet; }
- bool hasWidth() const { return m_widthSet; }
- bool hasHeight() const { return m_heightSet; }
- bool hasBoundingBoxMode() const { return m_boundingBoxModeSet; }
- bool hasBoundingBoxModeContent() const { return m_boundingBoxModeContentSet; }
- bool hasPatternTransform() const { return m_patternTransformSet; }
- bool hasPatternContentElement() const { return m_patternContentElementSet; }
-
- private:
- // Properties
- SVGLength m_x;
- SVGLength m_y;
- SVGLength m_width;
- SVGLength m_height;
- bool m_boundingBoxMode;
- bool m_boundingBoxModeContent;
- AffineTransform m_patternTransform;
- const SVGPatternElement* m_patternContentElement;
-
- // Property states
- bool m_xSet : 1;
- bool m_ySet : 1;
- bool m_widthSet : 1;
- bool m_heightSet : 1;
- bool m_boundingBoxModeSet : 1;
- bool m_boundingBoxModeContentSet : 1;
- bool m_patternTransformSet : 1;
- bool m_patternContentElementSet : 1;
- };
+
+class SVGPatternElement;
+
+struct PatternAttributes {
+ PatternAttributes()
+ : m_x()
+ , m_y()
+ , m_width()
+ , m_height()
+ , m_boundingBoxMode(true)
+ , m_boundingBoxModeContent(false)
+ , m_patternContentElement(0)
+ , m_xSet(false)
+ , m_ySet(false)
+ , m_widthSet(false)
+ , m_heightSet(false)
+ , m_boundingBoxModeSet(false)
+ , m_boundingBoxModeContentSet(false)
+ , m_patternTransformSet(false)
+ , m_patternContentElementSet(false)
+ {
+ }
+
+ SVGLength x() const { return m_x; }
+ SVGLength y() const { return m_y; }
+ SVGLength width() const { return m_width; }
+ SVGLength height() const { return m_height; }
+ bool boundingBoxMode() const { return m_boundingBoxMode; }
+ bool boundingBoxModeContent() const { return m_boundingBoxModeContent; }
+ AffineTransform patternTransform() const { return m_patternTransform; }
+ const SVGPatternElement* patternContentElement() const { return m_patternContentElement; }
+
+ void setX(const SVGLength& value)
+ {
+ m_x = value;
+ m_xSet = true;
+ }
+
+ void setY(const SVGLength& value)
+ {
+ m_y = value;
+ m_ySet = true;
+ }
+
+ void setWidth(const SVGLength& value)
+ {
+ m_width = value;
+ m_widthSet = true;
+ }
+
+ void setHeight(const SVGLength& value)
+ {
+ m_height = value;
+ m_heightSet = true;
+ }
+
+ void setBoundingBoxMode(bool value)
+ {
+ m_boundingBoxMode = value;
+ m_boundingBoxModeSet = true;
+ }
+
+ void setBoundingBoxModeContent(bool value)
+ {
+ m_boundingBoxModeContent = value;
+ m_boundingBoxModeContentSet = true;
+ }
+
+ void setPatternTransform(const AffineTransform& value)
+ {
+ m_patternTransform = value;
+ m_patternTransformSet = true;
+ }
+
+ void setPatternContentElement(const SVGPatternElement* value)
+ {
+ m_patternContentElement = value;
+ m_patternContentElementSet = true;
+ }
+
+ bool hasX() const { return m_xSet; }
+ bool hasY() const { return m_ySet; }
+ bool hasWidth() const { return m_widthSet; }
+ bool hasHeight() const { return m_heightSet; }
+ bool hasBoundingBoxMode() const { return m_boundingBoxModeSet; }
+ bool hasBoundingBoxModeContent() const { return m_boundingBoxModeContentSet; }
+ bool hasPatternTransform() const { return m_patternTransformSet; }
+ bool hasPatternContentElement() const { return m_patternContentElementSet; }
+
+private:
+ // Properties
+ SVGLength m_x;
+ SVGLength m_y;
+ SVGLength m_width;
+ SVGLength m_height;
+ bool m_boundingBoxMode;
+ bool m_boundingBoxModeContent;
+ AffineTransform m_patternTransform;
+ const SVGPatternElement* m_patternContentElement;
+
+ // Property states
+ bool m_xSet : 1;
+ bool m_ySet : 1;
+ bool m_widthSet : 1;
+ bool m_heightSet : 1;
+ bool m_boundingBoxModeSet : 1;
+ bool m_boundingBoxModeContentSet : 1;
+ bool m_patternTransformSet : 1;
+ bool m_patternContentElementSet : 1;
+};
} // namespace WebCore
#endif // ENABLE(SVG)
#endif
-
-// vim:ts=4:noet
diff --git a/WebCore/svg/RadialGradientAttributes.h b/WebCore/svg/RadialGradientAttributes.h
index 76a78ec..b461854 100644
--- a/WebCore/svg/RadialGradientAttributes.h
+++ b/WebCore/svg/RadialGradientAttributes.h
@@ -20,9 +20,8 @@
#ifndef RadialGradientAttributes_h
#define RadialGradientAttributes_h
-#include "GradientAttributes.h"
-
#if ENABLE(SVG)
+#include "GradientAttributes.h"
namespace WebCore {
struct RadialGradientAttributes : GradientAttributes {
diff --git a/WebCore/svg/SVGAElement.cpp b/WebCore/svg/SVGAElement.cpp
index b344a4e..4a1f18a 100644
--- a/WebCore/svg/SVGAElement.cpp
+++ b/WebCore/svg/SVGAElement.cpp
@@ -60,7 +60,13 @@ SVGAElement::~SVGAElement()
String SVGAElement::title() const
{
- return getAttribute(XLinkNames::titleAttr);
+ // If the xlink:title is set (non-empty string), use it.
+ const AtomicString& title = getAttribute(XLinkNames::titleAttr);
+ if (!title.isEmpty())
+ return title;
+
+ // Otherwise, use the title of this element.
+ return SVGStyledElement::title();
}
void SVGAElement::parseMappedAttribute(MappedAttribute* attr)
diff --git a/WebCore/svg/SVGAnimateElement.cpp b/WebCore/svg/SVGAnimateElement.cpp
index d431583..ff3317b 100644
--- a/WebCore/svg/SVGAnimateElement.cpp
+++ b/WebCore/svg/SVGAnimateElement.cpp
@@ -178,7 +178,7 @@ bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const
if (m_propertyType == ColorProperty) {
m_fromColor = SVGColor::colorFromRGBColorString(fromString);
m_toColor = SVGColor::colorFromRGBColorString(toString);
- if (m_fromColor.isValid() && m_toColor.isValid() || m_toColor.isValid() && animationMode() == ToAnimation)
+ if ((m_fromColor.isValid() && m_toColor.isValid()) || (m_toColor.isValid() && animationMode() == ToAnimation))
return true;
} else if (m_propertyType == NumberProperty) {
m_numberUnit = String();
diff --git a/WebCore/svg/SVGAnimatedProperty.h b/WebCore/svg/SVGAnimatedProperty.h
index 0e3ceda..b963265 100644
--- a/WebCore/svg/SVGAnimatedProperty.h
+++ b/WebCore/svg/SVGAnimatedProperty.h
@@ -48,13 +48,13 @@ public:
virtual void setBaseVal(PassType type)
{
m_creator.setBaseValue(type);
- m_contextElement->setSynchronizedSVGAttributes(false);
+ m_contextElement->invalidateSVGAttributes();
}
virtual void setAnimVal(PassType type)
{
m_creator.setValue(type);
- m_contextElement->setSynchronizedSVGAttributes(false);
+ m_contextElement->invalidateSVGAttributes();
}
virtual ReturnType baseVal() const { return m_creator.baseValue(); }
@@ -181,14 +181,14 @@ public: \
{ \
m_##LowerProperty.setValue(type); \
SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \
- contextElement->setSynchronizedSVGAttributes(false); \
+ contextElement->invalidateSVGAttributes(); \
} \
\
void set##UpperProperty##BaseValue(SVGAnimatedPropertyTraits<AnimatedType>::PassType type) \
{ \
m_##LowerProperty.setBaseValue(type); \
SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \
- contextElement->setSynchronizedSVGAttributes(false); \
+ contextElement->invalidateSVGAttributes(); \
} \
\
void synchronize##UpperProperty() \
diff --git a/WebCore/svg/SVGClipPathElement.cpp b/WebCore/svg/SVGClipPathElement.cpp
index 694e0bc..dd880f5 100644
--- a/WebCore/svg/SVGClipPathElement.cpp
+++ b/WebCore/svg/SVGClipPathElement.cpp
@@ -74,7 +74,7 @@ void SVGClipPathElement::svgAttributeChanged(const QualifiedName& attrName)
SVGLangSpace::isKnownAttribute(attrName) ||
SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
SVGStyledTransformableElement::isKnownAttribute(attrName))
- invalidateCanvasResources();
+ invalidateResourceClients();
}
void SVGClipPathElement::synchronizeProperty(const QualifiedName& attrName)
@@ -96,7 +96,9 @@ void SVGClipPathElement::synchronizeProperty(const QualifiedName& attrName)
void SVGClipPathElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
{
SVGStyledTransformableElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
- invalidateCanvasResources();
+
+ if (!changedByParser)
+ invalidateResourceClients();
}
RenderObject* SVGClipPathElement::createRenderer(RenderArena* arena, RenderStyle*)
diff --git a/WebCore/svg/SVGClipPathElement.h b/WebCore/svg/SVGClipPathElement.h
index dbf5380..40e34f0 100644
--- a/WebCore/svg/SVGClipPathElement.h
+++ b/WebCore/svg/SVGClipPathElement.h
@@ -29,6 +29,7 @@
#include "SVGTests.h"
namespace WebCore {
+
class SVGClipPathElement : public SVGStyledTransformableElement,
public SVGTests,
public SVGLangSpace,
diff --git a/WebCore/svg/SVGDocumentExtensions.cpp b/WebCore/svg/SVGDocumentExtensions.cpp
index ef2e40c..0db682f 100644
--- a/WebCore/svg/SVGDocumentExtensions.cpp
+++ b/WebCore/svg/SVGDocumentExtensions.cpp
@@ -62,7 +62,7 @@ void SVGDocumentExtensions::removeTimeContainer(SVGSVGElement* element)
m_timeContainers.remove(element);
}
-void SVGDocumentExtensions::addResource(const String& id, RenderSVGResource* resource)
+void SVGDocumentExtensions::addResource(const AtomicString& id, RenderSVGResourceContainer* resource)
{
ASSERT(resource);
@@ -73,16 +73,15 @@ void SVGDocumentExtensions::addResource(const String& id, RenderSVGResource* res
m_resources.set(id, resource);
}
-void SVGDocumentExtensions::removeResource(const String& id)
+void SVGDocumentExtensions::removeResource(const AtomicString& id)
{
- if (id.isEmpty())
+ if (id.isEmpty() || !m_resources.contains(id))
return;
- ASSERT(m_resources.contains(id));
m_resources.remove(id);
}
-RenderSVGResource* SVGDocumentExtensions::resourceById(const String& id) const
+RenderSVGResourceContainer* SVGDocumentExtensions::resourceById(const AtomicString& id) const
{
if (id.isEmpty())
return 0;
@@ -148,7 +147,7 @@ void SVGDocumentExtensions::addPendingResource(const AtomicString& id, SVGStyled
if (m_pendingResources.contains(id))
m_pendingResources.get(id)->add(obj);
else {
- HashSet<SVGStyledElement*>* set = new HashSet<SVGStyledElement*>();
+ HashSet<SVGStyledElement*>* set = new HashSet<SVGStyledElement*>;
set->add(obj);
m_pendingResources.add(id, set);
diff --git a/WebCore/svg/SVGDocumentExtensions.h b/WebCore/svg/SVGDocumentExtensions.h
index f5de647..d31536c 100644
--- a/WebCore/svg/SVGDocumentExtensions.h
+++ b/WebCore/svg/SVGDocumentExtensions.h
@@ -24,18 +24,16 @@
#define SVGDocumentExtensions_h
#if ENABLE(SVG)
-
-#include <wtf/PassOwnPtr.h>
-#include <wtf/HashSet.h>
-#include <wtf/HashMap.h>
-
-#include "StringHash.h"
+#include "AtomicStringHash.h"
#include "StringImpl.h"
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/PassOwnPtr.h>
namespace WebCore {
class Document;
-class RenderSVGResource;
+class RenderSVGResourceContainer;
class String;
class SVGStyledElement;
class SVGSMILElement;
@@ -49,9 +47,9 @@ public:
void addTimeContainer(SVGSVGElement*);
void removeTimeContainer(SVGSVGElement*);
- void addResource(const String& id, RenderSVGResource*);
- void removeResource(const String& id);
- RenderSVGResource* resourceById(const String& id) const;
+ void addResource(const AtomicString& id, RenderSVGResourceContainer*);
+ void removeResource(const AtomicString& id);
+ RenderSVGResourceContainer* resourceById(const AtomicString& id) const;
void startAnimations();
void pauseAnimations();
@@ -64,8 +62,8 @@ public:
private:
Document* m_doc; // weak reference
HashSet<SVGSVGElement*> m_timeContainers; // For SVG 1.2 support this will need to be made more general.
- HashMap<String, RenderSVGResource*> m_resources;
- HashMap<String, HashSet<SVGStyledElement*>*> m_pendingResources;
+ HashMap<AtomicString, RenderSVGResourceContainer*> m_resources;
+ HashMap<AtomicString, HashSet<SVGStyledElement*>*> m_pendingResources;
SVGDocumentExtensions(const SVGDocumentExtensions&);
SVGDocumentExtensions& operator=(const SVGDocumentExtensions&);
diff --git a/WebCore/svg/SVGElement.cpp b/WebCore/svg/SVGElement.cpp
index 41bbba4..ab146bb 100644
--- a/WebCore/svg/SVGElement.cpp
+++ b/WebCore/svg/SVGElement.cpp
@@ -41,7 +41,6 @@
#include "SVGElementInstance.h"
#include "SVGElementRareData.h"
#include "SVGNames.h"
-#include "SVGResource.h"
#include "SVGSVGElement.h"
#include "SVGURIReference.h"
#include "SVGUseElement.h"
@@ -53,7 +52,7 @@ namespace WebCore {
using namespace HTMLNames;
SVGElement::SVGElement(const QualifiedName& tagName, Document* document)
- : StyledElement(tagName, document, CreateElementZeroRefCount)
+ : StyledElement(tagName, document, CreateSVGElementZeroRefCount)
{
}
@@ -96,7 +95,7 @@ SVGElementRareData* SVGElement::ensureRareSVGData()
ASSERT(!SVGElementRareData::rareDataMap().contains(this));
SVGElementRareData* data = new SVGElementRareData;
SVGElementRareData::rareDataMap().set(this, data);
- m_hasRareSVGData = true;
+ setHasRareSVGData();
return data;
}
@@ -281,7 +280,7 @@ void SVGElement::insertedIntoDocument()
StyledElement::insertedIntoDocument();
SVGDocumentExtensions* extensions = document()->accessSVGExtensions();
- String resourceId = SVGURIReference::getTarget(getAttribute(idAttributeName()));
+ String resourceId = getAttribute(idAttributeName());
if (extensions->isPendingResource(resourceId)) {
OwnPtr<HashSet<SVGStyledElement*> > clients(extensions->removePendingResource(resourceId));
if (clients->isEmpty())
@@ -292,8 +291,6 @@ void SVGElement::insertedIntoDocument()
for (; it != end; ++it)
(*it)->buildPendingResource();
-
- SVGResource::invalidateClients(*clients);
}
}
@@ -309,18 +306,16 @@ void SVGElement::attributeChanged(Attribute* attr, bool preserveDecls)
void SVGElement::updateAnimatedSVGAttribute(const QualifiedName& name) const
{
- ASSERT(!m_areSVGAttributesValid);
-
- if (m_synchronizingSVGAttributes)
+ if (isSynchronizingSVGAttributes() || areSVGAttributesValid())
return;
- m_synchronizingSVGAttributes = true;
+ setIsSynchronizingSVGAttributes();
const_cast<SVGElement*>(this)->synchronizeProperty(name);
if (name == anyQName())
- m_areSVGAttributesValid = true;
+ setAreSVGAttributesValid();
- m_synchronizingSVGAttributes = false;
+ clearIsSynchronizingSVGAttributes();
}
ContainerNode* SVGElement::eventParentNode()
diff --git a/WebCore/svg/SVGElement.h b/WebCore/svg/SVGElement.h
index 88d7412..9467250 100644
--- a/WebCore/svg/SVGElement.h
+++ b/WebCore/svg/SVGElement.h
@@ -72,20 +72,21 @@ namespace WebCore {
virtual AffineTransform* supplementalTransform() { return 0; }
- void setSynchronizedSVGAttributes(bool value) { m_areSVGAttributesValid = value; }
+ void invalidateSVGAttributes() { clearAreSVGAttributesValid(); }
const HashSet<SVGElementInstance*>& instancesForElement() const;
void setCursorElement(SVGCursorElement*);
void setCursorImageValue(CSSCursorImageValue*);
+ virtual void updateAnimatedSVGAttribute(const QualifiedName&) const;
+
protected:
SVGElement(const QualifiedName&, Document*);
virtual void finishParsingChildren();
virtual void insertedIntoDocument();
virtual void attributeChanged(Attribute*, bool preserveDecls = false);
- virtual void updateAnimatedSVGAttribute(const QualifiedName&) const;
SVGElementRareData* rareSVGData() const;
SVGElementRareData* ensureRareSVGData();
@@ -93,7 +94,6 @@ namespace WebCore {
private:
friend class SVGElementInstance;
- virtual bool isSVGElement() const { return true; }
virtual bool isSupported(StringImpl* feature, StringImpl* version) const;
virtual ContainerNode* eventParentNode();
diff --git a/WebCore/svg/SVGElementInstance.idl b/WebCore/svg/SVGElementInstance.idl
index d23fea2..3fcadb9 100644
--- a/WebCore/svg/SVGElementInstance.idl
+++ b/WebCore/svg/SVGElementInstance.idl
@@ -90,12 +90,12 @@ module svg {
attribute [DontEnum] EventListener onsubmit;
attribute [DontEnum] EventListener onunload;
- [JSCCustom] void addEventListener(in DOMString type,
- in EventListener listener,
- in boolean useCapture);
- [JSCCustom] void removeEventListener(in DOMString type,
- in EventListener listener,
- in boolean useCapture);
+ void addEventListener(in DOMString type,
+ in EventListener listener,
+ in boolean useCapture);
+ void removeEventListener(in DOMString type,
+ in EventListener listener,
+ in boolean useCapture);
boolean dispatchEvent(in Event event)
raises(EventException);
#endif /* defined(LANGUAGE_OBJECTIVE_C) */
diff --git a/WebCore/svg/SVGFont.cpp b/WebCore/svg/SVGFont.cpp
index dacbac2..049d35e 100644
--- a/WebCore/svg/SVGFont.cpp
+++ b/WebCore/svg/SVGFont.cpp
@@ -27,6 +27,7 @@
#include "CSSFontSelector.h"
#include "GraphicsContext.h"
#include "RenderObject.h"
+#include "RenderSVGResourceSolidColor.h"
#include "SimpleFontData.h"
#include "SVGAltGlyphElement.h"
#include "SVGFontData.h"
@@ -35,8 +36,6 @@
#include "SVGFontElement.h"
#include "SVGFontFaceElement.h"
#include "SVGMissingGlyphElement.h"
-#include "SVGPaintServer.h"
-#include "SVGPaintServerSolid.h"
#include "XMLNames.h"
using namespace WTF::Unicode;
@@ -471,20 +470,20 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
FloatPoint currentPoint = point;
float scale = convertEmUnitToPixel(size(), fontFaceElement->unitsPerEm(), 1.0f);
- SVGPaintServer* activePaintServer = run.activePaintServer();
+ RenderSVGResource* activePaintingResource = run.activePaintingResource();
// If renderObject is not set, we're dealing for HTML text rendered using SVG Fonts.
if (!run.referencingRenderObject()) {
- ASSERT(!activePaintServer);
+ ASSERT(!activePaintingResource);
// TODO: We're only supporting simple filled HTML text so far.
- SVGPaintServerSolid* solidPaintServer = SVGPaintServer::sharedSolidPaintServer();
- solidPaintServer->setColor(context->fillColor());
+ RenderSVGResourceSolidColor* solidPaintingResource = RenderSVGResource::sharedSolidPaintingResource();
+ solidPaintingResource->setColor(context->fillColor());
- activePaintServer = solidPaintServer;
+ activePaintingResource = solidPaintingResource;
}
- ASSERT(activePaintServer);
+ ASSERT(activePaintingResource);
int charsConsumed;
String glyphName;
@@ -513,7 +512,7 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
SVGTextRunWalker<SVGTextRunWalkerDrawTextData> runWalker(fontData, fontElement, data, drawTextUsingSVGFontCallback, drawTextMissingGlyphCallback);
runWalker.walk(run, isVerticalText, language, from, to);
- SVGPaintTargetType targetType = context->textDrawingMode() == cTextStroke ? ApplyToStrokeTargetType : ApplyToFillTargetType;
+ RenderSVGResourceMode resourceMode = context->textDrawingMode() == cTextStroke ? ApplyToStrokeMode : ApplyToFillMode;
unsigned numGlyphs = data.glyphIdentifiers.size();
unsigned fallbackCharacterIndex = 0;
@@ -538,10 +537,10 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
context->beginPath();
context->addPath(glyphPath);
- if (activePaintServer->setup(context, run.referencingRenderObject(), targetType)) {
- activePaintServer->renderPath(context, run.referencingRenderObject(), targetType);
- activePaintServer->teardown(context, run.referencingRenderObject(), targetType);
- }
+
+ RenderStyle* style = run.referencingRenderObject() ? run.referencingRenderObject()->style() : 0;
+ if (activePaintingResource->applyResource(run.referencingRenderObject(), style, context, resourceMode))
+ activePaintingResource->postApplyResource(run.referencingRenderObject(), context, resourceMode);
context->restore();
}
diff --git a/WebCore/svg/SVGFontElement.cpp b/WebCore/svg/SVGFontElement.cpp
index 91d222c..a573350 100644
--- a/WebCore/svg/SVGFontElement.cpp
+++ b/WebCore/svg/SVGFontElement.cpp
@@ -95,149 +95,64 @@ void SVGFontElement::ensureGlyphCache() const
m_isGlyphCacheValid = true;
}
-
-// Returns the number of characters consumed or 0 if no range was found.
-static unsigned parseUnicodeRange(const UChar* characters, unsigned length, pair<unsigned, unsigned>& range)
+
+static bool stringMatchesUnicodeRange(const String& unicodeString, const UnicodeRanges& ranges, const HashSet<String>& unicodeValues)
{
- if (length < 2)
- return 0;
- if (characters[0] != 'U')
- return 0;
- if (characters[1] != '+')
- return 0;
-
- // Parse the starting hex number (or its prefix).
- unsigned start = 0;
- unsigned startLength = 0;
- for (unsigned i = 2; i < length; ++i) {
- if (!isASCIIHexDigit(characters[i]))
- break;
- if (++startLength > 6)
- return 0;
- start = (start << 4) | toASCIIHexValue(characters[i]);
- }
-
- // Handle the case of ranges separated by "-" sign.
- if (2 + startLength < length && characters[2 + startLength] == '-') {
- if (!startLength)
- return 0;
-
- // Parse the ending hex number (or its prefix).
- unsigned end = 0;
- unsigned endLength = 0;
- for (unsigned i = 2 + startLength + 1; i < length; ++i) {
- if (!isASCIIHexDigit(characters[i]))
- break;
- if (++endLength > 6)
- return 0;
- end = (end << 4) | toASCIIHexValue(characters[i]);
+ if (unicodeString.isEmpty())
+ return false;
+
+ if (!ranges.isEmpty()) {
+ UChar firstChar = unicodeString[0];
+ const UnicodeRanges::const_iterator end = ranges.end();
+ for (UnicodeRanges::const_iterator it = ranges.begin(); it != end; ++it) {
+ if (firstChar >= it->first && firstChar <= it->second)
+ return true;
}
-
- if (!endLength)
- return 0;
-
- range.first = start;
- range.second = end;
- return 2 + startLength + 1 + endLength;
}
+
+ if (!unicodeValues.isEmpty())
+ return unicodeValues.contains(unicodeString);
- // Handle the case of a number with some optional trailing question marks.
- unsigned end = start;
- for (unsigned i = 2 + startLength; i < length; ++i) {
- if (characters[i] != '?')
- break;
- if (++startLength > 6)
- return 0;
- start <<= 4;
- end = (end << 4) | 0xF;
- }
-
- if (!startLength)
- return 0;
-
- range.first = start;
- range.second = end;
- return 2 + startLength;
-}
-
-static bool parseUnicodeRangeList(const UChar* characters, unsigned length, Vector<pair<unsigned, unsigned> >& ranges)
-{
- ranges.clear();
- if (!length)
- return true;
-
- const UChar* remainingCharacters = characters;
- unsigned remainingLength = length;
-
- while (1) {
- pair<unsigned, unsigned> range;
- unsigned charactersConsumed = parseUnicodeRange(remainingCharacters, remainingLength, range);
- if (charactersConsumed) {
- ranges.append(range);
- remainingCharacters += charactersConsumed;
- remainingLength -= charactersConsumed;
- } else {
- if (!remainingLength)
- return false;
- UChar character = remainingCharacters[0];
- if (character == ',')
- return false;
- ranges.append(make_pair(character, character));
- ++remainingCharacters;
- --remainingLength;
- }
- if (!remainingLength)
- return true;
- if (remainingCharacters[0] != ',')
- return false;
- ++remainingCharacters;
- --remainingLength;
- }
+ return false;
}
-static bool stringMatchesUnicodeRange(const String& unicodeString, const String& unicodeRangeSpec)
+static bool stringMatchesGlyphName(const String& glyphName, const HashSet<String>& glyphValues)
{
- Vector<pair<unsigned, unsigned> > ranges;
- if (!parseUnicodeRangeList(unicodeRangeSpec.characters(), unicodeRangeSpec.length(), ranges))
- return false;
-
- if (unicodeString.length() != ranges.size())
+ if (glyphName.isEmpty())
return false;
+
+ if (!glyphValues.isEmpty())
+ return glyphValues.contains(glyphName);
- for (size_t i = 0; i < unicodeString.length(); ++i) {
- UChar c = unicodeString[i];
- if (c < ranges[i].first || c > ranges[i].second)
- return false;
- }
-
- return true;
+ return false;
}
static bool matches(const String& u1, const String& g1, const String& u2, const String& g2, const SVGHorizontalKerningPair& kerningPair)
{
- if (kerningPair.unicode1.length() && !stringMatchesUnicodeRange(u1, kerningPair.unicode1))
+ if (!stringMatchesUnicodeRange(u1, kerningPair.unicodeRange1, kerningPair.unicodeName1)
+ && !stringMatchesGlyphName(g1, kerningPair.glyphName1))
return false;
- if (kerningPair.glyphName1.length() && kerningPair.glyphName1 != g1)
- return false;
-
- if (kerningPair.unicode2.length() && !stringMatchesUnicodeRange(u2, kerningPair.unicode2))
- return false;
- if (kerningPair.glyphName2.length() && kerningPair.glyphName2 != g2)
+
+ if (!stringMatchesUnicodeRange(u2, kerningPair.unicodeRange2, kerningPair.unicodeName2)
+ && !stringMatchesGlyphName(g2, kerningPair.glyphName2))
return false;
-
+
return true;
}
-bool SVGFontElement::getHorizontalKerningPairForStringsAndGlyphs(const String& u1, const String& g1, const String& u2, const String& g2, SVGHorizontalKerningPair& kerningPair) const
+float SVGFontElement::getHorizontalKerningPairForStringsAndGlyphs(const String& u1, const String& g1, const String& u2, const String& g2) const
{
- for (size_t i = 0; i < m_kerningPairs.size(); ++i) {
- if (matches(u1, g1, u2, g2, m_kerningPairs[i])) {
- kerningPair = m_kerningPairs[i];
- return true;
- }
+ if (m_kerningPairs.isEmpty())
+ return 0.0f;
+
+ KerningPairVector::const_iterator it = m_kerningPairs.end() - 1;
+ const KerningPairVector::const_iterator begin = m_kerningPairs.begin() - 1;
+ for (; it != begin; --it) {
+ if (matches(u1, g1, u2, g2, *it))
+ return it->kerning;
}
-
- return false;
+
+ return 0.0f;
}
void SVGFontElement::getGlyphIdentifiersForString(const String& string, Vector<SVGGlyphIdentifier>& glyphs) const
diff --git a/WebCore/svg/SVGFontElement.h b/WebCore/svg/SVGFontElement.h
index 90641a8..31d83c4 100644
--- a/WebCore/svg/SVGFontElement.h
+++ b/WebCore/svg/SVGFontElement.h
@@ -44,7 +44,7 @@ namespace WebCore {
void getGlyphIdentifiersForString(const String&, Vector<SVGGlyphIdentifier>&) const;
- bool getHorizontalKerningPairForStringsAndGlyphs(const String& u1, const String& g1, const String& u2, const String& g2, SVGHorizontalKerningPair& kerningPair) const;
+ float getHorizontalKerningPairForStringsAndGlyphs(const String& u1, const String& g1, const String& u2, const String& g2) const;
SVGMissingGlyphElement* firstMissingGlyphElement() const;
diff --git a/WebCore/svg/SVGGElement.cpp b/WebCore/svg/SVGGElement.cpp
index 6e39bf5..d429400 100644
--- a/WebCore/svg/SVGGElement.cpp
+++ b/WebCore/svg/SVGGElement.cpp
@@ -23,6 +23,7 @@
#if ENABLE(SVG)
#include "SVGGElement.h"
+#include "RenderSVGHiddenContainer.h"
#include "RenderSVGTransformableContainer.h"
namespace WebCore {
@@ -79,16 +80,15 @@ void SVGGElement::synchronizeProperty(const QualifiedName& attrName)
synchronizeExternalResourcesRequired();
}
-void SVGGElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+RenderObject* SVGGElement::createRenderer(RenderArena* arena, RenderStyle* style)
{
- SVGStyledTransformableElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+ // SVG 1.1 testsuite explicitely uses constructs like <g display="none"><linearGradient>
+ // We still have to create renderers for the <g> & <linearGradient> element, though the
+ // subtree may be hidden - we only want the resource renderers to exist so they can be
+ // referenced from somewhere else.
+ if (style->display() == NONE)
+ return new (arena) RenderSVGHiddenContainer(this);
- if (renderer())
- renderer()->setNeedsLayout(true);
-}
-
-RenderObject* SVGGElement::createRenderer(RenderArena* arena, RenderStyle*)
-{
return new (arena) RenderSVGTransformableContainer(this);
}
diff --git a/WebCore/svg/SVGGElement.h b/WebCore/svg/SVGGElement.h
index 3e0dd8e..b90eddb 100644
--- a/WebCore/svg/SVGGElement.h
+++ b/WebCore/svg/SVGGElement.h
@@ -43,8 +43,8 @@ namespace WebCore {
virtual void parseMappedAttribute(MappedAttribute*);
virtual void svgAttributeChanged(const QualifiedName&);
virtual void synchronizeProperty(const QualifiedName&);
- virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+ virtual bool rendererIsNeeded(RenderStyle*) { return true; }
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
private:
diff --git a/WebCore/svg/SVGGradientElement.cpp b/WebCore/svg/SVGGradientElement.cpp
index f573265..b4bdb16 100644
--- a/WebCore/svg/SVGGradientElement.cpp
+++ b/WebCore/svg/SVGGradientElement.cpp
@@ -1,6 +1,7 @@
/*
Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+ Copyright (C) Research In Motion Limited 2010. 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
@@ -27,9 +28,9 @@
#include "MappedAttribute.h"
#include "RenderPath.h"
#include "RenderSVGHiddenContainer.h"
+#include "RenderSVGResourceLinearGradient.h"
+#include "RenderSVGResourceRadialGradient.h"
#include "SVGNames.h"
-#include "SVGPaintServerLinearGradient.h"
-#include "SVGPaintServerRadialGradient.h"
#include "SVGStopElement.h"
#include "SVGTransformList.h"
#include "SVGTransformable.h"
@@ -84,16 +85,13 @@ void SVGGradientElement::svgAttributeChanged(const QualifiedName& attrName)
{
SVGStyledElement::svgAttributeChanged(attrName);
- if (!m_resource)
- return;
-
- if (attrName == SVGNames::gradientUnitsAttr ||
- attrName == SVGNames::gradientTransformAttr ||
- attrName == SVGNames::spreadMethodAttr ||
- SVGURIReference::isKnownAttribute(attrName) ||
- SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
- SVGStyledElement::isKnownAttribute(attrName))
- m_resource->invalidate();
+ if (attrName == SVGNames::gradientUnitsAttr
+ || attrName == SVGNames::gradientTransformAttr
+ || attrName == SVGNames::spreadMethodAttr
+ || SVGURIReference::isKnownAttribute(attrName)
+ || SVGExternalResourcesRequired::isKnownAttribute(attrName)
+ || SVGStyledElement::isKnownAttribute(attrName))
+ invalidateResourceClients();
}
void SVGGradientElement::synchronizeProperty(const QualifiedName& attrName)
@@ -125,61 +123,34 @@ void SVGGradientElement::childrenChanged(bool changedByParser, Node* beforeChang
{
SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
- if (m_resource)
- m_resource->invalidate();
+ if (!changedByParser)
+ invalidateResourceClients();
}
-RenderObject* SVGGradientElement::createRenderer(RenderArena* arena, RenderStyle*)
+Vector<Gradient::ColorStop> SVGGradientElement::buildStops()
{
- return new (arena) RenderSVGHiddenContainer(this);
-}
-
-SVGResource* SVGGradientElement::canvasResource(const RenderObject*)
-{
- if (!m_resource) {
- if (gradientType() == LinearGradientPaintServer)
- m_resource = SVGPaintServerLinearGradient::create(this);
- else
- m_resource = SVGPaintServerRadialGradient::create(this);
- }
-
- return m_resource.get();
-}
-
-Vector<SVGGradientStop> SVGGradientElement::buildStops() const
-{
- Vector<SVGGradientStop> stops;
- RefPtr<RenderStyle> gradientStyle;
+ Vector<Gradient::ColorStop> stops;
+ float previousOffset = 0.0f;
for (Node* n = firstChild(); n; n = n->nextSibling()) {
SVGElement* element = n->isSVGElement() ? static_cast<SVGElement*>(n) : 0;
+ if (!element || !element->isGradientStop())
+ continue;
- if (element && element->isGradientStop()) {
- SVGStopElement* stop = static_cast<SVGStopElement*>(element);
- float stopOffset = stop->offset();
+ SVGStopElement* stop = static_cast<SVGStopElement*>(element);
+ Color color = stop->stopColorIncludingOpacity();
- Color color;
- float opacity;
+ // Figure out right monotonic offset
+ float offset = stop->offset();
+ offset = std::min(std::max(previousOffset, offset), 1.0f);
+ previousOffset = offset;
- if (stop->renderer()) {
- RenderStyle* stopStyle = stop->renderer()->style();
- color = stopStyle->svgStyle()->stopColor();
- opacity = stopStyle->svgStyle()->stopOpacity();
- } else {
- // If there is no renderer for this stop element, then a parent element
- // set display="none" - ie. <g display="none"><linearGradient><stop>..
- // Unfortunately we have to manually rebuild the stop style. See pservers-grad-19-b.svg
- if (!gradientStyle)
- gradientStyle = const_cast<SVGGradientElement*>(this)->styleForRenderer();
+ // Extract individual channel values
+ // FIXME: Why doesn't ColorStop take a Color and an offset??
+ float r, g, b, a;
+ color.getRGBA(r, g, b, a);
- RefPtr<RenderStyle> stopStyle = stop->resolveStyle(gradientStyle.get());
-
- color = stopStyle->svgStyle()->stopColor();
- opacity = stopStyle->svgStyle()->stopOpacity();
- }
-
- stops.append(makeGradientStop(stopOffset, makeRGBA(color.red(), color.green(), color.blue(), int(opacity * 255.))));
- }
+ stops.append(Gradient::ColorStop(offset, r, g, b, a));
}
return stops;
diff --git a/WebCore/svg/SVGGradientElement.h b/WebCore/svg/SVGGradientElement.h
index 122e1d9..4447ec4 100644
--- a/WebCore/svg/SVGGradientElement.h
+++ b/WebCore/svg/SVGGradientElement.h
@@ -22,8 +22,7 @@
#define SVGGradientElement_h
#if ENABLE(SVG)
-#include "RenderObject.h"
-#include "SVGPaintServerGradient.h"
+#include "Gradient.h"
#include "SVGExternalResourcesRequired.h"
#include "SVGStyledElement.h"
#include "SVGTransformList.h"
@@ -43,20 +42,8 @@ namespace WebCore {
virtual void synchronizeProperty(const QualifiedName&);
virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
- virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
- virtual SVGResource* canvasResource(const RenderObject*);
-
- protected:
- friend class SVGPaintServerGradient;
- friend class SVGLinearGradientElement;
- friend class SVGRadialGradientElement;
-
- virtual void buildGradient() const = 0;
- virtual SVGPaintServerType gradientType() const = 0;
-
- Vector<SVGGradientStop> buildStops() const;
- mutable RefPtr<SVGPaintServerGradient> m_resource;
+ Vector<Gradient::ColorStop> buildStops();
protected:
DECLARE_ANIMATED_PROPERTY(SVGGradientElement, SVGNames::spreadMethodAttr, int, SpreadMethod, spreadMethod)
diff --git a/WebCore/svg/SVGHKernElement.cpp b/WebCore/svg/SVGHKernElement.cpp
index 0ee3e76..1b8746b 100644
--- a/WebCore/svg/SVGHKernElement.cpp
+++ b/WebCore/svg/SVGHKernElement.cpp
@@ -28,7 +28,6 @@
#include "SVGFontFaceElement.h"
#include "SVGFontData.h"
#include "SVGNames.h"
-#include "SVGParserUtilities.h"
#include "SimpleFontData.h"
#include "XMLNames.h"
@@ -67,11 +66,12 @@ SVGHorizontalKerningPair SVGHKernElement::buildHorizontalKerningPair() const
{
SVGHorizontalKerningPair kerningPair;
- kerningPair.unicode1 = getAttribute(u1Attr);
- kerningPair.glyphName1 = getAttribute(g1Attr);
- kerningPair.unicode2 = getAttribute(u2Attr);
- kerningPair.glyphName2 = getAttribute(g2Attr);
- kerningPair.kerning = getAttribute(kAttr).string().toDouble();
+ // FIXME: KerningPairs shouldn't be created on parsing errors.
+ parseGlyphName(getAttribute(g1Attr), kerningPair.glyphName1);
+ parseGlyphName(getAttribute(g2Attr), kerningPair.glyphName2);
+ parseKerningUnicodeString(getAttribute(u1Attr), kerningPair.unicodeRange1, kerningPair.unicodeName1);
+ parseKerningUnicodeString(getAttribute(u2Attr), kerningPair.unicodeRange2, kerningPair.unicodeName2);
+ kerningPair.kerning = getAttribute(kAttr).string().toFloat();
return kerningPair;
}
diff --git a/WebCore/svg/SVGHKernElement.h b/WebCore/svg/SVGHKernElement.h
index 32772bd..3d13119 100644
--- a/WebCore/svg/SVGHKernElement.h
+++ b/WebCore/svg/SVGHKernElement.h
@@ -23,10 +23,10 @@
#define SVGHKernElement_h
#if ENABLE(SVG_FONTS)
+#include "SVGParserUtilities.h"
#include "SVGStyledElement.h"
#include <limits>
-#include "Path.h"
namespace WebCore {
@@ -35,11 +35,13 @@ namespace WebCore {
// Describe an SVG <hkern> element
struct SVGHorizontalKerningPair {
- String unicode1;
- String glyphName1;
- String unicode2;
- String glyphName2;
- double kerning;
+ UnicodeRanges unicodeRange1;
+ HashSet<String> unicodeName1;
+ HashSet<String> glyphName1;
+ UnicodeRanges unicodeRange2;
+ HashSet<String> unicodeName2;
+ HashSet<String> glyphName2;
+ float kerning;
SVGHorizontalKerningPair()
: kerning(0)
diff --git a/WebCore/svg/SVGLinearGradientElement.cpp b/WebCore/svg/SVGLinearGradientElement.cpp
index 665a1da..87021b1 100644
--- a/WebCore/svg/SVGLinearGradientElement.cpp
+++ b/WebCore/svg/SVGLinearGradientElement.cpp
@@ -3,6 +3,7 @@
2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
2008 Eric Seidel <eric@webkit.org>
2008 Dirk Schulze <krit@webkit.org>
+ Copyright (C) Research In Motion Limited 2010. 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
@@ -29,9 +30,9 @@
#include "FloatPoint.h"
#include "LinearGradientAttributes.h"
#include "MappedAttribute.h"
+#include "RenderSVGResourceLinearGradient.h"
#include "SVGLength.h"
#include "SVGNames.h"
-#include "SVGPaintServerLinearGradient.h"
#include "SVGTransform.h"
#include "SVGTransformList.h"
#include "SVGUnitTypes.h"
@@ -70,12 +71,11 @@ void SVGLinearGradientElement::svgAttributeChanged(const QualifiedName& attrName
{
SVGGradientElement::svgAttributeChanged(attrName);
- if (!m_resource)
- return;
-
- if (attrName == SVGNames::x1Attr || attrName == SVGNames::y1Attr ||
- attrName == SVGNames::x2Attr || attrName == SVGNames::y2Attr)
- m_resource->invalidate();
+ if (attrName == SVGNames::x1Attr
+ || attrName == SVGNames::y1Attr
+ || attrName == SVGNames::x2Attr
+ || attrName == SVGNames::y2Attr)
+ invalidateResourceClients();
}
void SVGLinearGradientElement::synchronizeProperty(const QualifiedName& attrName)
@@ -100,56 +100,18 @@ void SVGLinearGradientElement::synchronizeProperty(const QualifiedName& attrName
synchronizeY2();
}
-void SVGLinearGradientElement::buildGradient() const
+RenderObject* SVGLinearGradientElement::createRenderer(RenderArena* arena, RenderStyle*)
{
- LinearGradientAttributes attributes = collectGradientProperties();
-
- RefPtr<SVGPaintServerLinearGradient> linearGradient = WTF::static_pointer_cast<SVGPaintServerLinearGradient>(m_resource);
-
- FloatPoint startPoint;
- FloatPoint endPoint;
- if (attributes.boundingBoxMode()) {
- startPoint = FloatPoint(attributes.x1().valueAsPercentage(), attributes.y1().valueAsPercentage());
- endPoint = FloatPoint(attributes.x2().valueAsPercentage(), attributes.y2().valueAsPercentage());
- } else {
- startPoint = FloatPoint(attributes.x1().value(this), attributes.y1().value(this));
- endPoint = FloatPoint(attributes.x2().value(this), attributes.y2().value(this));
- }
-
- RefPtr<Gradient> gradient = Gradient::create(startPoint, endPoint);
- gradient->setSpreadMethod(attributes.spreadMethod());
-
- 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;
-
- // 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->setGradientTransform(attributes.gradientTransform());
- linearGradient->setGradientStart(startPoint);
- linearGradient->setGradientEnd(endPoint);
+ return new (arena) RenderSVGResourceLinearGradient(this);
}
-LinearGradientAttributes SVGLinearGradientElement::collectGradientProperties() const
+LinearGradientAttributes SVGLinearGradientElement::collectGradientProperties()
{
LinearGradientAttributes attributes;
- HashSet<const SVGGradientElement*> processedGradients;
+ HashSet<SVGGradientElement*> processedGradients;
bool isLinear = true;
- const SVGGradientElement* current = this;
+ SVGGradientElement* current = this;
while (current) {
if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spreadMethodAttr))
@@ -162,13 +124,13 @@ LinearGradientAttributes SVGLinearGradientElement::collectGradientProperties() c
attributes.setGradientTransform(current->gradientTransform()->consolidate().matrix());
if (!attributes.hasStops()) {
- const Vector<SVGGradientStop>& stops(current->buildStops());
+ const Vector<Gradient::ColorStop>& stops(current->buildStops());
if (!stops.isEmpty())
attributes.setStops(stops);
}
if (isLinear) {
- const SVGLinearGradientElement* linear = static_cast<const SVGLinearGradientElement*>(current);
+ SVGLinearGradientElement* linear = static_cast<SVGLinearGradientElement*>(current);
if (!attributes.hasX1() && current->hasAttribute(SVGNames::x1Attr))
attributes.setX1(linear->x1());
@@ -188,13 +150,13 @@ LinearGradientAttributes SVGLinearGradientElement::collectGradientProperties() c
// Respect xlink:href, take attributes from referenced element
Node* refNode = ownerDocument()->getElementById(SVGURIReference::getTarget(current->href()));
if (refNode && (refNode->hasTagName(SVGNames::linearGradientTag) || refNode->hasTagName(SVGNames::radialGradientTag))) {
- current = static_cast<const SVGGradientElement*>(const_cast<const Node*>(refNode));
+ current = static_cast<SVGGradientElement*>(refNode);
// Cycle detection
if (processedGradients.contains(current))
return LinearGradientAttributes();
- isLinear = current->gradientType() == LinearGradientPaintServer;
+ isLinear = current->hasTagName(SVGNames::linearGradientTag);
} else
current = 0;
}
@@ -202,6 +164,18 @@ LinearGradientAttributes SVGLinearGradientElement::collectGradientProperties() c
return attributes;
}
+void SVGLinearGradientElement::calculateStartEndPoints(const LinearGradientAttributes& attributes, FloatPoint& startPoint, FloatPoint& endPoint)
+{
+ // Determine gradient start/end points
+ if (attributes.boundingBoxMode()) {
+ startPoint = FloatPoint(attributes.x1().valueAsPercentage(), attributes.y1().valueAsPercentage());
+ endPoint = FloatPoint(attributes.x2().valueAsPercentage(), attributes.y2().valueAsPercentage());
+ } else {
+ startPoint = FloatPoint(attributes.x1().value(this), attributes.y1().value(this));
+ endPoint = FloatPoint(attributes.x2().value(this), attributes.y2().value(this));
+ }
+}
+
}
#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGLinearGradientElement.h b/WebCore/svg/SVGLinearGradientElement.h
index 0308c0e..f92fe80 100644
--- a/WebCore/svg/SVGLinearGradientElement.h
+++ b/WebCore/svg/SVGLinearGradientElement.h
@@ -38,11 +38,10 @@ namespace WebCore {
virtual void svgAttributeChanged(const QualifiedName&);
virtual void synchronizeProperty(const QualifiedName&);
- protected:
- virtual void buildGradient() const;
- virtual SVGPaintServerType gradientType() const { return LinearGradientPaintServer; }
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
- LinearGradientAttributes collectGradientProperties() const;
+ LinearGradientAttributes collectGradientProperties();
+ void calculateStartEndPoints(const LinearGradientAttributes&, FloatPoint& startPoint, FloatPoint& endPoint);
private:
DECLARE_ANIMATED_PROPERTY(SVGLinearGradientElement, SVGNames::x1Attr, SVGLength, X1, x1)
diff --git a/WebCore/svg/SVGMarkerElement.cpp b/WebCore/svg/SVGMarkerElement.cpp
index ba9728f..79a445c 100644
--- a/WebCore/svg/SVGMarkerElement.cpp
+++ b/WebCore/svg/SVGMarkerElement.cpp
@@ -111,7 +111,7 @@ void SVGMarkerElement::svgAttributeChanged(const QualifiedName& attrName)
SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
SVGFitToViewBox::isKnownAttribute(attrName) ||
SVGStyledElement::isKnownAttribute(attrName))
- invalidateCanvasResources();
+ invalidateResourceClients();
}
void SVGMarkerElement::synchronizeProperty(const QualifiedName& attrName)
@@ -157,7 +157,8 @@ void SVGMarkerElement::childrenChanged(bool changedByParser, Node* beforeChange,
{
SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
- invalidateCanvasResources();
+ if (!changedByParser)
+ invalidateResourceClients();
}
void SVGMarkerElement::setOrientToAuto()
@@ -165,7 +166,7 @@ void SVGMarkerElement::setOrientToAuto()
setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO);
setOrientAngleBaseValue(SVGAngle());
- invalidateCanvasResources();
+ invalidateResourceClients();
}
void SVGMarkerElement::setOrientToAngle(const SVGAngle& angle)
@@ -173,7 +174,7 @@ void SVGMarkerElement::setOrientToAngle(const SVGAngle& angle)
setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE);
setOrientAngleBaseValue(angle);
- invalidateCanvasResources();
+ invalidateResourceClients();
}
RenderObject* SVGMarkerElement::createRenderer(RenderArena* arena, RenderStyle*)
diff --git a/WebCore/svg/SVGMaskElement.cpp b/WebCore/svg/SVGMaskElement.cpp
index 67b0a98..6eb19fc 100644
--- a/WebCore/svg/SVGMaskElement.cpp
+++ b/WebCore/svg/SVGMaskElement.cpp
@@ -104,7 +104,7 @@ void SVGMaskElement::svgAttributeChanged(const QualifiedName& attrName)
SVGLangSpace::isKnownAttribute(attrName) ||
SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
SVGStyledElement::isKnownAttribute(attrName))
- invalidateCanvasResources();
+ invalidateResourceClients();
}
void SVGMaskElement::synchronizeProperty(const QualifiedName& attrName)
@@ -138,7 +138,9 @@ void SVGMaskElement::synchronizeProperty(const QualifiedName& attrName)
void SVGMaskElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
{
SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
- invalidateCanvasResources();
+
+ if (!changedByParser)
+ invalidateResourceClients();
}
FloatRect SVGMaskElement::maskBoundingBox(const FloatRect& objectBoundingBox) const
diff --git a/WebCore/svg/SVGParserUtilities.cpp b/WebCore/svg/SVGParserUtilities.cpp
index fc9ca5d..b24c3cc 100644
--- a/WebCore/svg/SVGParserUtilities.cpp
+++ b/WebCore/svg/SVGParserUtilities.cpp
@@ -44,6 +44,7 @@
#include "SVGPointList.h"
#include "SVGPathElement.h"
#include <math.h>
+#include <wtf/ASCIICType.h>
#include <wtf/MathExtras.h>
namespace WebCore {
@@ -840,6 +841,125 @@ bool pathSegListFromSVGData(SVGPathSegList* path, const String& d, bool process)
return builder.build(path, d, process);
}
+void parseGlyphName(const String& input, HashSet<String>& values)
+{
+ values.clear();
+
+ const UChar* ptr = input.characters();
+ const UChar* end = ptr + input.length();
+ skipOptionalSpaces(ptr, end);
+
+ while (ptr < end) {
+ // Leading and trailing white space, and white space before and after separators, will be ignored.
+ const UChar* inputStart = ptr;
+ while (ptr < end && *ptr != ',')
+ ++ptr;
+
+ if (ptr == inputStart)
+ break;
+
+ // walk backwards from the ; to ignore any whitespace
+ const UChar* inputEnd = ptr - 1;
+ while (inputStart < inputEnd && isWhitespace(*inputEnd))
+ --inputEnd;
+
+ values.add(String(inputStart, inputEnd - inputStart + 1));
+ skipOptionalSpacesOrDelimiter(ptr, end, ',');
+ }
+}
+
+static bool parseUnicodeRange(const UChar* characters, unsigned length, UnicodeRange& range)
+{
+ if (length < 2 || characters[0] != 'U' || characters[1] != '+')
+ return false;
+
+ // Parse the starting hex number (or its prefix).
+ unsigned startRange = 0;
+ unsigned startLength = 0;
+
+ const UChar* ptr = characters + 2;
+ const UChar* end = characters + length;
+ while (ptr < end) {
+ if (!isASCIIHexDigit(*ptr))
+ break;
+ ++startLength;
+ if (startLength > 6)
+ return false;
+ startRange = (startRange << 4) | toASCIIHexValue(*ptr);
+ ++ptr;
+ }
+
+ // Handle the case of ranges separated by "-" sign.
+ if (2 + startLength < length && *ptr == '-') {
+ if (!startLength)
+ return false;
+
+ // Parse the ending hex number (or its prefix).
+ unsigned endRange = 0;
+ unsigned endLength = 0;
+ ++ptr;
+ while (ptr < end) {
+ if (!isASCIIHexDigit(*ptr))
+ break;
+ ++endLength;
+ if (endLength > 6)
+ return false;
+ endRange = (endRange << 4) | toASCIIHexValue(*ptr);
+ ++ptr;
+ }
+
+ if (!endLength)
+ return false;
+
+ range.first = startRange;
+ range.second = endRange;
+ return true;
+ }
+
+ // Handle the case of a number with some optional trailing question marks.
+ unsigned endRange = startRange;
+ while (ptr < end) {
+ if (*ptr != '?')
+ break;
+ ++startLength;
+ if (startLength > 6)
+ return false;
+ startRange <<= 4;
+ endRange = (endRange << 4) | 0xF;
+ ++ptr;
+ }
+
+ if (!startLength)
+ return false;
+
+ range.first = startRange;
+ range.second = endRange;
+ return true;
+}
+
+void parseKerningUnicodeString(const String& input, UnicodeRanges& rangeList, HashSet<String>& stringList)
+{
+ const UChar* ptr = input.characters();
+ const UChar* end = ptr + input.length();
+
+ while (ptr < end) {
+ const UChar* inputStart = ptr;
+ while (ptr < end && *ptr != ',')
+ ++ptr;
+
+ if (ptr == inputStart)
+ break;
+
+ // Try to parse unicode range first
+ UnicodeRange range;
+ if (parseUnicodeRange(inputStart, ptr - inputStart, range))
+ rangeList.append(range);
+ else
+ stringList.add(String(inputStart, ptr - inputStart));
+ ++ptr;
+ }
+}
+
Vector<String> parseDelimitedString(const String& input, const char seperator)
{
Vector<String> values;
diff --git a/WebCore/svg/SVGParserUtilities.h b/WebCore/svg/SVGParserUtilities.h
index 8d3c9b2..3761688 100644
--- a/WebCore/svg/SVGParserUtilities.h
+++ b/WebCore/svg/SVGParserUtilities.h
@@ -23,6 +23,10 @@
#if ENABLE(SVG)
#include "ParserUtilities.h"
+#include <wtf/HashSet.h>
+
+typedef pair<unsigned, unsigned> UnicodeRange;
+typedef Vector<UnicodeRange> UnicodeRanges;
namespace WebCore {
@@ -64,6 +68,8 @@ namespace WebCore {
bool pathFromSVGData(Path& path, const String& d);
bool pathSegListFromSVGData(SVGPathSegList* pathSegList, const String& d, bool process = false);
Vector<String> parseDelimitedString(const String& input, const char seperator);
+ void parseKerningUnicodeString(const String& input, UnicodeRanges&, HashSet<String>& stringList);
+ void parseGlyphName(const String& input, HashSet<String>& values);
} // namespace WebCore
diff --git a/WebCore/svg/SVGPatternElement.cpp b/WebCore/svg/SVGPatternElement.cpp
index 7659afa..3df6198 100644
--- a/WebCore/svg/SVGPatternElement.cpp
+++ b/WebCore/svg/SVGPatternElement.cpp
@@ -1,6 +1,7 @@
/*
Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+ Copyright (C) Research In Motion Limited 2010. 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
@@ -31,9 +32,9 @@
#include "MappedAttribute.h"
#include "PatternAttributes.h"
#include "RenderSVGContainer.h"
+#include "RenderSVGResourcePattern.h"
#include "SVGLength.h"
#include "SVGNames.h"
-#include "SVGPaintServerPattern.h"
#include "SVGRenderSupport.h"
#include "SVGSVGElement.h"
#include "SVGStyledTransformableElement.h"
@@ -119,19 +120,20 @@ void SVGPatternElement::svgAttributeChanged(const QualifiedName& attrName)
{
SVGStyledElement::svgAttributeChanged(attrName);
- if (!m_resource)
- return;
-
- if (attrName == SVGNames::patternUnitsAttr || attrName == SVGNames::patternContentUnitsAttr ||
- attrName == SVGNames::patternTransformAttr || attrName == SVGNames::xAttr || attrName == SVGNames::yAttr ||
- attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr ||
- SVGURIReference::isKnownAttribute(attrName) ||
- SVGTests::isKnownAttribute(attrName) ||
- SVGLangSpace::isKnownAttribute(attrName) ||
- SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
- SVGFitToViewBox::isKnownAttribute(attrName) ||
- SVGStyledElement::isKnownAttribute(attrName))
- m_resource->invalidate();
+ if (attrName == SVGNames::patternUnitsAttr
+ || attrName == SVGNames::patternContentUnitsAttr
+ || attrName == SVGNames::patternTransformAttr
+ || attrName == SVGNames::xAttr
+ || attrName == SVGNames::yAttr
+ || attrName == SVGNames::widthAttr
+ || attrName == SVGNames::heightAttr
+ || SVGURIReference::isKnownAttribute(attrName)
+ || SVGTests::isKnownAttribute(attrName)
+ || SVGLangSpace::isKnownAttribute(attrName)
+ || SVGExternalResourcesRequired::isKnownAttribute(attrName)
+ || SVGFitToViewBox::isKnownAttribute(attrName)
+ || SVGStyledElement::isKnownAttribute(attrName))
+ invalidateResourceClients();
}
void SVGPatternElement::synchronizeProperty(const QualifiedName& attrName)
@@ -180,126 +182,13 @@ void SVGPatternElement::childrenChanged(bool changedByParser, Node* beforeChange
{
SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
- if (!m_resource)
- return;
-
- m_resource->invalidate();
-}
-
-void SVGPatternElement::buildPattern(const FloatRect& targetRect) const
-{
- PatternAttributes attributes = collectPatternProperties();
-
- // If we didn't find any pattern content, ignore the request.
- if (!attributes.patternContentElement() || !renderer() || !renderer()->style())
- return;
-
- FloatRect patternBoundaries;
- FloatRect patternContentBoundaries;
-
- // Determine specified pattern size
- if (attributes.boundingBoxMode())
- patternBoundaries = FloatRect(attributes.x().valueAsPercentage() * targetRect.width(),
- attributes.y().valueAsPercentage() * targetRect.height(),
- attributes.width().valueAsPercentage() * targetRect.width(),
- attributes.height().valueAsPercentage() * targetRect.height());
- else
- patternBoundaries = FloatRect(attributes.x().value(this),
- attributes.y().value(this),
- attributes.width().value(this),
- attributes.height().value(this));
-
- IntSize patternSize(patternBoundaries.width(), patternBoundaries.height());
- clampImageBufferSizeToViewport(document()->view(), patternSize);
-
- if (patternSize.width() < static_cast<int>(patternBoundaries.width()))
- patternBoundaries.setWidth(patternSize.width());
-
- if (patternSize.height() < static_cast<int>(patternBoundaries.height()))
- patternBoundaries.setHeight(patternSize.height());
-
- // Eventually calculate the pattern content boundaries (only needed with overflow="visible").
- RenderStyle* style = renderer()->style();
- if (style->overflowX() == OVISIBLE && style->overflowY() == OVISIBLE) {
- for (Node* n = attributes.patternContentElement()->firstChild(); n; n = n->nextSibling()) {
- if (!n->isSVGElement() || !static_cast<SVGElement*>(n)->isStyledTransformable() || !n->renderer())
- continue;
- patternContentBoundaries.unite(n->renderer()->repaintRectInLocalCoordinates());
- }
- }
-
- AffineTransform viewBoxCTM = viewBoxToViewTransform(viewBox(), preserveAspectRatio(), patternBoundaries.width(), patternBoundaries.height());
- FloatRect patternBoundariesIncludingOverflow = patternBoundaries;
-
- // Apply objectBoundingBoxMode fixup for patternContentUnits, if viewBox is not set.
- if (!patternContentBoundaries.isEmpty()) {
- if (!viewBoxCTM.isIdentity())
- patternContentBoundaries = viewBoxCTM.mapRect(patternContentBoundaries);
- else if (attributes.boundingBoxModeContent())
- patternContentBoundaries = FloatRect(patternContentBoundaries.x() * targetRect.width(),
- patternContentBoundaries.y() * targetRect.height(),
- patternContentBoundaries.width() * targetRect.width(),
- patternContentBoundaries.height() * targetRect.height());
-
- patternBoundariesIncludingOverflow.unite(patternContentBoundaries);
- }
-
- IntSize imageSize(lroundf(patternBoundariesIncludingOverflow.width()), lroundf(patternBoundariesIncludingOverflow.height()));
- clampImageBufferSizeToViewport(document()->view(), imageSize);
-
- OwnPtr<ImageBuffer> patternImage = ImageBuffer::create(imageSize);
-
- if (!patternImage)
- return;
-
- GraphicsContext* context = patternImage->context();
- ASSERT(context);
-
- context->save();
-
- // Move to pattern start origin
- if (patternBoundariesIncludingOverflow.location() != patternBoundaries.location()) {
- context->translate(patternBoundaries.x() - patternBoundariesIncludingOverflow.x(),
- patternBoundaries.y() - patternBoundariesIncludingOverflow.y());
-
- patternBoundaries.setLocation(patternBoundariesIncludingOverflow.location());
- }
-
- // Process viewBox or boundingBoxModeContent correction
- if (!viewBoxCTM.isIdentity())
- context->concatCTM(viewBoxCTM);
- else if (attributes.boundingBoxModeContent()) {
- context->translate(targetRect.x(), targetRect.y());
- context->scale(FloatSize(targetRect.width(), targetRect.height()));
- }
-
- // Render subtree into ImageBuffer
- for (Node* n = attributes.patternContentElement()->firstChild(); n; n = n->nextSibling()) {
- if (!n->isSVGElement() || !static_cast<SVGElement*>(n)->isStyled() || !n->renderer())
- continue;
- renderSubtreeToImage(patternImage.get(), n->renderer());
- }
-
- context->restore();
-
- m_resource->setPatternTransform(attributes.patternTransform());
- m_resource->setPatternBoundaries(patternBoundaries);
- m_resource->setTile(patternImage.release());
+ if (!changedByParser)
+ invalidateResourceClients();
}
RenderObject* SVGPatternElement::createRenderer(RenderArena* arena, RenderStyle*)
{
- RenderSVGContainer* patternContainer = new (arena) RenderSVGContainer(this);
- patternContainer->setDrawsContents(false);
- return patternContainer;
-}
-
-SVGResource* SVGPatternElement::canvasResource(const RenderObject*)
-{
- if (!m_resource)
- m_resource = SVGPaintServerPattern::create(this);
-
- return m_resource.get();
+ return new (arena) RenderSVGResourcePattern(this);
}
PatternAttributes SVGPatternElement::collectPatternProperties() const
diff --git a/WebCore/svg/SVGPatternElement.h b/WebCore/svg/SVGPatternElement.h
index fffbbca..014d2b4 100644
--- a/WebCore/svg/SVGPatternElement.h
+++ b/WebCore/svg/SVGPatternElement.h
@@ -22,11 +22,9 @@
#define SVGPatternElement_h
#if ENABLE(SVG)
-#include "RenderObject.h"
#include "SVGExternalResourcesRequired.h"
#include "SVGFitToViewBox.h"
#include "SVGLangSpace.h"
-#include "SVGPaintServerPattern.h"
#include "SVGStyledElement.h"
#include "SVGTests.h"
#include "SVGTransformList.h"
@@ -56,7 +54,8 @@ namespace WebCore {
virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
- virtual SVGResource* canvasResource(const RenderObject*);
+
+ PatternAttributes collectPatternProperties() const;
private:
DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::xAttr, SVGLength, X, x)
@@ -75,15 +74,7 @@ namespace WebCore {
// SVGPatternElement
DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::viewBoxAttr, FloatRect, ViewBox, viewBox)
- DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio)
-
- mutable RefPtr<SVGPaintServerPattern> m_resource;
-
- private:
- friend class SVGPaintServerPattern;
- void buildPattern(const FloatRect& targetRect) const;
-
- PatternAttributes collectPatternProperties() const;
+ DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio)
};
} // namespace WebCore
diff --git a/WebCore/svg/SVGPolyElement.cpp b/WebCore/svg/SVGPolyElement.cpp
index 371c679..73940dc 100644
--- a/WebCore/svg/SVGPolyElement.cpp
+++ b/WebCore/svg/SVGPolyElement.cpp
@@ -88,7 +88,7 @@ void SVGPolyElement::svgAttributeChanged(const QualifiedName& attrName)
// The points property is not a regular SVGAnimatedProperty, still we use the same SVG<->XML DOM synchronization framework.
if (attrName == SVGNames::pointsAttr)
- setSynchronizedSVGAttributes(false);
+ invalidateSVGAttributes();
RenderPath* renderer = static_cast<RenderPath*>(this->renderer());
if (!renderer)
diff --git a/WebCore/svg/SVGPolyElement.h b/WebCore/svg/SVGPolyElement.h
index b881ca2..88947de 100644
--- a/WebCore/svg/SVGPolyElement.h
+++ b/WebCore/svg/SVGPolyElement.h
@@ -48,7 +48,6 @@ namespace WebCore {
virtual void svgAttributeChanged(const QualifiedName&);
virtual void synchronizeProperty(const QualifiedName&);
- virtual bool rendererIsNeeded(RenderStyle* style) { return StyledElement::rendererIsNeeded(style); }
virtual bool supportsMarkers() const { return true; }
private:
diff --git a/WebCore/svg/SVGRadialGradientElement.cpp b/WebCore/svg/SVGRadialGradientElement.cpp
index b153c0f..29cc1cc 100644
--- a/WebCore/svg/SVGRadialGradientElement.cpp
+++ b/WebCore/svg/SVGRadialGradientElement.cpp
@@ -3,6 +3,7 @@
2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
2008 Eric Seidel <eric@webkit.org>
2008 Dirk Schulze <krit@webkit.org>
+ Copyright (C) Research In Motion Limited 2010. 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
@@ -29,10 +30,9 @@
#include "FloatPoint.h"
#include "MappedAttribute.h"
#include "RadialGradientAttributes.h"
-#include "RenderObject.h"
+#include "RenderSVGResourceRadialGradient.h"
#include "SVGLength.h"
#include "SVGNames.h"
-#include "SVGPaintServerRadialGradient.h"
#include "SVGStopElement.h"
#include "SVGTransform.h"
#include "SVGTransformList.h"
@@ -77,13 +77,12 @@ void SVGRadialGradientElement::svgAttributeChanged(const QualifiedName& attrName
{
SVGGradientElement::svgAttributeChanged(attrName);
- if (!m_resource)
- return;
-
- if (attrName == SVGNames::cxAttr || attrName == SVGNames::cyAttr ||
- attrName == SVGNames::fxAttr || attrName == SVGNames::fyAttr ||
- attrName == SVGNames::rAttr)
- m_resource->invalidate();
+ if (attrName == SVGNames::cxAttr
+ || attrName == SVGNames::cyAttr
+ || attrName == SVGNames::fxAttr
+ || attrName == SVGNames::fyAttr
+ || attrName == SVGNames::rAttr)
+ invalidateResourceClients();
}
void SVGRadialGradientElement::synchronizeProperty(const QualifiedName& attrName)
@@ -111,77 +110,18 @@ void SVGRadialGradientElement::synchronizeProperty(const QualifiedName& attrName
synchronizeR();
}
-void SVGRadialGradientElement::buildGradient() const
+RenderObject* SVGRadialGradientElement::createRenderer(RenderArena* arena, RenderStyle*)
{
- RadialGradientAttributes attributes = collectGradientProperties();
-
- RefPtr<SVGPaintServerRadialGradient> radialGradient = WTF::static_pointer_cast<SVGPaintServerRadialGradient>(m_resource);
-
- FloatPoint focalPoint;
- FloatPoint centerPoint;
- float radius;
- if (attributes.boundingBoxMode()) {
- focalPoint = FloatPoint(attributes.fx().valueAsPercentage(), attributes.fy().valueAsPercentage());
- centerPoint = FloatPoint(attributes.cx().valueAsPercentage(), attributes.cy().valueAsPercentage());
- radius = attributes.r().valueAsPercentage();
- } else {
- focalPoint = FloatPoint(attributes.fx().value(this), attributes.fy().value(this));
- centerPoint = FloatPoint(attributes.cx().value(this), attributes.cy().value(this));
- radius = attributes.r().value(this);
- }
-
- FloatPoint adjustedFocalPoint = focalPoint;
- float dfx = focalPoint.x() - centerPoint.x();
- float dfy = focalPoint.y() - centerPoint.y();
- float rMax = 0.99f * radius;
-
- // 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.
- // We scale the radius by 0.99 to match the behavior of FireFox.
- if (sqrt(dfx * dfx + dfy * dfy) > rMax) {
- float angle = atan2f(dfy, dfx);
-
- dfx = cosf(angle) * rMax;
- dfy = sinf(angle) * rMax;
- adjustedFocalPoint = FloatPoint(dfx + centerPoint.x(), dfy + centerPoint.y());
- }
-
- RefPtr<Gradient> gradient = Gradient::create(
- adjustedFocalPoint,
- 0.f, // SVG does not support a "focus radius"
- centerPoint,
- radius);
- gradient->setSpreadMethod(attributes.spreadMethod());
-
- 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;
-
- radialGradient->setBoundingBoxMode(attributes.boundingBoxMode());
- radialGradient->setGradientTransform(attributes.gradientTransform());
- radialGradient->setGradientCenter(centerPoint);
- radialGradient->setGradientFocal(focalPoint);
- radialGradient->setGradientRadius(radius);
- radialGradient->setGradientStops(attributes.stops());
+ return new (arena) RenderSVGResourceRadialGradient(this);
}
-RadialGradientAttributes SVGRadialGradientElement::collectGradientProperties() const
+RadialGradientAttributes SVGRadialGradientElement::collectGradientProperties()
{
RadialGradientAttributes attributes;
- HashSet<const SVGGradientElement*> processedGradients;
+ HashSet<SVGGradientElement*> processedGradients;
bool isRadial = true;
- const SVGGradientElement* current = this;
+ SVGGradientElement* current = this;
while (current) {
if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spreadMethodAttr))
@@ -194,13 +134,13 @@ RadialGradientAttributes SVGRadialGradientElement::collectGradientProperties() c
attributes.setGradientTransform(current->gradientTransform()->consolidate().matrix());
if (!attributes.hasStops()) {
- const Vector<SVGGradientStop>& stops(current->buildStops());
+ const Vector<Gradient::ColorStop>& stops(current->buildStops());
if (!stops.isEmpty())
attributes.setStops(stops);
}
if (isRadial) {
- const SVGRadialGradientElement* radial = static_cast<const SVGRadialGradientElement*>(current);
+ SVGRadialGradientElement* radial = static_cast<SVGRadialGradientElement*>(current);
if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAttr))
attributes.setCx(radial->cx());
@@ -223,13 +163,13 @@ RadialGradientAttributes SVGRadialGradientElement::collectGradientProperties() c
// Respect xlink:href, take attributes from referenced element
Node* refNode = ownerDocument()->getElementById(SVGURIReference::getTarget(current->href()));
if (refNode && (refNode->hasTagName(SVGNames::radialGradientTag) || refNode->hasTagName(SVGNames::linearGradientTag))) {
- current = static_cast<const SVGGradientElement*>(const_cast<const Node*>(refNode));
+ current = static_cast<SVGGradientElement*>(refNode);
// Cycle detection
if (processedGradients.contains(current))
return RadialGradientAttributes();
- isRadial = current->gradientType() == RadialGradientPaintServer;
+ isRadial = current->hasTagName(SVGNames::radialGradientTag);
} else
current = 0;
}
@@ -243,6 +183,37 @@ RadialGradientAttributes SVGRadialGradientElement::collectGradientProperties() c
return attributes;
}
+
+void SVGRadialGradientElement::calculateFocalCenterPointsAndRadius(const RadialGradientAttributes& attributes, FloatPoint& focalPoint, FloatPoint& centerPoint, float& radius)
+{
+ // Determine gradient focal/center points and radius
+ if (attributes.boundingBoxMode()) {
+ focalPoint = FloatPoint(attributes.fx().valueAsPercentage(), attributes.fy().valueAsPercentage());
+ centerPoint = FloatPoint(attributes.cx().valueAsPercentage(), attributes.cy().valueAsPercentage());
+ radius = attributes.r().valueAsPercentage();
+ } else {
+ focalPoint = FloatPoint(attributes.fx().value(this), attributes.fy().value(this));
+ centerPoint = FloatPoint(attributes.cx().value(this), attributes.cy().value(this));
+ radius = attributes.r().value(this);
+ }
+
+ // Eventually adjust focal points, as described below
+ float deltaX = focalPoint.x() - centerPoint.x();
+ float deltaY = focalPoint.y() - centerPoint.y();
+ float radiusMax = 0.99f * radius;
+
+ // 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.
+ // We scale the radius by 0.99 to match the behavior of FireFox.
+ if (sqrt(deltaX * deltaX + deltaY * deltaY) > radiusMax) {
+ float angle = atan2f(deltaY, deltaX);
+
+ deltaX = cosf(angle) * radiusMax;
+ deltaY = sinf(angle) * radiusMax;
+ focalPoint = FloatPoint(deltaX + centerPoint.x(), deltaY + centerPoint.y());
+ }
+}
+
}
#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGRadialGradientElement.h b/WebCore/svg/SVGRadialGradientElement.h
index 180948f..25219db 100644
--- a/WebCore/svg/SVGRadialGradientElement.h
+++ b/WebCore/svg/SVGRadialGradientElement.h
@@ -38,11 +38,10 @@ namespace WebCore {
virtual void svgAttributeChanged(const QualifiedName&);
virtual void synchronizeProperty(const QualifiedName&);
- protected:
- virtual void buildGradient() const;
- virtual SVGPaintServerType gradientType() const { return RadialGradientPaintServer; }
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
- RadialGradientAttributes collectGradientProperties() const;
+ RadialGradientAttributes collectGradientProperties();
+ void calculateFocalCenterPointsAndRadius(const RadialGradientAttributes&, FloatPoint& focalPoint, FloatPoint& centerPoint, float& radius);
private:
DECLARE_ANIMATED_PROPERTY(SVGRadialGradientElement, SVGNames::cxAttr, SVGLength, Cx, cx)
diff --git a/WebCore/svg/SVGStopElement.cpp b/WebCore/svg/SVGStopElement.cpp
index 3c97827..3ac2d5b 100644
--- a/WebCore/svg/SVGStopElement.cpp
+++ b/WebCore/svg/SVGStopElement.cpp
@@ -49,8 +49,6 @@ void SVGStopElement::parseMappedAttribute(MappedAttribute* attr)
setOffsetBaseValue(value.left(value.length() - 1).toFloat() / 100.0f);
else
setOffsetBaseValue(value.toFloat());
-
- setNeedsStyleRecalc();
} else
SVGStyledElement::parseMappedAttribute(attr);
}
@@ -68,6 +66,15 @@ RenderObject* SVGStopElement::createRenderer(RenderArena* arena, RenderStyle*)
return new (arena) RenderSVGGradientStop(this);
}
+Color SVGStopElement::stopColorIncludingOpacity() const
+{
+ ASSERT(renderer());
+ ASSERT(renderer()->style());
+
+ const SVGRenderStyle* svgStyle = renderer()->style()->svgStyle();
+ return colorWithOverrideAlpha(svgStyle->stopColor().rgb(), svgStyle->stopOpacity());
+}
+
}
#endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGStopElement.h b/WebCore/svg/SVGStopElement.h
index 23c09bb..222dd4d 100644
--- a/WebCore/svg/SVGStopElement.h
+++ b/WebCore/svg/SVGStopElement.h
@@ -32,13 +32,14 @@ namespace WebCore {
SVGStopElement(const QualifiedName&, Document*);
virtual ~SVGStopElement();
+ virtual void parseMappedAttribute(MappedAttribute*);
virtual void synchronizeProperty(const QualifiedName&);
+ Color stopColorIncludingOpacity() const;
+
private:
virtual bool isGradientStop() const { return true; }
- virtual void parseMappedAttribute(MappedAttribute*);
-
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
DECLARE_ANIMATED_PROPERTY(SVGStopElement, SVGNames::offsetAttr, float, Offset, offset)
diff --git a/WebCore/svg/SVGStyledElement.cpp b/WebCore/svg/SVGStyledElement.cpp
index 22c2008..9a3f950 100644
--- a/WebCore/svg/SVGStyledElement.cpp
+++ b/WebCore/svg/SVGStyledElement.cpp
@@ -41,8 +41,8 @@
#include "SVGNames.h"
#include "SVGRenderStyle.h"
#include "SVGRenderSupport.h"
-#include "SVGResource.h"
#include "SVGSVGElement.h"
+#include "SVGUseElement.h"
#include <wtf/Assertions.h>
namespace WebCore {
@@ -63,7 +63,50 @@ SVGStyledElement::SVGStyledElement(const QualifiedName& tagName, Document* doc)
SVGStyledElement::~SVGStyledElement()
{
- SVGResource::removeClient(this);
+}
+
+String SVGStyledElement::title() const
+{
+ // According to spec, we should not return titles when hovering over <svg> elements (those
+ // <title> elements are the title of the document, not a tooltip) so we instantly return.
+ if (hasTagName(SVGNames::svgTag))
+ return String();
+
+ // Walk up the tree, to find out whether we're inside a <use> shadow tree, to find the right title.
+ Node* parent = const_cast<SVGStyledElement*>(this);
+ while (parent) {
+ if (!parent->isShadowNode()) {
+ parent = parent->parentNode();
+ continue;
+ }
+
+ // Get the <use> element.
+ Node* shadowParent = parent->shadowParentNode();
+ if (shadowParent && shadowParent->isSVGElement() && shadowParent->hasTagName(SVGNames::useTag)) {
+ SVGUseElement* useElement = static_cast<SVGUseElement*>(shadowParent);
+ // If the <use> title is not empty we found the title to use.
+ String useTitle(useElement->title());
+ if (useTitle.isEmpty())
+ break;
+ return useTitle;
+ }
+ parent = parent->parentNode();
+ }
+
+ // If we aren't an instance in a <use> or the <use> title was not found, then find the first
+ // <title> child of this element.
+ Element* titleElement = firstElementChild();
+ for (; titleElement; titleElement = titleElement->nextElementSibling()) {
+ if (titleElement->hasTagName(SVGNames::titleTag) && titleElement->isSVGElement())
+ break;
+ }
+
+ // If a title child was found, return the text contents.
+ if (titleElement)
+ return titleElement->innerText();
+
+ // Otherwise return a null/empty string.
+ return String();
}
bool SVGStyledElement::rendererIsNeeded(RenderStyle* style)
@@ -200,19 +243,21 @@ void SVGStyledElement::svgAttributeChanged(const QualifiedName& attrName)
if (attrName.matches(HTMLNames::classAttr))
classAttributeChanged(className());
+ RenderObject* object = renderer();
+
if (attrName == idAttributeName()) {
// Notify resources about id changes, this is important as we cache resources by id in SVGDocumentExtensions
- if (renderer() && renderer()->isSVGResource()) {
- RenderSVGResource* resource = renderer()->toRenderSVGResource();
- resource->idChanged();
- }
+ if (object && object->isSVGResourceContainer())
+ object->toRenderSVGResourceContainer()->idChanged();
}
- // If we're the child of a resource element, be sure to invalidate it.
- invalidateResourcesInAncestorChain();
+ if (!document()->parsing() && object) {
+ // If we're the child of a resource element, tell the resource (and eventually its resources) that we've changed.
+ invalidateResourcesInAncestorChain();
- // If the element is using resources, invalidate them.
- invalidateResources();
+ // If we're referencing resources, tell them we've changed.
+ deregisterFromResources(object);
+ }
// Invalidate all SVGElementInstances associated with us
SVGElementInstance::invalidateAllInstancesOfElement(this);
@@ -226,20 +271,6 @@ void SVGStyledElement::synchronizeProperty(const QualifiedName& attrName)
synchronizeClassName();
}
-void SVGStyledElement::invalidateResources()
-{
- RenderObject* object = renderer();
- if (!object)
- return;
-
- Document* document = this->document();
-
- if (document->parsing())
- return;
-
- deregisterFromResources(object);
-}
-
void SVGStyledElement::invalidateResourcesInAncestorChain() const
{
Node* node = parentNode();
@@ -248,25 +279,25 @@ void SVGStyledElement::invalidateResourcesInAncestorChain() const
break;
SVGElement* element = static_cast<SVGElement*>(node);
- if (SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(element->isStyled() ? element : 0))
- styledElement->invalidateCanvasResources();
+ if (SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(element->isStyled() ? element : 0)) {
+ styledElement->invalidateResourceClients();
+
+ // If we found the first resource in the ancestor chain, immediately stop.
+ break;
+ }
node = node->parentNode();
}
}
-void SVGStyledElement::invalidateCanvasResources()
+void SVGStyledElement::invalidateResourceClients()
{
RenderObject* object = renderer();
if (!object)
return;
- if (object->isSVGResource())
- object->toRenderSVGResource()->invalidateClients();
-
- // The following lines will be removed soon, once all resources are handled by renderers.
- if (SVGResource* resource = canvasResource(object))
- resource->invalidate();
+ if (object->isSVGResourceContainer())
+ object->toRenderSVGResourceContainer()->invalidateClients();
}
void SVGStyledElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
@@ -274,7 +305,8 @@ void SVGStyledElement::childrenChanged(bool changedByParser, Node* beforeChange,
SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
// Invalidate all SVGElementInstances associated with us
- SVGElementInstance::invalidateAllInstancesOfElement(this);
+ if (!changedByParser)
+ SVGElementInstance::invalidateAllInstancesOfElement(this);
}
PassRefPtr<RenderStyle> SVGStyledElement::resolveStyle(RenderStyle* parentStyle)
@@ -309,12 +341,6 @@ PassRefPtr<CSSValue> SVGStyledElement::getPresentationAttribute(const String& na
return cssSVGAttr->style()->getPropertyCSSValue(name);
}
-void SVGStyledElement::detach()
-{
- SVGResource::removeClient(this);
- SVGElement::detach();
-}
-
bool SVGStyledElement::instanceUpdatesBlocked() const
{
return hasRareSVGData() && rareSVGData()->instanceUpdatesBlocked();
diff --git a/WebCore/svg/SVGStyledElement.h b/WebCore/svg/SVGStyledElement.h
index ea19aa5..69d7e96 100644
--- a/WebCore/svg/SVGStyledElement.h
+++ b/WebCore/svg/SVGStyledElement.h
@@ -29,8 +29,6 @@
namespace WebCore {
- class SVGResource;
-
void mapAttributeToCSSProperty(HashMap<AtomicStringImpl*, int>* propertyNameToIdMap, const QualifiedName& attrName);
class SVGStyledElement : public SVGElement,
@@ -39,6 +37,8 @@ namespace WebCore {
SVGStyledElement(const QualifiedName&, Document*);
virtual ~SVGStyledElement();
+ virtual String title() const;
+
virtual bool hasRelativeValues() const { return false; }
virtual bool isStyled() const { return true; }
virtual bool supportsMarkers() const { return false; }
@@ -49,7 +49,6 @@ namespace WebCore {
bool isKnownAttribute(const QualifiedName&);
virtual bool rendererIsNeeded(RenderStyle*);
- virtual SVGResource* canvasResource(const RenderObject*) { return 0; }
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(MappedAttribute*);
@@ -61,10 +60,8 @@ namespace WebCore {
// Centralized place to force a manual style resolution. Hacky but needed for now.
PassRefPtr<RenderStyle> resolveStyle(RenderStyle* parentStyle);
+ void invalidateResourceClients();
void invalidateResourcesInAncestorChain() const;
- void invalidateResources();
-
- virtual void detach();
bool instanceUpdatesBlocked() const;
void setInstanceUpdatesBlocked(bool);
@@ -74,8 +71,6 @@ namespace WebCore {
protected:
static int cssPropertyIdForSVGAttributeName(const QualifiedName&);
- void invalidateCanvasResources();
-
private:
DECLARE_ANIMATED_PROPERTY(SVGStyledElement, HTMLNames::classAttr, String, ClassName, className)
};
diff --git a/WebCore/svg/SVGTextContentElement.cpp b/WebCore/svg/SVGTextContentElement.cpp
index b28536b..3f1ec49 100644
--- a/WebCore/svg/SVGTextContentElement.cpp
+++ b/WebCore/svg/SVGTextContentElement.cpp
@@ -32,7 +32,7 @@
#include "MappedAttribute.h"
#include "Position.h"
#include "RenderSVGText.h"
-#include "SVGCharacterLayoutInfo.h"
+#include "SVGCharacterData.h"
#include "SVGInlineTextBox.h"
#include "SVGLength.h"
#include "SVGNames.h"
diff --git a/WebCore/svg/SVGTextPathElement.h b/WebCore/svg/SVGTextPathElement.h
index ff09ed2..0862335 100644
--- a/WebCore/svg/SVGTextPathElement.h
+++ b/WebCore/svg/SVGTextPathElement.h
@@ -58,7 +58,6 @@ namespace WebCore {
virtual void parseMappedAttribute(MappedAttribute*);
virtual void synchronizeProperty(const QualifiedName&);
- virtual bool rendererIsNeeded(RenderStyle* style) { return StyledElement::rendererIsNeeded(style); }
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
bool childShouldCreateRenderer(Node*) const;
diff --git a/WebCore/svg/SVGURIReference.cpp b/WebCore/svg/SVGURIReference.cpp
index 5fe71ab..5dbdfb8 100644
--- a/WebCore/svg/SVGURIReference.cpp
+++ b/WebCore/svg/SVGURIReference.cpp
@@ -60,8 +60,8 @@ String SVGURIReference::getTarget(const String& url)
} else if (url.find('#') > -1) { // format is #target
unsigned int start = url.find('#') + 1;
return url.substring(start, url.length() - start);
- } else // Normal Reference, ie. style="color-profile:changeColor"
- return url;
+ } else // The url doesn't have any target.
+ return String();
}
}
diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp
index 11d3f60..97ef710 100644
--- a/WebCore/svg/graphics/SVGImage.cpp
+++ b/WebCore/svg/graphics/SVGImage.cpp
@@ -186,13 +186,22 @@ void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl
context->clip(enclosingIntRect(dstRect));
if (compositeOp != CompositeSourceOver)
context->beginTransparencyLayer(1);
- context->translate(dstRect.location().x(), dstRect.location().y());
- context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()));
+
+ FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height());
+
+ // We can only draw the entire frame, clipped to the rect we want. So compute where the top left
+ // of the image would be if we were drawing without clipping, and translate accordingly.
+ FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.location().y() * scale.height());
+ FloatPoint destOffset = dstRect.location() - topLeftOffset;
+
+ context->translate(destOffset.x(), destOffset.y());
+ context->scale(scale);
view->resize(size());
if (view->needsLayout())
view->layout();
+
view->paint(context, IntRect(0, 0, view->width(), view->height()));
if (compositeOp != CompositeSourceOver)
diff --git a/WebCore/svg/graphics/SVGPaintServer.h b/WebCore/svg/graphics/SVGPaintServer.h
deleted file mode 100644
index d9d2218..0000000
--- a/WebCore/svg/graphics/SVGPaintServer.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SVGPaintServer_h
-#define SVGPaintServer_h
-
-#if ENABLE(SVG)
-
-#include "DashArray.h"
-#include "RenderObject.h"
-#include "SVGResource.h"
-
-#if PLATFORM(CG)
-#include <ApplicationServices/ApplicationServices.h>
-#endif
-
-namespace WebCore {
-
- enum SVGPaintServerType {
- // Painting mode
- SolidPaintServer = 0,
- PatternPaintServer = 1,
- LinearGradientPaintServer = 2,
- RadialGradientPaintServer = 3
- };
-
- enum SVGPaintTargetType {
- // Target mode
- ApplyToFillTargetType = 1,
- ApplyToStrokeTargetType = 2
- };
-
- class GraphicsContext;
- class RenderObject;
- class RenderStyle;
- class SVGPaintServerSolid;
-
- class SVGPaintServer : public SVGResource {
- public:
- virtual ~SVGPaintServer();
-
- virtual SVGResourceType resourceType() const { return PaintServerResourceType; }
-
- virtual SVGPaintServerType type() const = 0;
- virtual TextStream& externalRepresentation(TextStream&) const = 0;
-
- // To be implemented in platform specific code.
- virtual void draw(GraphicsContext*&, const RenderObject*, SVGPaintTargetType) const;
- virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText = false) const;
- virtual void renderPath(GraphicsContext*&, const RenderObject*, SVGPaintTargetType) const;
-
- virtual bool setup(GraphicsContext*&, const RenderObject*, const RenderStyle*, SVGPaintTargetType, bool isPaintingText = false) const = 0;
-
- bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText = false) const;
-
- static SVGPaintServer* strokePaintServer(const RenderStyle*, const RenderObject*);
- static SVGPaintServer* fillPaintServer(const RenderStyle*, const RenderObject*);
- static SVGPaintServerSolid* sharedSolidPaintServer();
-
- protected:
- SVGPaintServer();
- };
-
- TextStream& operator<<(TextStream&, const SVGPaintServer&);
-
- SVGPaintServer* getPaintServerById(Document*, const AtomicString&, const RenderObject*);
-
- void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*);
- DashArray dashArrayFromRenderingStyle(const RenderStyle* style, RenderStyle* rootStyle);
-} // namespace WebCore
-
-#endif
-
-#endif // SVGPaintServer_h
diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.cpp b/WebCore/svg/graphics/SVGPaintServerGradient.cpp
deleted file mode 100644
index 6e6ebfc..0000000
--- a/WebCore/svg/graphics/SVGPaintServerGradient.cpp
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServerGradient.h"
-
-#include "FloatConversion.h"
-#include "GraphicsContext.h"
-#include "ImageBuffer.h"
-#include "RenderObject.h"
-#include "RenderView.h"
-#include "SVGGradientElement.h"
-#include "SVGPaintServerLinearGradient.h"
-#include "SVGPaintServerRadialGradient.h"
-#include "SVGRenderSupport.h"
-#include "SVGRenderTreeAsText.h"
-
-using namespace std;
-
-namespace WebCore {
-
-static TextStream& operator<<(TextStream& ts, GradientSpreadMethod m)
-{
- switch (m) {
- case SpreadMethodPad:
- ts << "PAD"; break;
- case SpreadMethodRepeat:
- ts << "REPEAT"; break;
- case SpreadMethodReflect:
- ts << "REFLECT"; break;
- }
-
- return ts;
-}
-
-static TextStream& operator<<(TextStream& ts, const Vector<SVGGradientStop>& l)
-{
- ts << "[";
- for (Vector<SVGGradientStop>::const_iterator it = l.begin(); it != l.end(); ++it) {
- ts << "(" << it->first << "," << it->second << ")";
- if (it + 1 != l.end())
- ts << ", ";
- }
- ts << "]";
- return ts;
-}
-
-SVGPaintServerGradient::SVGPaintServerGradient(const SVGGradientElement* owner)
- : m_boundingBoxMode(true)
- , m_ownerElement(owner)
-#if PLATFORM(CG)
- , m_savedContext(0)
- , m_imageBuffer(0)
-#endif
-{
- ASSERT(owner);
-}
-
-SVGPaintServerGradient::~SVGPaintServerGradient()
-{
-}
-
-Gradient* SVGPaintServerGradient::gradient() const
-{
- return m_gradient.get();
-}
-
-void SVGPaintServerGradient::setGradient(PassRefPtr<Gradient> gradient)
-{
- m_gradient = gradient;
-}
-
-bool SVGPaintServerGradient::boundingBoxMode() const
-{
- return m_boundingBoxMode;
-}
-
-void SVGPaintServerGradient::setBoundingBoxMode(bool mode)
-{
- m_boundingBoxMode = mode;
-}
-
-AffineTransform SVGPaintServerGradient::gradientTransform() const
-{
- return m_gradientTransform;
-}
-
-void SVGPaintServerGradient::setGradientTransform(const AffineTransform& transform)
-{
- m_gradientTransform = transform;
-}
-
-#if PLATFORM(CG)
-static inline AffineTransform absoluteTransformForRenderer(const RenderObject* object)
-{
- AffineTransform absoluteTransform;
-
- const RenderObject* currentObject = object;
- while (currentObject) {
- absoluteTransform = currentObject->localToParentTransform() * absoluteTransform;
- currentObject = currentObject->parent();
- }
-
- return absoluteTransform;
-}
-
-static inline bool createMaskAndSwapContextForTextGradient(
- GraphicsContext*& context, GraphicsContext*& savedContext,
- OwnPtr<ImageBuffer>& imageBuffer, const RenderObject* object)
-{
- const RenderObject* textRootBlock = findTextRootObject(object);
-
- AffineTransform transform = absoluteTransformForRenderer(textRootBlock);
- FloatRect maskAbsoluteBoundingBox = transform.mapRect(textRootBlock->repaintRectInLocalCoordinates());
-
- IntRect maskImageRect = enclosingIntRect(maskAbsoluteBoundingBox);
- if (maskImageRect.isEmpty())
- return false;
-
- // Allocate an image buffer as big as the absolute unclipped size of the object
- OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(maskImageRect.size());
- if (!maskImage)
- return false;
-
- GraphicsContext* maskImageContext = maskImage->context();
-
- // Transform the mask image coordinate system to absolute screen coordinates
- maskImageContext->translate(-maskAbsoluteBoundingBox.x(), -maskAbsoluteBoundingBox.y());
- maskImageContext->concatCTM(transform);
-
- imageBuffer.set(maskImage.release());
- savedContext = context;
- context = maskImageContext;
-
- return true;
-}
-
-static inline AffineTransform clipToTextMask(GraphicsContext* context,
- OwnPtr<ImageBuffer>& imageBuffer, const RenderObject* object,
- const SVGPaintServerGradient* gradientServer)
-{
- const RenderObject* textRootBlock = findTextRootObject(object);
- context->clipToImageBuffer(textRootBlock->repaintRectInLocalCoordinates(), imageBuffer.get());
-
- AffineTransform matrix;
- if (gradientServer->boundingBoxMode()) {
- FloatRect maskBoundingBox = textRootBlock->objectBoundingBox();
- matrix.translate(maskBoundingBox.x(), maskBoundingBox.y());
- matrix.scaleNonUniform(maskBoundingBox.width(), maskBoundingBox.height());
- }
- matrix.multiply(gradientServer->gradientTransform());
- return matrix;
-}
-#endif
-
-bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, const RenderStyle*style, SVGPaintTargetType type, bool isPaintingText) const
-{
- m_ownerElement->buildGradient();
-
- const SVGRenderStyle* svgStyle = style->svgStyle();
- bool isFilled = (type & ApplyToFillTargetType) && svgStyle->hasFill();
- bool isStroked = (type & ApplyToStrokeTargetType) && svgStyle->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(svgStyle->fillOpacity());
- context->setFillGradient(m_gradient);
- context->setFillRule(svgStyle->fillRule());
- }
- if (isStroked) {
- context->setAlpha(svgStyle->strokeOpacity());
- context->setStrokeGradient(m_gradient);
- applyStrokeStyleToContext(context, style, object);
- }
-
- AffineTransform matrix;
- // CG platforms will handle the gradient space transform for text in
- // teardown, so we don't apply it here. For non-CG platforms, we
- // want the text bounding box applied to the gradient space transform now,
- // so the gradient shader can use it.
-#if PLATFORM(CG)
- if (boundingBoxMode() && !isPaintingText) {
-#else
- if (boundingBoxMode()) {
-#endif
- FloatRect bbox = object->objectBoundingBox();
- matrix.translate(bbox.x(), bbox.y());
- matrix.scaleNonUniform(bbox.width(), bbox.height());
- }
- matrix.multiply(gradientTransform());
- m_gradient->setGradientSpaceTransform(matrix);
-
- 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;
-
- AffineTransform matrix = clipToTextMask(context, m_imageBuffer, object, this);
- m_gradient->setGradientSpaceTransform(matrix);
- context->setFillGradient(m_gradient);
-
- const RenderObject* textRootBlock = findTextRootObject(object);
- context->fillRect(textRootBlock->repaintRectInLocalCoordinates());
-
- m_imageBuffer.clear();
- }
-#endif
- context->restore();
-}
-
-TextStream& SVGPaintServerGradient::externalRepresentation(TextStream& ts) const
-{
- // Gradients/patterns aren't setup, until they are used for painting. Work around that fact.
- m_ownerElement->buildGradient();
-
- // abstract, don't stream type
- ts << "[stops=" << gradientStops() << "]";
- if (m_gradient->spreadMethod() != SpreadMethodPad)
- ts << "[method=" << m_gradient->spreadMethod() << "]";
- if (!boundingBoxMode())
- ts << " [bounding box mode=" << boundingBoxMode() << "]";
- if (!gradientTransform().isIdentity())
- ts << " [transform=" << gradientTransform() << "]";
-
- return ts;
-}
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.h b/WebCore/svg/graphics/SVGPaintServerGradient.h
deleted file mode 100644
index 953b0d9..0000000
--- a/WebCore/svg/graphics/SVGPaintServerGradient.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SVGPaintServerGradient_h
-#define SVGPaintServerGradient_h
-
-#if ENABLE(SVG)
-
-#include "AffineTransform.h"
-#include "Color.h"
-#include "Gradient.h"
-#include "GraphicsContext.h"
-#include "SVGPaintServer.h"
-
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
- class ImageBuffer;
- class SVGGradientElement;
-
- typedef std::pair<float, Color> SVGGradientStop;
-
- class SVGPaintServerGradient : public SVGPaintServer {
- public:
- virtual ~SVGPaintServerGradient();
-
- void setGradient(PassRefPtr<Gradient>);
- Gradient* gradient() const;
-
- // Gradient start and end points are percentages when used in boundingBox mode.
- // For instance start point with value (0,0) is top-left and end point with
- // value (100, 100) is bottom-right. BoundingBox mode is enabled by default.
- bool boundingBoxMode() const;
- void setBoundingBoxMode(bool mode = true);
-
- AffineTransform gradientTransform() const;
- void setGradientTransform(const AffineTransform&);
-
- 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*, const RenderStyle*, SVGPaintTargetType, bool isPaintingText) const;
- virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
-
- protected:
- SVGPaintServerGradient(const SVGGradientElement* owner);
-
- private:
- Vector<SVGGradientStop> m_stops;
- RefPtr<Gradient> m_gradient;
- bool m_boundingBoxMode;
- AffineTransform m_gradientTransform;
- const SVGGradientElement* m_ownerElement;
-
-#if PLATFORM(CG)
- public:
- mutable GraphicsContext* m_savedContext;
- mutable OwnPtr<ImageBuffer> m_imageBuffer;
-#endif
- };
-
- inline SVGGradientStop makeGradientStop(float offset, const Color& color)
- {
- return std::make_pair(offset, color);
- }
-
-} // namespace WebCore
-
-#endif
-
-#endif // SVGPaintServerGradient_h
diff --git a/WebCore/svg/graphics/SVGPaintServerLinearGradient.cpp b/WebCore/svg/graphics/SVGPaintServerLinearGradient.cpp
deleted file mode 100644
index 08db2d2..0000000
--- a/WebCore/svg/graphics/SVGPaintServerLinearGradient.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServerLinearGradient.h"
-#include "SVGRenderTreeAsText.h"
-
-namespace WebCore {
-
-SVGPaintServerLinearGradient::SVGPaintServerLinearGradient(const SVGGradientElement* owner)
- : SVGPaintServerGradient(owner)
-{
-}
-
-SVGPaintServerLinearGradient::~SVGPaintServerLinearGradient()
-{
-}
-
-FloatPoint SVGPaintServerLinearGradient::gradientStart() const
-{
- return m_start;
-}
-
-void SVGPaintServerLinearGradient::setGradientStart(const FloatPoint& start)
-{
- m_start = start;
-}
-
-FloatPoint SVGPaintServerLinearGradient::gradientEnd() const
-{
- return m_end;
-}
-
-void SVGPaintServerLinearGradient::setGradientEnd(const FloatPoint& end)
-{
- m_end = end;
-}
-
-TextStream& SVGPaintServerLinearGradient::externalRepresentation(TextStream& ts) const
-{
- ts << "[type=LINEAR-GRADIENT] ";
- SVGPaintServerGradient::externalRepresentation(ts);
- ts << " [start=" << gradientStart() << "]"
- << " [end=" << gradientEnd() << "]";
- return ts;
-}
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/svg/graphics/SVGPaintServerLinearGradient.h b/WebCore/svg/graphics/SVGPaintServerLinearGradient.h
deleted file mode 100644
index f0568c7..0000000
--- a/WebCore/svg/graphics/SVGPaintServerLinearGradient.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SVGPaintServerLinearGradient_h
-#define SVGPaintServerLinearGradient_h
-
-#if ENABLE(SVG)
-
-#include "FloatPoint.h"
-#include "SVGPaintServerGradient.h"
-
-namespace WebCore {
-
- class SVGPaintServerLinearGradient : public SVGPaintServerGradient {
- public:
- static PassRefPtr<SVGPaintServerLinearGradient> create(const SVGGradientElement* owner) { return adoptRef(new SVGPaintServerLinearGradient(owner)); }
- virtual ~SVGPaintServerLinearGradient();
-
- virtual SVGPaintServerType type() const { return LinearGradientPaintServer; }
-
- FloatPoint gradientStart() const;
- void setGradientStart(const FloatPoint&);
-
- FloatPoint gradientEnd() const;
- void setGradientEnd(const FloatPoint&);
-
- virtual TextStream& externalRepresentation(TextStream&) const;
-
- private:
- SVGPaintServerLinearGradient(const SVGGradientElement* owner);
-
- FloatPoint m_start;
- FloatPoint m_end;
- };
-
-} // namespace WebCore
-
-#endif
-
-#endif // SVGPaintServerLinearGradient_h
diff --git a/WebCore/svg/graphics/SVGPaintServerPattern.cpp b/WebCore/svg/graphics/SVGPaintServerPattern.cpp
deleted file mode 100644
index 7fc75fb..0000000
--- a/WebCore/svg/graphics/SVGPaintServerPattern.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServerPattern.h"
-
-#include "AffineTransform.h"
-#include "GraphicsContext.h"
-#include "Image.h"
-#include "ImageBuffer.h"
-#include "Pattern.h"
-#include "RenderObject.h"
-#include "SVGPatternElement.h"
-#include "SVGRenderTreeAsText.h"
-
-using namespace std;
-
-namespace WebCore {
-
-SVGPaintServerPattern::SVGPaintServerPattern(const SVGPatternElement* owner)
- : m_ownerElement(owner)
- , m_pattern(0)
-{
- ASSERT(owner);
-}
-
-SVGPaintServerPattern::~SVGPaintServerPattern()
-{
-}
-
-FloatRect SVGPaintServerPattern::patternBoundaries() const
-{
- return m_patternBoundaries;
-}
-
-void SVGPaintServerPattern::setPatternBoundaries(const FloatRect& rect)
-{
- m_patternBoundaries = rect;
-}
-
-ImageBuffer* SVGPaintServerPattern::tile() const
-{
- return m_tile.get();
-}
-
-void SVGPaintServerPattern::setTile(PassOwnPtr<ImageBuffer> tile)
-{
- m_tile = tile;
-}
-
-AffineTransform SVGPaintServerPattern::patternTransform() const
-{
- return m_patternTransform;
-}
-
-void SVGPaintServerPattern::setPatternTransform(const AffineTransform& transform)
-{
- m_patternTransform = transform;
-}
-
-TextStream& SVGPaintServerPattern::externalRepresentation(TextStream& ts) const
-{
- // Gradients/patterns aren't setup, until they are used for painting. Work around that fact.
- m_ownerElement->buildPattern(FloatRect(0.0f, 0.0f, 1.0f, 1.0f));
-
- ts << "[type=PATTERN]"
- << " [bbox=" << patternBoundaries() << "]";
- if (!patternTransform().isIdentity())
- ts << " [pattern transform=" << patternTransform() << "]";
- return ts;
-}
-
-bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, const RenderStyle* style, SVGPaintTargetType type, bool isPaintingText) const
-{
- FloatRect targetRect = object->objectBoundingBox();
-
- const SVGRenderStyle* svgStyle = style->svgStyle();
- bool isFilled = (type & ApplyToFillTargetType) && svgStyle->hasFill();
- bool isStroked = (type & ApplyToStrokeTargetType) && svgStyle->hasStroke();
-
- ASSERT((isFilled && !isStroked) || (!isFilled && isStroked));
-
- m_ownerElement->buildPattern(targetRect);
- if (!tile())
- return false;
-
- context->save();
-
- 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);
- OwnPtr<ImageBuffer> tileImage = ImageBuffer::create(IntSize(tileWidth, tileHeight));
-
- 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(), style->colorSpace(), 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(svgStyle->fillOpacity());
- context->setFillPattern(m_pattern);
- context->setFillRule(svgStyle->fillRule());
- }
- if (isStroked) {
- context->setAlpha(svgStyle->strokeOpacity());
- context->setStrokePattern(m_pattern);
- applyStrokeStyleToContext(context, style, object);
- }
-
- AffineTransform matrix;
- matrix.translate(patternBoundaries().x(), patternBoundaries().y());
- matrix.multiply(patternTransform());
- m_pattern->setPatternSpaceTransform(matrix);
-
- 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
deleted file mode 100644
index 3d3da49..0000000
--- a/WebCore/svg/graphics/SVGPaintServerPattern.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SVGPaintServerPattern_h
-#define SVGPaintServerPattern_h
-
-#if ENABLE(SVG)
-
-#include "AffineTransform.h"
-#include "FloatRect.h"
-#include "Pattern.h"
-#include "SVGPaintServer.h"
-
-#include <memory>
-
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-
-namespace WebCore {
-
- class GraphicsContext;
- class ImageBuffer;
- class SVGPatternElement;
-
- class SVGPaintServerPattern : public SVGPaintServer {
- public:
- static PassRefPtr<SVGPaintServerPattern> create(const SVGPatternElement* owner) { return adoptRef(new SVGPaintServerPattern(owner)); }
-
- virtual ~SVGPaintServerPattern();
-
- virtual SVGPaintServerType type() const { return PatternPaintServer; }
-
- // Pattern boundaries
- void setPatternBoundaries(const FloatRect&);
- FloatRect patternBoundaries() const;
-
- ImageBuffer* tile() const;
- void setTile(PassOwnPtr<ImageBuffer>);
-
- AffineTransform patternTransform() const;
- void setPatternTransform(const AffineTransform&);
-
- virtual TextStream& externalRepresentation(TextStream&) const;
-
- virtual bool setup(GraphicsContext*&, const RenderObject*, const RenderStyle*, SVGPaintTargetType, bool isPaintingText) const;
- virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
-
- private:
- SVGPaintServerPattern(const SVGPatternElement*);
-
- OwnPtr<ImageBuffer> m_tile;
- const SVGPatternElement* m_ownerElement;
- AffineTransform m_patternTransform;
- FloatRect m_patternBoundaries;
-
- mutable RefPtr<Pattern> m_pattern;
- };
-
-} // namespace WebCore
-
-#endif
-
-#endif // SVGPaintServerPattern_h
diff --git a/WebCore/svg/graphics/SVGPaintServerRadialGradient.cpp b/WebCore/svg/graphics/SVGPaintServerRadialGradient.cpp
deleted file mode 100644
index a795ab5..0000000
--- a/WebCore/svg/graphics/SVGPaintServerRadialGradient.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServerRadialGradient.h"
-#include "SVGRenderTreeAsText.h"
-
-namespace WebCore {
-
-SVGPaintServerRadialGradient::SVGPaintServerRadialGradient(const SVGGradientElement* owner)
- : SVGPaintServerGradient(owner)
- , m_radius(0.0f)
-{
-}
-
-SVGPaintServerRadialGradient::~SVGPaintServerRadialGradient()
-{
-}
-
-
-FloatPoint SVGPaintServerRadialGradient::gradientCenter() const
-{
- return m_center;
-}
-
-void SVGPaintServerRadialGradient::setGradientCenter(const FloatPoint& center)
-{
- m_center = center;
-}
-
-FloatPoint SVGPaintServerRadialGradient::gradientFocal() const
-{
- return m_focal;
-}
-
-void SVGPaintServerRadialGradient::setGradientFocal(const FloatPoint& focal)
-{
- m_focal = focal;
-}
-
-float SVGPaintServerRadialGradient::gradientRadius() const
-{
- return m_radius;
-}
-
-void SVGPaintServerRadialGradient::setGradientRadius(float radius)
-{
- m_radius = radius;
-}
-
-TextStream& SVGPaintServerRadialGradient::externalRepresentation(TextStream& ts) const
-{
- ts << "[type=RADIAL-GRADIENT] ";
- SVGPaintServerGradient::externalRepresentation(ts);
- ts << " [center=" << gradientCenter() << "]"
- << " [focal=" << gradientFocal() << "]"
- << " [radius=" << gradientRadius() << "]";
- return ts;
-}
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/svg/graphics/SVGPaintServerRadialGradient.h b/WebCore/svg/graphics/SVGPaintServerRadialGradient.h
deleted file mode 100644
index 749ba08..0000000
--- a/WebCore/svg/graphics/SVGPaintServerRadialGradient.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SVGPaintServerRadialGradient_h
-#define SVGPaintServerRadialGradient_h
-
-#if ENABLE(SVG)
-
-#include "FloatPoint.h"
-#include "SVGPaintServerGradient.h"
-
-namespace WebCore {
-
- class SVGPaintServerRadialGradient : public SVGPaintServerGradient {
- public:
- static PassRefPtr<SVGPaintServerRadialGradient> create(const SVGGradientElement* owner) { return adoptRef(new SVGPaintServerRadialGradient(owner)); }
- virtual ~SVGPaintServerRadialGradient();
-
- virtual SVGPaintServerType type() const { return RadialGradientPaintServer; }
-
- FloatPoint gradientCenter() const;
- void setGradientCenter(const FloatPoint&);
-
- FloatPoint gradientFocal() const;
- void setGradientFocal(const FloatPoint&);
-
- float gradientRadius() const;
- void setGradientRadius(float);
-
- virtual TextStream& externalRepresentation(TextStream&) const;
-
- private:
- SVGPaintServerRadialGradient(const SVGGradientElement* owner);
-
- float m_radius;
- FloatPoint m_center;
- FloatPoint m_focal;
- };
-
-} // namespace WebCore
-
-#endif
-
-#endif // SVGPaintServerRadialGradient_h
diff --git a/WebCore/svg/graphics/SVGPaintServerSolid.cpp b/WebCore/svg/graphics/SVGPaintServerSolid.cpp
deleted file mode 100644
index 8921bb0..0000000
--- a/WebCore/svg/graphics/SVGPaintServerSolid.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServerSolid.h"
-
-#include "GraphicsContext.h"
-#include "RenderPath.h"
-#include "SVGRenderTreeAsText.h"
-
-namespace WebCore {
-
-SVGPaintServerSolid::SVGPaintServerSolid()
-{
-}
-
-SVGPaintServerSolid::~SVGPaintServerSolid()
-{
-}
-
-Color SVGPaintServerSolid::color() const
-{
- return m_color;
-}
-
-void SVGPaintServerSolid::setColor(const Color& color)
-{
- m_color = color;
-}
-
-TextStream& SVGPaintServerSolid::externalRepresentation(TextStream& ts) const
-{
- ts << "[type=SOLID]"
- << " [color="<< color() << "]";
- return ts;
-}
-
-bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, const RenderStyle* style, SVGPaintTargetType type, bool isPaintingText) const
-{
- const SVGRenderStyle* svgStyle = style ? style->svgStyle() : 0;
- ColorSpace colorSpace = style ? style->colorSpace() : DeviceColorSpace;
-
- if ((type & ApplyToFillTargetType) && (!style || svgStyle->hasFill())) {
- context->setAlpha(style ? svgStyle->fillOpacity() : 1);
- context->setFillColor(color().rgb(), colorSpace);
- 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(), colorSpace);
-
- if (style)
- applyStrokeStyleToContext(context, style, object);
-
- if (isPaintingText)
- context->setTextDrawingMode(cTextStroke);
- }
-
- return true;
-}
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/svg/graphics/SVGPaintServerSolid.h b/WebCore/svg/graphics/SVGPaintServerSolid.h
deleted file mode 100644
index 680b0fe..0000000
--- a/WebCore/svg/graphics/SVGPaintServerSolid.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SVGPaintServerSolid_h
-#define SVGPaintServerSolid_h
-
-#if ENABLE(SVG)
-
-#include "Color.h"
-#include "SVGPaintServer.h"
-
-namespace WebCore {
-
- class SVGPaintServerSolid : public SVGPaintServer {
- public:
- static PassRefPtr<SVGPaintServerSolid> create() { return adoptRef(new SVGPaintServerSolid); }
- virtual ~SVGPaintServerSolid();
-
- virtual SVGPaintServerType type() const { return SolidPaintServer; }
-
- Color color() const;
- void setColor(const Color&);
-
- virtual TextStream& externalRepresentation(TextStream&) const;
-
- virtual bool setup(GraphicsContext*&, const RenderObject*, const RenderStyle*, SVGPaintTargetType, bool isPaintingText) const;
-
- private:
- SVGPaintServerSolid();
-
- Color m_color;
- };
-
-} // namespace WebCore
-
-#endif
-
-#endif // SVGPaintServerSolid_h
diff --git a/WebCore/svg/graphics/SVGResource.cpp b/WebCore/svg/graphics/SVGResource.cpp
deleted file mode 100644
index d1dd0e7..0000000
--- a/WebCore/svg/graphics/SVGResource.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGResource.h"
-
-#include "RenderPath.h"
-#include "SVGElement.h"
-#include "SVGStyledElement.h"
-#include <wtf/HashSet.h>
-#include <wtf/StdLibExtras.h>
-
-namespace WebCore {
-
-typedef HashSet<SVGResource*> ResourceSet;
-
-static ResourceSet& resourceSet()
-{
- DEFINE_STATIC_LOCAL(ResourceSet, set, ());
- return set;
-}
-
-SVGResource::SVGResource()
-{
- ASSERT(!resourceSet().contains(this));
- resourceSet().add(this);
-}
-
-SVGResource::~SVGResource()
-{
- ASSERT(resourceSet().contains(this));
- resourceSet().remove(this);
-}
-
-void SVGResource::invalidate()
-{
- HashSet<SVGStyledElement*>::const_iterator it = m_clients.begin();
- const HashSet<SVGStyledElement*>::const_iterator end = m_clients.end();
-
- for (; it != end; ++it) {
- SVGStyledElement* cur = *it;
-
- if (cur->renderer())
- cur->renderer()->setNeedsLayout(true);
-
- cur->invalidateResourcesInAncestorChain();
- }
-}
-
-void SVGResource::invalidateClients(HashSet<SVGStyledElement*> clients)
-{
- HashSet<SVGStyledElement*>::const_iterator it = clients.begin();
- const HashSet<SVGStyledElement*>::const_iterator end = clients.end();
-
- for (; it != end; ++it) {
- SVGStyledElement* cur = *it;
-
- if (cur->renderer())
- cur->renderer()->setNeedsLayout(true);
-
- cur->invalidateResourcesInAncestorChain();
- }
-}
-
-void SVGResource::removeClient(SVGStyledElement* item)
-{
- ResourceSet::iterator it = resourceSet().begin();
- ResourceSet::iterator end = resourceSet().end();
-
- for (; it != end; ++it) {
- SVGResource* resource = *it;
- if (!resource->m_clients.contains(item))
- continue;
- resource->m_clients.remove(item);
- }
-}
-
-void SVGResource::addClient(SVGStyledElement* item)
-{
- if (m_clients.contains(item))
- return;
-
- m_clients.add(item);
-}
-
-TextStream& SVGResource::externalRepresentation(TextStream& ts) const
-{
- return ts;
-}
-
-SVGResource* getResourceById(Document* document, const AtomicString& id, const RenderObject* object)
-{
- if (id.isEmpty())
- return 0;
-
- Element* element = document->getElementById(id);
- SVGElement* svgElement = 0;
- if (element && element->isSVGElement())
- svgElement = static_cast<SVGElement*>(element);
-
- if (svgElement && svgElement->isStyled())
- return static_cast<SVGStyledElement*>(svgElement)->canvasResource(object);
-
- return 0;
-}
-
-TextStream& operator<<(TextStream& ts, const SVGResource& r)
-{
- return r.externalRepresentation(ts);
-}
-
-}
-
-#endif
diff --git a/WebCore/svg/graphics/SVGResource.h b/WebCore/svg/graphics/SVGResource.h
deleted file mode 100644
index 319add7..0000000
--- a/WebCore/svg/graphics/SVGResource.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SVGResource_h
-#define SVGResource_h
-
-#if ENABLE(SVG)
-#include "PlatformString.h"
-#include "RenderObject.h"
-#include "StringHash.h"
-
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class AtomicString;
-class Document;
-class SVGStyledElement;
-class TextStream;
-
-enum SVGResourceType {
- // Painting mode
- ImageResourceType,
- PaintServerResourceType,
-
- // For resource tracking we need to know how many types of resource there are
- _ResourceTypeCount
-};
-
-// The SVGResource file represent various graphics resources:
-// - Pattern resource
-// - Linear/Radial gradient resource
-//
-// SVG creates/uses these resources.
-
-class SVGResource : public RefCounted<SVGResource> {
-public:
- virtual ~SVGResource();
-
- virtual void invalidate();
-
- void addClient(SVGStyledElement*);
- virtual SVGResourceType resourceType() const = 0;
-
- bool isPaintServer() const { return resourceType() == PaintServerResourceType; }
-
- virtual TextStream& externalRepresentation(TextStream&) const;
-
- static void invalidateClients(HashSet<SVGStyledElement*>);
- static void removeClient(SVGStyledElement*);
-
-protected:
- SVGResource();
-
-private:
- HashSet<SVGStyledElement*> m_clients;
-};
-
-SVGResource* getResourceById(Document*, const AtomicString&, const RenderObject*);
-
-TextStream& operator<<(TextStream&, const SVGResource&);
-
-}
-
-#endif
-#endif
diff --git a/WebCore/svg/graphics/SVGResourceListener.h b/WebCore/svg/graphics/SVGResourceListener.h
deleted file mode 100644
index e69de29..0000000
--- a/WebCore/svg/graphics/SVGResourceListener.h
+++ /dev/null