+2010-12-29 Dirk Schulze <krit@wbekit.org>
+
+ Reviewed by Darin Adler.
+
+ Cleanup SVG code according to the webkit style rules 3
+ https://bugs.webkit.org/show_bug.cgi?id=51490
+
+ Last patch to fix indention and other style issues according to the WebKit style rules in the SVG code.
+ Just one file can't be fixed for check-webkit-style.
+ * SVGAllInOne.cpp: check-webkit-style wants a config.h at the beginning
+
+ No changes of functionality, so no new tests.
+
+ * svg/SVGAllInOne.cpp:
+ * svg/SVGImage.cpp:
+ * svg/SVGLength.cpp:
+ (WebCore::SVGLength::setValue):
+ * svg/SVGPolygonElement.h:
+ * svg/SVGPolylineElement.h:
+ * svg/SVGPreserveAspectRatio.cpp:
+ (WebCore::SVGPreserveAspectRatio::parsePreserveAspectRatio):
+ (WebCore::SVGPreserveAspectRatio::transformRect):
+ * svg/SVGSVGElement.cpp:
+ (WebCore::SVGSVGElement::viewport):
+ * svg/SVGSetElement.h:
+ * svg/SVGStylable.h:
+ (WebCore::SVGStylable::~SVGStylable):
+ * svg/SVGStyledLocatableElement.h:
+ (WebCore::SVGStyledLocatableElement::localCoordinateSpaceTransform):
+ (WebCore::SVGStyledLocatableElement::isStyledLocatable):
+ * svg/SVGStyledTransformableElement.cpp:
+ (WebCore::SVGStyledTransformableElement::isKnownAttribute):
+ * svg/SVGSwitchElement.cpp:
+ (WebCore::SVGSwitchElement::childShouldCreateRenderer):
+ * svg/SVGTests.cpp:
+ (WebCore::SVGTests::parseMappedAttribute):
+ * svg/SVGTextContentElement.cpp:
+ (WebCore::SVGTextContentElement::isKnownAttribute):
+ * svg/SVGTextPathElement.cpp:
+ * svg/SVGTextPathElement.h:
+ * svg/SVGTitleElement.h:
+ (WebCore::SVGTitleElement::rendererIsNeeded):
+ * svg/SVGTransformDistance.cpp:
+ (WebCore::SVGTransformDistance::SVGTransformDistance):
+ (WebCore::SVGTransformDistance::scaledDistance):
+ (WebCore::SVGTransformDistance::addSVGTransforms):
+ (WebCore::SVGTransformDistance::addSVGTransform):
+ (WebCore::SVGTransformDistance::addToSVGTransform):
+ (WebCore::SVGTransformDistance::isZero):
+ * svg/SVGTransformList.cpp:
+ * svg/SVGURIReference.cpp:
+ (WebCore::SVGURIReference::getTarget):
+ * svg/SVGVKernElement.h:
+ * svg/SVGViewSpec.cpp:
+ (WebCore::SVGViewSpec::parseViewSpec):
+ * svg/SVGZoomAndPan.h:
+ (WebCore::SVGZoomAndPan::SVGZoomAndPan):
+ (WebCore::SVGZoomAndPan::~SVGZoomAndPan):
+ (WebCore::SVGZoomAndPan::zoomAndPan):
+ * svg/SVGZoomEvent.h:
+ (WebCore::SVGZoomEvent::create):
+ * svg/animation/SMILTime.cpp:
+ (WebCore::operator*):
+ * svg/animation/SMILTime.h:
+ (WebCore::SMILTime::SMILTime):
+ (WebCore::SMILTime::unresolved):
+ (WebCore::SMILTime::indefinite):
+ (WebCore::SMILTime::operator=):
+ (WebCore::SMILTime::value):
+ (WebCore::SMILTime::isFinite):
+ (WebCore::SMILTime::isIndefinite):
+ (WebCore::SMILTime::isUnresolved):
+ (WebCore::operator==):
+ (WebCore::operator!): new operator checks for 0 or infinite values.
+ (WebCore::operator!=):
+ (WebCore::operator>):
+ (WebCore::operator<):
+ (WebCore::operator>=):
+ (WebCore::operator<=):
+ * svg/animation/SMILTimeContainer.h:
+ (WebCore::SMILTimeContainer::create):
+ (WebCore::SMILTimeContainer::setDocumentOrderIndexesDirty):
+ * svg/animation/SVGSMILElement.cpp:
+ (WebCore::ConditionEventListener::operator==):
+ (WebCore::SVGSMILElement::repeatingDuration):
+ (WebCore::SVGSMILElement::resolveInterval):
+ (WebCore::SVGSMILElement::calculateAnimationPercentAndRepeat):
+ * svg/animation/SVGSMILElement.h:
+ (WebCore::SVGSMILElement::timeContainer):
+ (WebCore::SVGSMILElement::intervalBegin):
+ (WebCore::SVGSMILElement::intervalEnd):
+ (WebCore::SVGSMILElement::previousIntervalBegin):
+ (WebCore::SVGSMILElement::documentOrderIndex):
+ (WebCore::SVGSMILElement::setDocumentOrderIndex):
+ * svg/graphics/SVGImage.h:
+ (WebCore::SVGImage::create):
+ (WebCore::SVGImage::destroyDecodedData):
+ (WebCore::SVGImage::decodedSize):
+ (WebCore::SVGImage::frameAtIndex):
+ * svg/graphics/filters/SVGFilterBuilder.h:
+ (WebCore::SVGFilterBuilder::create):
+ (WebCore::SVGFilterBuilder::lastEffect):
+ (WebCore::SVGFilterBuilder::getEffectReferences):
+ (WebCore::SVGFilterBuilder::addBuiltinEffects):
+
2010-12-29 Abhishek Arya <inferno@chromium.org>
Reviewed by Darin Adler.
#include "SVGTextPositioningElement.cpp"
#include "SVGTitleElement.cpp"
#include "SVGTransform.cpp"
-#include "SVGTransformable.cpp"
#include "SVGTransformDistance.cpp"
#include "SVGTransformList.cpp"
+#include "SVGTransformable.cpp"
#include "SVGURIReference.cpp"
#include "SVGUseElement.cpp"
#include "SVGVKernElement.cpp"
case LengthTypeNumber:
m_valueInSpecifiedUnits = value;
break;
- case LengthTypePercentage:
- {
+ case LengthTypePercentage: {
float result = convertValueFromUserUnitsToPercentage(value, context, ec);
if (!ec)
m_valueInSpecifiedUnits = result;
break;
}
- case LengthTypeEMS:
- {
+ case LengthTypeEMS: {
float result = convertValueFromUserUnitsToEMS(value, context, ec);
if (!ec)
m_valueInSpecifiedUnits = result;
break;
}
- case LengthTypeEXS:
- {
+ case LengthTypeEXS: {
float result = convertValueFromUserUnitsToEXS(value, context, ec);
if (!ec)
m_valueInSpecifiedUnits = result;
namespace WebCore {
- class SVGPolygonElement : public SVGPolyElement {
- public:
- static PassRefPtr<SVGPolygonElement> create(const QualifiedName&, Document*);
+class SVGPolygonElement : public SVGPolyElement {
+public:
+ static PassRefPtr<SVGPolygonElement> create(const QualifiedName&, Document*);
- private:
- SVGPolygonElement(const QualifiedName&, Document*);
+private:
+ SVGPolygonElement(const QualifiedName&, Document*);
- virtual void toPathData(Path&) const;
- };
+ virtual void toPathData(Path&) const;
+};
} // namespace WebCore
namespace WebCore {
- class SVGPolylineElement : public SVGPolyElement {
- public:
- static PassRefPtr<SVGPolylineElement> create(const QualifiedName&, Document*);
+class SVGPolylineElement : public SVGPolyElement {
+public:
+ static PassRefPtr<SVGPolylineElement> create(const QualifiedName&, Document*);
- private:
- SVGPolylineElement(const QualifiedName&, Document*);
+private:
+ SVGPolylineElement(const QualifiedName&, Document*);
- virtual void toPathData(Path&) const;
- };
+ virtual void toPathData(Path&) const;
+};
} // namespace WebCore
// FIXME: Rewrite this parser, without gotos!
if (!skipOptionalSpaces(currParam, end))
- goto bail_out;
+ goto bailOut;
if (*currParam == 'd') {
if (!skipString(currParam, end, "defer"))
- goto bail_out;
+ goto bailOut;
// FIXME: We just ignore the "defer" here.
if (!skipOptionalSpaces(currParam, end))
- goto bail_out;
+ goto bailOut;
}
if (*currParam == 'n') {
if (!skipString(currParam, end, "none"))
- goto bail_out;
+ goto bailOut;
skipOptionalSpaces(currParam, end);
} else if (*currParam == 'x') {
if ((end - currParam) < 8)
- goto bail_out;
+ goto bailOut;
if (currParam[1] != 'M' || currParam[4] != 'Y' || currParam[5] != 'M')
- goto bail_out;
+ goto bailOut;
if (currParam[2] == 'i') {
if (currParam[3] == 'n') {
if (currParam[6] == 'i') {
else if (currParam[7] == 'd')
aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMID;
else
- goto bail_out;
+ goto bailOut;
} else if (currParam[6] == 'a' && currParam[7] == 'x')
aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMAX;
else
- goto bail_out;
+ goto bailOut;
} else if (currParam[3] == 'd') {
if (currParam[6] == 'i') {
if (currParam[7] == 'n')
else if (currParam[7] == 'd')
aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
else
- goto bail_out;
+ goto bailOut;
} else if (currParam[6] == 'a' && currParam[7] == 'x')
aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMAX;
else
- goto bail_out;
+ goto bailOut;
} else
- goto bail_out;
+ goto bailOut;
} else if (currParam[2] == 'a' && currParam[3] == 'x') {
if (currParam[6] == 'i') {
if (currParam[7] == 'n')
else if (currParam[7] == 'd')
aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMID;
else
- goto bail_out;
+ goto bailOut;
} else if (currParam[6] == 'a' && currParam[7] == 'x')
aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMAX;
else
- goto bail_out;
+ goto bailOut;
} else
- goto bail_out;
+ goto bailOut;
currParam += 8;
skipOptionalSpaces(currParam, end);
} else
- goto bail_out;
+ goto bailOut;
if (currParam < end) {
if (*currParam == 'm') {
if (!skipString(currParam, end, "meet"))
- goto bail_out;
+ goto bailOut;
skipOptionalSpaces(currParam, end);
} else if (*currParam == 's') {
if (!skipString(currParam, end, "slice"))
- goto bail_out;
+ goto bailOut;
skipOptionalSpaces(currParam, end);
if (aspectRatio.m_align != SVG_PRESERVEASPECTRATIO_NONE)
aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_SLICE;
}
if (end != currParam && validate) {
-bail_out:
+bailOut:
// FIXME: Should the two values be set to UNKNOWN instead?
aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_NONE;
aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_MEET;
switch (m_meetOrSlice) {
case SVGPreserveAspectRatio::SVG_MEETORSLICE_UNKNOWN:
break;
- case SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET:
- {
+ case SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET: {
float widthToHeightMultiplier = srcRect.height() / srcRect.width();
if (origDestHeight > origDestWidth * widthToHeightMultiplier) {
destRect.setHeight(origDestWidth * widthToHeightMultiplier);
}
break;
}
- case SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE:
- {
+ case SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE: {
float widthToHeightMultiplier = srcRect.height() / srcRect.width();
// if the destination height is less than the height of the image we'll be drawing
if (origDestHeight < origDestWidth * widthToHeightMultiplier) {
FloatRect SVGSVGElement::viewport() const
{
- double _x = 0.0;
- double _y = 0.0;
+ double x = 0;
+ double y = 0;
if (!isOutermostSVG()) {
- _x = x().value(this);
- _y = y().value(this);
+ x = this->x().value(this);
+ y = this->y().value(this);
}
float w = width().value(this);
float h = height().value(this);
AffineTransform viewBox = viewBoxToViewTransform(w, h);
double wDouble = w;
double hDouble = h;
- viewBox.map(_x, _y, _x, _y);
+ viewBox.map(x, y, x, y);
viewBox.map(w, h, wDouble, hDouble);
- return FloatRect::narrowPrecision(_x, _y, wDouble, hDouble);
+ return FloatRect::narrowPrecision(x, y, wDouble, hDouble);
}
int SVGSVGElement::relativeWidthValue() const
namespace WebCore {
- // SVGAnimateElement implements superset of the functionality.
- class SVGSetElement : public SVGAnimateElement {
- public:
- static PassRefPtr<SVGSetElement> create(const QualifiedName&, Document*);
-
- private:
- SVGSetElement(const QualifiedName&, Document*);
- };
+// SVGAnimateElement implements superset of the functionality.
+class SVGSetElement : public SVGAnimateElement {
+public:
+ static PassRefPtr<SVGSetElement> create(const QualifiedName&, Document*);
+
+private:
+ SVGSetElement(const QualifiedName&, Document*);
+};
} // namespace WebCore
namespace WebCore {
- class CSSValue;
- class CSSStyleDeclaration;
+class CSSValue;
+class CSSStyleDeclaration;
- class SVGStylable {
- public:
- virtual ~SVGStylable() { }
+class SVGStylable {
+public:
+ virtual ~SVGStylable() { }
- virtual CSSStyleDeclaration* style() = 0;
- virtual PassRefPtr<CSSValue> getPresentationAttribute(const String&) = 0;
- };
+ virtual CSSStyleDeclaration* style() = 0;
+ virtual PassRefPtr<CSSValue> getPresentationAttribute(const String&) = 0;
+};
} // namespace WebCore
namespace WebCore {
- class SVGElement;
+class SVGElement;
- class SVGStyledLocatableElement : public SVGStyledElement,
- virtual public SVGLocatable {
- public:
- virtual SVGElement* nearestViewportElement() const;
- virtual SVGElement* farthestViewportElement() const;
+class SVGStyledLocatableElement : public SVGStyledElement,
+ virtual public SVGLocatable {
+public:
+ virtual SVGElement* nearestViewportElement() const;
+ virtual SVGElement* farthestViewportElement() const;
- virtual FloatRect getBBox(StyleUpdateStrategy = AllowStyleUpdate) const;
- virtual AffineTransform getCTM(StyleUpdateStrategy = AllowStyleUpdate) const;
- virtual AffineTransform getScreenCTM(StyleUpdateStrategy = AllowStyleUpdate) const;
+ virtual FloatRect getBBox(StyleUpdateStrategy = AllowStyleUpdate) const;
+ virtual AffineTransform getCTM(StyleUpdateStrategy = AllowStyleUpdate) const;
+ virtual AffineTransform getScreenCTM(StyleUpdateStrategy = AllowStyleUpdate) const;
- virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const { return SVGLocatable::localCoordinateSpaceTransform(mode); }
+ virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const { return SVGLocatable::localCoordinateSpaceTransform(mode); }
- protected:
- SVGStyledLocatableElement(const QualifiedName&, Document*);
+protected:
+ SVGStyledLocatableElement(const QualifiedName&, Document*);
- private:
- virtual bool isStyledLocatable() const { return true; }
- };
+private:
+ virtual bool isStyledLocatable() const { return true; }
+};
} // namespace WebCore
bool SVGStyledTransformableElement::isKnownAttribute(const QualifiedName& attrName)
{
- return SVGTransformable::isKnownAttribute(attrName) ||
- SVGStyledLocatableElement::isKnownAttribute(attrName);
+ return SVGTransformable::isKnownAttribute(attrName) || SVGStyledLocatableElement::isKnownAttribute(attrName);
}
SVGElement* SVGStyledTransformableElement::nearestViewportElement() const
{
// FIXME: This function does not do what the comment below implies it does.
// It will create a renderer for any valid SVG element children, not just the first one.
+ for (Node* node = firstChild(); node; node = node->nextSibling()) {
+ if (!node->isSVGElement())
+ continue;
- for (Node* n = firstChild(); n != 0; n = n->nextSibling()) {
- if (n->isSVGElement()) {
- SVGElement* element = static_cast<SVGElement*>(n);
- if (element && element->isValid())
- return (n == child); // Only allow this child if it's the first valid child
- }
+ SVGElement* element = static_cast<SVGElement*>(node);
+ if (!element || !element->isValid())
+ continue;
+
+ return node == child; // Only allow this child if it's the first valid child
}
return false;
if (attr->name() == SVGNames::requiredFeaturesAttr) {
m_requiredFeatures.value.reset(attr->value());
return true;
- } else if (attr->name() == SVGNames::requiredExtensionsAttr) {
+ }
+ if (attr->name() == SVGNames::requiredExtensionsAttr) {
m_requiredExtensions.value.reset(attr->value());
return true;
- } else if (attr->name() == SVGNames::systemLanguageAttr) {
+ }
+ if (attr->name() == SVGNames::systemLanguageAttr) {
m_systemLanguage.value.reset(attr->value());
return true;
}
bool SVGTextContentElement::isKnownAttribute(const QualifiedName& attrName)
{
- return (attrName.matches(SVGNames::lengthAdjustAttr) ||
- attrName.matches(SVGNames::textLengthAttr) ||
- SVGLangSpace::isKnownAttribute(attrName) ||
- SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
- SVGStyledElement::isKnownAttribute(attrName));
+ return attrName.matches(SVGNames::lengthAdjustAttr)
+ || attrName.matches(SVGNames::textLengthAttr)
+ || SVGLangSpace::isKnownAttribute(attrName)
+ || SVGExternalResourcesRequired::isKnownAttribute(attrName)
+ || SVGStyledElement::isKnownAttribute(attrName);
}
bool SVGTextContentElement::selfHasRelativeLengths() const
#include "SVGTextPathElement.h"
#include "Attribute.h"
-#include "SVGNames.h"
#include "RenderSVGResource.h"
#include "RenderSVGTextPath.h"
+#include "SVGNames.h"
namespace WebCore {
namespace WebCore {
- enum SVGTextPathMethodType {
+enum SVGTextPathMethodType {
SVG_TEXTPATH_METHODTYPE_UNKNOWN = 0,
SVG_TEXTPATH_METHODTYPE_ALIGN = 1,
SVG_TEXTPATH_METHODTYPE_STRETCH = 2
namespace WebCore {
- class SVGTitleElement : public SVGStyledElement,
- public SVGLangSpace {
- public:
- static PassRefPtr<SVGTitleElement> create(const QualifiedName&, Document*);
+class SVGTitleElement : public SVGStyledElement,
+ public SVGLangSpace {
+public:
+ static PassRefPtr<SVGTitleElement> create(const QualifiedName&, Document*);
- private:
- SVGTitleElement(const QualifiedName&, Document*);
+private:
+ SVGTitleElement(const QualifiedName&, Document*);
- virtual void insertedIntoDocument();
- virtual void removedFromDocument();
- virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
+ virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
- virtual bool rendererIsNeeded(RenderStyle*) { return false; }
- };
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+};
} // namespace WebCore
case SVGTransform::SVG_TRANSFORM_MATRIX:
// FIXME: need to be able to subtract to matrices
return;
- case SVGTransform::SVG_TRANSFORM_ROTATE:
- {
+ case SVGTransform::SVG_TRANSFORM_ROTATE: {
FloatSize centerDistance = toSVGTransform.rotationCenter() - fromSVGTransform.rotationCenter();
m_angle = toSVGTransform.angle() - fromSVGTransform.angle();
m_cx = centerDistance.width();
m_cy = centerDistance.height();
return;
}
- case SVGTransform::SVG_TRANSFORM_TRANSLATE:
- {
+ case SVGTransform::SVG_TRANSFORM_TRANSLATE: {
FloatSize translationDistance = toSVGTransform.translate() - fromSVGTransform.translate();
m_transform.translate(translationDistance.width(), translationDistance.height());
return;
}
- case SVGTransform::SVG_TRANSFORM_SCALE:
- {
+ case SVGTransform::SVG_TRANSFORM_SCALE: {
float scaleX = toSVGTransform.scale().width() - fromSVGTransform.scale().width();
float scaleY = toSVGTransform.scale().height() - fromSVGTransform.scale().height();
m_transform.scaleNonUniform(scaleX, scaleY);
case SVGTransform::SVG_TRANSFORM_SCALE:
case SVGTransform::SVG_TRANSFORM_MATRIX:
return SVGTransformDistance(m_type, m_angle * scaleFactor, m_cx * scaleFactor, m_cy * scaleFactor, AffineTransform(m_transform).scale(scaleFactor));
- case SVGTransform::SVG_TRANSFORM_TRANSLATE:
- {
+ case SVGTransform::SVG_TRANSFORM_TRANSLATE: {
AffineTransform newTransform(m_transform);
newTransform.setE(m_transform.e() * scaleFactor);
newTransform.setF(m_transform.f() * scaleFactor);
switch (first.type()) {
case SVGTransform::SVG_TRANSFORM_UNKNOWN:
return SVGTransform();
- case SVGTransform::SVG_TRANSFORM_ROTATE:
- {
+ case SVGTransform::SVG_TRANSFORM_ROTATE: {
transform.setRotate(first.angle() + second.angle(), first.rotationCenter().x() + second.rotationCenter().x(),
first.rotationCenter().y() + second.rotationCenter().y());
return transform;
case SVGTransform::SVG_TRANSFORM_MATRIX:
transform.setMatrix(first.matrix() * second.matrix());
return transform;
- case SVGTransform::SVG_TRANSFORM_TRANSLATE:
- {
+ case SVGTransform::SVG_TRANSFORM_TRANSLATE: {
float dx = first.translate().x() + second.translate().x();
float dy = first.translate().y() + second.translate().y();
transform.setTranslate(dx, dy);
return transform;
}
- case SVGTransform::SVG_TRANSFORM_SCALE:
- {
+ case SVGTransform::SVG_TRANSFORM_SCALE: {
FloatSize scale = first.scale() + second.scale();
transform.setScale(scale.width(), scale.height());
return transform;
m_cx += absoluteValue ? fabsf(transform.rotationCenter().x()) : transform.rotationCenter().x();
m_cy += absoluteValue ? fabsf(transform.rotationCenter().y()) : transform.rotationCenter().y();
// fall through
- case SVGTransform::SVG_TRANSFORM_TRANSLATE:
- {
+ case SVGTransform::SVG_TRANSFORM_TRANSLATE: {
float dx = absoluteValue ? fabsf(transform.translate().x()) : transform.translate().x();
float dy = absoluteValue ? fabsf(transform.translate().y()) : transform.translate().y();
m_transform.translate(dx, dy);
return;
}
- case SVGTransform::SVG_TRANSFORM_SCALE:
- {
+ case SVGTransform::SVG_TRANSFORM_SCALE: {
float scaleX = absoluteValue ? fabsf(transform.scale().width()) : transform.scale().width();
float scaleY = absoluteValue ? fabsf(transform.scale().height()) : transform.scale().height();
m_transform.scaleNonUniform(scaleX, scaleY);
return SVGTransform();
case SVGTransform::SVG_TRANSFORM_MATRIX:
return SVGTransform(transform.matrix() * m_transform);
- case SVGTransform::SVG_TRANSFORM_TRANSLATE:
- {
+ case SVGTransform::SVG_TRANSFORM_TRANSLATE: {
FloatPoint translation = transform.translate();
translation += FloatSize::narrowPrecision(m_transform.e(), m_transform.f());
newTransform.setTranslate(translation.x(), translation.y());
return newTransform;
}
- case SVGTransform::SVG_TRANSFORM_SCALE:
- {
+ case SVGTransform::SVG_TRANSFORM_SCALE: {
FloatSize scale = transform.scale();
scale += FloatSize::narrowPrecision(m_transform.a(), m_transform.d());
newTransform.setScale(scale.width(), scale.height());
return newTransform;
}
- case SVGTransform::SVG_TRANSFORM_ROTATE:
- {
+ case SVGTransform::SVG_TRANSFORM_ROTATE: {
// FIXME: I'm not certain the translation is calculated correctly here
FloatPoint center = transform.rotationCenter();
newTransform.setRotate(transform.angle() + m_angle,
bool SVGTransformDistance::isZero() const
{
- return (m_transform == AffineTransform() && m_angle == 0);
+ return m_transform.isIdentity() && !m_angle;
}
float SVGTransformDistance::distance() const
{
switch (m_type) {
case SVGTransform::SVG_TRANSFORM_UNKNOWN:
- return 0.0f;
+ return 0;
case SVGTransform::SVG_TRANSFORM_ROTATE:
return sqrtf(m_angle * m_angle + m_cx * m_cx + m_cy * m_cy);
case SVGTransform::SVG_TRANSFORM_MATRIX:
- return 0.0f; // I'm not quite sure yet what distance between two matrices means.
+ return 0; // I'm not quite sure yet what distance between two matrices means.
case SVGTransform::SVG_TRANSFORM_SCALE:
return static_cast<float>(sqrt(m_transform.a() * m_transform.a() + m_transform.d() * m_transform.d()));
case SVGTransform::SVG_TRANSFORM_TRANSLATE:
return m_angle;
}
ASSERT_NOT_REACHED();
- return 0.0f;
+ return 0;
}
}
#include "AffineTransform.h"
#include "SVGSVGElement.h"
#include "SVGTransform.h"
-#include <wtf/text/StringConcatenate.h>
+
#include <wtf/text/StringBuilder.h>
+#include <wtf/text/StringConcatenate.h>
namespace WebCore {
size_t start = url.find('#') + 1;
size_t end = url.reverseFind(')');
return url.substring(start, end - start);
- } else if (url.find('#') != notFound) { // format is #target
+ }
+ if (url.find('#') != notFound) { // format is #target
size_t start = url.find('#') + 1;
return url.substring(start, url.length() - start);
- } else // The url doesn't have any target.
- return String();
+ }
+
+ // The url doesn't have any target.
+ return String();
}
}
#include "SVGFontElement.h"
#include "SVGParserUtilities.h"
#include "SVGStyledElement.h"
-#include <wtf/Forward.h>
#include <limits>
+#include <wtf/Forward.h>
namespace WebCore {
if (!skipString(currViewSpec, end, svgViewSpec, WTF_ARRAY_LENGTH(svgViewSpec)))
return false;
- if (currViewSpec >= end || *currViewSpec != '(' )
+ if (currViewSpec >= end || *currViewSpec != '(')
return false;
currViewSpec++;
namespace WebCore {
- class Attribute;
- class QualifiedName;
-
- class SVGZoomAndPan {
- public:
- enum SVGZoomAndPanType {
- SVG_ZOOMANDPAN_UNKNOWN = 0,
- SVG_ZOOMANDPAN_DISABLE = 1,
- SVG_ZOOMANDPAN_MAGNIFY = 2
- };
+class Attribute;
+class QualifiedName;
+
+class SVGZoomAndPan {
+public:
+ enum SVGZoomAndPanType {
+ SVG_ZOOMANDPAN_UNKNOWN = 0,
+ SVG_ZOOMANDPAN_DISABLE = 1,
+ SVG_ZOOMANDPAN_MAGNIFY = 2
+ };
- SVGZoomAndPan() : m_zoomAndPan(SVG_ZOOMANDPAN_MAGNIFY) { }
- virtual ~SVGZoomAndPan() { }
+ SVGZoomAndPan() : m_zoomAndPan(SVG_ZOOMANDPAN_MAGNIFY) { }
+ virtual ~SVGZoomAndPan() { }
- unsigned short zoomAndPan() const { return m_zoomAndPan; }
- virtual void setZoomAndPan(unsigned short zoomAndPan);
+ unsigned short zoomAndPan() const { return m_zoomAndPan; }
+ virtual void setZoomAndPan(unsigned short zoomAndPan);
- bool parseMappedAttribute(Attribute*);
- bool isKnownAttribute(const QualifiedName&);
+ bool parseMappedAttribute(Attribute*);
+ bool isKnownAttribute(const QualifiedName&);
- bool parseZoomAndPan(const UChar*& start, const UChar* end);
+ bool parseZoomAndPan(const UChar*& start, const UChar* end);
- private:
- unsigned short m_zoomAndPan;
- };
+private:
+ unsigned short m_zoomAndPan;
+};
} // namespace WebCore
namespace WebCore {
- class SVGZoomEvent : public UIEvent {
- public:
- static PassRefPtr<SVGZoomEvent> create() { return adoptRef(new SVGZoomEvent); }
+class SVGZoomEvent : public UIEvent {
+public:
+ static PassRefPtr<SVGZoomEvent> create() { return adoptRef(new SVGZoomEvent); }
- // 'SVGZoomEvent' functions
- FloatRect zoomRectScreen() const;
+ // 'SVGZoomEvent' functions
+ FloatRect zoomRectScreen() const;
- float previousScale() const;
- void setPreviousScale(float);
+ float previousScale() const;
+ void setPreviousScale(float);
- FloatPoint previousTranslate() const;
+ FloatPoint previousTranslate() const;
- float newScale() const;
- void setNewScale(float);
+ float newScale() const;
+ void setNewScale(float);
- FloatPoint newTranslate() const;
+ FloatPoint newTranslate() const;
- private:
- SVGZoomEvent();
+private:
+ SVGZoomEvent();
- virtual bool isSVGZoomEvent() const;
+ virtual bool isSVGZoomEvent() const;
- float m_newScale;
- float m_previousScale;
-
- FloatRect m_zoomRectScreen;
-
- FloatPoint m_newTranslate;
- FloatPoint m_previousTranslate;
- };
+ float m_newScale;
+ float m_previousScale;
+
+ FloatRect m_zoomRectScreen;
+
+ FloatPoint m_newTranslate;
+ FloatPoint m_previousTranslate;
+};
} // namespace WebCore
{
if (a.isUnresolved() || b.isUnresolved())
return SMILTime::unresolved();
- if (a.value() == 0 || b.value() == 0)
+ if (!a.value() || !b.value())
return SMILTime(0);
if (a.isIndefinite() || b.isIndefinite())
return SMILTime::indefinite();
namespace WebCore {
- class SMILTime {
- public:
- SMILTime() : m_time(0) { }
- SMILTime(double time) : m_time(time) { }
- SMILTime(const SMILTime& o) : m_time(o.m_time) { }
-
- static SMILTime unresolved() { return unresolvedValue; }
- static SMILTime indefinite() { return indefiniteValue; }
-
- SMILTime& operator=(const SMILTime& o) { m_time = o.m_time; return *this; }
- double value() const { return m_time; }
-
- bool isFinite() const { return m_time < indefiniteValue; }
- bool isIndefinite() const { return m_time == indefiniteValue; }
- bool isUnresolved() const { return m_time == unresolvedValue; }
-
- private:
- static const double unresolvedValue;
- static const double indefiniteValue;
+class SMILTime {
+public:
+ SMILTime() : m_time(0) { }
+ SMILTime(double time) : m_time(time) { }
+ SMILTime(const SMILTime& o) : m_time(o.m_time) { }
+
+ static SMILTime unresolved() { return unresolvedValue; }
+ static SMILTime indefinite() { return indefiniteValue; }
+
+ SMILTime& operator=(const SMILTime& o) { m_time = o.m_time; return *this; }
+ double value() const { return m_time; }
+
+ bool isFinite() const { return m_time < indefiniteValue; }
+ bool isIndefinite() const { return m_time == indefiniteValue; }
+ bool isUnresolved() const { return m_time == unresolvedValue; }
+
+private:
+ static const double unresolvedValue;
+ static const double indefiniteValue;
- double m_time;
- };
+ double m_time;
+};
- inline bool operator==(const SMILTime& a, const SMILTime& b) { return a.isFinite() && a.value() == b.value(); }
- inline bool operator!=(const SMILTime& a, const SMILTime& b) { return !operator==(a, b); }
- inline bool operator>(const SMILTime& a, const SMILTime& b) { return a.value() > b.value(); }
- inline bool operator<(const SMILTime& a, const SMILTime& b) { return a.value() < b.value(); }
- inline bool operator>=(const SMILTime& a, const SMILTime& b) { return a.value() > b.value() || operator==(a, b); }
- inline bool operator<=(const SMILTime& a, const SMILTime& b) { return a.value() < b.value() || operator==(a, b); }
+inline bool operator==(const SMILTime& a, const SMILTime& b) { return a.isFinite() && a.value() == b.value(); }
+inline bool operator!(const SMILTime& a) { return !a.isFinite() || !a.value(); }
+inline bool operator!=(const SMILTime& a, const SMILTime& b) { return !operator==(a, b); }
+inline bool operator>(const SMILTime& a, const SMILTime& b) { return a.value() > b.value(); }
+inline bool operator<(const SMILTime& a, const SMILTime& b) { return a.value() < b.value(); }
+inline bool operator>=(const SMILTime& a, const SMILTime& b) { return a.value() > b.value() || operator==(a, b); }
+inline bool operator<=(const SMILTime& a, const SMILTime& b) { return a.value() < b.value() || operator==(a, b); }
+
+SMILTime operator+(const SMILTime&, const SMILTime&);
+SMILTime operator-(const SMILTime&, const SMILTime&);
+// So multiplying times does not make too much sense but SMIL defines it for duration * repeatCount
+SMILTime operator*(const SMILTime&, const SMILTime&);
- SMILTime operator+(const SMILTime&, const SMILTime&);
- SMILTime operator-(const SMILTime&, const SMILTime&);
- // So multiplying times does not make too much sense but SMIL defines it for duration * repeatCount
- SMILTime operator*(const SMILTime&, const SMILTime&);
}
-#endif
-#endif
+#endif // ENABLE(SVG)
+#endif // SMILTime_h
namespace WebCore {
- class SVGElement;
- class SVGSMILElement;
- class SVGSVGElement;
+class SVGElement;
+class SVGSMILElement;
+class SVGSVGElement;
- class SMILTimeContainer : public RefCounted<SMILTimeContainer> {
- public:
- static PassRefPtr<SMILTimeContainer> create(SVGSVGElement* owner) { return adoptRef(new SMILTimeContainer(owner)); }
+class SMILTimeContainer : public RefCounted<SMILTimeContainer> {
+public:
+ static PassRefPtr<SMILTimeContainer> create(SVGSVGElement* owner) { return adoptRef(new SMILTimeContainer(owner)); }
+
+ void schedule(SVGSMILElement*);
+ void unschedule(SVGSMILElement*);
- void schedule(SVGSMILElement*);
- void unschedule(SVGSMILElement*);
-
- SMILTime elapsed() const;
+ SMILTime elapsed() const;
- bool isActive() const;
- bool isPaused() const;
-
- void begin();
- void pause();
- void resume();
-
- void setDocumentOrderIndexesDirty() { m_documentOrderIndexesDirty = true; }
+ bool isActive() const;
+ bool isPaused() const;
+
+ void begin();
+ void pause();
+ void resume();
+
+ void setDocumentOrderIndexesDirty() { m_documentOrderIndexesDirty = true; }
- // Move to a specific time. Only used for DRT testing purposes.
- void sampleAnimationAtTime(const String& elementId, double seconds);
+ // Move to a specific time. Only used for DRT testing purposes.
+ void sampleAnimationAtTime(const String& elementId, double seconds);
- private:
- SMILTimeContainer(SVGSVGElement* owner);
-
- void timerFired(Timer<SMILTimeContainer>*);
- void startTimer(SMILTime fireTime, SMILTime minimumDelay = 0);
- void updateAnimations(SMILTime elapsed);
-
- void updateDocumentOrderIndexes();
- void sortByPriority(Vector<SVGSMILElement*>& smilElements, SMILTime elapsed);
-
- typedef pair<SVGElement*, String> ElementAttributePair;
- String baseValueFor(ElementAttributePair);
-
- double m_beginTime;
- double m_pauseTime;
- double m_accumulatedPauseTime;
- double m_nextManualSampleTime;
- String m_nextSamplingTarget;
+private:
+ SMILTimeContainer(SVGSVGElement* owner);
+
+ void timerFired(Timer<SMILTimeContainer>*);
+ void startTimer(SMILTime fireTime, SMILTime minimumDelay = 0);
+ void updateAnimations(SMILTime elapsed);
+
+ void updateDocumentOrderIndexes();
+ void sortByPriority(Vector<SVGSMILElement*>& smilElements, SMILTime elapsed);
+
+ typedef pair<SVGElement*, String> ElementAttributePair;
+ String baseValueFor(ElementAttributePair);
+
+ double m_beginTime;
+ double m_pauseTime;
+ double m_accumulatedPauseTime;
+ double m_nextManualSampleTime;
+ String m_nextSamplingTarget;
- bool m_documentOrderIndexesDirty;
-
- Timer<SMILTimeContainer> m_timer;
+ bool m_documentOrderIndexesDirty;
+
+ Timer<SMILTimeContainer> m_timer;
- typedef HashSet<SVGSMILElement*> TimingElementSet;
- TimingElementSet m_scheduledAnimations;
-
- typedef HashMap<ElementAttributePair, String> BaseValueMap;
- BaseValueMap m_savedBaseValues;
+ typedef HashSet<SVGSMILElement*> TimingElementSet;
+ TimingElementSet m_scheduledAnimations;
+
+ typedef HashMap<ElementAttributePair, String> BaseValueMap;
+ BaseValueMap m_savedBaseValues;
- SVGSVGElement* m_ownerSVGElement;
- };
+ SVGSVGElement* m_ownerSVGElement;
+};
}
-#endif
-#endif
+#endif // ENABLE(SVG)
+#endif // SMILTimeContainer_h
bool ConditionEventListener::operator==(const EventListener& listener)
{
if (const ConditionEventListener* conditionEventListener = ConditionEventListener::cast(&listener))
- return m_animation == conditionEventListener->m_animation &&
- m_condition == conditionEventListener->m_condition;
+ return m_animation == conditionEventListener->m_animation && m_condition == conditionEventListener->m_condition;
return false;
}
SMILTime repeatCount = this->repeatCount();
SMILTime repeatDur = this->repeatDur();
SMILTime simpleDuration = this->simpleDuration();
- if (simpleDuration == 0 || (repeatDur.isUnresolved() && repeatCount.isUnresolved()))
+ if (!simpleDuration || (repeatDur.isUnresolved() && repeatCount.isUnresolved()))
return simpleDuration;
SMILTime repeatCountDuration = simpleDuration * repeatCount;
return min(repeatCountDuration, min(repeatDur, SMILTime::indefinite()));
beginResult = tempBegin;
endResult = tempEnd;
return;
- } else if (restart() == RestartNever)
+ }
+ if (restart() == RestartNever)
break;
- else
- beginAfter = tempEnd;
+
+ beginAfter = tempEnd;
lastIntervalTempEnd = tempEnd;
}
beginResult = SMILTime::unresolved();
repeat = 0;
return 0.f;
}
- if (simpleDuration == 0) {
+ if (!simpleDuration) {
repeat = 0;
return 1.f;
}
SMILTime repeatingDuration = this->repeatingDuration();
if (elapsed >= m_intervalEnd || activeTime > repeatingDuration) {
repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuration.value());
- if (fmod(repeatingDuration.value(), simpleDuration.value() == 0.))
+ if (fmod(repeatingDuration.value(), !simpleDuration.value()))
repeat--;
return 1.f;
}
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
#ifndef SVGSMILElement_h
#define SVGSMILElement_h
#if ENABLE(SVG_ANIMATION)
-
-#include "SVGElement.h"
#include "SMILTime.h"
+#include "SVGElement.h"
+
#include <wtf/HashMap.h>
namespace WebCore {
- class ConditionEventListener;
- class SMILTimeContainer;
-
- // This class implements SMIL interval timing model as needed for SVG animation.
- class SVGSMILElement : public SVGElement {
- public:
- SVGSMILElement(const QualifiedName&, Document*);
- virtual ~SVGSMILElement();
-
- static bool isSMILElement(Node* node);
-
- virtual void parseMappedAttribute(Attribute*);
- virtual void attributeChanged(Attribute*, bool preserveDecls);
- virtual void insertedIntoDocument();
- virtual void removedFromDocument();
- virtual void finishParsingChildren();
-
- SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); }
-
- SVGElement* targetElement() const;
- String attributeName() const;
-
- void beginByLinkActivation();
-
- enum Restart { RestartAlways, RestartWhenNotActive, RestartNever };
- Restart restart() const;
-
- enum FillMode { FillRemove, FillFreeze };
- FillMode fill() const;
-
- String xlinkHref() const;
-
- SMILTime dur() const;
- SMILTime repeatDur() const;
- SMILTime repeatCount() const;
- SMILTime maxValue() const;
- SMILTime minValue() const;
-
- SMILTime elapsed() const;
-
- SMILTime intervalBegin() const { return m_intervalBegin; }
- SMILTime intervalEnd() const { return m_intervalEnd; }
- SMILTime previousIntervalBegin() const { return m_previousIntervalBegin; }
- SMILTime simpleDuration() const;
-
- void progress(SMILTime elapsed, SVGSMILElement* resultsElement);
- SMILTime nextProgressTime() const;
-
- static SMILTime parseClockValue(const String&);
- static SMILTime parseOffsetValue(const String&);
-
- bool isContributing(SMILTime elapsed) const;
- bool isInactive() const;
- bool isFrozen() const;
-
- unsigned documentOrderIndex() const { return m_documentOrderIndex; }
- void setDocumentOrderIndex(unsigned index) { m_documentOrderIndex = index; }
-
- virtual bool isAdditive() const = 0;
- virtual void resetToBaseValue(const String&) = 0;
- virtual void applyResultsToTarget() = 0;
-
+class ConditionEventListener;
+class SMILTimeContainer;
+
+// This class implements SMIL interval timing model as needed for SVG animation.
+class SVGSMILElement : public SVGElement {
+public:
+ SVGSMILElement(const QualifiedName&, Document*);
+ virtual ~SVGSMILElement();
+
+ static bool isSMILElement(Node*);
+
+ virtual void parseMappedAttribute(Attribute*);
+ virtual void attributeChanged(Attribute*, bool preserveDecls);
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
+ virtual void finishParsingChildren();
+
+ SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); }
+
+ SVGElement* targetElement() const;
+ String attributeName() const;
+
+ void beginByLinkActivation();
+
+ enum Restart {
+ RestartAlways,
+ RestartWhenNotActive,
+ RestartNever
+ };
+
+ Restart restart() const;
+
+ enum FillMode {
+ FillRemove,
+ FillFreeze
+ };
+
+ FillMode fill() const;
+
+ String xlinkHref() const;
+
+ SMILTime dur() const;
+ SMILTime repeatDur() const;
+ SMILTime repeatCount() const;
+ SMILTime maxValue() const;
+ SMILTime minValue() const;
+
+ SMILTime elapsed() const;
+
+ SMILTime intervalBegin() const { return m_intervalBegin; }
+ SMILTime intervalEnd() const { return m_intervalEnd; }
+ SMILTime previousIntervalBegin() const { return m_previousIntervalBegin; }
+ SMILTime simpleDuration() const;
+
+ void progress(SMILTime elapsed, SVGSMILElement* resultsElement);
+ SMILTime nextProgressTime() const;
+
+ static SMILTime parseClockValue(const String&);
+ static SMILTime parseOffsetValue(const String&);
+
+ bool isContributing(SMILTime elapsed) const;
+ bool isInactive() const;
+ bool isFrozen() const;
+
+ unsigned documentOrderIndex() const { return m_documentOrderIndex; }
+ void setDocumentOrderIndex(unsigned index) { m_documentOrderIndex = index; }
+
+ virtual bool isAdditive() const = 0;
+ virtual void resetToBaseValue(const String&) = 0;
+ virtual void applyResultsToTarget() = 0;
+
protected:
- void addBeginTime(SMILTime time);
- void addEndTime(SMILTime time);
-
+ void addBeginTime(SMILTime);
+ void addEndTime(SMILTime);
+
private:
- virtual void startedActiveInterval() = 0;
- virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) = 0;
- virtual void endedActiveInterval() = 0;
-
- enum BeginOrEnd { Begin, End };
- SMILTime findInstanceTime(BeginOrEnd beginOrEnd, SMILTime minimumTime, bool equalsMinimumOK) const;
- void resolveFirstInterval();
- void resolveNextInterval();
- void resolveInterval(bool first, SMILTime& beginResult, SMILTime& endResult) const;
- SMILTime resolveActiveEnd(SMILTime resolvedBegin, SMILTime resolvedEnd) const;
- SMILTime repeatingDuration() const;
- void checkRestart(SMILTime elapsed);
- void beginListChanged();
- void endListChanged();
- void reschedule();
-
- // This represents conditions on elements begin or end list that need to be resolved on runtime
- // for example <animate begin="otherElement.begin + 8s; button.click" ... />
- struct Condition {
- enum Type { EventBase, Syncbase, AccessKey };
- Condition(Type, BeginOrEnd beginOrEnd, const String& baseID, const String& name, SMILTime offset, int repeats = -1);
- Type m_type;
- BeginOrEnd m_beginOrEnd;
- String m_baseID;
- String m_name;
- SMILTime m_offset;
- int m_repeats;
- RefPtr<Element> m_syncbase;
- RefPtr<ConditionEventListener> m_eventListener;
- };
- bool parseCondition(const String&, BeginOrEnd beginOrEnd);
- void parseBeginOrEnd(const String&, BeginOrEnd beginOrEnd);
- Element* eventBaseFor(const Condition&) const;
-
- void connectConditions();
- void disconnectConditions();
-
- // Event base timing
- void handleConditionEvent(Event*, Condition*);
-
- // Syncbase timing
- enum NewOrExistingInterval { NewInterval, ExistingInterval };
- void notifyDependentsIntervalChanged(NewOrExistingInterval);
- void createInstanceTimesFromSyncbase(SVGSMILElement* syncbase, NewOrExistingInterval);
- void addTimeDependent(SVGSMILElement*);
- void removeTimeDependent(SVGSMILElement*);
-
- enum ActiveState { Inactive, Active, Frozen };
- ActiveState determineActiveState(SMILTime elapsed) const;
- float calculateAnimationPercentAndRepeat(SMILTime elapsed, unsigned& repeat) const;
- SMILTime calculateNextProgressTime(SMILTime elapsed) const;
-
- Vector<Condition> m_conditions;
- bool m_conditionsConnected;
- bool m_hasEndEventConditions;
-
- typedef HashSet<SVGSMILElement*> TimeDependentSet;
- TimeDependentSet m_timeDependents;
-
- // Instance time lists
- Vector<SMILTime> m_beginTimes;
- Vector<SMILTime> m_endTimes;
-
- // This is the upcoming or current interval
- SMILTime m_intervalBegin;
- SMILTime m_intervalEnd;
-
- SMILTime m_previousIntervalBegin;
-
- bool m_isWaitingForFirstInterval;
+ virtual void startedActiveInterval() = 0;
+ virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) = 0;
+ virtual void endedActiveInterval() = 0;
+
+ enum BeginOrEnd {
+ Begin,
+ End
+ };
- ActiveState m_activeState;
- float m_lastPercent;
- unsigned m_lastRepeat;
-
- SMILTime m_nextProgressTime;
-
- RefPtr<SMILTimeContainer> m_timeContainer;
- unsigned m_documentOrderIndex;
-
- mutable SMILTime m_cachedDur;
- mutable SMILTime m_cachedRepeatDur;
- mutable SMILTime m_cachedRepeatCount;
- mutable SMILTime m_cachedMin;
- mutable SMILTime m_cachedMax;
-
- friend class ConditionEventListener;
+ SMILTime findInstanceTime(BeginOrEnd, SMILTime minimumTime, bool equalsMinimumOK) const;
+ void resolveFirstInterval();
+ void resolveNextInterval();
+ void resolveInterval(bool first, SMILTime& beginResult, SMILTime& endResult) const;
+ SMILTime resolveActiveEnd(SMILTime resolvedBegin, SMILTime resolvedEnd) const;
+ SMILTime repeatingDuration() const;
+ void checkRestart(SMILTime elapsed);
+ void beginListChanged();
+ void endListChanged();
+ void reschedule();
+
+ // This represents conditions on elements begin or end list that need to be resolved on runtime
+ // for example <animate begin="otherElement.begin + 8s; button.click" ... />
+ struct Condition {
+ enum Type {
+ EventBase,
+ Syncbase,
+ AccessKey
+ };
+
+ Condition(Type, BeginOrEnd, const String& baseID, const String& name, SMILTime offset, int repeats = -1);
+ Type m_type;
+ BeginOrEnd m_beginOrEnd;
+ String m_baseID;
+ String m_name;
+ SMILTime m_offset;
+ int m_repeats;
+ RefPtr<Element> m_syncbase;
+ RefPtr<ConditionEventListener> m_eventListener;
+ };
+ bool parseCondition(const String&, BeginOrEnd beginOrEnd);
+ void parseBeginOrEnd(const String&, BeginOrEnd beginOrEnd);
+ Element* eventBaseFor(const Condition&) const;
+
+ void connectConditions();
+ void disconnectConditions();
+
+ // Event base timing
+ void handleConditionEvent(Event*, Condition*);
+
+ // Syncbase timing
+ enum NewOrExistingInterval {
+ NewInterval,
+ ExistingInterval
+ };
+
+ void notifyDependentsIntervalChanged(NewOrExistingInterval);
+ void createInstanceTimesFromSyncbase(SVGSMILElement* syncbase, NewOrExistingInterval);
+ void addTimeDependent(SVGSMILElement*);
+ void removeTimeDependent(SVGSMILElement*);
+
+ enum ActiveState {
+ Inactive,
+ Active,
+ Frozen
};
+ ActiveState determineActiveState(SMILTime elapsed) const;
+ float calculateAnimationPercentAndRepeat(SMILTime elapsed, unsigned& repeat) const;
+ SMILTime calculateNextProgressTime(SMILTime elapsed) const;
+
+ Vector<Condition> m_conditions;
+ bool m_conditionsConnected;
+ bool m_hasEndEventConditions;
+
+ typedef HashSet<SVGSMILElement*> TimeDependentSet;
+ TimeDependentSet m_timeDependents;
+
+ // Instance time lists
+ Vector<SMILTime> m_beginTimes;
+ Vector<SMILTime> m_endTimes;
+
+ // This is the upcoming or current interval
+ SMILTime m_intervalBegin;
+ SMILTime m_intervalEnd;
+
+ SMILTime m_previousIntervalBegin;
+
+ bool m_isWaitingForFirstInterval;
+
+ ActiveState m_activeState;
+ float m_lastPercent;
+ unsigned m_lastRepeat;
+
+ SMILTime m_nextProgressTime;
+
+ RefPtr<SMILTimeContainer> m_timeContainer;
+ unsigned m_documentOrderIndex;
+
+ mutable SMILTime m_cachedDur;
+ mutable SMILTime m_cachedRepeatDur;
+ mutable SMILTime m_cachedRepeatCount;
+ mutable SMILTime m_cachedMin;
+ mutable SMILTime m_cachedMax;
+
+ friend class ConditionEventListener;
+};
+
}
-#endif
-#endif
+#endif // ENABLE(SVG)
+#endif // SVGSMILElement_h
// Moving this #include above FrameLoader.h causes the Windows build to fail due to warnings about
// alignment in Timer<FrameLoader>. It seems that the definition of EmptyFrameLoaderClient is what
// causes this (removing that definition fixes the warnings), but it isn't clear why.
-#include "EmptyClients.h"
+#include "EmptyClients.h" // NOLINT
namespace WebCore {
namespace WebCore {
- class Page;
- class SVGImageChromeClient;
-
- class SVGImage : public Image {
- public:
- static PassRefPtr<SVGImage> create(ImageObserver* observer)
- {
- return adoptRef(new SVGImage(observer));
- }
-
- private:
- virtual ~SVGImage();
-
- virtual String filenameExtension() const;
-
- virtual void setContainerSize(const IntSize&);
- virtual bool usesContainerSize() const;
- virtual bool hasRelativeWidth() const;
- virtual bool hasRelativeHeight() const;
-
- virtual IntSize size() const;
-
- virtual bool dataChanged(bool allDataReceived);
-
- // FIXME: SVGImages are underreporting decoded sizes and will be unable
- // to prune because these functions are not implemented yet.
- virtual void destroyDecodedData(bool) { }
- virtual unsigned decodedSize() const { return 0; }
-
- virtual NativeImagePtr frameAtIndex(size_t) { return 0; }
-
- SVGImage(ImageObserver*);
- virtual void draw(GraphicsContext*, const FloatRect& fromRect, const FloatRect& toRect, ColorSpace styleColorSpace, CompositeOperator);
-
- virtual NativeImagePtr nativeImageForCurrentFrame();
-
- OwnPtr<SVGImageChromeClient> m_chromeClient;
- OwnPtr<Page> m_page;
- RefPtr<Image> m_frameCache;
- };
+class Page;
+class SVGImageChromeClient;
+
+class SVGImage : public Image {
+public:
+ static PassRefPtr<SVGImage> create(ImageObserver* observer)
+ {
+ return adoptRef(new SVGImage(observer));
+ }
+
+private:
+ virtual ~SVGImage();
+
+ virtual String filenameExtension() const;
+
+ virtual void setContainerSize(const IntSize&);
+ virtual bool usesContainerSize() const;
+ virtual bool hasRelativeWidth() const;
+ virtual bool hasRelativeHeight() const;
+
+ virtual IntSize size() const;
+
+ virtual bool dataChanged(bool allDataReceived);
+
+ // FIXME: SVGImages are underreporting decoded sizes and will be unable
+ // to prune because these functions are not implemented yet.
+ virtual void destroyDecodedData(bool) { }
+ virtual unsigned decodedSize() const { return 0; }
+
+ virtual NativeImagePtr frameAtIndex(size_t) { return 0; }
+
+ SVGImage(ImageObserver*);
+ virtual void draw(GraphicsContext*, const FloatRect& fromRect, const FloatRect& toRect, ColorSpace styleColorSpace, CompositeOperator);
+
+ virtual NativeImagePtr nativeImageForCurrentFrame();
+
+ OwnPtr<SVGImageChromeClient> m_chromeClient;
+ OwnPtr<Page> m_page;
+ RefPtr<Image> m_frameCache;
+};
}
#endif // ENABLE(SVG)
-
-#endif
+#endif // SVGImage_h
/*
* Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
+ * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
#ifndef SVGFilterBuilder_h
#define SVGFilterBuilder_h
-#include "config.h"
-
#if ENABLE(SVG) && ENABLE(FILTERS)
#include "FilterEffect.h"
#include "PlatformString.h"
#include <wtf/text/AtomicStringHash.h>
namespace WebCore {
-
- class SVGFilterBuilder : public RefCounted<SVGFilterBuilder> {
- public:
- typedef HashSet<FilterEffect*> FilterEffectSet;
- static PassRefPtr<SVGFilterBuilder> create(Filter* filter) { return adoptRef(new SVGFilterBuilder(filter)); }
+class SVGFilterBuilder : public RefCounted<SVGFilterBuilder> {
+public:
+ typedef HashSet<FilterEffect*> FilterEffectSet;
+
+ static PassRefPtr<SVGFilterBuilder> create(Filter* filter) { return adoptRef(new SVGFilterBuilder(filter)); }
- void add(const AtomicString& id, RefPtr<FilterEffect> effect);
+ void add(const AtomicString& id, RefPtr<FilterEffect> effect);
- FilterEffect* getEffectById(const AtomicString& id) const;
- FilterEffect* lastEffect() const { return m_lastEffect.get(); }
+ FilterEffect* getEffectById(const AtomicString& id) const;
+ FilterEffect* lastEffect() const { return m_lastEffect.get(); }
- void appendEffectToEffectReferences(RefPtr<FilterEffect>);
+ void appendEffectToEffectReferences(RefPtr<FilterEffect>);
- inline FilterEffectSet& getEffectReferences(FilterEffect* effect)
- {
- // Only allowed for effects belongs to this builder.
- ASSERT(m_effectReferences.contains(effect));
- return m_effectReferences.find(effect)->second;
- }
+ inline FilterEffectSet& getEffectReferences(FilterEffect* effect)
+ {
+ // Only allowed for effects belongs to this builder.
+ ASSERT(m_effectReferences.contains(effect));
+ return m_effectReferences.find(effect)->second;
+ }
- void clearEffects();
+ void clearEffects();
- private:
- SVGFilterBuilder(Filter*);
+private:
+ SVGFilterBuilder(Filter*);
- inline void addBuiltinEffects()
- {
- HashMap<AtomicString, RefPtr<FilterEffect> >::iterator end = m_builtinEffects.end();
- for (HashMap<AtomicString, RefPtr<FilterEffect> >::iterator iterator = m_builtinEffects.begin(); iterator != end; ++iterator)
- m_effectReferences.add(iterator->second, FilterEffectSet());
- }
+ inline void addBuiltinEffects()
+ {
+ HashMap<AtomicString, RefPtr<FilterEffect> >::iterator end = m_builtinEffects.end();
+ for (HashMap<AtomicString, RefPtr<FilterEffect> >::iterator iterator = m_builtinEffects.begin(); iterator != end; ++iterator)
+ m_effectReferences.add(iterator->second, FilterEffectSet());
+ }
- HashMap<AtomicString, RefPtr<FilterEffect> > m_builtinEffects;
- HashMap<AtomicString, RefPtr<FilterEffect> > m_namedEffects;
- // The value is a list, which contains those filter effects,
- // which depends on the key filter effect.
- HashMap<RefPtr<FilterEffect>, FilterEffectSet> m_effectReferences;
+ HashMap<AtomicString, RefPtr<FilterEffect> > m_builtinEffects;
+ HashMap<AtomicString, RefPtr<FilterEffect> > m_namedEffects;
+ // The value is a list, which contains those filter effects,
+ // which depends on the key filter effect.
+ HashMap<RefPtr<FilterEffect>, FilterEffectSet> m_effectReferences;
- RefPtr<FilterEffect> m_lastEffect;
- };
+ RefPtr<FilterEffect> m_lastEffect;
+};
-} //namespace WebCore
+} // namespace WebCore
#endif // ENABLE(SVG) && ENABLE(FILTERS)
-#endif
+#endif // SVGFilterBuilder_h